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

const (
	SourceNewsdataCategoryBusiness      SourceNewsdataCategory = "business"
	SourceNewsdataCategoryEntertainment SourceNewsdataCategory = "entertainment"
	SourceNewsdataCategoryEnvironment   SourceNewsdataCategory = "environment"
	SourceNewsdataCategoryFood          SourceNewsdataCategory = "food"
	SourceNewsdataCategoryHealth        SourceNewsdataCategory = "health"
	SourceNewsdataCategoryPolitics      SourceNewsdataCategory = "politics"
	SourceNewsdataCategoryScience       SourceNewsdataCategory = "science"
	SourceNewsdataCategorySports        SourceNewsdataCategory = "sports"
	SourceNewsdataCategoryTechnology    SourceNewsdataCategory = "technology"
	SourceNewsdataCategoryTop           SourceNewsdataCategory = "top"
	SourceNewsdataCategoryWorld         SourceNewsdataCategory = "world"
)

func (e SourceNewsdataCategory) ToPointer() *SourceNewsdataCategory {
	return &e
}
func (e *SourceNewsdataCategory) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "business":
		fallthrough
	case "entertainment":
		fallthrough
	case "environment":
		fallthrough
	case "food":
		fallthrough
	case "health":
		fallthrough
	case "politics":
		fallthrough
	case "science":
		fallthrough
	case "sports":
		fallthrough
	case "technology":
		fallthrough
	case "top":
		fallthrough
	case "world":
		*e = SourceNewsdataCategory(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceNewsdataCategory: %v", v)
	}
}

type SourceNewsdataCountry string

