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

// Category - The category you want to get top headlines for.
type Category string

const (
	CategoryBusiness      Category = "business"
	CategoryEntertainment Category = "entertainment"
	CategoryGeneral       Category = "general"
	CategoryHealth        Category = "health"
	CategoryScience       Category = "science"
	CategorySports        Category = "sports"
	CategoryTechnology    Category = "technology"
)

func (e Category) ToPointer() *Category {
	return &e
}
func (e *Category) 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 "general":
		fallthrough
	case "health":
		fallthrough
	case "science":
		fallthrough
	case "sports":
		fallthrough
	case "technology":
		*e = Category(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Category: %v", v)
	}
}

// Country - The 2-letter ISO 3166-1 code of the country you want to get headlines
// for. You can't mix this with the sources parameter.
type Country string

const (
	CountryAe Country = "ae"
	CountryAr Country = "ar"
	CountryAt Country = "at"
	CountryAu Country = "au"
	CountryBe Country = "be"
	CountryBg Country = "bg"
	CountryBr Country = "br"
	CountryCa Country = "ca"
	CountryCh Country = "ch"
	CountryCn Country = "cn"
	CountryCo Country = "co"
	CountryCu Country = "cu"
	CountryCz Country = "cz"
	CountryDe Country = "de"
	CountryEg Country = "eg"
	CountryFr Country = "fr"
	CountryGb Country = "gb"
	CountryGr Country = "gr"
	CountryHk Country = "hk"
	CountryHu Country = "hu"
	CountryID Country = "id"
	CountryIe Country = "ie"
	CountryIl Country = "il"
	CountryIn Country = "in"
	CountryIt Country = "it"
	CountryJp Country = "jp"
	CountryKr Country = "kr"
	CountryLt Country = "lt"
	CountryLv Country = "lv"
	CountryMa Country = "ma"
	CountryMx Country = "mx"
	CountryMy Country = "my"
	CountryNg Country = "ng"
	CountryNl Country = "nl"
	CountryNo Country = "no"
	CountryNz Country = "nz"
	CountryPh Country = "ph"
	CountryPl Country = "pl"
	CountryPt Country = "pt"
	CountryRo Country = "ro"
	CountryRs Country = "rs"
	CountryRu Country = "ru"
	CountrySa Country = "sa"
	CountrySe Country = "se"
	CountrySg Country = "sg"
	CountrySi Country = "si"
	CountrySk Country = "sk"
	CountryTh Country = "th"
	CountryTr Country = "tr"
	CountryTw Country = "tw"
	CountryUa Country = "ua"
	CountryUs Country = "us"
	CountryVe Country = "ve"
	CountryZa Country = "za"
)

func (e Country) ToPointer() *Country {
	return &e
}
func (e *Country) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "ae":
		fallthrough
	case "ar":
		fallthrough
	case "at":
		fallthrough
	case "au":
		fallthrough
	case "be":
		fallthrough
	case "bg":
		fallthrough
	case "br":
		fallthrough
	case "ca":
		fallthrough
	case "ch":
		fallthrough
	case "cn":
		fallthrough
	case "co":
		fallthrough
	case "cu":
		fallthrough
	case "cz":
		fallthrough
	case "de":
		fallthrough
	case "eg":
		fallthrough
	case "fr":
		fallthrough
	case "gb":
		fallthrough
	case "gr":
		fallthrough
	case "hk":
		fallthrough
	case "hu":
		fallthrough
	case "id":
		fallthrough
	case "ie":
		fallthrough
	case "il":
		fallthrough
	case "in":
		fallthrough
	case "it":
		fallthrough
	case "jp":
		fallthrough
	case "kr":
		fallthrough
	case "lt":
		fallthrough
	case "lv":
		fallthrough
	case "ma":
		fallthrough
	case "mx":
		fallthrough
	case "my":
		fallthrough
	case "ng":
		fallthrough
	case "nl":
		fallthrough
	case "no":
		fallthrough
	case "nz":
		fallthrough
	case "ph":
		fallthrough
	case "pl":
		fallthrough
	case "pt":
		fallthrough
	case "ro":
		fallthrough
	case "rs":
		fallthrough
	case "ru":
		fallthrough
	case "sa":
		fallthrough
	case "se":
		fallthrough
	case "sg":
		fallthrough
	case "si":
		fallthrough
	case "sk":
		fallthrough
	case "th":
		fallthrough
	case "tr":
		fallthrough
	case "tw":
		fallthrough
	case "ua":
		fallthrough
	case "us":
		fallthrough
	case "ve":
		fallthrough
	case "za":
		*e = Country(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Country: %v", v)
	}
}

// Language - The 2-letter ISO-639-1 code of the language you want to get headlines
// for. Possible options: ar de en es fr he it nl no pt ru se ud zh.
type Language string

