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

// SourceGnewsCountry - This parameter allows you to specify the country where the news articles returned by the API were published, the contents of the articles are not necessarily related to the specified country. You have to set as value the 2 letters code of the country you want to filter.
type SourceGnewsCountry string

const (
	SourceGnewsCountryAu SourceGnewsCountry = "au"
	SourceGnewsCountryBr SourceGnewsCountry = "br"
	SourceGnewsCountryCa SourceGnewsCountry = "ca"
	SourceGnewsCountryCn SourceGnewsCountry = "cn"
	SourceGnewsCountryEg SourceGnewsCountry = "eg"
	SourceGnewsCountryFr SourceGnewsCountry = "fr"
	SourceGnewsCountryDe SourceGnewsCountry = "de"
	SourceGnewsCountryGr SourceGnewsCountry = "gr"
	SourceGnewsCountryHk SourceGnewsCountry = "hk"
	SourceGnewsCountryIn SourceGnewsCountry = "in"
	SourceGnewsCountryIe SourceGnewsCountry = "ie"
	SourceGnewsCountryIl SourceGnewsCountry = "il"
	SourceGnewsCountryIt SourceGnewsCountry = "it"
	SourceGnewsCountryJp SourceGnewsCountry = "jp"
	SourceGnewsCountryNl SourceGnewsCountry = "nl"
	SourceGnewsCountryNo SourceGnewsCountry = "no"
	SourceGnewsCountryPk SourceGnewsCountry = "pk"
	SourceGnewsCountryPe SourceGnewsCountry = "pe"
	SourceGnewsCountryPh SourceGnewsCountry = "ph"
	SourceGnewsCountryPt SourceGnewsCountry = "pt"
	SourceGnewsCountryRo SourceGnewsCountry = "ro"
	SourceGnewsCountryRu SourceGnewsCountry = "ru"
	SourceGnewsCountrySg SourceGnewsCountry = "sg"
	SourceGnewsCountryEs SourceGnewsCountry = "es"
	SourceGnewsCountrySe SourceGnewsCountry = "se"
	SourceGnewsCountryCh SourceGnewsCountry = "ch"
	SourceGnewsCountryTw SourceGnewsCountry = "tw"
	SourceGnewsCountryUa SourceGnewsCountry = "ua"
	SourceGnewsCountryGb SourceGnewsCountry = "gb"
	SourceGnewsCountryUs SourceGnewsCountry = "us"
)

func (e SourceGnewsCountry) ToPointer() *SourceGnewsCountry {
	return &e
}
func (e *SourceGnewsCountry) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "au":
		fallthrough
	case "br":
		fallthrough
	case "ca":
		fallthrough
	case "cn":
		fallthrough
	case "eg":
		fallthrough
	case "fr":
		fallthrough
	case "de":
		fallthrough
	case "gr":
		fallthrough
	case "hk":
		fallthrough
	case "in":
		fallthrough
	case "ie":
		fallthrough
	case "il":
		fallthrough
	case "it":
		fallthrough
	case "jp":
		fallthrough
	case "nl":
		fallthrough
	case "no":
		fallthrough
	case "pk":
		fallthrough
	case "pe":
		fallthrough
	case "ph":
		fallthrough
	case "pt":
		fallthrough
	case "ro":
		fallthrough
	case "ru":
		fallthrough
	case "sg":
		fallthrough
	case "es":
		fallthrough
	case "se":
		fallthrough
	case "ch":
		fallthrough
	case "tw":
		fallthrough
	case "ua":
		fallthrough
	case "gb":
		fallthrough
	case "us":
		*e = SourceGnewsCountry(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceGnewsCountry: %v", v)
	}
}

type In string

const (
	InTitle       In = "title"
	InDescription In = "description"
	InContent     In = "content"
)

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

type SourceGnewsLanguage string