const (
	SourceNewsdataCountryAr SourceNewsdataCountry = "ar"
	SourceNewsdataCountryAu SourceNewsdataCountry = "au"
	SourceNewsdataCountryAt SourceNewsdataCountry = "at"
	SourceNewsdataCountryBd SourceNewsdataCountry = "bd"
	SourceNewsdataCountryBy SourceNewsdataCountry = "by"
	SourceNewsdataCountryBe SourceNewsdataCountry = "be"
	SourceNewsdataCountryBr SourceNewsdataCountry = "br"
	SourceNewsdataCountryBg SourceNewsdataCountry = "bg"
	SourceNewsdataCountryCa SourceNewsdataCountry = "ca"
	SourceNewsdataCountryCl SourceNewsdataCountry = "cl"
	SourceNewsdataCountryCn SourceNewsdataCountry = "cn"
	SourceNewsdataCountryCo SourceNewsdataCountry = "co"
	SourceNewsdataCountryCr SourceNewsdataCountry = "cr"
	SourceNewsdataCountryCu SourceNewsdataCountry = "cu"
	SourceNewsdataCountryCz SourceNewsdataCountry = "cz"
	SourceNewsdataCountryDk SourceNewsdataCountry = "dk"
	SourceNewsdataCountryDo SourceNewsdataCountry = "do"
	SourceNewsdataCountryEc SourceNewsdataCountry = "ec"
	SourceNewsdataCountryEg SourceNewsdataCountry = "eg"
	SourceNewsdataCountryEe SourceNewsdataCountry = "ee"
	SourceNewsdataCountryEt SourceNewsdataCountry = "et"
	SourceNewsdataCountryFi SourceNewsdataCountry = "fi"
	SourceNewsdataCountryFr SourceNewsdataCountry = "fr"
	SourceNewsdataCountryDe SourceNewsdataCountry = "de"
	SourceNewsdataCountryGr SourceNewsdataCountry = "gr"
	SourceNewsdataCountryHk SourceNewsdataCountry = "hk"
	SourceNewsdataCountryHu SourceNewsdataCountry = "hu"
	SourceNewsdataCountryIn SourceNewsdataCountry = "in"
	SourceNewsdataCountryID SourceNewsdataCountry = "id"
	SourceNewsdataCountryIq SourceNewsdataCountry = "iq"
	SourceNewsdataCountryIe SourceNewsdataCountry = "ie"
	SourceNewsdataCountryIl SourceNewsdataCountry = "il"
	SourceNewsdataCountryIt SourceNewsdataCountry = "it"
	SourceNewsdataCountryJp SourceNewsdataCountry = "jp"
	SourceNewsdataCountryKz SourceNewsdataCountry = "kz"
	SourceNewsdataCountryKw SourceNewsdataCountry = "kw"
	SourceNewsdataCountryLv SourceNewsdataCountry = "lv"
	SourceNewsdataCountryLb SourceNewsdataCountry = "lb"
	SourceNewsdataCountryLt SourceNewsdataCountry = "lt"
	SourceNewsdataCountryMy SourceNewsdataCountry = "my"
	SourceNewsdataCountryMx SourceNewsdataCountry = "mx"
	SourceNewsdataCountryMa SourceNewsdataCountry = "ma"
	SourceNewsdataCountryMm SourceNewsdataCountry = "mm"
	SourceNewsdataCountryNl SourceNewsdataCountry = "nl"
	SourceNewsdataCountryNz SourceNewsdataCountry = "nz"
	SourceNewsdataCountryNg SourceNewsdataCountry = "ng"
	SourceNewsdataCountryKp SourceNewsdataCountry = "kp"
	SourceNewsdataCountryNo SourceNewsdataCountry = "no"
	SourceNewsdataCountryPk SourceNewsdataCountry = "pk"
	SourceNewsdataCountryPe SourceNewsdataCountry = "pe"
	SourceNewsdataCountryPh SourceNewsdataCountry = "ph"
	SourceNewsdataCountryPl SourceNewsdataCountry = "pl"
	SourceNewsdataCountryPt SourceNewsdataCountry = "pt"
	SourceNewsdataCountryPr SourceNewsdataCountry = "pr"
	SourceNewsdataCountryRo SourceNewsdataCountry = "ro"
	SourceNewsdataCountryRu SourceNewsdataCountry = "ru"
	SourceNewsdataCountrySa SourceNewsdataCountry = "sa"
	SourceNewsdataCountryRs SourceNewsdataCountry = "rs"
	SourceNewsdataCountrySg SourceNewsdataCountry = "sg"
	SourceNewsdataCountrySk SourceNewsdataCountry = "sk"
	SourceNewsdataCountrySi SourceNewsdataCountry = "si"
	SourceNewsdataCountryZa SourceNewsdataCountry = "za"
	SourceNewsdataCountryKr SourceNewsdataCountry = "kr"
	SourceNewsdataCountryEs SourceNewsdataCountry = "es"
	SourceNewsdataCountrySe SourceNewsdataCountry = "se"
	SourceNewsdataCountryCh SourceNewsdataCountry = "ch"
	SourceNewsdataCountryTw SourceNewsdataCountry = "tw"
	SourceNewsdataCountryTz SourceNewsdataCountry = "tz"
	SourceNewsdataCountryTh SourceNewsdataCountry = "th"
	SourceNewsdataCountryTr SourceNewsdataCountry = "tr"
	SourceNewsdataCountryUa SourceNewsdataCountry = "ua"
	SourceNewsdataCountryAe SourceNewsdataCountry = "ae"
	SourceNewsdataCountryGb SourceNewsdataCountry = "gb"
	SourceNewsdataCountryUs SourceNewsdataCountry = "us"
	SourceNewsdataCountryVe SourceNewsdataCountry = "ve"
	SourceNewsdataCountryVi SourceNewsdataCountry = "vi"
)

