// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package shared

import (
	"encoding/json"
	"fmt"
)

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

const (
	SourceGnewsUpdateCountryAu SourceGnewsUpdateCountry = "au"
	SourceGnewsUpdateCountryBr SourceGnewsUpdateCountry = "br"
	SourceGnewsUpdateCountryCa SourceGnewsUpdateCountry = "ca"
	SourceGnewsUpdateCountryCn SourceGnewsUpdateCountry = "cn"
	SourceGnewsUpdateCountryEg SourceGnewsUpdateCountry = "eg"
	SourceGnewsUpdateCountryFr SourceGnewsUpdateCountry = "fr"
	SourceGnewsUpdateCountryDe SourceGnewsUpdateCountry = "de"
	SourceGnewsUpdateCountryGr SourceGnewsUpdateCountry = "gr"
	SourceGnewsUpdateCountryHk SourceGnewsUpdateCountry = "hk"
	SourceGnewsUpdateCountryIn SourceGnewsUpdateCountry = "in"
	SourceGnewsUpdateCountryIe SourceGnewsUpdateCountry = "ie"
	SourceGnewsUpdateCountryIl SourceGnewsUpdateCountry = "il"
	SourceGnewsUpdateCountryIt SourceGnewsUpdateCountry = "it"
	SourceGnewsUpdateCountryJp SourceGnewsUpdateCountry = "jp"
	SourceGnewsUpdateCountryNl SourceGnewsUpdateCountry = "nl"
	SourceGnewsUpdateCountryNo SourceGnewsUpdateCountry = "no"
	SourceGnewsUpdateCountryPk SourceGnewsUpdateCountry = "pk"
	SourceGnewsUpdateCountryPe SourceGnewsUpdateCountry = "pe"
	SourceGnewsUpdateCountryPh SourceGnewsUpdateCountry = "ph"
	SourceGnewsUpdateCountryPt SourceGnewsUpdateCountry = "pt"
	SourceGnewsUpdateCountryRo SourceGnewsUpdateCountry = "ro"
	SourceGnewsUpdateCountryRu SourceGnewsUpdateCountry = "ru"
	SourceGnewsUpdateCountrySg SourceGnewsUpdateCountry = "sg"
	SourceGnewsUpdateCountryEs SourceGnewsUpdateCountry = "es"
	SourceGnewsUpdateCountrySe SourceGnewsUpdateCountry = "se"
	SourceGnewsUpdateCountryCh SourceGnewsUpdateCountry = "ch"
	SourceGnewsUpdateCountryTw SourceGnewsUpdateCountry = "tw"
	SourceGnewsUpdateCountryUa SourceGnewsUpdateCountry = "ua"
	SourceGnewsUpdateCountryGb SourceGnewsUpdateCountry = "gb"
	SourceGnewsUpdateCountryUs SourceGnewsUpdateCountry = "us"
)

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

type SourceGnewsUpdateIn string

const (
	SourceGnewsUpdateInTitle       SourceGnewsUpdateIn = "title"
	SourceGnewsUpdateInDescription SourceGnewsUpdateIn = "description"
	SourceGnewsUpdateInContent     SourceGnewsUpdateIn = "content"
)

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

type SourceGnewsUpdateLanguage string

