import {z} from 'zod' export type GoogleAdsSearchads360V23CommonDeviceInfo = {type?: ('UNSPECIFIED' | 'UNKNOWN' | 'MOBILE' | 'TABLET' | 'DESKTOP' | 'CONNECTED_TV' | 'OTHER') | undefined}; export type GoogleAdsSearchads360V23CommonHotelAdvanceBookingWindowInfo = {maxDays?: unknown | undefined, minDays?: unknown | undefined}; export type GoogleAdsSearchads360V23CommonHotelCheckInDateRangeInfo = {endDate?: string | undefined, startDate?: string | undefined}; export type GoogleAdsSearchads360V23CommonHotelCheckInDayInfo = {dayOfWeek?: ('UNSPECIFIED' | 'UNKNOWN' | 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY') | undefined}; export type GoogleAdsSearchads360V23CommonHotelDateSelectionTypeInfo = {type?: ('UNSPECIFIED' | 'UNKNOWN' | 'DEFAULT_SELECTION' | 'USER_SELECTED') | undefined}; export type GoogleAdsSearchads360V23CommonHotelLengthOfStayInfo = {maxNights?: unknown | undefined, minNights?: unknown | undefined}; export type GoogleAdsSearchads360V23ResourcesAdGroupBidModifier = {adGroup?: string | undefined, baseAdGroup?: string | undefined, bidModifier?: number | undefined, bidModifierSource?: ('UNSPECIFIED' | 'UNKNOWN' | 'CAMPAIGN' | 'AD_GROUP') | undefined, criterionId?: unknown | undefined, device?: GoogleAdsSearchads360V23CommonDeviceInfo | undefined, hotelAdvanceBookingWindow?: GoogleAdsSearchads360V23CommonHotelAdvanceBookingWindowInfo | undefined, hotelCheckInDateRange?: GoogleAdsSearchads360V23CommonHotelCheckInDateRangeInfo | undefined, hotelCheckInDay?: GoogleAdsSearchads360V23CommonHotelCheckInDayInfo | undefined, hotelDateSelectionType?: GoogleAdsSearchads360V23CommonHotelDateSelectionTypeInfo | undefined, hotelLengthOfStay?: GoogleAdsSearchads360V23CommonHotelLengthOfStayInfo | undefined, resourceName?: string | undefined}; export type GoogleAdsSearchads360V23ServicesAdGroupBidModifierOperation = {create?: GoogleAdsSearchads360V23ResourcesAdGroupBidModifier | undefined, remove?: string | undefined, update?: GoogleAdsSearchads360V23ResourcesAdGroupBidModifier | undefined, updateMask?: unknown | undefined}; export type GoogleAdsSearchads360V23ServicesMutateAdGroupBidModifiersRequest = {operations?: Array | undefined, partialFailure?: boolean | undefined, responseContentType?: ('UNSPECIFIED' | 'RESOURCE_NAME_ONLY' | 'MUTABLE_RESOURCE') | undefined, validateOnly?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdAdGroupBidModifiersMutateArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesMutateAdGroupBidModifiersRequest}; export type CreateApiV23CustomersCustomersIdAdGroupBidModifiersMutateOptions = {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 googleAdsSearchads360V23CommonDeviceInfo = z.object({type: z.enum(["UNSPECIFIED", "UNKNOWN", "MOBILE", "TABLET", "DESKTOP", "CONNECTED_TV", "OTHER"]).optional()}); export const googleAdsSearchads360V23CommonHotelAdvanceBookingWindowInfo = z.object({maxDays: z.string().optional(), minDays: z.string().optional()}); export const googleAdsSearchads360V23CommonHotelCheckInDateRangeInfo = z.object({endDate: z.string().optional(), startDate: z.string().optional()}); export const googleAdsSearchads360V23CommonHotelCheckInDayInfo = z.object({dayOfWeek: z.enum(["UNSPECIFIED", "UNKNOWN", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]).optional()}); export const googleAdsSearchads360V23CommonHotelDateSelectionTypeInfo = z.object({type: z.enum(["UNSPECIFIED", "UNKNOWN", "DEFAULT_SELECTION", "USER_SELECTED"]).optional()}); export const googleAdsSearchads360V23CommonHotelLengthOfStayInfo = z.object({maxNights: z.string().optional(), minNights: z.string().optional()}); export const googleAdsSearchads360V23ResourcesAdGroupBidModifier = z.object({adGroup: z.string().optional(), baseAdGroup: z.string().optional(), bidModifier: z.number().optional(), bidModifierSource: z.enum(["UNSPECIFIED", "UNKNOWN", "CAMPAIGN", "AD_GROUP"]).optional(), criterionId: z.string().optional(), device: googleAdsSearchads360V23CommonDeviceInfo.optional(), hotelAdvanceBookingWindow: googleAdsSearchads360V23CommonHotelAdvanceBookingWindowInfo.optional(), hotelCheckInDateRange: googleAdsSearchads360V23CommonHotelCheckInDateRangeInfo.optional(), hotelCheckInDay: googleAdsSearchads360V23CommonHotelCheckInDayInfo.optional(), hotelDateSelectionType: googleAdsSearchads360V23CommonHotelDateSelectionTypeInfo.optional(), hotelLengthOfStay: googleAdsSearchads360V23CommonHotelLengthOfStayInfo.optional(), resourceName: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateAdGroupBidModifierResult = z.object({adGroupBidModifier: googleAdsSearchads360V23ResourcesAdGroupBidModifier.optional(), resourceName: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateAdGroupBidModifiersResponse = z.object({partialFailureError: googleRpcStatus.optional(), results: z.array(googleAdsSearchads360V23ServicesMutateAdGroupBidModifierResult).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 ad group bid modifiers. Operation statuses are returned. List of thrown errors: [AdGroupBidModifierError]() [AuthenticationError]() [AuthorizationError]() [ContextError]() [CriterionError]() [DatabaseError]() [DistinctError]() [FieldError]() [FieldMaskError]() [HeaderError]() [IdError]() [InternalError]() [MutateError]() [NewResourceCreationError]() [NotEmptyError]() [OperatorError]() [QuotaError]() [RangeError]() [RequestError]() [ResourceCountLimitExceededError]() [SizeLimitError]() [StringFormatError]() [StringLengthError]() * * POST /v23/customers/{customersId}/adGroupBidModifiers:mutate */ export const createApiV23CustomersCustomersIdAdGroupBidModifiersMutate = async (args: CreateApiV23CustomersCustomersIdAdGroupBidModifiersMutateArgs, options?: CreateApiV23CustomersCustomersIdAdGroupBidModifiersMutateOptions) => { 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))}/adGroupBidModifiers: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(googleAdsSearchads360V23ServicesMutateAdGroupBidModifiersResponse, await res.json()) };