// 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"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/types"
	"time"
)

type NewsdataIo string

const (
	NewsdataIoNewsdataIo NewsdataIo = "newsdata-io"
)

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

type SourceNewsdataIo struct {
	APIKey string `json:"api_key"`
	// Search the news articles for a specific category. You can add up to 5 categories in a single query.
	Categories []any `json:"categories,omitempty"`
	// Search the news articles from a specific country. You can add up to 5 countries in a single query. Example: au, jp, br
	Countries []any `json:"countries,omitempty"`
	// Search the news articles for specific domains or news sources. You can add up to 5 domains in a single query.
	Domains []any `json:"domains,omitempty"`
	// Choose an end date. Now UTC is default value
	EndDate *types.Date `json:"end_date,omitempty"`
	// Search the news articles for a specific language. You can add up to 5 languages in a single query.
	Languages []any `json:"languages,omitempty"`
	// Search news articles for specific keywords or phrases present in the news title, content, URL, meta keywords and meta description.
	SearchQuery *string    `json:"search_query,omitempty"`
	StartDate   time.Time  `json:"start_date"`
	sourceType  NewsdataIo `const:"newsdata-io" json:"sourceType"`
}

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

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

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

func (o *SourceNewsdataIo) GetCategories() []any {
	if o == nil {
		return nil
	}
	return o.Categories
}

func (o *SourceNewsdataIo) GetCountries() []any {
	if o == nil {
		return nil
	}
	return o.Countries
}

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

func (o *SourceNewsdataIo) GetEndDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.EndDate
}

func (o *SourceNewsdataIo) GetLanguages() []any {
	if o == nil {
		return nil
	}
	return o.Languages
}

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

func (o *SourceNewsdataIo) GetStartDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.StartDate
}

func (o *SourceNewsdataIo) GetSourceType() NewsdataIo {
	return NewsdataIoNewsdataIo
}
