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

// Lang - You can use lang parameter to get the output in your language. The contents of the description field will be translated. See <a href="https://openweathermap.org/api/one-call-api#multi">here</a> for the list of supported languages.
type Lang string

const (
	LangAf   Lang = "af"
	LangAl   Lang = "al"
	LangAr   Lang = "ar"
	LangAz   Lang = "az"
	LangBg   Lang = "bg"
	LangCa   Lang = "ca"
	LangCz   Lang = "cz"
	LangDa   Lang = "da"
	LangDe   Lang = "de"
	LangEl   Lang = "el"
	LangEn   Lang = "en"
	LangEu   Lang = "eu"
	LangFa   Lang = "fa"
	LangFi   Lang = "fi"
	LangFr   Lang = "fr"
	LangGl   Lang = "gl"
	LangHe   Lang = "he"
	LangHi   Lang = "hi"
	LangHr   Lang = "hr"
	LangHu   Lang = "hu"
	LangID   Lang = "id"
	LangIt   Lang = "it"
	LangJa   Lang = "ja"
	LangKr   Lang = "kr"
	LangLa   Lang = "la"
	LangLt   Lang = "lt"
	LangMk   Lang = "mk"
	LangNo   Lang = "no"
	LangNl   Lang = "nl"
	LangPl   Lang = "pl"
	LangPt   Lang = "pt"
	LangPtBr Lang = "pt_br"
	LangRo   Lang = "ro"
	LangRu   Lang = "ru"
	LangSv   Lang = "sv"
	LangSe   Lang = "se"
	LangSk   Lang = "sk"
	LangSl   Lang = "sl"
	LangSp   Lang = "sp"
	LangEs   Lang = "es"
	LangSr   Lang = "sr"
	LangTh   Lang = "th"
	LangTr   Lang = "tr"
	LangUa   Lang = "ua"
	LangUk   Lang = "uk"
	LangVi   Lang = "vi"
	LangZhCn Lang = "zh_cn"
	LangZhTw Lang = "zh_tw"
	LangZu   Lang = "zu"
)

func (e Lang) ToPointer() *Lang {
	return &e
}
func (e *Lang) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "af":
		fallthrough
	case "al":
		fallthrough
	case "ar":
		fallthrough
	case "az":
		fallthrough
	case "bg":
		fallthrough
	case "ca":
		fallthrough
	case "cz":
		fallthrough
	case "da":
		fallthrough
	case "de":
		fallthrough
	case "el":
		fallthrough
	case "en":
		fallthrough
	case "eu":
		fallthrough
	case "fa":
		fallthrough
	case "fi":
		fallthrough
	case "fr":
		fallthrough
	case "gl":
		fallthrough
	case "he":
		fallthrough
	case "hi":
		fallthrough
	case "hr":
		fallthrough
	case "hu":
		fallthrough
	case "id":
		fallthrough
	case "it":
		fallthrough
	case "ja":
		fallthrough
	case "kr":
		fallthrough
	case "la":
		fallthrough
	case "lt":
		fallthrough
	case "mk":
		fallthrough
	case "no":
		fallthrough
	case "nl":
		fallthrough
	case "pl":
		fallthrough
	case "pt":
		fallthrough
	case "pt_br":
		fallthrough
	case "ro":
		fallthrough
	case "ru":
		fallthrough
	case "sv":
		fallthrough
	case "se":
		fallthrough
	case "sk":
		fallthrough
	case "sl":
		fallthrough
	case "sp":
		fallthrough
	case "es":
		fallthrough
	case "sr":
		fallthrough
	case "th":
		fallthrough
	case "tr":
		fallthrough
	case "ua":
		fallthrough
	case "uk":
		fallthrough
	case "vi":
		fallthrough
	case "zh_cn":
		fallthrough
	case "zh_tw":
		fallthrough
	case "zu":
		*e = Lang(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Lang: %v", v)
	}
}

// Units of measurement. standard, metric and imperial units are available. If you do not use the units parameter, standard units will be applied by default.
type Units string

const (
	UnitsStandard Units = "standard"
	UnitsMetric   Units = "metric"
	UnitsImperial Units = "imperial"
)

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

type Openweather string

const (
	OpenweatherOpenweather Openweather = "openweather"
)

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

type SourceOpenweather struct {
	// API KEY
	Appid string `json:"appid"`
	// You can use lang parameter to get the output in your language. The contents of the description field will be translated. See <a href="https://openweathermap.org/api/one-call-api#multi">here</a> for the list of supported languages.
	Lang *Lang `json:"lang,omitempty"`
	// Latitude, decimal (-90; 90). If you need the geocoder to automatic convert city names and zip-codes to geo coordinates and the other way around, please use the OpenWeather Geocoding API
	Lat string `json:"lat"`
	// Longitude, decimal (-180; 180). If you need the geocoder to automatic convert city names and zip-codes to geo coordinates and the other way around, please use the OpenWeather Geocoding API
	Lon string `json:"lon"`
	// True for particular day
	OnlyCurrent *bool `json:"only_current,omitempty"`
	// Units of measurement. standard, metric and imperial units are available. If you do not use the units parameter, standard units will be applied by default.
	Units      *Units      `json:"units,omitempty"`
	sourceType Openweather `const:"openweather" json:"sourceType"`
}

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

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

func (o *SourceOpenweather) GetAppid() string {
	if o == nil {
		return ""
	}
	return o.Appid
}

func (o *SourceOpenweather) GetLang() *Lang {
	if o == nil {
		return nil
	}
	return o.Lang
}

func (o *SourceOpenweather) GetLat() string {
	if o == nil {
		return ""
	}
	return o.Lat
}

func (o *SourceOpenweather) GetLon() string {
	if o == nil {
		return ""
	}
	return o.Lon
}

func (o *SourceOpenweather) GetOnlyCurrent() *bool {
	if o == nil {
		return nil
	}
	return o.OnlyCurrent
}

func (o *SourceOpenweather) GetUnits() *Units {
	if o == nil {
		return nil
	}
	return o.Units
}

func (o *SourceOpenweather) GetSourceType() Openweather {
	return OpenweatherOpenweather
}
