import {z} from 'zod' export type GoogleAdsSearchads360V23ResourcesCallReportingSetting = {callConversionAction?: string | undefined, callConversionReportingEnabled?: boolean | undefined, callReportingEnabled?: boolean | undefined}; export type GoogleAdsSearchads360V23ResourcesConversionTrackingSetting = {acceptedCustomerDataTerms?: boolean | undefined, conversionTrackingId?: unknown | undefined, conversionTrackingStatus?: ('UNSPECIFIED' | 'UNKNOWN' | 'NOT_CONVERSION_TRACKED' | 'CONVERSION_TRACKING_MANAGED_BY_SELF' | 'CONVERSION_TRACKING_MANAGED_BY_THIS_MANAGER' | 'CONVERSION_TRACKING_MANAGED_BY_ANOTHER_MANAGER') | undefined, crossAccountConversionTrackingId?: unknown | undefined, enhancedConversionsForLeadsEnabled?: boolean | undefined, googleAdsConversionCustomer?: string | undefined, googleAdsCrossAccountConversionTrackingId?: unknown | undefined}; export type GoogleAdsSearchads360V23ResourcesCustomerAgreementSetting = {acceptedLeadFormTerms?: boolean | undefined}; export type GoogleAdsSearchads360V23ResourcesDoubleClickCampaignManagerSetting = {advertiserId?: unknown | undefined, networkId?: unknown | undefined, timeZone?: string | undefined}; export type GoogleAdsSearchads360V23ResourcesGranularInsuranceStatus = {categoryId?: string | undefined, geoCriterionId?: unknown | undefined, verificationStatus?: ('UNSPECIFIED' | 'UNKNOWN' | 'NEEDS_REVIEW' | 'FAILED' | 'PASSED' | 'NOT_APPLICABLE' | 'NO_SUBMISSION' | 'PARTIAL_SUBMISSION' | 'PENDING_ESCALATION') | undefined}; export type GoogleAdsSearchads360V23ResourcesGranularLicenseStatus = {categoryId?: string | undefined, geoCriterionId?: unknown | undefined, verificationStatus?: ('UNSPECIFIED' | 'UNKNOWN' | 'NEEDS_REVIEW' | 'FAILED' | 'PASSED' | 'NOT_APPLICABLE' | 'NO_SUBMISSION' | 'PARTIAL_SUBMISSION' | 'PENDING_ESCALATION') | undefined}; export type GoogleAdsSearchads360V23ResourcesLocalServicesSettings = {granularInsuranceStatuses?: Array | undefined, granularLicenseStatuses?: Array | undefined}; export type GoogleAdsSearchads360V23ResourcesRemarketingSetting = {googleGlobalSiteTag?: string | undefined}; export type GoogleAdsSearchads360V23CommonCustomerThirdPartyBrandLiftIntegrationPartner = {allowShareCost?: boolean | undefined, brandLiftIntegrationPartner?: ('UNSPECIFIED' | 'UNKNOWN' | 'KANTAR_MILLWARD_BROWN' | 'DYNATA' | 'INTAGE' | 'MACROMILL') | undefined}; export type GoogleAdsSearchads360V23CommonCustomerThirdPartyBrandSafetyIntegrationPartner = {brandSafetyIntegrationPartner?: ('UNSPECIFIED' | 'UNKNOWN' | 'DOUBLE_VERIFY' | 'INTEGRAL_AD_SCIENCE' | 'ZEFR') | undefined}; export type GoogleAdsSearchads360V23CommonCustomerThirdPartyReachIntegrationPartner = {allowShareCost?: boolean | undefined, reachIntegrationPartner?: ('UNSPECIFIED' | 'UNKNOWN' | 'NIELSEN' | 'COMSCORE' | 'KANTAR_MILLWARD_BROWN' | 'VIDEO_RESEARCH' | 'GEMIUS' | 'MEDIA_SCOPE' | 'AUDIENCE_PROJECT' | 'VIDEO_AMP' | 'ISPOT_TV') | undefined}; export type GoogleAdsSearchads360V23CommonCustomerThirdPartyViewabilityIntegrationPartner = {allowShareCost?: boolean | undefined, viewabilityIntegrationPartner?: ('UNSPECIFIED' | 'UNKNOWN' | 'DOUBLE_VERIFY' | 'INTEGRAL_AD_SCIENCE') | undefined}; export type GoogleAdsSearchads360V23CommonCustomerThirdPartyIntegrationPartners = {brandLiftIntegrationPartners?: Array | undefined, brandSafetyIntegrationPartners?: Array | undefined, reachIntegrationPartners?: Array | undefined, viewabilityIntegrationPartners?: Array | undefined}; export type GoogleAdsSearchads360V23ResourcesVideoCustomer = {thirdPartyIntegrationPartners?: GoogleAdsSearchads360V23CommonCustomerThirdPartyIntegrationPartners | undefined}; export type GoogleAdsSearchads360V23ResourcesCustomer = {accountLevel?: ('UNSPECIFIED' | 'UNKNOWN' | 'CLIENT_ACCOUNT_FACEBOOK' | 'CLIENT_ACCOUNT_GOOGLE_ADS' | 'CLIENT_ACCOUNT_MICROSOFT' | 'CLIENT_ACCOUNT_YAHOO_JAPAN' | 'CLIENT_ACCOUNT_ENGINE_TRACK' | 'MANAGER' | 'SUB_MANAGER' | 'ASSOCIATE_MANAGER') | undefined, accountStatus?: ('UNSPECIFIED' | 'UNKNOWN' | 'ENABLED' | 'PAUSED' | 'SUSPENDED' | 'REMOVED' | 'DRAFT') | undefined, accountType?: ('UNSPECIFIED' | 'UNKNOWN' | 'BAIDU' | 'ENGINE_TRACK' | 'FACEBOOK' | 'FACEBOOK_GATEWAY' | 'GOOGLE_ADS' | 'MICROSOFT' | 'SEARCH_ADS_360' | 'YAHOO_JAPAN') | undefined, associateManagerDescriptiveName?: string | undefined, associateManagerId?: unknown | undefined, autoTaggingEnabled?: boolean | undefined, callReportingSetting?: GoogleAdsSearchads360V23ResourcesCallReportingSetting | undefined, containsEuPoliticalAdvertising?: ('UNSPECIFIED' | 'UNKNOWN' | 'CONTAINS_EU_POLITICAL_ADVERTISING' | 'DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING') | undefined, conversionTrackingSetting?: GoogleAdsSearchads360V23ResourcesConversionTrackingSetting | undefined, creationTime?: string | undefined, currencyCode?: string | undefined, customerAgreementSetting?: GoogleAdsSearchads360V23ResourcesCustomerAgreementSetting | undefined, descriptiveName?: string | undefined, doubleClickCampaignManagerSetting?: GoogleAdsSearchads360V23ResourcesDoubleClickCampaignManagerSetting | undefined, engineId?: string | undefined, finalUrlSuffix?: string | undefined, hasPartnersBadge?: boolean | undefined, id?: unknown | undefined, imageAssetAutoMigrationDone?: boolean | undefined, imageAssetAutoMigrationDoneDateTime?: string | undefined, lastModifiedTime?: string | undefined, localServicesSettings?: GoogleAdsSearchads360V23ResourcesLocalServicesSettings | undefined, locationAssetAutoMigrationDone?: boolean | undefined, locationAssetAutoMigrationDoneDateTime?: string | undefined, manager?: boolean | undefined, managerDescriptiveName?: string | undefined, managerId?: unknown | undefined, optimizationScore?: number | undefined, optimizationScoreWeight?: number | undefined, payPerConversionEligibilityFailureReasons?: (Array<'UNSPECIFIED' | 'UNKNOWN' | 'NOT_ENOUGH_CONVERSIONS' | 'CONVERSION_LAG_TOO_HIGH' | 'HAS_CAMPAIGN_WITH_SHARED_BUDGET' | 'HAS_UPLOAD_CLICKS_CONVERSION' | 'AVERAGE_DAILY_SPEND_TOO_HIGH' | 'ANALYSIS_NOT_COMPLETE' | 'OTHER'>) | undefined, remarketingSetting?: GoogleAdsSearchads360V23ResourcesRemarketingSetting | undefined, resourceName?: string | undefined, status?: ('UNSPECIFIED' | 'UNKNOWN' | 'ENABLED' | 'CANCELED' | 'SUSPENDED' | 'CLOSED') | undefined, subManagerDescriptiveName?: string | undefined, subManagerId?: unknown | undefined, testAccount?: boolean | undefined, timeZone?: string | undefined, trackingUrlTemplate?: string | undefined, videoBrandSafetySuitability?: ('UNSPECIFIED' | 'UNKNOWN' | 'EXPANDED_INVENTORY' | 'STANDARD_INVENTORY' | 'LIMITED_INVENTORY') | undefined, videoCustomer?: GoogleAdsSearchads360V23ResourcesVideoCustomer | undefined}; export type GoogleAdsSearchads360V23ServicesCustomerOperation = {update?: GoogleAdsSearchads360V23ResourcesCustomer | undefined, updateMask?: unknown | undefined}; export type GoogleAdsSearchads360V23ServicesMutateCustomerRequest = {operation?: GoogleAdsSearchads360V23ServicesCustomerOperation | undefined, responseContentType?: ('UNSPECIFIED' | 'RESOURCE_NAME_ONLY' | 'MUTABLE_RESOURCE') | undefined, validateOnly?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdMutateArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesMutateCustomerRequest}; export type CreateApiV23CustomersCustomersIdMutateOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleAdsSearchads360V23ResourcesCallReportingSetting = z.object({callConversionAction: z.string().optional(), callConversionReportingEnabled: z.boolean().optional(), callReportingEnabled: z.boolean().optional()}); export const googleAdsSearchads360V23ResourcesConversionTrackingSetting = z.object({acceptedCustomerDataTerms: z.boolean().optional(), conversionTrackingId: z.string().optional(), conversionTrackingStatus: z.enum(["UNSPECIFIED", "UNKNOWN", "NOT_CONVERSION_TRACKED", "CONVERSION_TRACKING_MANAGED_BY_SELF", "CONVERSION_TRACKING_MANAGED_BY_THIS_MANAGER", "CONVERSION_TRACKING_MANAGED_BY_ANOTHER_MANAGER"]).optional(), crossAccountConversionTrackingId: z.string().optional(), enhancedConversionsForLeadsEnabled: z.boolean().optional(), googleAdsConversionCustomer: z.string().optional(), googleAdsCrossAccountConversionTrackingId: z.string().optional()}); export const googleAdsSearchads360V23ResourcesCustomerAgreementSetting = z.object({acceptedLeadFormTerms: z.boolean().optional()}); export const googleAdsSearchads360V23ResourcesDoubleClickCampaignManagerSetting = z.object({advertiserId: z.string().optional(), networkId: z.string().optional(), timeZone: z.string().optional()}); export const googleAdsSearchads360V23ResourcesGranularInsuranceStatus = z.object({categoryId: z.string().optional(), geoCriterionId: z.string().optional(), verificationStatus: z.enum(["UNSPECIFIED", "UNKNOWN", "NEEDS_REVIEW", "FAILED", "PASSED", "NOT_APPLICABLE", "NO_SUBMISSION", "PARTIAL_SUBMISSION", "PENDING_ESCALATION"]).optional()}); export const googleAdsSearchads360V23ResourcesGranularLicenseStatus = z.object({categoryId: z.string().optional(), geoCriterionId: z.string().optional(), verificationStatus: z.enum(["UNSPECIFIED", "UNKNOWN", "NEEDS_REVIEW", "FAILED", "PASSED", "NOT_APPLICABLE", "NO_SUBMISSION", "PARTIAL_SUBMISSION", "PENDING_ESCALATION"]).optional()}); export const googleAdsSearchads360V23ResourcesLocalServicesSettings = z.object({granularInsuranceStatuses: z.array(googleAdsSearchads360V23ResourcesGranularInsuranceStatus).optional(), granularLicenseStatuses: z.array(googleAdsSearchads360V23ResourcesGranularLicenseStatus).optional()}); export const googleAdsSearchads360V23ResourcesRemarketingSetting = z.object({googleGlobalSiteTag: z.string().optional()}); export const googleAdsSearchads360V23CommonCustomerThirdPartyBrandLiftIntegrationPartner = z.object({allowShareCost: z.boolean().optional(), brandLiftIntegrationPartner: z.enum(["UNSPECIFIED", "UNKNOWN", "KANTAR_MILLWARD_BROWN", "DYNATA", "INTAGE", "MACROMILL"]).optional()}); export const googleAdsSearchads360V23CommonCustomerThirdPartyBrandSafetyIntegrationPartner = z.object({brandSafetyIntegrationPartner: z.enum(["UNSPECIFIED", "UNKNOWN", "DOUBLE_VERIFY", "INTEGRAL_AD_SCIENCE", "ZEFR"]).optional()}); export const googleAdsSearchads360V23CommonCustomerThirdPartyReachIntegrationPartner = z.object({allowShareCost: z.boolean().optional(), reachIntegrationPartner: z.enum(["UNSPECIFIED", "UNKNOWN", "NIELSEN", "COMSCORE", "KANTAR_MILLWARD_BROWN", "VIDEO_RESEARCH", "GEMIUS", "MEDIA_SCOPE", "AUDIENCE_PROJECT", "VIDEO_AMP", "ISPOT_TV"]).optional()}); export const googleAdsSearchads360V23CommonCustomerThirdPartyViewabilityIntegrationPartner = z.object({allowShareCost: z.boolean().optional(), viewabilityIntegrationPartner: z.enum(["UNSPECIFIED", "UNKNOWN", "DOUBLE_VERIFY", "INTEGRAL_AD_SCIENCE"]).optional()}); export const googleAdsSearchads360V23CommonCustomerThirdPartyIntegrationPartners = z.object({brandLiftIntegrationPartners: z.array(googleAdsSearchads360V23CommonCustomerThirdPartyBrandLiftIntegrationPartner).optional(), brandSafetyIntegrationPartners: z.array(googleAdsSearchads360V23CommonCustomerThirdPartyBrandSafetyIntegrationPartner).optional(), reachIntegrationPartners: z.array(googleAdsSearchads360V23CommonCustomerThirdPartyReachIntegrationPartner).optional(), viewabilityIntegrationPartners: z.array(googleAdsSearchads360V23CommonCustomerThirdPartyViewabilityIntegrationPartner).optional()}); export const googleAdsSearchads360V23ResourcesVideoCustomer = z.object({thirdPartyIntegrationPartners: googleAdsSearchads360V23CommonCustomerThirdPartyIntegrationPartners.optional()}); export const googleAdsSearchads360V23ResourcesCustomer = z.object({accountLevel: z.enum(["UNSPECIFIED", "UNKNOWN", "CLIENT_ACCOUNT_FACEBOOK", "CLIENT_ACCOUNT_GOOGLE_ADS", "CLIENT_ACCOUNT_MICROSOFT", "CLIENT_ACCOUNT_YAHOO_JAPAN", "CLIENT_ACCOUNT_ENGINE_TRACK", "MANAGER", "SUB_MANAGER", "ASSOCIATE_MANAGER"]).optional(), accountStatus: z.enum(["UNSPECIFIED", "UNKNOWN", "ENABLED", "PAUSED", "SUSPENDED", "REMOVED", "DRAFT"]).optional(), accountType: z.enum(["UNSPECIFIED", "UNKNOWN", "BAIDU", "ENGINE_TRACK", "FACEBOOK", "FACEBOOK_GATEWAY", "GOOGLE_ADS", "MICROSOFT", "SEARCH_ADS_360", "YAHOO_JAPAN"]).optional(), associateManagerDescriptiveName: z.string().optional(), associateManagerId: z.string().optional(), autoTaggingEnabled: z.boolean().optional(), callReportingSetting: googleAdsSearchads360V23ResourcesCallReportingSetting.optional(), containsEuPoliticalAdvertising: z.enum(["UNSPECIFIED", "UNKNOWN", "CONTAINS_EU_POLITICAL_ADVERTISING", "DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING"]).optional(), conversionTrackingSetting: googleAdsSearchads360V23ResourcesConversionTrackingSetting.optional(), creationTime: z.string().optional(), currencyCode: z.string().optional(), customerAgreementSetting: googleAdsSearchads360V23ResourcesCustomerAgreementSetting.optional(), descriptiveName: z.string().optional(), doubleClickCampaignManagerSetting: googleAdsSearchads360V23ResourcesDoubleClickCampaignManagerSetting.optional(), engineId: z.string().optional(), finalUrlSuffix: z.string().optional(), hasPartnersBadge: z.boolean().optional(), id: z.string().optional(), imageAssetAutoMigrationDone: z.boolean().optional(), imageAssetAutoMigrationDoneDateTime: z.string().optional(), lastModifiedTime: z.string().optional(), localServicesSettings: googleAdsSearchads360V23ResourcesLocalServicesSettings.optional(), locationAssetAutoMigrationDone: z.boolean().optional(), locationAssetAutoMigrationDoneDateTime: z.string().optional(), manager: z.boolean().optional(), managerDescriptiveName: z.string().optional(), managerId: z.string().optional(), optimizationScore: z.number().optional(), optimizationScoreWeight: z.number().optional(), payPerConversionEligibilityFailureReasons: z.array(z.enum(["UNSPECIFIED", "UNKNOWN", "NOT_ENOUGH_CONVERSIONS", "CONVERSION_LAG_TOO_HIGH", "HAS_CAMPAIGN_WITH_SHARED_BUDGET", "HAS_UPLOAD_CLICKS_CONVERSION", "AVERAGE_DAILY_SPEND_TOO_HIGH", "ANALYSIS_NOT_COMPLETE", "OTHER"])).optional(), remarketingSetting: googleAdsSearchads360V23ResourcesRemarketingSetting.optional(), resourceName: z.string().optional(), status: z.enum(["UNSPECIFIED", "UNKNOWN", "ENABLED", "CANCELED", "SUSPENDED", "CLOSED"]).optional(), subManagerDescriptiveName: z.string().optional(), subManagerId: z.string().optional(), testAccount: z.boolean().optional(), timeZone: z.string().optional(), trackingUrlTemplate: z.string().optional(), videoBrandSafetySuitability: z.enum(["UNSPECIFIED", "UNKNOWN", "EXPANDED_INVENTORY", "STANDARD_INVENTORY", "LIMITED_INVENTORY"]).optional(), videoCustomer: googleAdsSearchads360V23ResourcesVideoCustomer.optional()}); export const googleAdsSearchads360V23ServicesMutateCustomerResult = z.object({customer: googleAdsSearchads360V23ResourcesCustomer.optional(), resourceName: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateCustomerResponse = z.object({result: googleAdsSearchads360V23ServicesMutateCustomerResult.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Updates a customer. Operation statuses are returned. List of thrown errors: [AuthenticationError]() [AuthorizationError]() [DatabaseError]() [FieldMaskError]() [HeaderError]() [InternalError]() [QuotaError]() [RequestError]() [UrlFieldError]() * * POST /v23/customers/{customersId}:mutate */ export const createApiV23CustomersCustomersIdMutate = async (args: CreateApiV23CustomersCustomersIdMutateArgs, options?: CreateApiV23CustomersCustomersIdMutateOptions) => { const {baseUrl = "https://searchads360.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v23/customers/${encodeURIComponent(String(args.customersId))}:mutate${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(googleAdsSearchads360V23ServicesMutateCustomerResponse, await res.json()) };