import {z} from 'zod' export type GetApiUserprofilesUserprofilesIdTargetableRemarketingListsArgs = {userprofilesId: string, advertiserId: unknown, active?: boolean | undefined, maxResults?: number | undefined, name?: string | undefined, pageToken?: string | undefined, sortField?: ('ID' | 'NAME') | undefined, sortOrder?: ('ASCENDING' | 'DESCENDING') | undefined}; export type GetApiUserprofilesUserprofilesIdTargetableRemarketingListsOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const dimensionValue = z.object({dimensionName: z.string().optional(), etag: z.string().optional(), id: z.string().optional(), kind: z.string().optional(), matchType: z.enum(["EXACT", "BEGINS_WITH", "CONTAINS", "WILDCARD_EXPRESSION"]).optional(), value: z.string().optional()}); export const targetableRemarketingList = z.object({accountId: z.string().optional(), active: z.boolean().optional(), advertiserId: z.string().optional(), advertiserIdDimensionValue: dimensionValue.optional(), description: z.string().optional(), id: z.string().optional(), kind: z.string().optional(), lifeSpan: z.string().optional(), listSize: z.string().optional(), listSource: z.enum(["REMARKETING_LIST_SOURCE_OTHER", "REMARKETING_LIST_SOURCE_ADX", "REMARKETING_LIST_SOURCE_DFP", "REMARKETING_LIST_SOURCE_XFP", "REMARKETING_LIST_SOURCE_DFA", "REMARKETING_LIST_SOURCE_GA", "REMARKETING_LIST_SOURCE_YOUTUBE", "REMARKETING_LIST_SOURCE_DBM", "REMARKETING_LIST_SOURCE_GPLUS", "REMARKETING_LIST_SOURCE_DMP", "REMARKETING_LIST_SOURCE_PLAY_STORE"]).optional(), name: z.string().optional(), subaccountId: z.string().optional()}); export const targetableRemarketingListsListResponse = z.object({kind: z.string().optional(), nextPageToken: z.string().optional(), targetableRemarketingLists: z.array(targetableRemarketingList).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 }; /** * Retrieves a list of targetable remarketing lists, possibly filtered. This method supports paging. * * GET /userprofiles/{userprofilesId}/targetableRemarketingLists */ export const getApiUserprofilesUserprofilesIdTargetableRemarketingLists = async (args: GetApiUserprofilesUserprofilesIdTargetableRemarketingListsArgs, options?: GetApiUserprofilesUserprofilesIdTargetableRemarketingListsOptions) => { const {baseUrl = "https://dfareporting.googleapis.com/dfareporting/v5", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.advertiserId != null) query.append("advertiserId", String(args.advertiserId)) if (args.active != null) query.append("active", String(args.active)) if (args.maxResults != null) query.append("maxResults", String(args.maxResults)) if (args.name != null) query.append("name", String(args.name)) if (args.pageToken != null) query.append("pageToken", String(args.pageToken)) if (args.sortField != null) query.append("sortField", String(args.sortField)) if (args.sortOrder != null) query.append("sortOrder", String(args.sortOrder)) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/userprofiles/${encodeURIComponent(String(args.userprofilesId))}/targetableRemarketingLists${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(targetableRemarketingListsListResponse, await res.json()) };