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

// SourceAlphaVantageUpdateInterval - Time-series data point interval. Required for intraday endpoints.
type SourceAlphaVantageUpdateInterval string

const (
	SourceAlphaVantageUpdateIntervalOnemin     SourceAlphaVantageUpdateInterval = "1min"
	SourceAlphaVantageUpdateIntervalFivemin    SourceAlphaVantageUpdateInterval = "5min"
	SourceAlphaVantageUpdateIntervalFifteenmin SourceAlphaVantageUpdateInterval = "15min"
	SourceAlphaVantageUpdateIntervalThirtymin  SourceAlphaVantageUpdateInterval = "30min"
	SourceAlphaVantageUpdateIntervalSixtymin   SourceAlphaVantageUpdateInterval = "60min"
)

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

// SourceAlphaVantageUpdateOutputSize - Whether to return full or compact data (the last 100 data points).
type SourceAlphaVantageUpdateOutputSize string

const (
	SourceAlphaVantageUpdateOutputSizeCompact SourceAlphaVantageUpdateOutputSize = "compact"
	SourceAlphaVantageUpdateOutputSizeFull    SourceAlphaVantageUpdateOutputSize = "full"
)

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

type SourceAlphaVantageUpdate struct {
	// Whether to return adjusted data. Only applicable to intraday endpoints.
	//
	Adjusted *bool `default:"false" json:"adjusted"`
	// API Key
	APIKey string `json:"api_key"`
	// Time-series data point interval. Required for intraday endpoints.
	//
	Interval *SourceAlphaVantageUpdateInterval `default:"1min" json:"interval"`
	// Whether to return full or compact data (the last 100 data points).
	//
	Outputsize *SourceAlphaVantageUpdateOutputSize `default:"compact" json:"outputsize"`
	// Stock symbol (with exchange code)
	Symbol string `json:"symbol"`
}

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

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

func (o *SourceAlphaVantageUpdate) GetAdjusted() *bool {
	if o == nil {
		return nil
	}
	return o.Adjusted
}

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

func (o *SourceAlphaVantageUpdate) GetInterval() *SourceAlphaVantageUpdateInterval {
	if o == nil {
		return nil
	}
	return o.Interval
}

func (o *SourceAlphaVantageUpdate) GetOutputsize() *SourceAlphaVantageUpdateOutputSize {
	if o == nil {
		return nil
	}
	return o.Outputsize
}

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