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

// SourceYahooFinancePriceInterval - The interval of between prices queried.
type SourceYahooFinancePriceInterval string

const (
	SourceYahooFinancePriceIntervalOnem     SourceYahooFinancePriceInterval = "1m"
	SourceYahooFinancePriceIntervalFivem    SourceYahooFinancePriceInterval = "5m"
	SourceYahooFinancePriceIntervalFifteenm SourceYahooFinancePriceInterval = "15m"
	SourceYahooFinancePriceIntervalThirtym  SourceYahooFinancePriceInterval = "30m"
	SourceYahooFinancePriceIntervalNinetym  SourceYahooFinancePriceInterval = "90m"
	SourceYahooFinancePriceIntervalOneh     SourceYahooFinancePriceInterval = "1h"
	SourceYahooFinancePriceIntervalOned     SourceYahooFinancePriceInterval = "1d"
	SourceYahooFinancePriceIntervalFived    SourceYahooFinancePriceInterval = "5d"
	SourceYahooFinancePriceIntervalOnewk    SourceYahooFinancePriceInterval = "1wk"
	SourceYahooFinancePriceIntervalOnemo    SourceYahooFinancePriceInterval = "1mo"
	SourceYahooFinancePriceIntervalThreemo  SourceYahooFinancePriceInterval = "3mo"
)

func (e SourceYahooFinancePriceInterval) ToPointer() *SourceYahooFinancePriceInterval {
	return &e
}
func (e *SourceYahooFinancePriceInterval) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "1m":
		fallthrough
	case "5m":
		fallthrough
	case "15m":
		fallthrough
	case "30m":
		fallthrough
	case "90m":
		fallthrough
	case "1h":
		fallthrough
	case "1d":
		fallthrough
	case "5d":
		fallthrough
	case "1wk":
		fallthrough
	case "1mo":
		fallthrough
	case "3mo":
		*e = SourceYahooFinancePriceInterval(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceYahooFinancePriceInterval: %v", v)
	}
}

// Range - The range of prices to be queried.
type Range string

const (
	RangeOned    Range = "1d"
	RangeFived   Range = "5d"
	RangeSevend  Range = "7d"
	RangeOnemo   Range = "1mo"
	RangeThreemo Range = "3mo"
	RangeSixmo   Range = "6mo"
	RangeOney    Range = "1y"
	RangeTwoy    Range = "2y"
	RangeFivey   Range = "5y"
	RangeYtd     Range = "ytd"
	RangeMax     Range = "max"
)

func (e Range) ToPointer() *Range {
	return &e
}
func (e *Range) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "1d":
		fallthrough
	case "5d":
		fallthrough
	case "7d":
		fallthrough
	case "1mo":
		fallthrough
	case "3mo":
		fallthrough
	case "6mo":
		fallthrough
	case "1y":
		fallthrough
	case "2y":
		fallthrough
	case "5y":
		fallthrough
	case "ytd":
		fallthrough
	case "max":
		*e = Range(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Range: %v", v)
	}
}

type YahooFinancePrice string

const (
	YahooFinancePriceYahooFinancePrice YahooFinancePrice = "yahoo-finance-price"
)

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

type SourceYahooFinancePrice struct {
	// The interval of between prices queried.
	Interval *SourceYahooFinancePriceInterval `json:"interval,omitempty"`
	// The range of prices to be queried.
	Range *Range `json:"range,omitempty"`
	// Comma-separated identifiers for the stocks to be queried. Whitespaces are allowed.
	Tickers    string            `json:"tickers"`
	sourceType YahooFinancePrice `const:"yahoo-finance-price" json:"sourceType"`
}

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

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

func (o *SourceYahooFinancePrice) GetInterval() *SourceYahooFinancePriceInterval {
	if o == nil {
		return nil
	}
	return o.Interval
}

func (o *SourceYahooFinancePrice) GetRange() *Range {
	if o == nil {
		return nil
	}
	return o.Range
}

func (o *SourceYahooFinancePrice) GetTickers() string {
	if o == nil {
		return ""
	}
	return o.Tickers
}

func (o *SourceYahooFinancePrice) GetSourceType() YahooFinancePrice {
	return YahooFinancePriceYahooFinancePrice
}
