// 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"
)

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

const (
	TechnicalIndicatorTypeDema     TechnicalIndicatorType = "DEMA"
	TechnicalIndicatorTypeEma      TechnicalIndicatorType = "EMA"
	TechnicalIndicatorTypeSma      TechnicalIndicatorType = "SMA"
	TechnicalIndicatorTypeWma      TechnicalIndicatorType = "WMA"
	TechnicalIndicatorTypeRsi      TechnicalIndicatorType = "RSI"
	TechnicalIndicatorTypeTema     TechnicalIndicatorType = "TEMA"
	TechnicalIndicatorTypeWilliams TechnicalIndicatorType = "Williams"
	TechnicalIndicatorTypeAdx      TechnicalIndicatorType = "ADX"
)

func (e TechnicalIndicatorType) ToPointer() *TechnicalIndicatorType {
	return &e
}
func (e *TechnicalIndicatorType) 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 = TechnicalIndicatorType(v)
		return nil
	default:
		return fmt.Errorf("invalid value for TechnicalIndicatorType: %v", v)
	}
}

type TimeInterval string

const (
	TimeIntervalDaily      TimeInterval = "daily"
	TimeIntervalOnemin     TimeInterval = "1min"
	TimeIntervalFivemin    TimeInterval = "5min"
	TimeIntervalFifteenmin TimeInterval = "15min"
	TimeIntervalThirtymin  TimeInterval = "30min"
	TimeIntervalOnehour    TimeInterval = "1hour"
	TimeIntervalFourhour   TimeInterval = "4hour"
)

func (e TimeInterval) ToPointer() *TimeInterval {
	return &e
}
func (e *TimeInterval) 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 = TimeInterval(v)
		return nil
	default:
		return fmt.Errorf("invalid value for TimeInterval: %v", v)
	}
}

// TimeAggregates - Size of the time
type TimeAggregates string

const (
	TimeAggregatesMinute  TimeAggregates = "minute"
	TimeAggregatesHour    TimeAggregates = "hour"
	TimeAggregatesDay     TimeAggregates = "day"
	TimeAggregatesWeek    TimeAggregates = "week"
	TimeAggregatesMonth   TimeAggregates = "month"
	TimeAggregatesQuarter TimeAggregates = "quarter"
	TimeAggregatesYear    TimeAggregates = "year"
)

func (e TimeAggregates) ToPointer() *TimeAggregates {
	return &e
}
func (e *TimeAggregates) 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 = TimeAggregates(v)
		return nil
	default:
		return fmt.Errorf("invalid value for TimeAggregates: %v", v)
	}
}

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

const (
	TimePeriodAnnual  TimePeriod = "annual"
	TimePeriodQuarter TimePeriod = "quarter"
)

func (e TimePeriod) ToPointer() *TimePeriod {
	return &e
}
func (e *TimePeriod) 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 = TimePeriod(v)
		return nil
	default:
		return fmt.Errorf("invalid value for TimePeriod: %v", v)
	}
}

type Finage string

const (
	FinageFinage Finage = "finage"
)

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

type SourceFinage 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 *TechnicalIndicatorType `default:"SMA" json:"tech_indicator_type"`
	Time              *TimeInterval           `default:"daily" json:"time"`
	// Size of the time
	TimeAggregates *TimeAggregates `default:"day" json:"time_aggregates"`
	// Time Period for cash flow stmts
	TimePeriod *TimePeriod `json:"time_period,omitempty"`
	sourceType Finage      `const:"finage" json:"sourceType"`
}

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

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

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

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

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

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

func (o *SourceFinage) GetTechIndicatorType() *TechnicalIndicatorType {
	if o == nil {
		return nil
	}
	return o.TechIndicatorType
}

func (o *SourceFinage) GetTime() *TimeInterval {
	if o == nil {
		return nil
	}
	return o.Time
}

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

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

func (o *SourceFinage) GetSourceType() Finage {
	return FinageFinage
}
