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

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

const (
	IntervalOnemin     Interval = "1min"
	IntervalFivemin    Interval = "5min"
	IntervalFifteenmin Interval = "15min"
	IntervalThirtymin  Interval = "30min"
	IntervalSixtymin   Interval = "60min"
)

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

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

const (
	OutputSizeCompact OutputSize = "compact"
	OutputSizeFull    OutputSize = "full"
)

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

type AlphaVantage string

const (
	AlphaVantageAlphaVantage AlphaVantage = "alpha-vantage"
)

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

type SourceAlphaVantage 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 *Interval `default:"1min" json:"interval"`
	// Whether to return full or compact data (the last 100 data points).
	//
	Outputsize *OutputSize `default:"compact" json:"outputsize"`
	// Stock symbol (with exchange code)
	Symbol     string       `json:"symbol"`
	sourceType AlphaVantage `const:"alpha-vantage" json:"sourceType"`
}

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

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

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

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

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

func (o *SourceAlphaVantage) GetOutputsize() *OutputSize {
	if o == nil {
		return nil
	}
	return o.Outputsize
}

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

func (o *SourceAlphaVantage) GetSourceType() AlphaVantage {
	return AlphaVantageAlphaVantage
}