const (
	LanguageAr Language = "ar"
	LanguageDe Language = "de"
	LanguageEn Language = "en"
	LanguageEs Language = "es"
	LanguageFr Language = "fr"
	LanguageHe Language = "he"
	LanguageIt Language = "it"
	LanguageNl Language = "nl"
	LanguageNo Language = "no"
	LanguagePt Language = "pt"
	LanguageRu Language = "ru"
	LanguageSe Language = "se"
	LanguageUd Language = "ud"
	LanguageZh Language = "zh"
)

func (e Language) ToPointer() *Language {
	return &e
}
func (e *Language) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "ar":
		fallthrough
	case "de":
		fallthrough
	case "en":
		fallthrough
	case "es":
		fallthrough
	case "fr":
		fallthrough
	case "he":
		fallthrough
	case "it":
		fallthrough
	case "nl":
		fallthrough
	case "no":
		fallthrough
	case "pt":
		fallthrough
	case "ru":
		fallthrough
	case "se":
		fallthrough
	case "ud":
		fallthrough
	case "zh":
		*e = Language(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Language: %v", v)
	}
}

type SearchIn string

const (
	SearchInTitle       SearchIn = "title"
	SearchInDescription SearchIn = "description"
	SearchInContent     SearchIn = "content"
)

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

// SortBy - The order to sort the articles in. Possible options: relevancy,
// popularity, publishedAt.
type SortBy string

const (
	SortByRelevancy   SortBy = "relevancy"
	SortByPopularity  SortBy = "popularity"
	SortByPublishedAt SortBy = "publishedAt"
)

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

type NewsAPI string

const (
	NewsAPINewsAPI NewsAPI = "news-api"
)

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

type SourceNewsAPI struct {
	// API Key
	APIKey string `json:"api_key"`
	// The category you want to get top headlines for.
	Category *Category `default:"business" json:"category"`
	// The 2-letter ISO 3166-1 code of the country you want to get headlines
	// for. You can't mix this with the sources parameter.
	//
	Country *Country `default:"us" json:"country"`
	// A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com,
	// engadget.com) to restrict the search to.
	//
	Domains []string `json:"domains,omitempty"`
	// A date and optional time for the newest article allowed. This should
	// be in ISO 8601 format.
	//
	EndDate *string `json:"end_date,omitempty"`
	// A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com,
	// engadget.com) to remove from the results.
	//
	ExcludeDomains []string `json:"exclude_domains,omitempty"`
	// The 2-letter ISO-639-1 code of the language you want to get headlines
	// for. Possible options: ar de en es fr he it nl no pt ru se ud zh.
	//
	Language *Language `json:"language,omitempty"`
	// Where to apply search query. Possible values are: title, description,
	// content.
	//
	SearchIn []SearchIn `json:"search_in,omitempty"`
	// Search query. See https://newsapi.org/docs/endpoints/everything for
	// information.
	//
	SearchQuery *string `json:"search_query,omitempty"`
	// The order to sort the articles in. Possible options: relevancy,
	// popularity, publishedAt.
	//
	SortBy *SortBy `default:"publishedAt" json:"sort_by"`
	// Identifiers (maximum 20) for the news sources or blogs you want
	// headlines from. Use the `/sources` endpoint to locate these
	// programmatically or look at the sources index:
	// https://newsapi.com/sources. Will override both country and category.
	//
	Sources []string `json:"sources,omitempty"`
	// A date and optional time for the oldest article allowed. This should
	// be in ISO 8601 format.
	//
	StartDate  *string `json:"start_date,omitempty"`
	sourceType NewsAPI `const:"news-api" json:"sourceType"`
}

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

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

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

func (o *SourceNewsAPI) GetCategory() *Category {
	if o == nil {
		return nil
	}
	return o.Category
}

func (o *SourceNewsAPI) GetCountry() *Country {
	if o == nil {
		return nil
	}
	return o.Country
}

func (o *SourceNewsAPI) GetDomains() []string {
	if o == nil {
		return nil
	}
	return o.Domains
}

func (o *SourceNewsAPI) GetEndDate() *string {
	if o == nil {
		return nil
	}
	return o.EndDate
}

func (o *SourceNewsAPI) GetExcludeDomains() []string {
	if o == nil {
		return nil
	}
	return o.ExcludeDomains
}

func (o *SourceNewsAPI) GetLanguage() *Language {
	if o == nil {
		return nil
	}
	return o.Language
}

func (o *SourceNewsAPI) GetSearchIn() []SearchIn {
	if o == nil {
		return nil
	}
	return o.SearchIn
}

func (o *SourceNewsAPI) GetSearchQuery() *string {
	if o == nil {
		return nil
	}
	return o.SearchQuery
}

func (o *SourceNewsAPI) GetSortBy() *SortBy {
	if o == nil {
		return nil
	}
	return o.SortBy
}

func (o *SourceNewsAPI) GetSources() []string {
	if o == nil {
		return nil
	}
	return o.Sources
}

func (o *SourceNewsAPI) GetStartDate() *string {
	if o == nil {
		return nil
	}
	return o.StartDate
}

func (o *SourceNewsAPI) GetSourceType() NewsAPI {
	return NewsAPINewsAPI
}
