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

// SourceBingAdsUpdateOperator - An Operator that will be used to filter accounts. The Contains predicate has features for matching words, matching inflectional forms of words, searching using wildcard characters, and searching using proximity. The Equals is used to return all rows where account name is equal(=) to the string that you provided
type SourceBingAdsUpdateOperator string

const (
	SourceBingAdsUpdateOperatorContains SourceBingAdsUpdateOperator = "Contains"
	SourceBingAdsUpdateOperatorEquals   SourceBingAdsUpdateOperator = "Equals"
)

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

// SourceBingAdsUpdateAccountNames - Account Names Predicates Config.
type SourceBingAdsUpdateAccountNames struct {
	// Account Name is a string value for comparing with the specified predicate.
	Name string `json:"name"`
	// An Operator that will be used to filter accounts. The Contains predicate has features for matching words, matching inflectional forms of words, searching using wildcard characters, and searching using proximity. The Equals is used to return all rows where account name is equal(=) to the string that you provided
	Operator SourceBingAdsUpdateOperator `json:"operator"`
}

func (o *SourceBingAdsUpdateAccountNames) GetName() string {
	if o == nil {
		return ""
	}
	return o.Name
}

func (o *SourceBingAdsUpdateAccountNames) GetOperator() SourceBingAdsUpdateOperator {
	if o == nil {
		return SourceBingAdsUpdateOperator("")
	}
	return o.Operator
}

type SourceBingAdsUpdateAuthMethod string

const (
	SourceBingAdsUpdateAuthMethodOauth20 SourceBingAdsUpdateAuthMethod = "oauth2.0"
)

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

// SourceBingAdsUpdateReportingDataObject - The name of the the object derives from the ReportRequest object. You can find it in Bing Ads Api docs - Reporting API - Reporting Data Objects.
type SourceBingAdsUpdateReportingDataObject string

const (
	SourceBingAdsUpdateReportingDataObjectAccountPerformanceReportRequest               SourceBingAdsUpdateReportingDataObject = "AccountPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectAdDynamicTextPerformanceReportRequest         SourceBingAdsUpdateReportingDataObject = "AdDynamicTextPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectAdExtensionByAdReportRequest                  SourceBingAdsUpdateReportingDataObject = "AdExtensionByAdReportRequest"
	SourceBingAdsUpdateReportingDataObjectAdExtensionByKeywordReportRequest             SourceBingAdsUpdateReportingDataObject = "AdExtensionByKeywordReportRequest"
	SourceBingAdsUpdateReportingDataObjectAdExtensionDetailReportRequest                SourceBingAdsUpdateReportingDataObject = "AdExtensionDetailReportRequest"
	SourceBingAdsUpdateReportingDataObjectAdGroupPerformanceReportRequest               SourceBingAdsUpdateReportingDataObject = "AdGroupPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectAdPerformanceReportRequest                    SourceBingAdsUpdateReportingDataObject = "AdPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectAgeGenderAudienceReportRequest                SourceBingAdsUpdateReportingDataObject = "AgeGenderAudienceReportRequest"
	SourceBingAdsUpdateReportingDataObjectAudiencePerformanceReportRequest              SourceBingAdsUpdateReportingDataObject = "AudiencePerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectCallDetailReportRequest                       SourceBingAdsUpdateReportingDataObject = "CallDetailReportRequest"
	SourceBingAdsUpdateReportingDataObjectCampaignPerformanceReportRequest              SourceBingAdsUpdateReportingDataObject = "CampaignPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectConversionPerformanceReportRequest            SourceBingAdsUpdateReportingDataObject = "ConversionPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectDestinationURLPerformanceReportRequest        SourceBingAdsUpdateReportingDataObject = "DestinationUrlPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectDsaAutoTargetPerformanceReportRequest         SourceBingAdsUpdateReportingDataObject = "DSAAutoTargetPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectDsaCategoryPerformanceReportRequest           SourceBingAdsUpdateReportingDataObject = "DSACategoryPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectDsaSearchQueryPerformanceReportRequest        SourceBingAdsUpdateReportingDataObject = "DSASearchQueryPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectGeographicPerformanceReportRequest            SourceBingAdsUpdateReportingDataObject = "GeographicPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectGoalsAndFunnelsReportRequest                  SourceBingAdsUpdateReportingDataObject = "GoalsAndFunnelsReportRequest"
	SourceBingAdsUpdateReportingDataObjectHotelDimensionPerformanceReportRequest        SourceBingAdsUpdateReportingDataObject = "HotelDimensionPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectHotelGroupPerformanceReportRequest            SourceBingAdsUpdateReportingDataObject = "HotelGroupPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectKeywordPerformanceReportRequest               SourceBingAdsUpdateReportingDataObject = "KeywordPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectNegativeKeywordConflictReportRequest          SourceBingAdsUpdateReportingDataObject = "NegativeKeywordConflictReportRequest"
	SourceBingAdsUpdateReportingDataObjectProductDimensionPerformanceReportRequest      SourceBingAdsUpdateReportingDataObject = "ProductDimensionPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectProductMatchCountReportRequest                SourceBingAdsUpdateReportingDataObject = "ProductMatchCountReportRequest"
	SourceBingAdsUpdateReportingDataObjectProductNegativeKeywordConflictReportRequest   SourceBingAdsUpdateReportingDataObject = "ProductNegativeKeywordConflictReportRequest"
	SourceBingAdsUpdateReportingDataObjectProductPartitionPerformanceReportRequest      SourceBingAdsUpdateReportingDataObject = "ProductPartitionPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectProductPartitionUnitPerformanceReportRequest  SourceBingAdsUpdateReportingDataObject = "ProductPartitionUnitPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectProductSearchQueryPerformanceReportRequest    SourceBingAdsUpdateReportingDataObject = "ProductSearchQueryPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectProfessionalDemographicsAudienceReportRequest SourceBingAdsUpdateReportingDataObject = "ProfessionalDemographicsAudienceReportRequest"
	SourceBingAdsUpdateReportingDataObjectPublisherUsagePerformanceReportRequest        SourceBingAdsUpdateReportingDataObject = "PublisherUsagePerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectSearchCampaignChangeHistoryReportRequest      SourceBingAdsUpdateReportingDataObject = "SearchCampaignChangeHistoryReportRequest"
	SourceBingAdsUpdateReportingDataObjectSearchQueryPerformanceReportRequest           SourceBingAdsUpdateReportingDataObject = "SearchQueryPerformanceReportRequest"
	SourceBingAdsUpdateReportingDataObjectShareOfVoiceReportRequest                     SourceBingAdsUpdateReportingDataObject = "ShareOfVoiceReportRequest"
	SourceBingAdsUpdateReportingDataObjectUserLocationPerformanceReportRequest          SourceBingAdsUpdateReportingDataObject = "UserLocationPerformanceReportRequest"
)

