import {z} from 'zod' export type GoogleAdsSearchads360V23CommonBusinessProfileBusinessNameFilter = {businessName?: string | undefined, filterType?: ('UNSPECIFIED' | 'UNKNOWN' | 'EXACT') | undefined}; export type GoogleAdsSearchads360V23CommonDynamicBusinessProfileLocationGroupFilter = {businessNameFilter?: GoogleAdsSearchads360V23CommonBusinessProfileBusinessNameFilter | undefined, labelFilters?: Array | undefined, listingIdFilters?: Array | undefined}; export type GoogleAdsSearchads360V23CommonBusinessProfileLocationGroup = {dynamicBusinessProfileLocationGroupFilter?: GoogleAdsSearchads360V23CommonDynamicBusinessProfileLocationGroupFilter | undefined}; export type GoogleAdsSearchads360V23CommonChainFilter = {chainId?: unknown | undefined, locationAttributes?: Array | undefined}; export type GoogleAdsSearchads360V23CommonChainLocationGroup = {dynamicChainLocationGroupFilters?: Array | undefined}; export type GoogleAdsSearchads360V23ResourcesAssetSetHotelPropertyData = {hotelCenterId?: unknown | undefined, partnerName?: string | undefined}; export type GoogleAdsSearchads360V23CommonBusinessProfileLocationSet = {businessAccountId?: string | undefined, businessNameFilter?: string | undefined, emailAddress?: string | undefined, httpAuthorizationToken?: string | undefined, labelFilters?: Array | undefined, listingIdFilters?: Array | undefined}; export type GoogleAdsSearchads360V23CommonChainSet = {chains?: Array | undefined, relationshipType?: ('UNSPECIFIED' | 'UNKNOWN' | 'AUTO_DEALERS' | 'GENERAL_RETAILERS') | undefined}; export type GoogleAdsSearchads360V23CommonMapsLocationInfo = {placeId?: string | undefined}; export type GoogleAdsSearchads360V23CommonMapsLocationSet = {mapsLocations?: Array | undefined}; export type GoogleAdsSearchads360V23CommonLocationSet = {businessProfileLocationSet?: GoogleAdsSearchads360V23CommonBusinessProfileLocationSet | undefined, chainLocationSet?: GoogleAdsSearchads360V23CommonChainSet | undefined, locationOwnershipType?: ('UNSPECIFIED' | 'UNKNOWN' | 'BUSINESS_OWNER' | 'AFFILIATE') | undefined, mapsLocationSet?: GoogleAdsSearchads360V23CommonMapsLocationSet | undefined}; export type GoogleAdsSearchads360V23ResourcesAssetSetMerchantCenterFeed = {feedLabel?: string | undefined, merchantId?: unknown | undefined}; export type GoogleAdsSearchads360V23ResourcesAssetSet = {businessProfileLocationGroup?: GoogleAdsSearchads360V23CommonBusinessProfileLocationGroup | undefined, chainLocationGroup?: GoogleAdsSearchads360V23CommonChainLocationGroup | undefined, hotelPropertyData?: GoogleAdsSearchads360V23ResourcesAssetSetHotelPropertyData | undefined, id?: unknown | undefined, locationGroupParentAssetSetId?: unknown | undefined, locationSet?: GoogleAdsSearchads360V23CommonLocationSet | undefined, merchantCenterFeed?: GoogleAdsSearchads360V23ResourcesAssetSetMerchantCenterFeed | undefined, name?: string | undefined, resourceName?: string | undefined, status?: ('UNSPECIFIED' | 'UNKNOWN' | 'ENABLED' | 'REMOVED') | undefined, type?: ('UNSPECIFIED' | 'UNKNOWN' | 'PAGE_FEED' | 'DYNAMIC_EDUCATION' | 'MERCHANT_CENTER_FEED' | 'DYNAMIC_REAL_ESTATE' | 'DYNAMIC_CUSTOM' | 'DYNAMIC_HOTELS_AND_RENTALS' | 'DYNAMIC_FLIGHTS' | 'DYNAMIC_TRAVEL' | 'DYNAMIC_LOCAL' | 'DYNAMIC_JOBS' | 'LOCATION_SYNC' | 'BUSINESS_PROFILE_DYNAMIC_LOCATION_GROUP' | 'CHAIN_DYNAMIC_LOCATION_GROUP' | 'STATIC_LOCATION_GROUP' | 'HOTEL_PROPERTY' | 'TRAVEL_FEED') | undefined}; export type GoogleAdsSearchads360V23ServicesAssetSetOperation = {create?: GoogleAdsSearchads360V23ResourcesAssetSet | undefined, remove?: string | undefined, update?: GoogleAdsSearchads360V23ResourcesAssetSet | undefined, updateMask?: unknown | undefined}; export type GoogleAdsSearchads360V23ServicesMutateAssetSetsRequest = {operations?: Array | undefined, partialFailure?: boolean | undefined, responseContentType?: ('UNSPECIFIED' | 'RESOURCE_NAME_ONLY' | 'MUTABLE_RESOURCE') | undefined, validateOnly?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdAssetSetsMutateArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesMutateAssetSetsRequest}; export type CreateApiV23CustomersCustomersIdAssetSetsMutateOptions = {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 googleAdsSearchads360V23CommonBusinessProfileBusinessNameFilter = z.object({businessName: z.string().optional(), filterType: z.enum(["UNSPECIFIED", "UNKNOWN", "EXACT"]).optional()}); export const googleAdsSearchads360V23CommonDynamicBusinessProfileLocationGroupFilter = z.object({businessNameFilter: googleAdsSearchads360V23CommonBusinessProfileBusinessNameFilter.optional(), labelFilters: z.array(z.string()).optional(), listingIdFilters: z.array(z.string()).optional()}); export const googleAdsSearchads360V23CommonBusinessProfileLocationGroup = z.object({dynamicBusinessProfileLocationGroupFilter: googleAdsSearchads360V23CommonDynamicBusinessProfileLocationGroupFilter.optional()}); export const googleAdsSearchads360V23CommonChainFilter = z.object({chainId: z.string().optional(), locationAttributes: z.array(z.string()).optional()}); export const googleAdsSearchads360V23CommonChainLocationGroup = z.object({dynamicChainLocationGroupFilters: z.array(googleAdsSearchads360V23CommonChainFilter).optional()}); export const googleAdsSearchads360V23ResourcesAssetSetHotelPropertyData = z.object({hotelCenterId: z.string().optional(), partnerName: z.string().optional()}); export const googleAdsSearchads360V23CommonBusinessProfileLocationSet = z.object({businessAccountId: z.string().optional(), businessNameFilter: z.string().optional(), emailAddress: z.string().optional(), httpAuthorizationToken: z.string().optional(), labelFilters: z.array(z.string()).optional(), listingIdFilters: z.array(z.string()).optional()}); export const googleAdsSearchads360V23CommonChainSet = z.object({chains: z.array(googleAdsSearchads360V23CommonChainFilter).optional(), relationshipType: z.enum(["UNSPECIFIED", "UNKNOWN", "AUTO_DEALERS", "GENERAL_RETAILERS"]).optional()}); export const googleAdsSearchads360V23CommonMapsLocationInfo = z.object({placeId: z.string().optional()}); export const googleAdsSearchads360V23CommonMapsLocationSet = z.object({mapsLocations: z.array(googleAdsSearchads360V23CommonMapsLocationInfo).optional()}); export const googleAdsSearchads360V23CommonLocationSet = z.object({businessProfileLocationSet: googleAdsSearchads360V23CommonBusinessProfileLocationSet.optional(), chainLocationSet: googleAdsSearchads360V23CommonChainSet.optional(), locationOwnershipType: z.enum(["UNSPECIFIED", "UNKNOWN", "BUSINESS_OWNER", "AFFILIATE"]).optional(), mapsLocationSet: googleAdsSearchads360V23CommonMapsLocationSet.optional()}); export const googleAdsSearchads360V23ResourcesAssetSetMerchantCenterFeed = z.object({feedLabel: z.string().optional(), merchantId: z.string().optional()}); export const googleAdsSearchads360V23ResourcesAssetSet = z.object({businessProfileLocationGroup: googleAdsSearchads360V23CommonBusinessProfileLocationGroup.optional(), chainLocationGroup: googleAdsSearchads360V23CommonChainLocationGroup.optional(), hotelPropertyData: googleAdsSearchads360V23ResourcesAssetSetHotelPropertyData.optional(), id: z.string().optional(), locationGroupParentAssetSetId: z.string().optional(), locationSet: googleAdsSearchads360V23CommonLocationSet.optional(), merchantCenterFeed: googleAdsSearchads360V23ResourcesAssetSetMerchantCenterFeed.optional(), name: z.string().optional(), resourceName: z.string().optional(), status: z.enum(["UNSPECIFIED", "UNKNOWN", "ENABLED", "REMOVED"]).optional(), type: z.enum(["UNSPECIFIED", "UNKNOWN", "PAGE_FEED", "DYNAMIC_EDUCATION", "MERCHANT_CENTER_FEED", "DYNAMIC_REAL_ESTATE", "DYNAMIC_CUSTOM", "DYNAMIC_HOTELS_AND_RENTALS", "DYNAMIC_FLIGHTS", "DYNAMIC_TRAVEL", "DYNAMIC_LOCAL", "DYNAMIC_JOBS", "LOCATION_SYNC", "BUSINESS_PROFILE_DYNAMIC_LOCATION_GROUP", "CHAIN_DYNAMIC_LOCATION_GROUP", "STATIC_LOCATION_GROUP", "HOTEL_PROPERTY", "TRAVEL_FEED"]).optional()}); export const googleAdsSearchads360V23ServicesMutateAssetSetResult = z.object({assetSet: googleAdsSearchads360V23ResourcesAssetSet.optional(), resourceName: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateAssetSetsResponse = z.object({partialFailureError: googleRpcStatus.optional(), results: z.array(googleAdsSearchads360V23ServicesMutateAssetSetResult).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 asset sets. Operation statuses are returned. * * POST /v23/customers/{customersId}/assetSets:mutate */ export const createApiV23CustomersCustomersIdAssetSetsMutate = async (args: CreateApiV23CustomersCustomersIdAssetSetsMutateArgs, options?: CreateApiV23CustomersCustomersIdAssetSetsMutateOptions) => { 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))}/assetSets: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(googleAdsSearchads360V23ServicesMutateAssetSetsResponse, await res.json()) };