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

const (
	MercadoAdsMercadoAds MercadoAds = "mercado-ads"
)

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

type SourceMercadoAds struct {
	ClientID           string `json:"client_id"`
	ClientRefreshToken string `json:"client_refresh_token"`
	ClientSecret       string `json:"client_secret"`
	// Cannot exceed 90 days from current day for Product Ads
	EndDate      *types.Date `json:"end_date,omitempty"`
	LookbackDays *float64    `default:"7" json:"lookback_days"`
	// Cannot exceed 90 days from current day for Product Ads, and 90 days from "End Date" on Brand and Display Ads
	StartDate  *types.Date `json:"start_date,omitempty"`
	sourceType MercadoAds  `const:"mercado-ads" json:"sourceType"`
}

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

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

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

func (o *SourceMercadoAds) GetClientRefreshToken() string {
	if o == nil {
		return ""
	}
	return o.ClientRefreshToken
}

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

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

func (o *SourceMercadoAds) GetLookbackDays() *float64 {
	if o == nil {
		return nil
	}
	return o.LookbackDays
}

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

func (o *SourceMercadoAds) GetSourceType() MercadoAds {
	return MercadoAdsMercadoAds
}
