// 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 Weatherstack string

const (
	WeatherstackWeatherstack Weatherstack = "weatherstack"
)

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

type SourceWeatherstack struct {
	// API access key used to retrieve data from the Weatherstack API.(https://weatherstack.com/product)
	AccessKey string `json:"access_key"`
	// This is required for enabling the Historical date API with format- (YYYY-MM-DD). * Note, only supported by paid accounts
	HistoricalDate string `json:"historical_date"`
	// A location to query such as city, IP, latitudeLongitude, or zipcode. Multiple locations with semicolon seperated if using a professional plan or higher. For more info- (https://weatherstack.com/documentation#query_parameter)
	Query      string       `json:"query"`
	sourceType Weatherstack `const:"weatherstack" json:"sourceType"`
}

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

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

func (o *SourceWeatherstack) GetAccessKey() string {
	if o == nil {
		return ""
	}
	return o.AccessKey
}

func (o *SourceWeatherstack) GetHistoricalDate() string {
	if o == nil {
		return ""
	}
	return o.HistoricalDate
}

func (o *SourceWeatherstack) GetQuery() string {
	if o == nil {
		return ""
	}
	return o.Query
}

func (o *SourceWeatherstack) GetSourceType() Weatherstack {
	return WeatherstackWeatherstack
}
