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

type OpenExchangeRates string

const (
	OpenExchangeRatesOpenExchangeRates OpenExchangeRates = "open-exchange-rates"
)

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

type SourceOpenExchangeRates struct {
	// App ID provided by Open Exchange Rates
	AppID string `json:"app_id"`
	// Change base currency (3-letter code, default is USD - only modifiable in paid plans)
	Base *string `default:"USD" json:"base"`
	// Start getting data from that date.
	StartDate  string            `json:"start_date"`
	sourceType OpenExchangeRates `const:"open-exchange-rates" json:"sourceType"`
}

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

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

func (o *SourceOpenExchangeRates) GetAppID() string {
	if o == nil {
		return ""
	}
	return o.AppID
}

func (o *SourceOpenExchangeRates) GetBase() *string {
	if o == nil {
		return nil
	}
	return o.Base
}

func (o *SourceOpenExchangeRates) GetStartDate() string {
	if o == nil {
		return ""
	}
	return o.StartDate
}

func (o *SourceOpenExchangeRates) GetSourceType() OpenExchangeRates {
	return OpenExchangeRatesOpenExchangeRates
}