func (e SourceNewsdataCountry) ToPointer() *SourceNewsdataCountry {
	return &e
}
func (e *SourceNewsdataCountry) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "ar":
		fallthrough
	case "au":
		fallthrough
	case "at":
		fallthrough
	case "bd":
		fallthrough
	case "by":
		fallthrough
	case "be":
		fallthrough
	case "br":
		fallthrough
	case "bg":
		fallthrough
	case "ca":
		fallthrough
	case "cl":
		fallthrough
	case "cn":
		fallthrough
	case "co":
		fallthrough
	case "cr":
		fallthrough
	case "cu":
		fallthrough
	case "cz":
		fallthrough
	case "dk":
		fallthrough
	case "do":
		fallthrough
	case "ec":
		fallthrough
	case "eg":
		fallthrough
	case "ee":
		fallthrough
	case "et":
		fallthrough
	case "fi":
		fallthrough
	case "fr":
		fallthrough
	case "de":
		fallthrough
	case "gr":
		fallthrough
	case "hk":
		fallthrough
	case "hu":
		fallthrough
	case "in":
		fallthrough
	case "id":
		fallthrough
	case "iq":
		fallthrough
	case "ie":
		fallthrough
	case "il":
		fallthrough
	case "it":
		fallthrough
	case "jp":
		fallthrough
	case "kz":
		fallthrough
	case "kw":
		fallthrough
	case "lv":
		fallthrough
	case "lb":
		fallthrough
	case "lt":
		fallthrough
	case "my":
		fallthrough
	case "mx":
		fallthrough
	case "ma":
		fallthrough
	case "mm":
		fallthrough
	case "nl":
		fallthrough
	case "nz":
		fallthrough
	case "ng":
		fallthrough
	case "kp":
		fallthrough
	case "no":
		fallthrough
	case "pk":
		fallthrough
	case "pe":
		fallthrough
	case "ph":
		fallthrough
	case "pl":
		fallthrough
	case "pt":
		fallthrough
	case "pr":
		fallthrough
	case "ro":
		fallthrough
	case "ru":
		fallthrough
	case "sa":
		fallthrough
	case "rs":
		fallthrough
	case "sg":
		fallthrough
	case "sk":
		fallthrough
	case "si":
		fallthrough
	case "za":
		fallthrough
	case "kr":
		fallthrough
	case "es":
		fallthrough
	case "se":
		fallthrough
	case "ch":
		fallthrough
	case "tw":
		fallthrough
	case "tz":
		fallthrough
	case "th":
		fallthrough
	case "tr":
		fallthrough
	case "ua":
		fallthrough
	case "ae":
		fallthrough
	case "gb":
		fallthrough
	case "us":
		fallthrough
	case "ve":
		fallthrough
	case "vi":
		*e = SourceNewsdataCountry(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceNewsdataCountry: %v", v)
	}
}

type SourceNewsdataLanguage string

const (
	SourceNewsdataLanguageBe  SourceNewsdataLanguage = "be"
	SourceNewsdataLanguageAm  SourceNewsdataLanguage = "am"
	SourceNewsdataLanguageAr  SourceNewsdataLanguage = "ar"
	SourceNewsdataLanguageBn  SourceNewsdataLanguage = "bn"
	SourceNewsdataLanguageBs  SourceNewsdataLanguage = "bs"
	SourceNewsdataLanguageBg  SourceNewsdataLanguage = "bg"
	SourceNewsdataLanguageMy  SourceNewsdataLanguage = "my"
	SourceNewsdataLanguageCkb SourceNewsdataLanguage = "ckb"
	SourceNewsdataLanguageZh  SourceNewsdataLanguage = "zh"
	SourceNewsdataLanguageHr  SourceNewsdataLanguage = "hr"
	SourceNewsdataLanguageCs  SourceNewsdataLanguage = "cs"
	SourceNewsdataLanguageDa  SourceNewsdataLanguage = "da"
	SourceNewsdataLanguageNl  SourceNewsdataLanguage = "nl"
	SourceNewsdataLanguageEn  SourceNewsdataLanguage = "en"
	SourceNewsdataLanguageEt  SourceNewsdataLanguage = "et"
	SourceNewsdataLanguageFi  SourceNewsdataLanguage = "fi"
	SourceNewsdataLanguageFr  SourceNewsdataLanguage = "fr"
	SourceNewsdataLanguageDe  SourceNewsdataLanguage = "de"
	SourceNewsdataLanguageEl  SourceNewsdataLanguage = "el"
	SourceNewsdataLanguageHe  SourceNewsdataLanguage = "he"
	SourceNewsdataLanguageHi  SourceNewsdataLanguage = "hi"
	SourceNewsdataLanguageHu  SourceNewsdataLanguage = "hu"
	SourceNewsdataLanguageIn  SourceNewsdataLanguage = "in"
	SourceNewsdataLanguageIt  SourceNewsdataLanguage = "it"
	SourceNewsdataLanguageJp  SourceNewsdataLanguage = "jp"
	SourceNewsdataLanguageKo  SourceNewsdataLanguage = "ko"
	SourceNewsdataLanguageLv  SourceNewsdataLanguage = "lv"
	SourceNewsdataLanguageLt  SourceNewsdataLanguage = "lt"
	SourceNewsdataLanguageMs  SourceNewsdataLanguage = "ms"
	SourceNewsdataLanguageNo  SourceNewsdataLanguage = "no"
	SourceNewsdataLanguagePl  SourceNewsdataLanguage = "pl"
	SourceNewsdataLanguagePt  SourceNewsdataLanguage = "pt"
	SourceNewsdataLanguageRo  SourceNewsdataLanguage = "ro"
	SourceNewsdataLanguageRu  SourceNewsdataLanguage = "ru"
	SourceNewsdataLanguageSr  SourceNewsdataLanguage = "sr"
	SourceNewsdataLanguageSk  SourceNewsdataLanguage = "sk"
	SourceNewsdataLanguageSl  SourceNewsdataLanguage = "sl"
	SourceNewsdataLanguageEs  SourceNewsdataLanguage = "es"
	SourceNewsdataLanguageSw  SourceNewsdataLanguage = "sw"
	SourceNewsdataLanguageSv  SourceNewsdataLanguage = "sv"
	SourceNewsdataLanguageTh  SourceNewsdataLanguage = "th"
	SourceNewsdataLanguageTr  SourceNewsdataLanguage = "tr"
	SourceNewsdataLanguageUk  SourceNewsdataLanguage = "uk"
	SourceNewsdataLanguageUr  SourceNewsdataLanguage = "ur"
	SourceNewsdataLanguageVi  SourceNewsdataLanguage = "vi"
)

