// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package shared

import (
	"encoding/json"
	"fmt"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/internal/utils"
	"time"
)

// SourceFinageUpdateTechnicalIndicatorType - One of DEMA, EMA, SMA, WMA, RSI, TEMA, Williams, ADX
type SourceFinageUpdateTechnicalIndicatorType string

const (
	SourceFinageUpdateTechnicalIndicatorTypeDema     SourceFinageUpdateTechnicalIndicatorType = "DEMA"
	SourceFinageUpdateTechnicalIndicatorTypeEma      SourceFinageUpdateTechnicalIndicatorType = "EMA"
	SourceFinageUpdateTechnicalIndicatorTypeSma      SourceFinageUpdateTechnicalIndicatorType = "SMA"
	SourceFinageUpdateTechnicalIndicatorTypeWma      SourceFinageUpdateTechnicalIndicatorType = "WMA"
	SourceFinageUpdateTechnicalIndicatorTypeRsi      SourceFinageUpdateTechnicalIndicatorType = "RSI"
	SourceFinageUpdateTechnicalIndicatorTypeTema     SourceFinageUpdateTechnicalIndicatorType = "TEMA"
	SourceFinageUpdateTechnicalIndicatorTypeWilliams SourceFinageUpdateTechnicalIndicatorType = "Williams"
	SourceFinageUpdateTechnicalIndicatorTypeAdx      SourceFinageUpdateTechnicalIndicatorType = "ADX"
)

func (e SourceFinageUpdateTechnicalIndicatorType) ToPointer() *SourceFinageUpdateTechnicalIndicatorType {
	return &e
}
func (e *SourceFinageUpdateTechnicalIndicatorType) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "DEMA":
		fallthrough
	case "EMA":
		fallthrough
	case "SMA":
		fallthrough
	case "WMA":
		fallthrough
	case "RSI":
		fallthrough
	case "TEMA":
		fallthrough
	case "Williams":
		fallthrough
	case "ADX":
		*e = SourceFinageUpdateTechnicalIndicatorType(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceFinageUpdateTechnicalIndicatorType: %v", v)
	}
}

type SourceFinageUpdateTimeInterval string

const (
	SourceFinageUpdateTimeIntervalDaily      SourceFinageUpdateTimeInterval = "daily"
	SourceFinageUpdateTimeIntervalOnemin     SourceFinageUpdateTimeInterval = "1min"
	SourceFinageUpdateTimeIntervalFivemin    SourceFinageUpdateTimeInterval = "5min"
	SourceFinageUpdateTimeIntervalFifteenmin SourceFinageUpdateTimeInterval = "15min"
	SourceFinageUpdateTimeIntervalThirtymin  SourceFinageUpdateTimeInterval = "30min"
	SourceFinageUpdateTimeIntervalOnehour    SourceFinageUpdateTimeInterval = "1hour"
	SourceFinageUpdateTimeIntervalFourhour   SourceFinageUpdateTimeInterval = "4hour"
)

func (e SourceFinageUpdateTimeInterval) ToPointer() *SourceFinageUpdateTimeInterval {
	return &e
}
func (e *SourceFinageUpdateTimeInterval) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "daily":
		fallthrough
	case "1min":
		fallthrough
	case "5min":
		fallthrough
	case "15min":
		fallthrough
	case "30min":
		fallthrough
	case "1hour":
		fallthrough
	case "4hour":
		*e = SourceFinageUpdateTimeInterval(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceFinageUpdateTimeInterval: %v", v)
	}
}

// SourceFinageUpdateTimeAggregates - Size of the time
type SourceFinageUpdateTimeAggregates string

