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

type SourceAmazonAdsUpdateAuthType string

const (
	SourceAmazonAdsUpdateAuthTypeOauth20 SourceAmazonAdsUpdateAuthType = "oauth2.0"
)

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

// SourceAmazonAdsUpdateRegion - Region to pull data from (EU/NA/FE). See <a href="https://advertising.amazon.com/API/docs/en-us/info/api-overview#api-endpoints">docs</a> for more details.
type SourceAmazonAdsUpdateRegion string

const (
	SourceAmazonAdsUpdateRegionNa SourceAmazonAdsUpdateRegion = "NA"
	SourceAmazonAdsUpdateRegionEu SourceAmazonAdsUpdateRegion = "EU"
	SourceAmazonAdsUpdateRegionFe SourceAmazonAdsUpdateRegion = "FE"
)

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

type SourceAmazonAdsUpdate struct {
	authType *SourceAmazonAdsUpdateAuthType `const:"oauth2.0" json:"auth_type"`
	// The client ID of your Amazon Ads developer application. See the <a href="https://advertising.amazon.com/API/docs/en-us/get-started/generate-api-tokens#retrieve-your-client-id-and-client-secret">docs</a> for more information.
	ClientID string `json:"client_id"`
	// The client secret of your Amazon Ads developer application. See the <a href="https://advertising.amazon.com/API/docs/en-us/get-started/generate-api-tokens#retrieve-your-client-id-and-client-secret">docs</a> for more information.
	ClientSecret string `json:"client_secret"`
	// The amount of days to go back in time to get the updated data from Amazon Ads
	LookBackWindow *int64 `default:"3" json:"look_back_window"`
	// Marketplace IDs you want to fetch data for. Note: If Profile IDs are also selected, profiles will be selected if they match the Profile ID OR the Marketplace ID.
	MarketplaceIds []string `json:"marketplace_ids,omitempty"`
	// Profile IDs you want to fetch data for. The Amazon Ads source connector supports only profiles with seller and vendor type, profiles with agency type will be ignored. See <a href="https://advertising.amazon.com/API/docs/en-us/concepts/authorization/profiles">docs</a> for more details. Note: If Marketplace IDs are also selected, profiles will be selected if they match the Profile ID OR the Marketplace ID.
	Profiles []int64 `json:"profiles,omitempty"`
	// Amazon Ads refresh token. See the <a href="https://advertising.amazon.com/API/docs/en-us/get-started/generate-api-tokens">docs</a> for more information on how to obtain this token.
	RefreshToken string `json:"refresh_token"`
	// Region to pull data from (EU/NA/FE). See <a href="https://advertising.amazon.com/API/docs/en-us/info/api-overview#api-endpoints">docs</a> for more details.
	Region *SourceAmazonAdsUpdateRegion `default:"NA" json:"region"`
	// The Start date for collecting reports, should not be more than 60 days in the past. In YYYY-MM-DD format
	StartDate *types.Date `json:"start_date,omitempty"`
}

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

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

func (o *SourceAmazonAdsUpdate) GetAuthType() *SourceAmazonAdsUpdateAuthType {
	return SourceAmazonAdsUpdateAuthTypeOauth20.ToPointer()
}

func (o *SourceAmazonAdsUpdate) GetClientID() string {
	if o == nil {
		return ""
	}
	return o.ClientID
}

func (o *SourceAmazonAdsUpdate) GetClientSecret() string {
	if o == nil {
		return ""
	}
	return o.ClientSecret
}

func (o *SourceAmazonAdsUpdate) GetLookBackWindow() *int64 {
	if o == nil {
		return nil
	}
	return o.LookBackWindow
}

func (o *SourceAmazonAdsUpdate) GetMarketplaceIds() []string {
	if o == nil {
		return nil
	}
	return o.MarketplaceIds
}

func (o *SourceAmazonAdsUpdate) GetProfiles() []int64 {
	if o == nil {
		return nil
	}
	return o.Profiles
}

func (o *SourceAmazonAdsUpdate) GetRefreshToken() string {
	if o == nil {
		return ""
	}
	return o.RefreshToken
}

func (o *SourceAmazonAdsUpdate) GetRegion() *SourceAmazonAdsUpdateRegion {
	if o == nil {
		return nil
	}
	return o.Region
}

func (o *SourceAmazonAdsUpdate) GetStartDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.StartDate
}
