import {z} from 'zod' export type GoogleAdsSearchads360V23CommonContentLabelInfo = {type?: ('UNSPECIFIED' | 'UNKNOWN' | 'SEXUALLY_SUGGESTIVE' | 'BELOW_THE_FOLD' | 'PARKED_DOMAIN' | 'JUVENILE' | 'PROFANITY' | 'TRAGEDY' | 'VIDEO' | 'VIDEO_RATING_DV_G' | 'VIDEO_RATING_DV_PG' | 'VIDEO_RATING_DV_T' | 'VIDEO_RATING_DV_MA' | 'VIDEO_NOT_YET_RATED' | 'EMBEDDED_VIDEO' | 'LIVE_STREAMING_VIDEO' | 'SOCIAL_ISSUES' | 'BRAND_SUITABILITY_CONTENT_FOR_FAMILIES' | 'BRAND_SUITABILITY_GAMES_FIGHTING' | 'BRAND_SUITABILITY_GAMES_MATURE' | 'BRAND_SUITABILITY_HEALTH_SENSITIVE' | 'BRAND_SUITABILITY_HEALTH_SOURCE_UNDETERMINED' | 'BRAND_SUITABILITY_NEWS_RECENT' | 'BRAND_SUITABILITY_NEWS_SENSITIVE' | 'BRAND_SUITABILITY_NEWS_SOURCE_NOT_FEATURED' | 'BRAND_SUITABILITY_POLITICS' | 'BRAND_SUITABILITY_RELIGION') | undefined}; export type GoogleAdsSearchads360V23CommonIpBlockInfo = {ipAddress?: string | undefined}; export type GoogleAdsSearchads360V23CommonMobileAppCategoryInfo = {mobileAppCategoryConstant?: string | undefined}; export type GoogleAdsSearchads360V23CommonMobileApplicationInfo = {appId?: string | undefined, name?: string | undefined}; export type GoogleAdsSearchads360V23CommonNegativeKeywordListInfo = {sharedSet?: string | undefined}; export type GoogleAdsSearchads360V23CommonPlacementInfo = {url?: string | undefined}; export type GoogleAdsSearchads360V23CommonPlacementListInfo = {sharedSet?: string | undefined}; export type GoogleAdsSearchads360V23CommonYouTubeChannelInfo = {channelId?: string | undefined}; export type GoogleAdsSearchads360V23CommonYouTubeVideoInfo = {videoId?: string | undefined}; export type GoogleAdsSearchads360V23ResourcesCustomerNegativeCriterion = {contentLabel?: GoogleAdsSearchads360V23CommonContentLabelInfo | undefined, id?: unknown | undefined, ipBlock?: GoogleAdsSearchads360V23CommonIpBlockInfo | undefined, mobileAppCategory?: GoogleAdsSearchads360V23CommonMobileAppCategoryInfo | undefined, mobileApplication?: GoogleAdsSearchads360V23CommonMobileApplicationInfo | undefined, negativeKeywordList?: GoogleAdsSearchads360V23CommonNegativeKeywordListInfo | undefined, placement?: GoogleAdsSearchads360V23CommonPlacementInfo | undefined, placementList?: GoogleAdsSearchads360V23CommonPlacementListInfo | undefined, resourceName?: string | undefined, type?: ('UNSPECIFIED' | 'UNKNOWN' | 'KEYWORD' | 'PLACEMENT' | 'MOBILE_APP_CATEGORY' | 'MOBILE_APPLICATION' | 'DEVICE' | 'LOCATION' | 'LISTING_GROUP' | 'AD_SCHEDULE' | 'AGE_RANGE' | 'GENDER' | 'INCOME_RANGE' | 'PARENTAL_STATUS' | 'YOUTUBE_VIDEO' | 'YOUTUBE_CHANNEL' | 'USER_LIST' | 'PROXIMITY' | 'TOPIC' | 'LISTING_SCOPE' | 'LANGUAGE' | 'IP_BLOCK' | 'CONTENT_LABEL' | 'CARRIER' | 'USER_INTEREST' | 'WEBPAGE' | 'OPERATING_SYSTEM_VERSION' | 'APP_PAYMENT_MODEL' | 'MOBILE_DEVICE' | 'CUSTOM_AFFINITY' | 'CUSTOM_INTENT' | 'LOCATION_GROUP' | 'CUSTOM_AUDIENCE' | 'COMBINED_AUDIENCE' | 'KEYWORD_THEME' | 'AUDIENCE' | 'NEGATIVE_KEYWORD_LIST' | 'LOCAL_SERVICE_ID' | 'SEARCH_THEME' | 'BRAND' | 'BRAND_LIST' | 'LIFE_EVENT' | 'WEBPAGE_LIST' | 'VIDEO_LINEUP' | 'PLACEMENT_LIST' | 'VERTICAL_ADS_ITEM_GROUP_RULE_LIST' | 'VERTICAL_ADS_ITEM_GROUP_RULE') | undefined, youtubeChannel?: GoogleAdsSearchads360V23CommonYouTubeChannelInfo | undefined, youtubeVideo?: GoogleAdsSearchads360V23CommonYouTubeVideoInfo | undefined}; export type GoogleAdsSearchads360V23ServicesCustomerNegativeCriterionOperation = {create?: GoogleAdsSearchads360V23ResourcesCustomerNegativeCriterion | undefined, remove?: string | undefined}; export type GoogleAdsSearchads360V23ServicesMutateCustomerNegativeCriteriaRequest = {operations?: Array | undefined, partialFailure?: boolean | undefined, responseContentType?: ('UNSPECIFIED' | 'RESOURCE_NAME_ONLY' | 'MUTABLE_RESOURCE') | undefined, validateOnly?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdCustomerNegativeCriteriaMutateArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesMutateCustomerNegativeCriteriaRequest}; export type CreateApiV23CustomersCustomersIdCustomerNegativeCriteriaMutateOptions = {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 googleAdsSearchads360V23CommonContentLabelInfo = z.object({type: z.enum(["UNSPECIFIED", "UNKNOWN", "SEXUALLY_SUGGESTIVE", "BELOW_THE_FOLD", "PARKED_DOMAIN", "JUVENILE", "PROFANITY", "TRAGEDY", "VIDEO", "VIDEO_RATING_DV_G", "VIDEO_RATING_DV_PG", "VIDEO_RATING_DV_T", "VIDEO_RATING_DV_MA", "VIDEO_NOT_YET_RATED", "EMBEDDED_VIDEO", "LIVE_STREAMING_VIDEO", "SOCIAL_ISSUES", "BRAND_SUITABILITY_CONTENT_FOR_FAMILIES", "BRAND_SUITABILITY_GAMES_FIGHTING", "BRAND_SUITABILITY_GAMES_MATURE", "BRAND_SUITABILITY_HEALTH_SENSITIVE", "BRAND_SUITABILITY_HEALTH_SOURCE_UNDETERMINED", "BRAND_SUITABILITY_NEWS_RECENT", "BRAND_SUITABILITY_NEWS_SENSITIVE", "BRAND_SUITABILITY_NEWS_SOURCE_NOT_FEATURED", "BRAND_SUITABILITY_POLITICS", "BRAND_SUITABILITY_RELIGION"]).optional()}); export const googleAdsSearchads360V23CommonIpBlockInfo = z.object({ipAddress: z.string().optional()}); export const googleAdsSearchads360V23CommonMobileAppCategoryInfo = z.object({mobileAppCategoryConstant: z.string().optional()}); export const googleAdsSearchads360V23CommonMobileApplicationInfo = z.object({appId: z.string().optional(), name: z.string().optional()}); export const googleAdsSearchads360V23CommonNegativeKeywordListInfo = z.object({sharedSet: z.string().optional()}); export const googleAdsSearchads360V23CommonPlacementInfo = z.object({url: z.string().optional()}); export const googleAdsSearchads360V23CommonPlacementListInfo = z.object({sharedSet: z.string().optional()}); export const googleAdsSearchads360V23CommonYouTubeChannelInfo = z.object({channelId: z.string().optional()}); export const googleAdsSearchads360V23CommonYouTubeVideoInfo = z.object({videoId: z.string().optional()}); export const googleAdsSearchads360V23ResourcesCustomerNegativeCriterion = z.object({contentLabel: googleAdsSearchads360V23CommonContentLabelInfo.optional(), id: z.string().optional(), ipBlock: googleAdsSearchads360V23CommonIpBlockInfo.optional(), mobileAppCategory: googleAdsSearchads360V23CommonMobileAppCategoryInfo.optional(), mobileApplication: googleAdsSearchads360V23CommonMobileApplicationInfo.optional(), negativeKeywordList: googleAdsSearchads360V23CommonNegativeKeywordListInfo.optional(), placement: googleAdsSearchads360V23CommonPlacementInfo.optional(), placementList: googleAdsSearchads360V23CommonPlacementListInfo.optional(), resourceName: z.string().optional(), type: z.enum(["UNSPECIFIED", "UNKNOWN", "KEYWORD", "PLACEMENT", "MOBILE_APP_CATEGORY", "MOBILE_APPLICATION", "DEVICE", "LOCATION", "LISTING_GROUP", "AD_SCHEDULE", "AGE_RANGE", "GENDER", "INCOME_RANGE", "PARENTAL_STATUS", "YOUTUBE_VIDEO", "YOUTUBE_CHANNEL", "USER_LIST", "PROXIMITY", "TOPIC", "LISTING_SCOPE", "LANGUAGE", "IP_BLOCK", "CONTENT_LABEL", "CARRIER", "USER_INTEREST", "WEBPAGE", "OPERATING_SYSTEM_VERSION", "APP_PAYMENT_MODEL", "MOBILE_DEVICE", "CUSTOM_AFFINITY", "CUSTOM_INTENT", "LOCATION_GROUP", "CUSTOM_AUDIENCE", "COMBINED_AUDIENCE", "KEYWORD_THEME", "AUDIENCE", "NEGATIVE_KEYWORD_LIST", "LOCAL_SERVICE_ID", "SEARCH_THEME", "BRAND", "BRAND_LIST", "LIFE_EVENT", "WEBPAGE_LIST", "VIDEO_LINEUP", "PLACEMENT_LIST", "VERTICAL_ADS_ITEM_GROUP_RULE_LIST", "VERTICAL_ADS_ITEM_GROUP_RULE"]).optional(), youtubeChannel: googleAdsSearchads360V23CommonYouTubeChannelInfo.optional(), youtubeVideo: googleAdsSearchads360V23CommonYouTubeVideoInfo.optional()}); export const googleAdsSearchads360V23ServicesMutateCustomerNegativeCriteriaResult = z.object({customerNegativeCriterion: googleAdsSearchads360V23ResourcesCustomerNegativeCriterion.optional(), resourceName: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateCustomerNegativeCriteriaResponse = z.object({partialFailureError: googleRpcStatus.optional(), results: z.array(googleAdsSearchads360V23ServicesMutateCustomerNegativeCriteriaResult).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 or removes criteria. Operation statuses are returned. List of thrown errors: [AuthenticationError]() [AuthorizationError]() [CriterionError]() [DatabaseError]() [FieldError]() [HeaderError]() [InternalError]() [MutateError]() [QuotaError]() [RequestError]() * * POST /v23/customers/{customersId}/customerNegativeCriteria:mutate */ export const createApiV23CustomersCustomersIdCustomerNegativeCriteriaMutate = async (args: CreateApiV23CustomersCustomersIdCustomerNegativeCriteriaMutateArgs, options?: CreateApiV23CustomersCustomersIdCustomerNegativeCriteriaMutateOptions) => { 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))}/customerNegativeCriteria: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(googleAdsSearchads360V23ServicesMutateCustomerNegativeCriteriaResponse, await res.json()) };