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

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

const (
	SourceFinnhubUpdateMarketNewsCategoryGeneral SourceFinnhubUpdateMarketNewsCategory = "general"
	SourceFinnhubUpdateMarketNewsCategoryForex   SourceFinnhubUpdateMarketNewsCategory = "forex"
	SourceFinnhubUpdateMarketNewsCategoryCrypto  SourceFinnhubUpdateMarketNewsCategory = "crypto"
	SourceFinnhubUpdateMarketNewsCategoryMerger  SourceFinnhubUpdateMarketNewsCategory = "merger"
)

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

type SourceFinnhubUpdate 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 *SourceFinnhubUpdateMarketNewsCategory `default:"general" json:"market_news_category"`
	StartDate2         time.Time                              `json:"start_date_2"`
	Symbols            []any                                  `json:"symbols"`
}

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

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

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

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

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

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

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