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

// MarketNewsCategory - This parameter can be 1 of the following values general, forex, crypto, merger.
type MarketNewsCategory string

const (
	MarketNewsCategoryGeneral MarketNewsCategory = "general"
	MarketNewsCategoryForex   MarketNewsCategory = "forex"
	MarketNewsCategoryCrypto  MarketNewsCategory = "crypto"
	MarketNewsCategoryMerger  MarketNewsCategory = "merger"
)

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

type Finnhub string

const (
	FinnhubFinnhub Finnhub = "finnhub"
)

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

type SourceFinnhub struct {
	// The API key to use for authentication
	APIKey string `json:"api_key"`
	// More info: https://finnhub.io/docs/api/stock-symbols
	Exchange *string `default:"US" json:"exchange"`
	// This parameter can be 1 of the following values general, forex, crypto, merger.
	MarketNewsCategory *MarketNewsCategory `default:"general" json:"market_news_category"`
	StartDate2         time.Time           `json:"start_date_2"`
	Symbols            []any               `json:"symbols"`
	sourceType         Finnhub             `const:"finnhub" json:"sourceType"`
}

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

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

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

func (o *SourceFinnhub) GetExchange() *string {
	if o == nil {
		return nil
	}
	return o.Exchange
}

func (o *SourceFinnhub) GetMarketNewsCategory() *MarketNewsCategory {
	if o == nil {
		return nil
	}
	return o.MarketNewsCategory
}

func (o *SourceFinnhub) GetStartDate2() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.StartDate2
}

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

func (o *SourceFinnhub) GetSourceType() Finnhub {
	return FinnhubFinnhub
}