func (e SourceBingAdsUpdateReportingDataObject) ToPointer() *SourceBingAdsUpdateReportingDataObject {
	return &e
}
func (e *SourceBingAdsUpdateReportingDataObject) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "AccountPerformanceReportRequest":
		fallthrough
	case "AdDynamicTextPerformanceReportRequest":
		fallthrough
	case "AdExtensionByAdReportRequest":
		fallthrough
	case "AdExtensionByKeywordReportRequest":
		fallthrough
	case "AdExtensionDetailReportRequest":
		fallthrough
	case "AdGroupPerformanceReportRequest":
		fallthrough
	case "AdPerformanceReportRequest":
		fallthrough
	case "AgeGenderAudienceReportRequest":
		fallthrough
	case "AudiencePerformanceReportRequest":
		fallthrough
	case "CallDetailReportRequest":
		fallthrough
	case "CampaignPerformanceReportRequest":
		fallthrough
	case "ConversionPerformanceReportRequest":
		fallthrough
	case "DestinationUrlPerformanceReportRequest":
		fallthrough
	case "DSAAutoTargetPerformanceReportRequest":
		fallthrough
	case "DSACategoryPerformanceReportRequest":
		fallthrough
	case "DSASearchQueryPerformanceReportRequest":
		fallthrough
	case "GeographicPerformanceReportRequest":
		fallthrough
	case "GoalsAndFunnelsReportRequest":
		fallthrough
	case "HotelDimensionPerformanceReportRequest":
		fallthrough
	case "HotelGroupPerformanceReportRequest":
		fallthrough
	case "KeywordPerformanceReportRequest":
		fallthrough
	case "NegativeKeywordConflictReportRequest":
		fallthrough
	case "ProductDimensionPerformanceReportRequest":
		fallthrough
	case "ProductMatchCountReportRequest":
		fallthrough
	case "ProductNegativeKeywordConflictReportRequest":
		fallthrough
	case "ProductPartitionPerformanceReportRequest":
		fallthrough
	case "ProductPartitionUnitPerformanceReportRequest":
		fallthrough
	case "ProductSearchQueryPerformanceReportRequest":
		fallthrough
	case "ProfessionalDemographicsAudienceReportRequest":
		fallthrough
	case "PublisherUsagePerformanceReportRequest":
		fallthrough
	case "SearchCampaignChangeHistoryReportRequest":
		fallthrough
	case "SearchQueryPerformanceReportRequest":
		fallthrough
	case "ShareOfVoiceReportRequest":
		fallthrough
	case "UserLocationPerformanceReportRequest":
		*e = SourceBingAdsUpdateReportingDataObject(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceBingAdsUpdateReportingDataObject: %v", v)
	}
}

