// 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"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/types"
)

// SourceCoingeckoCoinsUpdateDays - The number of days of data for market chart.
type SourceCoingeckoCoinsUpdateDays string

const (
	SourceCoingeckoCoinsUpdateDaysOne                      SourceCoingeckoCoinsUpdateDays = "1"
	SourceCoingeckoCoinsUpdateDaysSeven                    SourceCoingeckoCoinsUpdateDays = "7"
	SourceCoingeckoCoinsUpdateDaysFourteen                 SourceCoingeckoCoinsUpdateDays = "14"
	SourceCoingeckoCoinsUpdateDaysThirty                   SourceCoingeckoCoinsUpdateDays = "30"
	SourceCoingeckoCoinsUpdateDaysNinety                   SourceCoingeckoCoinsUpdateDays = "90"
	SourceCoingeckoCoinsUpdateDaysOneHundredAndEighty      SourceCoingeckoCoinsUpdateDays = "180"
	SourceCoingeckoCoinsUpdateDaysThreeHundredAndSixtyFive SourceCoingeckoCoinsUpdateDays = "365"
	SourceCoingeckoCoinsUpdateDaysMax                      SourceCoingeckoCoinsUpdateDays = "max"
)

func (e SourceCoingeckoCoinsUpdateDays) ToPointer() *SourceCoingeckoCoinsUpdateDays {
	return &e
}
func (e *SourceCoingeckoCoinsUpdateDays) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "1":
		fallthrough
	case "7":
		fallthrough
	case "14":
		fallthrough
	case "30":
		fallthrough
	case "90":
		fallthrough
	case "180":
		fallthrough
	case "365":
		fallthrough
	case "max":
		*e = SourceCoingeckoCoinsUpdateDays(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceCoingeckoCoinsUpdateDays: %v", v)
	}
}

type SourceCoingeckoCoinsUpdate struct {
	// API Key (for pro users)
	APIKey *string `json:"api_key,omitempty"`
	// CoinGecko coin ID (e.g. bitcoin). Can be retrieved from the
	// `/coins/list` endpoint.
	//
	CoinID string `json:"coin_id"`
	// The number of days of data for market chart.
	//
	Days *SourceCoingeckoCoinsUpdateDays `default:"30" json:"days"`
	// The end date for the historical data stream in dd-mm-yyyy format.
	//
	EndDate *types.Date `json:"end_date,omitempty"`
	// The start date for the historical data stream in dd-mm-yyyy format.
	//
	StartDate types.Date `json:"start_date"`
	// The target currency of market data (e.g. usd, eur, jpy, etc.)
	//
	VsCurrency string `json:"vs_currency"`
}

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

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

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

func (o *SourceCoingeckoCoinsUpdate) GetCoinID() string {
	if o == nil {
		return ""
	}
	return o.CoinID
}

func (o *SourceCoingeckoCoinsUpdate) GetDays() *SourceCoingeckoCoinsUpdateDays {
	if o == nil {
		return nil
	}
	return o.Days
}

func (o *SourceCoingeckoCoinsUpdate) GetEndDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.EndDate
}

func (o *SourceCoingeckoCoinsUpdate) GetStartDate() types.Date {
	if o == nil {
		return types.Date{}
	}
	return o.StartDate
}

func (o *SourceCoingeckoCoinsUpdate) GetVsCurrency() string {
	if o == nil {
		return ""
	}
	return o.VsCurrency
}