const (
	SourceGnewsUpdateLanguageAr SourceGnewsUpdateLanguage = "ar"
	SourceGnewsUpdateLanguageZh SourceGnewsUpdateLanguage = "zh"
	SourceGnewsUpdateLanguageNl SourceGnewsUpdateLanguage = "nl"
	SourceGnewsUpdateLanguageEn SourceGnewsUpdateLanguage = "en"
	SourceGnewsUpdateLanguageFr SourceGnewsUpdateLanguage = "fr"
	SourceGnewsUpdateLanguageDe SourceGnewsUpdateLanguage = "de"
	SourceGnewsUpdateLanguageEl SourceGnewsUpdateLanguage = "el"
	SourceGnewsUpdateLanguageHe SourceGnewsUpdateLanguage = "he"
	SourceGnewsUpdateLanguageHi SourceGnewsUpdateLanguage = "hi"
	SourceGnewsUpdateLanguageIt SourceGnewsUpdateLanguage = "it"
	SourceGnewsUpdateLanguageJa SourceGnewsUpdateLanguage = "ja"
	SourceGnewsUpdateLanguageMl SourceGnewsUpdateLanguage = "ml"
	SourceGnewsUpdateLanguageMr SourceGnewsUpdateLanguage = "mr"
	SourceGnewsUpdateLanguageNo SourceGnewsUpdateLanguage = "no"
	SourceGnewsUpdateLanguagePt SourceGnewsUpdateLanguage = "pt"
	SourceGnewsUpdateLanguageRo SourceGnewsUpdateLanguage = "ro"
	SourceGnewsUpdateLanguageRu SourceGnewsUpdateLanguage = "ru"
	SourceGnewsUpdateLanguageEs SourceGnewsUpdateLanguage = "es"
	SourceGnewsUpdateLanguageSv SourceGnewsUpdateLanguage = "sv"
	SourceGnewsUpdateLanguageTa SourceGnewsUpdateLanguage = "ta"
	SourceGnewsUpdateLanguageTe SourceGnewsUpdateLanguage = "te"
	SourceGnewsUpdateLanguageUk SourceGnewsUpdateLanguage = "uk"
)

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

type SourceGnewsUpdateNullable string

const (
	SourceGnewsUpdateNullableTitle       SourceGnewsUpdateNullable = "title"
	SourceGnewsUpdateNullableDescription SourceGnewsUpdateNullable = "description"
	SourceGnewsUpdateNullableContent     SourceGnewsUpdateNullable = "content"
)

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

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

const (
	SourceGnewsUpdateSortByPublishedAt SourceGnewsUpdateSortBy = "publishedAt"
	SourceGnewsUpdateSortByRelevance   SourceGnewsUpdateSortBy = "relevance"
)

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

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

const (
	SourceGnewsUpdateTopHeadlinesTopicBreakingNews  SourceGnewsUpdateTopHeadlinesTopic = "breaking-news"
	SourceGnewsUpdateTopHeadlinesTopicWorld         SourceGnewsUpdateTopHeadlinesTopic = "world"
	SourceGnewsUpdateTopHeadlinesTopicNation        SourceGnewsUpdateTopHeadlinesTopic = "nation"
	SourceGnewsUpdateTopHeadlinesTopicBusiness      SourceGnewsUpdateTopHeadlinesTopic = "business"
	SourceGnewsUpdateTopHeadlinesTopicTechnology    SourceGnewsUpdateTopHeadlinesTopic = "technology"
	SourceGnewsUpdateTopHeadlinesTopicEntertainment SourceGnewsUpdateTopHeadlinesTopic = "entertainment"
	SourceGnewsUpdateTopHeadlinesTopicSports        SourceGnewsUpdateTopHeadlinesTopic = "sports"
	SourceGnewsUpdateTopHeadlinesTopicScience       SourceGnewsUpdateTopHeadlinesTopic = "science"
	SourceGnewsUpdateTopHeadlinesTopicHealth        SourceGnewsUpdateTopHeadlinesTopic = "health"
)

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

type SourceGnewsUpdate 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 *SourceGnewsUpdateCountry `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       []SourceGnewsUpdateIn      `json:"in,omitempty"`
	Language *SourceGnewsUpdateLanguage `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 []SourceGnewsUpdateNullable `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 *SourceGnewsUpdateSortBy `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 *SourceGnewsUpdateTopHeadlinesTopic `json:"top_headlines_topic,omitempty"`
}

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

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

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

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

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

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

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

func (o *SourceGnewsUpdate) GetSortby() *SourceGnewsUpdateSortBy {
	if o == nil {
		return nil
	}
	return o.Sortby
}

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

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

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