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

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

const (
	OperatorContains Operator = "Contains"
	OperatorEquals   Operator = "Equals"
)

func (e Operator) ToPointer() *Operator {
	return &e
}
func (e *Operator) 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 = Operator(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Operator: %v", v)
	}
}

// AccountNames - Account Names Predicates Config.
type AccountNames 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 Operator `json:"operator"`
}

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

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

type AuthMethod string

const (
	AuthMethodOauth20 AuthMethod = "oauth2.0"
)

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

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

const (
	ReportingDataObjectAccountPerformanceReportRequest               ReportingDataObject = "AccountPerformanceReportRequest"
	ReportingDataObjectAdDynamicTextPerformanceReportRequest         ReportingDataObject = "AdDynamicTextPerformanceReportRequest"
	ReportingDataObjectAdExtensionByAdReportRequest                  ReportingDataObject = "AdExtensionByAdReportRequest"
	ReportingDataObjectAdExtensionByKeywordReportRequest             ReportingDataObject = "AdExtensionByKeywordReportRequest"
	ReportingDataObjectAdExtensionDetailReportRequest                ReportingDataObject = "AdExtensionDetailReportRequest"
	ReportingDataObjectAdGroupPerformanceReportRequest               ReportingDataObject = "AdGroupPerformanceReportRequest"
	ReportingDataObjectAdPerformanceReportRequest                    ReportingDataObject = "AdPerformanceReportRequest"
	ReportingDataObjectAgeGenderAudienceReportRequest                ReportingDataObject = "AgeGenderAudienceReportRequest"
	ReportingDataObjectAudiencePerformanceReportRequest              ReportingDataObject = "AudiencePerformanceReportRequest"
	ReportingDataObjectCallDetailReportRequest                       ReportingDataObject = "CallDetailReportRequest"
	ReportingDataObjectCampaignPerformanceReportRequest              ReportingDataObject = "CampaignPerformanceReportRequest"
	ReportingDataObjectConversionPerformanceReportRequest            ReportingDataObject = "ConversionPerformanceReportRequest"
	ReportingDataObjectDestinationURLPerformanceReportRequest        ReportingDataObject = "DestinationUrlPerformanceReportRequest"
	ReportingDataObjectDsaAutoTargetPerformanceReportRequest         ReportingDataObject = "DSAAutoTargetPerformanceReportRequest"
	ReportingDataObjectDsaCategoryPerformanceReportRequest           ReportingDataObject = "DSACategoryPerformanceReportRequest"
	ReportingDataObjectDsaSearchQueryPerformanceReportRequest        ReportingDataObject = "DSASearchQueryPerformanceReportRequest"
	ReportingDataObjectGeographicPerformanceReportRequest            ReportingDataObject = "GeographicPerformanceReportRequest"
	ReportingDataObjectGoalsAndFunnelsReportRequest                  ReportingDataObject = "GoalsAndFunnelsReportRequest"
	ReportingDataObjectHotelDimensionPerformanceReportRequest        ReportingDataObject = "HotelDimensionPerformanceReportRequest"
	ReportingDataObjectHotelGroupPerformanceReportRequest            ReportingDataObject = "HotelGroupPerformanceReportRequest"
	ReportingDataObjectKeywordPerformanceReportRequest               ReportingDataObject = "KeywordPerformanceReportRequest"
	ReportingDataObjectNegativeKeywordConflictReportRequest          ReportingDataObject = "NegativeKeywordConflictReportRequest"
	ReportingDataObjectProductDimensionPerformanceReportRequest      ReportingDataObject = "ProductDimensionPerformanceReportRequest"
	ReportingDataObjectProductMatchCountReportRequest                ReportingDataObject = "ProductMatchCountReportRequest"
	ReportingDataObjectProductNegativeKeywordConflictReportRequest   ReportingDataObject = "ProductNegativeKeywordConflictReportRequest"
	ReportingDataObjectProductPartitionPerformanceReportRequest      ReportingDataObject = "ProductPartitionPerformanceReportRequest"
	ReportingDataObjectProductPartitionUnitPerformanceReportRequest  ReportingDataObject = "ProductPartitionUnitPerformanceReportRequest"
	ReportingDataObjectProductSearchQueryPerformanceReportRequest    ReportingDataObject = "ProductSearchQueryPerformanceReportRequest"
	ReportingDataObjectProfessionalDemographicsAudienceReportRequest ReportingDataObject = "ProfessionalDemographicsAudienceReportRequest"
	ReportingDataObjectPublisherUsagePerformanceReportRequest        ReportingDataObject = "PublisherUsagePerformanceReportRequest"
	ReportingDataObjectSearchCampaignChangeHistoryReportRequest      ReportingDataObject = "SearchCampaignChangeHistoryReportRequest"
	ReportingDataObjectSearchQueryPerformanceReportRequest           ReportingDataObject = "SearchQueryPerformanceReportRequest"
	ReportingDataObjectShareOfVoiceReportRequest                     ReportingDataObject = "ShareOfVoiceReportRequest"
	ReportingDataObjectUserLocationPerformanceReportRequest          ReportingDataObject = "UserLocationPerformanceReportRequest"
)

func (e ReportingDataObject) ToPointer() *ReportingDataObject {
	return &e
}
func (e *ReportingDataObject) 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 = ReportingDataObject(v)
		return nil
	default:
		return fmt.Errorf("invalid value for ReportingDataObject: %v", v)
	}
}

type CustomReportConfig 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 ReportingDataObject `json:"reporting_object"`
}

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

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

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

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

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

func (o *CustomReportConfig) GetReportingObject() ReportingDataObject {
	if o == nil {
		return ReportingDataObject("")
	}
	return o.ReportingObject
}

type BingAds string

const (
	BingAdsBingAds BingAds = "bing-ads"
)

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

type SourceBingAds struct {
	// Predicates that will be used to sync data by specific accounts.
	AccountNames []AccountNames `json:"account_names,omitempty"`
	authMethod   *AuthMethod    `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 []CustomReportConfig `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"`
	sourceType BingAds `const:"bing-ads" json:"sourceType"`
}

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

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

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

func (o *SourceBingAds) GetAuthMethod() *AuthMethod {
	return AuthMethodOauth20.ToPointer()
}

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

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

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

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

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

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

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

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

func (o *SourceBingAds) GetSourceType() BingAds {
	return BingAdsBingAds
}