type SourceBingAdsUpdateCustomReportConfig struct {
	// The name of the custom report, this name would be used as stream name
	Name string `json:"name"`
	// A list of available aggregations.
	ReportAggregation *string `default:"[Hourly]" json:"report_aggregation"`
	// A list of available report object columns. You can find it in description of reporting object that you want to add to custom report.
	ReportColumns []string `json:"report_columns"`
	// The name of the the object derives from the ReportRequest object. You can find it in Bing Ads Api docs - Reporting API - Reporting Data Objects.
	ReportingObject SourceBingAdsUpdateReportingDataObject `json:"reporting_object"`
}

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

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

func (o *SourceBingAdsUpdateCustomReportConfig) GetName() string {
	if o == nil {
		return ""
	}
	return o.Name
}

func (o *SourceBingAdsUpdateCustomReportConfig) GetReportAggregation() *string {
	if o == nil {
		return nil
	}
	return o.ReportAggregation
}

func (o *SourceBingAdsUpdateCustomReportConfig) GetReportColumns() []string {
	if o == nil {
		return []string{}
	}
	return o.ReportColumns
}

func (o *SourceBingAdsUpdateCustomReportConfig) GetReportingObject() SourceBingAdsUpdateReportingDataObject {
	if o == nil {
		return SourceBingAdsUpdateReportingDataObject("")
	}
	return o.ReportingObject
}

type SourceBingAdsUpdate struct {
	// Predicates that will be used to sync data by specific accounts.
	AccountNames []SourceBingAdsUpdateAccountNames `json:"account_names,omitempty"`
	authMethod   *SourceBingAdsUpdateAuthMethod    `const:"oauth2.0" json:"auth_method,omitempty"`
	// The Client ID of your Microsoft Advertising developer application.
	ClientID string `json:"client_id"`
	// The Client Secret of your Microsoft Advertising developer application.
	ClientSecret *string `default:"" json:"client_secret"`
	// You can add your Custom Bing Ads report by creating one.
	CustomReports []SourceBingAdsUpdateCustomReportConfig `json:"custom_reports,omitempty"`
	// Developer token associated with user. See more info <a href="https://docs.microsoft.com/en-us/advertising/guides/get-started?view=bingads-13#get-developer-token"> in the docs</a>.
	DeveloperToken string `json:"developer_token"`
	// Also known as attribution or conversion window. How far into the past to look for records (in days). If your conversion window has an hours/minutes granularity, round it up to the number of days exceeding. Used only for performance report streams in incremental mode without specified Reports Start Date.
	LookbackWindow *int64 `default:"0" json:"lookback_window"`
	// Refresh Token to renew the expired Access Token.
	RefreshToken string `json:"refresh_token"`
	// The start date from which to begin replicating report data. Any data generated before this date will not be replicated in reports. This is a UTC date in YYYY-MM-DD format. If not set, data from previous and current calendar year will be replicated.
	ReportsStartDate *types.Date `json:"reports_start_date,omitempty"`
	// The Tenant ID of your Microsoft Advertising developer application. Set this to "common" unless you know you need a different value.
	TenantID *string `default:"common" json:"tenant_id"`
}

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

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

func (o *SourceBingAdsUpdate) GetAccountNames() []SourceBingAdsUpdateAccountNames {
	if o == nil {
		return nil
	}
	return o.AccountNames
}

func (o *SourceBingAdsUpdate) GetAuthMethod() *SourceBingAdsUpdateAuthMethod {
	return SourceBingAdsUpdateAuthMethodOauth20.ToPointer()
}

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

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

func (o *SourceBingAdsUpdate) GetCustomReports() []SourceBingAdsUpdateCustomReportConfig {
	if o == nil {
		return nil
	}
	return o.CustomReports
}

func (o *SourceBingAdsUpdate) GetDeveloperToken() string {
	if o == nil {
		return ""
	}
	return o.DeveloperToken
}

func (o *SourceBingAdsUpdate) GetLookbackWindow() *int64 {
	if o == nil {
		return nil
	}
	return o.LookbackWindow
}

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

func (o *SourceBingAdsUpdate) GetReportsStartDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.ReportsStartDate
}

func (o *SourceBingAdsUpdate) GetTenantID() *string {
	if o == nil {
		return nil
	}
	return o.TenantID
}