const (
	SourceGnewsLanguageAr SourceGnewsLanguage = "ar"
	SourceGnewsLanguageZh SourceGnewsLanguage = "zh"
	SourceGnewsLanguageNl SourceGnewsLanguage = "nl"
	SourceGnewsLanguageEn SourceGnewsLanguage = "en"
	SourceGnewsLanguageFr SourceGnewsLanguage = "fr"
	SourceGnewsLanguageDe SourceGnewsLanguage = "de"
	SourceGnewsLanguageEl SourceGnewsLanguage = "el"
	SourceGnewsLanguageHe SourceGnewsLanguage = "he"
	SourceGnewsLanguageHi SourceGnewsLanguage = "hi"
	SourceGnewsLanguageIt SourceGnewsLanguage = "it"
	SourceGnewsLanguageJa SourceGnewsLanguage = "ja"
	SourceGnewsLanguageMl SourceGnewsLanguage = "ml"
	SourceGnewsLanguageMr SourceGnewsLanguage = "mr"
	SourceGnewsLanguageNo SourceGnewsLanguage = "no"
	SourceGnewsLanguagePt SourceGnewsLanguage = "pt"
	SourceGnewsLanguageRo SourceGnewsLanguage = "ro"
	SourceGnewsLanguageRu SourceGnewsLanguage = "ru"
	SourceGnewsLanguageEs SourceGnewsLanguage = "es"
	SourceGnewsLanguageSv SourceGnewsLanguage = "sv"
	SourceGnewsLanguageTa SourceGnewsLanguage = "ta"
	SourceGnewsLanguageTe SourceGnewsLanguage = "te"
	SourceGnewsLanguageUk SourceGnewsLanguage = "uk"
)

func (e SourceGnewsLanguage) ToPointer() *SourceGnewsLanguage {
	return &e
}
func (e *SourceGnewsLanguage) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "ar":
		fallthrough
	case "zh":
		fallthrough
	case "nl":
		fallthrough
	case "en":
		fallthrough
	case "fr":
		fallthrough
	case "de":
		fallthrough
	case "el":
		fallthrough
	case "he":
		fallthrough
	case "hi":
		fallthrough
	case "it":
		fallthrough
	case "ja":
		fallthrough
	case "ml":
		fallthrough
	case "mr":
		fallthrough
	case "no":
		fallthrough
	case "pt":
		fallthrough
	case "ro":
		fallthrough
	case "ru":
		fallthrough
	case "es":
		fallthrough
	case "sv":
		fallthrough
	case "ta":
		fallthrough
	case "te":
		fallthrough
	case "uk":
		*e = SourceGnewsLanguage(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceGnewsLanguage: %v", v)
	}
}

type Nullable string

const (
	NullableTitle       Nullable = "title"
	NullableDescription Nullable = "description"
	NullableContent     Nullable = "content"
)

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

// SourceGnewsSortBy - This parameter allows you to choose with which type of sorting the articles should be returned. Two values  are possible:
//   - publishedAt = sort by publication date, the articles with the most recent
//
// publication date are returned first
//   - relevance = sort by best match to keywords, the articles with the best
//
// match are returned first
type SourceGnewsSortBy string

const (
	SourceGnewsSortByPublishedAt SourceGnewsSortBy = "publishedAt"
	SourceGnewsSortByRelevance   SourceGnewsSortBy = "relevance"
)

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

// TopHeadlinesTopic - This parameter allows you to change the category for the request.
type TopHeadlinesTopic string

const (
	TopHeadlinesTopicBreakingNews  TopHeadlinesTopic = "breaking-news"
	TopHeadlinesTopicWorld         TopHeadlinesTopic = "world"
	TopHeadlinesTopicNation        TopHeadlinesTopic = "nation"
	TopHeadlinesTopicBusiness      TopHeadlinesTopic = "business"
	TopHeadlinesTopicTechnology    TopHeadlinesTopic = "technology"
	TopHeadlinesTopicEntertainment TopHeadlinesTopic = "entertainment"
	TopHeadlinesTopicSports        TopHeadlinesTopic = "sports"
	TopHeadlinesTopicScience       TopHeadlinesTopic = "science"
	TopHeadlinesTopicHealth        TopHeadlinesTopic = "health"
)

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

type Gnews string

const (
	GnewsGnews Gnews = "gnews"
)

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

