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

const (
	AwinAdvertiserAwinAdvertiser AwinAdvertiser = "awin-advertiser"
)

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

type SourceAwinAdvertiser struct {
	// Your Awin Advertiser ID. You can find this in your Awin dashboard or account settings.
	AdvertiserID string `json:"advertiserId"`
	// Your Awin API key. Generate this from your Awin account under API Credentials.
	APIKey string `json:"api_key"`
	// Number of days to look back on each sync to catch any updates to existing records.
	LookbackDays int64 `json:"lookback_days"`
	// Start date for data replication in YYYY-MM-DD format
	StartDate types.Date `json:"start_date"`
	// The time window size for each API request in ISO8601 duration format.
	// For the campaign performance stream, Awin API explicitly limits the period between startDate and endDate to 400 days maximum.
	//
	StepIncrement *string        `default:"P400D" json:"step_increment"`
	sourceType    AwinAdvertiser `const:"awin-advertiser" json:"sourceType"`
}

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

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

func (o *SourceAwinAdvertiser) GetAdvertiserID() string {
	if o == nil {
		return ""
	}
	return o.AdvertiserID
}

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

func (o *SourceAwinAdvertiser) GetLookbackDays() int64 {
	if o == nil {
		return 0
	}
	return o.LookbackDays
}

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

func (o *SourceAwinAdvertiser) GetStepIncrement() *string {
	if o == nil {
		return nil
	}
	return o.StepIncrement
}

func (o *SourceAwinAdvertiser) GetSourceType() AwinAdvertiser {
	return AwinAdvertiserAwinAdvertiser
}
