import {z} from 'zod' export type GoogleAdsSearchads360V23ServicesRemoveCampaignAutomaticallyCreatedAssetOperation = {asset?: string | undefined, campaign?: string | undefined, fieldType?: ('UNSPECIFIED' | 'UNKNOWN' | 'HEADLINE' | 'DESCRIPTION' | 'MANDATORY_AD_TEXT' | 'MARKETING_IMAGE' | 'MEDIA_BUNDLE' | 'YOUTUBE_VIDEO' | 'BOOK_ON_GOOGLE' | 'LEAD_FORM' | 'PROMOTION' | 'CALLOUT' | 'STRUCTURED_SNIPPET' | 'SITELINK' | 'MOBILE_APP' | 'HOTEL_CALLOUT' | 'CALL' | 'PRICE' | 'LONG_HEADLINE' | 'BUSINESS_NAME' | 'SQUARE_MARKETING_IMAGE' | 'PORTRAIT_MARKETING_IMAGE' | 'LOGO' | 'LANDSCAPE_LOGO' | 'VIDEO' | 'CALL_TO_ACTION_SELECTION' | 'AD_IMAGE' | 'BUSINESS_LOGO' | 'HOTEL_PROPERTY' | 'DEMAND_GEN_CAROUSEL_CARD' | 'BUSINESS_MESSAGE' | 'TALL_PORTRAIT_MARKETING_IMAGE' | 'LANDING_PAGE_PREVIEW' | 'LONG_DESCRIPTION' | 'CALL_TO_ACTION') | undefined}; export type GoogleAdsSearchads360V23ServicesRemoveCampaignAutomaticallyCreatedAssetRequest = {operations?: Array | undefined, partialFailure?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdRemoveCampaignAutomaticallyCreatedAssetArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesRemoveCampaignAutomaticallyCreatedAssetRequest}; export type CreateApiV23CustomersCustomersIdRemoveCampaignAutomaticallyCreatedAssetOptions = {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 googleAdsSearchads360V23ServicesRemoveCampaignAutomaticallyCreatedAssetResponse = z.object({partialFailureError: googleRpcStatus.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 }; /** * Removes automatically created assets from a campaign. List of thrown errors: [AuthenticationError]() [AuthorizationError]() [ContextError]() [FieldError]() [InternalError]() [MutateError]() [PartialFailureError]() [QuotaError]() [RequestError]() * * POST /v23/customers/{customersId}:removeCampaignAutomaticallyCreatedAsset */ export const createApiV23CustomersCustomersIdRemoveCampaignAutomaticallyCreatedAsset = async (args: CreateApiV23CustomersCustomersIdRemoveCampaignAutomaticallyCreatedAssetArgs, options?: CreateApiV23CustomersCustomersIdRemoveCampaignAutomaticallyCreatedAssetOptions) => { 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))}:removeCampaignAutomaticallyCreatedAsset${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(googleAdsSearchads360V23ServicesRemoveCampaignAutomaticallyCreatedAssetResponse, await res.json()) };