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

// SourceTwelveDataInterval - Between two consecutive points in time series Supports: 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 1day, 1week, 1month
type SourceTwelveDataInterval string

const (
	SourceTwelveDataIntervalOnemin       SourceTwelveDataInterval = "1min"
	SourceTwelveDataIntervalFivemin      SourceTwelveDataInterval = "5min"
	SourceTwelveDataIntervalFifteenmin   SourceTwelveDataInterval = "15min"
	SourceTwelveDataIntervalThirtymin    SourceTwelveDataInterval = "30min"
	SourceTwelveDataIntervalFortyFivemin SourceTwelveDataInterval = "45min"
	SourceTwelveDataIntervalOneh         SourceTwelveDataInterval = "1h"
	SourceTwelveDataIntervalTwoh         SourceTwelveDataInterval = "2h"
	SourceTwelveDataIntervalFourh        SourceTwelveDataInterval = "4h"
	SourceTwelveDataIntervalOneday       SourceTwelveDataInterval = "1day"
	SourceTwelveDataIntervalOneweek      SourceTwelveDataInterval = "1week"
	SourceTwelveDataIntervalOnemonth     SourceTwelveDataInterval = "1month"
)

func (e SourceTwelveDataInterval) ToPointer() *SourceTwelveDataInterval {
	return &e
}
func (e *SourceTwelveDataInterval) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "1min":
		fallthrough
	case "5min":
		fallthrough
	case "15min":
		fallthrough
	case "30min":
		fallthrough
	case "45min":
		fallthrough
	case "1h":
		fallthrough
	case "2h":
		fallthrough
	case "4h":
		fallthrough
	case "1day":
		fallthrough
	case "1week":
		fallthrough
	case "1month":
		*e = SourceTwelveDataInterval(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceTwelveDataInterval: %v", v)
	}
}

type TwelveData string

const (
	TwelveDataTwelveData TwelveData = "twelve-data"
)

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

type SourceTwelveData struct {
	APIKey string `json:"api_key"`
	// Where instrument is traded
	Country *string `json:"country,omitempty"`
	// Where instrument is traded
	Exchange *string `json:"exchange,omitempty"`
	// Between two consecutive points in time series Supports: 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 1day, 1week, 1month
	Interval *SourceTwelveDataInterval `default:"1day" json:"interval"`
	// Ticker of the instrument
	Symbol     *string    `json:"symbol,omitempty"`
	sourceType TwelveData `const:"twelve-data" json:"sourceType"`
}

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

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

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

func (o *SourceTwelveData) GetCountry() *string {
	if o == nil {
		return nil
	}
	return o.Country
}

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

func (o *SourceTwelveData) GetInterval() *SourceTwelveDataInterval {
	if o == nil {
		return nil
	}
	return o.Interval
}

func (o *SourceTwelveData) GetSymbol() *string {
	if o == nil {
		return nil
	}
	return o.Symbol
}

func (o *SourceTwelveData) GetSourceType() TwelveData {
	return TwelveDataTwelveData
}
