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

package shared

import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/internal/utils"
)

// SourceOutbrainAmplifyUpdateDefinitionOfConversionCountInReports - The definition of conversion count in reports. See <a href="https://amplifyv01.docs.apiary.io/#reference/performance-reporting/periodic/retrieve-performance-statistics-for-all-marketer-campaigns-by-periodic-breakdown">the docs</a>.
type SourceOutbrainAmplifyUpdateDefinitionOfConversionCountInReports string

const (
	SourceOutbrainAmplifyUpdateDefinitionOfConversionCountInReportsClickViewTime  SourceOutbrainAmplifyUpdateDefinitionOfConversionCountInReports = "click/view_time"
	SourceOutbrainAmplifyUpdateDefinitionOfConversionCountInReportsConversionTime SourceOutbrainAmplifyUpdateDefinitionOfConversionCountInReports = "conversion_time"
)

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

type SourceOutbrainAmplifyUpdateBothUsernameAndPasswordIsRequiredForAuthenticationRequest string

const (
	SourceOutbrainAmplifyUpdateBothUsernameAndPasswordIsRequiredForAuthenticationRequestUsernamePassword SourceOutbrainAmplifyUpdateBothUsernameAndPasswordIsRequiredForAuthenticationRequest = "username_password"
)

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

type SourceOutbrainAmplifyUpdateUsernamePassword struct {
	// Add Password for authentication.
	Password string                                                                               `json:"password"`
	type_    SourceOutbrainAmplifyUpdateBothUsernameAndPasswordIsRequiredForAuthenticationRequest `const:"username_password" json:"type"`
	// Add Username for authentication.
	Username string `json:"username"`
}

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

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

func (o *SourceOutbrainAmplifyUpdateUsernamePassword) GetPassword() string {
	if o == nil {
		return ""
	}
	return o.Password
}

func (o *SourceOutbrainAmplifyUpdateUsernamePassword) GetType() SourceOutbrainAmplifyUpdateBothUsernameAndPasswordIsRequiredForAuthenticationRequest {
	return SourceOutbrainAmplifyUpdateBothUsernameAndPasswordIsRequiredForAuthenticationRequestUsernamePassword
}

func (o *SourceOutbrainAmplifyUpdateUsernamePassword) GetUsername() string {
	if o == nil {
		return ""
	}
	return o.Username
}

type SourceOutbrainAmplifyUpdateAccessTokenIsRequiredForAuthenticationRequests string

const (
	SourceOutbrainAmplifyUpdateAccessTokenIsRequiredForAuthenticationRequestsAccessToken SourceOutbrainAmplifyUpdateAccessTokenIsRequiredForAuthenticationRequests = "access_token"
)

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

type SourceOutbrainAmplifyUpdateAccessToken struct {
	// Access Token for making authenticated requests.
	AccessToken string                                                                    `json:"access_token"`
	type_       SourceOutbrainAmplifyUpdateAccessTokenIsRequiredForAuthenticationRequests `const:"access_token" json:"type"`
}

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

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

func (o *SourceOutbrainAmplifyUpdateAccessToken) GetAccessToken() string {
	if o == nil {
		return ""
	}
	return o.AccessToken
}

func (o *SourceOutbrainAmplifyUpdateAccessToken) GetType() SourceOutbrainAmplifyUpdateAccessTokenIsRequiredForAuthenticationRequests {
	return SourceOutbrainAmplifyUpdateAccessTokenIsRequiredForAuthenticationRequestsAccessToken
}

type SourceOutbrainAmplifyUpdateAuthenticationMethodType string

const (
	SourceOutbrainAmplifyUpdateAuthenticationMethodTypeSourceOutbrainAmplifyUpdateAccessToken      SourceOutbrainAmplifyUpdateAuthenticationMethodType = "source-outbrain-amplify-update_Access token"
	SourceOutbrainAmplifyUpdateAuthenticationMethodTypeSourceOutbrainAmplifyUpdateUsernamePassword SourceOutbrainAmplifyUpdateAuthenticationMethodType = "source-outbrain-amplify-update_Username Password"
)

