import {z} from 'zod' export type GoogleAdsSearchads360V23CommonEnhancedCpc = Record; export type GoogleAdsSearchads360V23CommonMaximizeConversionValue = {cpcBidCeilingMicros?: unknown | undefined, cpcBidFloorMicros?: unknown | undefined, targetRoas?: number | undefined, targetRoasTolerancePercentMillis?: unknown | undefined}; export type GoogleAdsSearchads360V23CommonMaximizeConversions = {cpcBidCeilingMicros?: unknown | undefined, cpcBidFloorMicros?: unknown | undefined, targetCpaMicros?: unknown | undefined}; export type GoogleAdsSearchads360V23CommonTargetCpa = {cpcBidCeilingMicros?: unknown | undefined, cpcBidFloorMicros?: unknown | undefined, targetCpaMicros?: unknown | undefined}; export type GoogleAdsSearchads360V23CommonTargetImpressionShare = {cpcBidCeilingMicros?: unknown | undefined, location?: ('UNSPECIFIED' | 'UNKNOWN' | 'ANYWHERE_ON_PAGE' | 'TOP_OF_PAGE' | 'ABSOLUTE_TOP_OF_PAGE') | undefined, locationFractionMicros?: unknown | undefined}; export type GoogleAdsSearchads360V23CommonTargetRoas = {cpcBidCeilingMicros?: unknown | undefined, cpcBidFloorMicros?: unknown | undefined, targetRoas?: number | undefined, targetRoasTolerancePercentMillis?: unknown | undefined}; export type GoogleAdsSearchads360V23CommonTargetSpend = {cpcBidCeilingMicros?: unknown | undefined, targetSpendMicros?: unknown | undefined}; export type GoogleAdsSearchads360V23ResourcesBiddingStrategy = {alignedCampaignBudgetId?: unknown | undefined, campaignCount?: unknown | undefined, currencyCode?: string | undefined, effectiveCurrencyCode?: string | undefined, enhancedCpc?: GoogleAdsSearchads360V23CommonEnhancedCpc | undefined, id?: unknown | undefined, maximizeConversionValue?: GoogleAdsSearchads360V23CommonMaximizeConversionValue | undefined, maximizeConversions?: GoogleAdsSearchads360V23CommonMaximizeConversions | undefined, name?: string | undefined, nonRemovedCampaignCount?: unknown | undefined, resourceName?: string | undefined, status?: ('UNSPECIFIED' | 'UNKNOWN' | 'ENABLED' | 'REMOVED') | undefined, targetCpa?: GoogleAdsSearchads360V23CommonTargetCpa | undefined, targetImpressionShare?: GoogleAdsSearchads360V23CommonTargetImpressionShare | undefined, targetRoas?: GoogleAdsSearchads360V23CommonTargetRoas | undefined, targetSpend?: GoogleAdsSearchads360V23CommonTargetSpend | undefined, type?: ('UNSPECIFIED' | 'UNKNOWN' | 'COMMISSION' | 'ENHANCED_CPC' | 'INVALID' | 'MANUAL_CPA' | 'MANUAL_CPC' | 'MANUAL_CPM' | 'MANUAL_CPV' | 'MAXIMIZE_CONVERSIONS' | 'MAXIMIZE_CONVERSION_VALUE' | 'PAGE_ONE_PROMOTED' | 'PERCENT_CPC' | 'TARGET_CPA' | 'TARGET_CPC' | 'TARGET_CPM' | 'TARGET_IMPRESSION_SHARE' | 'TARGET_OUTRANK_SHARE' | 'TARGET_ROAS' | 'TARGET_SPEND') | undefined}; export type GoogleAdsSearchads360V23ServicesBiddingStrategyOperation = {create?: GoogleAdsSearchads360V23ResourcesBiddingStrategy | undefined, remove?: string | undefined, update?: GoogleAdsSearchads360V23ResourcesBiddingStrategy | undefined, updateMask?: unknown | undefined}; export type GoogleAdsSearchads360V23ServicesMutateBiddingStrategiesRequest = {operations?: Array | undefined, partialFailure?: boolean | undefined, responseContentType?: ('UNSPECIFIED' | 'RESOURCE_NAME_ONLY' | 'MUTABLE_RESOURCE') | undefined, validateOnly?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdBiddingStrategiesMutateArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesMutateBiddingStrategiesRequest}; export type CreateApiV23CustomersCustomersIdBiddingStrategiesMutateOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleRpcStatus = z.object({code: z.number().int().optional(), details: z.array(z.record(z.string(), z.unknown())).optional(), message: z.string().optional()}); export const googleAdsSearchads360V23CommonEnhancedCpc = z.object({}); export const googleAdsSearchads360V23CommonMaximizeConversionValue = z.object({cpcBidCeilingMicros: z.string().optional(), cpcBidFloorMicros: z.string().optional(), targetRoas: z.number().optional(), targetRoasTolerancePercentMillis: z.string().optional()}); export const googleAdsSearchads360V23CommonMaximizeConversions = z.object({cpcBidCeilingMicros: z.string().optional(), cpcBidFloorMicros: z.string().optional(), targetCpaMicros: z.string().optional()}); export const googleAdsSearchads360V23CommonTargetCpa = z.object({cpcBidCeilingMicros: z.string().optional(), cpcBidFloorMicros: z.string().optional(), targetCpaMicros: z.string().optional()}); export const googleAdsSearchads360V23CommonTargetImpressionShare = z.object({cpcBidCeilingMicros: z.string().optional(), location: z.enum(["UNSPECIFIED", "UNKNOWN", "ANYWHERE_ON_PAGE", "TOP_OF_PAGE", "ABSOLUTE_TOP_OF_PAGE"]).optional(), locationFractionMicros: z.string().optional()}); export const googleAdsSearchads360V23CommonTargetRoas = z.object({cpcBidCeilingMicros: z.string().optional(), cpcBidFloorMicros: z.string().optional(), targetRoas: z.number().optional(), targetRoasTolerancePercentMillis: z.string().optional()}); export const googleAdsSearchads360V23CommonTargetSpend = z.object({cpcBidCeilingMicros: z.string().optional(), targetSpendMicros: z.string().optional()}); export const googleAdsSearchads360V23ResourcesBiddingStrategy = z.object({alignedCampaignBudgetId: z.string().optional(), campaignCount: z.string().optional(), currencyCode: z.string().optional(), effectiveCurrencyCode: z.string().optional(), enhancedCpc: googleAdsSearchads360V23CommonEnhancedCpc.optional(), id: z.string().optional(), maximizeConversionValue: googleAdsSearchads360V23CommonMaximizeConversionValue.optional(), maximizeConversions: googleAdsSearchads360V23CommonMaximizeConversions.optional(), name: z.string().optional(), nonRemovedCampaignCount: z.string().optional(), resourceName: z.string().optional(), status: z.enum(["UNSPECIFIED", "UNKNOWN", "ENABLED", "REMOVED"]).optional(), targetCpa: googleAdsSearchads360V23CommonTargetCpa.optional(), targetImpressionShare: googleAdsSearchads360V23CommonTargetImpressionShare.optional(), targetRoas: googleAdsSearchads360V23CommonTargetRoas.optional(), targetSpend: googleAdsSearchads360V23CommonTargetSpend.optional(), type: z.enum(["UNSPECIFIED", "UNKNOWN", "COMMISSION", "ENHANCED_CPC", "INVALID", "MANUAL_CPA", "MANUAL_CPC", "MANUAL_CPM", "MANUAL_CPV", "MAXIMIZE_CONVERSIONS", "MAXIMIZE_CONVERSION_VALUE", "PAGE_ONE_PROMOTED", "PERCENT_CPC", "TARGET_CPA", "TARGET_CPC", "TARGET_CPM", "TARGET_IMPRESSION_SHARE", "TARGET_OUTRANK_SHARE", "TARGET_ROAS", "TARGET_SPEND"]).optional()}); export const googleAdsSearchads360V23ServicesMutateBiddingStrategyResult = z.object({biddingStrategy: googleAdsSearchads360V23ResourcesBiddingStrategy.optional(), resourceName: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateBiddingStrategiesResponse = z.object({partialFailureError: googleRpcStatus.optional(), results: z.array(googleAdsSearchads360V23ServicesMutateBiddingStrategyResult).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, updates, or removes bidding strategies. Operation statuses are returned. List of thrown errors: [AdxError]() [AuthenticationError]() [AuthorizationError]() [BiddingError]() [BiddingStrategyError]() [ContextError]() [DatabaseError]() [DateError]() [DistinctError]() [FieldError]() [FieldMaskError]() [HeaderError]() [IdError]() [InternalError]() [MutateError]() [NewResourceCreationError]() [NotEmptyError]() [NullError]() [OperationAccessDeniedError]() [OperatorError]() [QuotaError]() [RangeError]() [RequestError]() [SizeLimitError]() [StringFormatError]() [StringLengthError]() * * POST /v23/customers/{customersId}/biddingStrategies:mutate */ export const createApiV23CustomersCustomersIdBiddingStrategiesMutate = async (args: CreateApiV23CustomersCustomersIdBiddingStrategiesMutateArgs, options?: CreateApiV23CustomersCustomersIdBiddingStrategiesMutateOptions) => { 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))}/biddingStrategies: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(googleAdsSearchads360V23ServicesMutateBiddingStrategiesResponse, await res.json()) };