type SourceGnews struct {
	// API Key
	APIKey string `json:"api_key"`
	// This parameter allows you to specify the country where the news articles returned by the API were published, the contents of the articles are not necessarily related to the specified country. You have to set as value the 2 letters code of the country you want to filter.
	Country *SourceGnewsCountry `json:"country,omitempty"`
	// This parameter allows you to filter the articles that have a publication date smaller than or equal to the  specified value. The date must respect the following format: YYYY-MM-DD hh:mm:ss (in UTC)
	EndDate *string `json:"end_date,omitempty"`
	// This parameter allows you to choose in which attributes the keywords are searched. The attributes that can be set are title, description and content. It is possible to combine several attributes.
	In       []In                 `json:"in,omitempty"`
	Language *SourceGnewsLanguage `json:"language,omitempty"`
	// This parameter allows you to specify the attributes that you allow to return null values. The attributes that  can be set are title, description and content. It is possible to combine several attributes
	Nullable []Nullable `json:"nullable,omitempty"`
	// This parameter allows you to specify your search keywords to find the news articles you are looking for. The keywords will be used to return the most relevant articles. It is possible to use logical operators  with keywords. - Phrase Search Operator: This operator allows you to make an exact search. Keywords surrounded by
	//   quotation marks are used to search for articles with the exact same keyword
	// sequence.
	//   For example the query: "Apple iPhone" will return articles matching at
	// least once this sequence of keywords. - Logical AND Operator: This operator allows you to make sure that several keywords are all used in the article
	//   search. By default the space character acts as an AND operator, it is
	// possible to replace the space character
	//   by AND to obtain the same result. For example the query: Apple Microsoft
	// is equivalent to Apple AND Microsoft - Logical OR Operator: This operator allows you to retrieve articles matching the keyword a or the keyword b.
	//   It is important to note that this operator has a higher precedence than
	// the AND operator. For example the
	//   query: Apple OR Microsoft will return all articles matching the keyword
	// Apple as well as all articles matching
	//   the keyword Microsoft
	// - Logical NOT Operator: This operator allows you to remove from the results the articles corresponding to the
	//   specified keywords. To use it, you need to add NOT in front of each word
	// or phrase surrounded by quotes.
	//   For example the query: Apple NOT iPhone will return all articles matching
	// the keyword Apple but not the keyword
	//   iPhone
	Query string `json:"query"`
	// This parameter allows you to choose with which type of sorting the articles should be returned. Two values  are possible:
	//   - publishedAt = sort by publication date, the articles with the most recent
	// publication date are returned first
	//   - relevance = sort by best match to keywords, the articles with the best
	// match are returned first
	Sortby *SourceGnewsSortBy `json:"sortby,omitempty"`
	// This parameter allows you to filter the articles that have a publication date greater than or equal to the  specified value. The date must respect the following format: YYYY-MM-DD hh:mm:ss (in UTC)
	StartDate *string `json:"start_date,omitempty"`
	// This parameter allows you to specify your search keywords to find the news articles you are looking for. The keywords will be used to return the most relevant articles. It is possible to use logical operators  with keywords. - Phrase Search Operator: This operator allows you to make an exact search. Keywords surrounded by
	//   quotation marks are used to search for articles with the exact same keyword
	// sequence.
	//   For example the query: "Apple iPhone" will return articles matching at
	// least once this sequence of keywords. - Logical AND Operator: This operator allows you to make sure that several keywords are all used in the article
	//   search. By default the space character acts as an AND operator, it is
	// possible to replace the space character
	//   by AND to obtain the same result. For example the query: Apple Microsoft
	// is equivalent to Apple AND Microsoft - Logical OR Operator: This operator allows you to retrieve articles matching the keyword a or the keyword b.
	//   It is important to note that this operator has a higher precedence than
	// the AND operator. For example the
	//   query: Apple OR Microsoft will return all articles matching the keyword
	// Apple as well as all articles matching
	//   the keyword Microsoft
	// - Logical NOT Operator: This operator allows you to remove from the results the articles corresponding to the
	//   specified keywords. To use it, you need to add NOT in front of each word
	// or phrase surrounded by quotes.
	//   For example the query: Apple NOT iPhone will return all articles matching
	// the keyword Apple but not the keyword
	//   iPhone
	TopHeadlinesQuery *string `json:"top_headlines_query,omitempty"`
	// This parameter allows you to change the category for the request.
	TopHeadlinesTopic *TopHeadlinesTopic `json:"top_headlines_topic,omitempty"`
	sourceType        Gnews              `const:"gnews" json:"sourceType"`
}

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

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

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

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

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

func (o *SourceGnews) GetIn() []In {
	if o == nil {
		return nil
	}
	return o.In
}

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

func (o *SourceGnews) GetNullable() []Nullable {
	if o == nil {
		return nil
	}
	return o.Nullable
}

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

func (o *SourceGnews) GetSortby() *SourceGnewsSortBy {
	if o == nil {
		return nil
	}
	return o.Sortby
}

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

func (o *SourceGnews) GetTopHeadlinesQuery() *string {
	if o == nil {
		return nil
	}
	return o.TopHeadlinesQuery
}

func (o *SourceGnews) GetTopHeadlinesTopic() *TopHeadlinesTopic {
	if o == nil {
		return nil
	}
	return o.TopHeadlinesTopic
}

func (o *SourceGnews) GetSourceType() Gnews {
	return GnewsGnews
}