func (e SourceNewsdataLanguage) ToPointer() *SourceNewsdataLanguage {
	return &e
}
func (e *SourceNewsdataLanguage) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "be":
		fallthrough
	case "am":
		fallthrough
	case "ar":
		fallthrough
	case "bn":
		fallthrough
	case "bs":
		fallthrough
	case "bg":
		fallthrough
	case "my":
		fallthrough
	case "ckb":
		fallthrough
	case "zh":
		fallthrough
	case "hr":
		fallthrough
	case "cs":
		fallthrough
	case "da":
		fallthrough
	case "nl":
		fallthrough
	case "en":
		fallthrough
	case "et":
		fallthrough
	case "fi":
		fallthrough
	case "fr":
		fallthrough
	case "de":
		fallthrough
	case "el":
		fallthrough
	case "he":
		fallthrough
	case "hi":
		fallthrough
	case "hu":
		fallthrough
	case "in":
		fallthrough
	case "it":
		fallthrough
	case "jp":
		fallthrough
	case "ko":
		fallthrough
	case "lv":
		fallthrough
	case "lt":
		fallthrough
	case "ms":
		fallthrough
	case "no":
		fallthrough
	case "pl":
		fallthrough
	case "pt":
		fallthrough
	case "ro":
		fallthrough
	case "ru":
		fallthrough
	case "sr":
		fallthrough
	case "sk":
		fallthrough
	case "sl":
		fallthrough
	case "es":
		fallthrough
	case "sw":
		fallthrough
	case "sv":
		fallthrough
	case "th":
		fallthrough
	case "tr":
		fallthrough
	case "uk":
		fallthrough
	case "ur":
		fallthrough
	case "vi":
		*e = SourceNewsdataLanguage(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceNewsdataLanguage: %v", v)
	}
}

type Newsdata string

const (
	NewsdataNewsdata Newsdata = "newsdata"
)

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

type SourceNewsdata struct {
	OneOf any `json:"OneOf,omitempty"`
	// API Key
	APIKey string `json:"api_key"`
	// Categories (maximum 5) to restrict the search to.
	Category []SourceNewsdataCategory `json:"category,omitempty"`
	// 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to.
	Country []SourceNewsdataCountry `json:"country,omitempty"`
	// Domains (maximum 5) to restrict the search to. Use the sources stream to find top sources id.
	Domain []string `json:"domain,omitempty"`
	// Languages (maximum 5) to restrict the search to.
	Language   []SourceNewsdataLanguage `json:"language,omitempty"`
	sourceType Newsdata                 `const:"newsdata" json:"sourceType"`
}

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

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

func (o *SourceNewsdata) GetOneOf() any {
	if o == nil {
		return nil
	}
	return o.OneOf
}

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

func (o *SourceNewsdata) GetCategory() []SourceNewsdataCategory {
	if o == nil {
		return nil
	}
	return o.Category
}

func (o *SourceNewsdata) GetCountry() []SourceNewsdataCountry {
	if o == nil {
		return nil
	}
	return o.Country
}

func (o *SourceNewsdata) GetDomain() []string {
	if o == nil {
		return nil
	}
	return o.Domain
}

func (o *SourceNewsdata) GetLanguage() []SourceNewsdataLanguage {
	if o == nil {
		return nil
	}
	return o.Language
}

func (o *SourceNewsdata) GetSourceType() Newsdata {
	return NewsdataNewsdata
}