const (
	SourceFinageUpdateTimeAggregatesMinute  SourceFinageUpdateTimeAggregates = "minute"
	SourceFinageUpdateTimeAggregatesHour    SourceFinageUpdateTimeAggregates = "hour"
	SourceFinageUpdateTimeAggregatesDay     SourceFinageUpdateTimeAggregates = "day"
	SourceFinageUpdateTimeAggregatesWeek    SourceFinageUpdateTimeAggregates = "week"
	SourceFinageUpdateTimeAggregatesMonth   SourceFinageUpdateTimeAggregates = "month"
	SourceFinageUpdateTimeAggregatesQuarter SourceFinageUpdateTimeAggregates = "quarter"
	SourceFinageUpdateTimeAggregatesYear    SourceFinageUpdateTimeAggregates = "year"
)

func (e SourceFinageUpdateTimeAggregates) ToPointer() *SourceFinageUpdateTimeAggregates {
	return &e
}
func (e *SourceFinageUpdateTimeAggregates) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "minute":
		fallthrough
	case "hour":
		fallthrough
	case "day":
		fallthrough
	case "week":
		fallthrough
	case "month":
		fallthrough
	case "quarter":
		fallthrough
	case "year":
		*e = SourceFinageUpdateTimeAggregates(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceFinageUpdateTimeAggregates: %v", v)
	}
}

// SourceFinageUpdateTimePeriod - Time Period for cash flow stmts
type SourceFinageUpdateTimePeriod string

const (
	SourceFinageUpdateTimePeriodAnnual  SourceFinageUpdateTimePeriod = "annual"
	SourceFinageUpdateTimePeriodQuarter SourceFinageUpdateTimePeriod = "quarter"
)

func (e SourceFinageUpdateTimePeriod) ToPointer() *SourceFinageUpdateTimePeriod {
	return &e
}
func (e *SourceFinageUpdateTimePeriod) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "annual":
		fallthrough
	case "quarter":
		*e = SourceFinageUpdateTimePeriod(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceFinageUpdateTimePeriod: %v", v)
	}
}

type SourceFinageUpdate struct {
	APIKey string `json:"api_key"`
	// Time period. Default is 10
	Period    *string   `json:"period,omitempty"`
	StartDate time.Time `json:"start_date"`
	// List of symbols
	Symbols []any `json:"symbols"`
	// One of DEMA, EMA, SMA, WMA, RSI, TEMA, Williams, ADX
	TechIndicatorType *SourceFinageUpdateTechnicalIndicatorType `default:"SMA" json:"tech_indicator_type"`
	Time              *SourceFinageUpdateTimeInterval           `default:"daily" json:"time"`
	// Size of the time
	TimeAggregates *SourceFinageUpdateTimeAggregates `default:"day" json:"time_aggregates"`
	// Time Period for cash flow stmts
	TimePeriod *SourceFinageUpdateTimePeriod `json:"time_period,omitempty"`
}

func (s SourceFinageUpdate) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(s, "", false)
}

func (s *SourceFinageUpdate) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil {
		return err
	}
	return nil
}

func (o *SourceFinageUpdate) GetAPIKey() string {
	if o == nil {
		return ""
	}
	return o.APIKey
}

func (o *SourceFinageUpdate) GetPeriod() *string {
	if o == nil {
		return nil
	}
	return o.Period
}

func (o *SourceFinageUpdate) GetStartDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.StartDate
}

func (o *SourceFinageUpdate) GetSymbols() []any {
	if o == nil {
		return []any{}
	}
	return o.Symbols
}

func (o *SourceFinageUpdate) GetTechIndicatorType() *SourceFinageUpdateTechnicalIndicatorType {
	if o == nil {
		return nil
	}
	return o.TechIndicatorType
}

func (o *SourceFinageUpdate) GetTime() *SourceFinageUpdateTimeInterval {
	if o == nil {
		return nil
	}
	return o.Time
}

func (o *SourceFinageUpdate) GetTimeAggregates() *SourceFinageUpdateTimeAggregates {
	if o == nil {
		return nil
	}
	return o.TimeAggregates
}

func (o *SourceFinageUpdate) GetTimePeriod() *SourceFinageUpdateTimePeriod {
	if o == nil {
		return nil
	}
	return o.TimePeriod
}