// SourceOutbrainAmplifyUpdateAuthenticationMethod - Credentials for making authenticated requests requires either username/password or access_token.
type SourceOutbrainAmplifyUpdateAuthenticationMethod struct {
	SourceOutbrainAmplifyUpdateAccessToken      *SourceOutbrainAmplifyUpdateAccessToken      `queryParam:"inline"`
	SourceOutbrainAmplifyUpdateUsernamePassword *SourceOutbrainAmplifyUpdateUsernamePassword `queryParam:"inline"`

	Type SourceOutbrainAmplifyUpdateAuthenticationMethodType
}

func CreateSourceOutbrainAmplifyUpdateAuthenticationMethodSourceOutbrainAmplifyUpdateAccessToken(sourceOutbrainAmplifyUpdateAccessToken SourceOutbrainAmplifyUpdateAccessToken) SourceOutbrainAmplifyUpdateAuthenticationMethod {
	typ := SourceOutbrainAmplifyUpdateAuthenticationMethodTypeSourceOutbrainAmplifyUpdateAccessToken

	return SourceOutbrainAmplifyUpdateAuthenticationMethod{
		SourceOutbrainAmplifyUpdateAccessToken: &sourceOutbrainAmplifyUpdateAccessToken,
		Type:                                   typ,
	}
}

func CreateSourceOutbrainAmplifyUpdateAuthenticationMethodSourceOutbrainAmplifyUpdateUsernamePassword(sourceOutbrainAmplifyUpdateUsernamePassword SourceOutbrainAmplifyUpdateUsernamePassword) SourceOutbrainAmplifyUpdateAuthenticationMethod {
	typ := SourceOutbrainAmplifyUpdateAuthenticationMethodTypeSourceOutbrainAmplifyUpdateUsernamePassword

	return SourceOutbrainAmplifyUpdateAuthenticationMethod{
		SourceOutbrainAmplifyUpdateUsernamePassword: &sourceOutbrainAmplifyUpdateUsernamePassword,
		Type: typ,
	}
}

func (u *SourceOutbrainAmplifyUpdateAuthenticationMethod) UnmarshalJSON(data []byte) error {

	var sourceOutbrainAmplifyUpdateAccessToken SourceOutbrainAmplifyUpdateAccessToken = SourceOutbrainAmplifyUpdateAccessToken{}
	if err := utils.UnmarshalJSON(data, &sourceOutbrainAmplifyUpdateAccessToken, "", true, true); err == nil {
		u.SourceOutbrainAmplifyUpdateAccessToken = &sourceOutbrainAmplifyUpdateAccessToken
		u.Type = SourceOutbrainAmplifyUpdateAuthenticationMethodTypeSourceOutbrainAmplifyUpdateAccessToken
		return nil
	}

	var sourceOutbrainAmplifyUpdateUsernamePassword SourceOutbrainAmplifyUpdateUsernamePassword = SourceOutbrainAmplifyUpdateUsernamePassword{}
	if err := utils.UnmarshalJSON(data, &sourceOutbrainAmplifyUpdateUsernamePassword, "", true, true); err == nil {
		u.SourceOutbrainAmplifyUpdateUsernamePassword = &sourceOutbrainAmplifyUpdateUsernamePassword
		u.Type = SourceOutbrainAmplifyUpdateAuthenticationMethodTypeSourceOutbrainAmplifyUpdateUsernamePassword
		return nil
	}

	return fmt.Errorf("could not unmarshal `%s` into any supported union types for SourceOutbrainAmplifyUpdateAuthenticationMethod", string(data))
}

