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 GoogleAdsSearchads360V23ServicesCreateCustomerClientRequest = {accessRole?: ('UNSPECIFIED' | 'UNKNOWN' | 'ADMIN' | 'STANDARD' | 'READ_ONLY' | 'EMAIL_ONLY') | undefined, customerClient?: GoogleAdsSearchads360V23ResourcesCustomer | undefined, emailAddress?: string | undefined, validateOnly?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdCreateCustomerClientArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesCreateCustomerClientRequest}; export type CreateApiV23CustomersCustomersIdCreateCustomerClientOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleAdsSearchads360V23ServicesCreateCustomerClientResponse = z.object({invitationLink: z.string().optional(), resourceName: z.string().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 }; /** * Creates a new client under manager. The new client customer is returned. List of thrown errors: [AccessInvitationError]() [AuthenticationError]() [AuthorizationError]() [CurrencyCodeError]() [HeaderError]() [InternalError]() [ManagerLinkError]() [QuotaError]() [RequestError]() [StringLengthError]() [TimeZoneError]() * * POST /v23/customers/{customersId}:createCustomerClient */ export const createApiV23CustomersCustomersIdCreateCustomerClient = async (args: CreateApiV23CustomersCustomersIdCreateCustomerClientArgs, options?: CreateApiV23CustomersCustomersIdCreateCustomerClientOptions) => { 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))}:createCustomerClient${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(googleAdsSearchads360V23ServicesCreateCustomerClientResponse, await res.json()) };