import {z} from 'zod' export type PatchAdSetAttributionConfigurationV24Q3 = {attributionMethod?: ('unknown' | 'criteoAttribution' | 'googleAnalyticsLastClick' | 'googleAnalyticsDataDriven' | 'lastClick' | 'postClick' | null) | undefined, lookbackWindow?: ('unknown' | '30M' | '24H' | '7D' | '30D' | null) | undefined}; export type NillableDecimal = {value?: (number | null) | undefined} | null; export type PatchAdSetBiddingV24Q3 = {bidAmount?: NillableDecimal | undefined}; export type PatchAdSetBudgetV24Q3 = {budgetAmount?: NillableDecimal | undefined, budgetDeliverySmoothing?: ('accelerated' | 'standard' | null) | undefined, budgetDeliveryWeek?: ('undefined' | 'mondayToSunday' | 'tuesdayToMonday' | 'wednesdayToTuesday' | 'thursdayToWednesday' | 'fridayToThursday' | 'saturdayToFriday' | 'sundayToSaturday' | null) | undefined, budgetRenewal?: ('undefined' | 'daily' | 'monthly' | 'lifetime' | 'weekly' | null) | undefined, budgetStrategy?: ('capped' | 'uncapped' | null) | undefined}; export type NillableDateTime = {value?: (string | null) | undefined} | null; export type PatchAdSetSchedulingV24Q3 = {endDate?: NillableDateTime | undefined, startDate?: NillableDateTime | undefined}; export type AdSetDeliveryLimitationsV24Q3 = {devices?: (Array<'other' | 'desktop' | 'mobile' | 'tablet'> | null) | undefined, environments?: (Array<'web' | 'inApp'> | null) | undefined, operatingSystems?: (Array<'android' | 'ios' | 'unknown'> | null) | undefined} | null; export type AdSetFrequencyCappingV24Q3 = {frequency?: ('hourly' | 'daily' | 'lifetime' | 'advanced' | null) | undefined, maximumImpressions?: (number | null) | undefined} | null; export type AdSetTargetingRuleV24Q3 = {operand?: ('undefined' | 'in' | 'notIn') | undefined, values?: (Array | null) | undefined}; export type NillableAdSetTargetingRuleV24Q3 = {value?: (AdSetTargetingRuleV24Q3 | null) | undefined} | null; export type AdSetGeoLocationV24Q3 = {countries?: NillableAdSetTargetingRuleV24Q3 | undefined, subdivisions?: NillableAdSetTargetingRuleV24Q3 | undefined, zipCodes?: NillableAdSetTargetingRuleV24Q3 | undefined} | null; export type AdSetTargetingV24Q3 = {deliveryLimitations?: AdSetDeliveryLimitationsV24Q3 | undefined, frequencyCapping?: ({value?: AdSetFrequencyCappingV24Q3 | undefined} | null) | undefined, geoLocation?: AdSetGeoLocationV24Q3 | undefined} | null; export type PatchAdSetV24Q3 = {attributionConfiguration?: PatchAdSetAttributionConfigurationV24Q3 | undefined, bidding?: PatchAdSetBiddingV24Q3 | undefined, budget?: PatchAdSetBudgetV24Q3 | undefined, name?: (string | null) | undefined, scheduling?: PatchAdSetSchedulingV24Q3 | undefined, targeting?: AdSetTargetingV24Q3 | undefined}; export type WriteModelPatchAdSetV24Q3 = {attributes?: PatchAdSetV24Q3 | undefined, id?: (string | null) | undefined, type?: (string | null) | undefined}; export type RequestsPatchAdSetV24Q3 = {data?: (Array | null) | undefined}; export type PatchApi202601MarketingSolutionsAdSetsArgs = {body: RequestsPatchAdSetV24Q3}; export type PatchApi202601MarketingSolutionsAdSetsOptions = {baseUrl?: string | undefined, oauth?: string | undefined, fetch?: typeof fetch | undefined}; export const adSetIdV24Q3 = z.object({}).nullable(); export const readModelAdSetIdV24Q3 = z.object({attributes: adSetIdV24Q3.optional(), id: z.string().nullable().optional(), type: z.string().nullable().optional()}); export const commonProblem = z.object({code: z.string().nullable().optional(), detail: z.string().nullable().optional(), instance: z.string().nullable().optional(), source: z.record(z.string(), z.string()).nullable().optional(), stackTrace: z.string().nullable().optional(), title: z.string().nullable().optional(), traceId: z.string().nullable().optional(), traceIdentifier: z.string().nullable().optional(), type: z.enum(["unknown", "access-control", "authentication", "authorization", "availability", "deprecation", "quota", "validation"]).nullable().optional()}); export const responsesAdSetIdV24Q3 = z.object({data: z.array(readModelAdSetIdV24Q3).nullable().optional(), errors: z.array(commonProblem).nullable().optional(), warnings: z.array(commonProblem).nullable().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 }; /** * /2026-01/marketing-solutions/ad-sets * * PATCH /2026-01/marketing-solutions/ad-sets */ export const patchApi202601MarketingSolutionsAdSets = async (args: PatchApi202601MarketingSolutionsAdSetsArgs, options?: PatchApi202601MarketingSolutionsAdSetsOptions) => { const {baseUrl = "https://api.criteo.com", fetch: fetchFn = fetch, oauth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (oauth !== undefined) headers.set('authorization', `Bearer ${oauth}`) const url = `${baseUrl.replace(/\/+$/, '')}/2026-01/marketing-solutions/ad-sets${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(responsesAdSetIdV24Q3, await res.json()) };