func (u SourceOutbrainAmplifyUpdateAuthenticationMethod) MarshalJSON() ([]byte, error) {
	if u.SourceOutbrainAmplifyUpdateAccessToken != nil {
		return utils.MarshalJSON(u.SourceOutbrainAmplifyUpdateAccessToken, "", true)
	}

	if u.SourceOutbrainAmplifyUpdateUsernamePassword != nil {
		return utils.MarshalJSON(u.SourceOutbrainAmplifyUpdateUsernamePassword, "", true)
	}

	return nil, errors.New("could not marshal union type SourceOutbrainAmplifyUpdateAuthenticationMethod: all fields are null")
}

// SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegion - The granularity used for geo location data in reports.
type SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegion string

const (
	SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegionCountry   SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegion = "country"
	SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegionRegion    SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegion = "region"
	SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegionSubregion SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegion = "subregion"
)

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

// SourceOutbrainAmplifyUpdateGranularityForPeriodicReports - The granularity used for periodic data in reports. See <a href="https://amplifyv01.docs.apiary.io/#reference/performance-reporting/periodic/retrieve-performance-statistics-for-all-marketer-campaigns-by-periodic-breakdown">the docs</a>.
type SourceOutbrainAmplifyUpdateGranularityForPeriodicReports string

const (
	SourceOutbrainAmplifyUpdateGranularityForPeriodicReportsDaily   SourceOutbrainAmplifyUpdateGranularityForPeriodicReports = "daily"
	SourceOutbrainAmplifyUpdateGranularityForPeriodicReportsWeekly  SourceOutbrainAmplifyUpdateGranularityForPeriodicReports = "weekly"
	SourceOutbrainAmplifyUpdateGranularityForPeriodicReportsMonthly SourceOutbrainAmplifyUpdateGranularityForPeriodicReports = "monthly"
)

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

type SourceOutbrainAmplifyUpdate struct {
	// The definition of conversion count in reports. See <a href="https://amplifyv01.docs.apiary.io/#reference/performance-reporting/periodic/retrieve-performance-statistics-for-all-marketer-campaigns-by-periodic-breakdown">the docs</a>.
	ConversionCount *SourceOutbrainAmplifyUpdateDefinitionOfConversionCountInReports `json:"conversion_count,omitempty"`
	// Credentials for making authenticated requests requires either username/password or access_token.
	Credentials SourceOutbrainAmplifyUpdateAuthenticationMethod `json:"credentials"`
	// Date in the format YYYY-MM-DD.
	EndDate *string `json:"end_date,omitempty"`
	// The granularity used for geo location data in reports.
	GeoLocationBreakdown *SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegion `json:"geo_location_breakdown,omitempty"`
	// The granularity used for periodic data in reports. See <a href="https://amplifyv01.docs.apiary.io/#reference/performance-reporting/periodic/retrieve-performance-statistics-for-all-marketer-campaigns-by-periodic-breakdown">the docs</a>.
	ReportGranularity *SourceOutbrainAmplifyUpdateGranularityForPeriodicReports `json:"report_granularity,omitempty"`
	// Date in the format YYYY-MM-DD eg. 2017-01-25. Any data before this date will not be replicated.
	StartDate string `json:"start_date"`
}

func (o *SourceOutbrainAmplifyUpdate) GetConversionCount() *SourceOutbrainAmplifyUpdateDefinitionOfConversionCountInReports {
	if o == nil {
		return nil
	}
	return o.ConversionCount
}

func (o *SourceOutbrainAmplifyUpdate) GetCredentials() SourceOutbrainAmplifyUpdateAuthenticationMethod {
	if o == nil {
		return SourceOutbrainAmplifyUpdateAuthenticationMethod{}
	}
	return o.Credentials
}

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

func (o *SourceOutbrainAmplifyUpdate) GetGeoLocationBreakdown() *SourceOutbrainAmplifyUpdateGranularityForGeoLocationRegion {
	if o == nil {
		return nil
	}
	return o.GeoLocationBreakdown
}

func (o *SourceOutbrainAmplifyUpdate) GetReportGranularity() *SourceOutbrainAmplifyUpdateGranularityForPeriodicReports {
	if o == nil {
		return nil
	}
	return o.ReportGranularity
}

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