import {z} from 'zod' export type MobileApp = {directory?: ('UNKNOWN' | 'APPLE_APP_STORE' | 'GOOGLE_PLAY_STORE' | 'ROKU_APP_STORE' | 'AMAZON_FIRETV_APP_STORE' | 'PLAYSTATION_APP_STORE' | 'APPLE_TV_APP_STORE' | 'XBOX_APP_STORE' | 'SAMSUNG_TV_APP_STORE' | 'ANDROID_TV_APP_STORE' | 'GENERIC_CTV_APP_STORE') | undefined, id?: string | undefined, kind?: string | undefined, publisherName?: string | undefined, title?: string | undefined}; export type DeepLink = {appUrl?: string | undefined, fallbackUrl?: string | undefined, kind?: string | undefined, mobileApp?: MobileApp | undefined, remarketingListIds?: Array | undefined}; export type LandingPage = {advertiserId?: unknown | undefined, archived?: boolean | undefined, deepLinks?: Array | undefined, id?: unknown | undefined, kind?: string | undefined, name?: string | undefined, url?: string | undefined}; export type UpdateApiUserprofilesUserprofilesIdAdvertiserLandingPagesArgs = {userprofilesId: string, body: LandingPage}; export type UpdateApiUserprofilesUserprofilesIdAdvertiserLandingPagesOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const mobileApp = z.object({directory: z.enum(["UNKNOWN", "APPLE_APP_STORE", "GOOGLE_PLAY_STORE", "ROKU_APP_STORE", "AMAZON_FIRETV_APP_STORE", "PLAYSTATION_APP_STORE", "APPLE_TV_APP_STORE", "XBOX_APP_STORE", "SAMSUNG_TV_APP_STORE", "ANDROID_TV_APP_STORE", "GENERIC_CTV_APP_STORE"]).optional(), id: z.string().optional(), kind: z.string().optional(), publisherName: z.string().optional(), title: z.string().optional()}); export const deepLink = z.object({appUrl: z.string().optional(), fallbackUrl: z.string().optional(), kind: z.string().optional(), mobileApp: mobileApp.optional(), remarketingListIds: z.array(z.string()).optional()}); export const landingPage = z.object({advertiserId: z.string().optional(), archived: z.boolean().optional(), deepLinks: z.array(deepLink).optional(), id: z.string().optional(), kind: z.string().optional(), name: z.string().optional(), url: z.string().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 }; /** * Updates an existing landing page. * * PUT /userprofiles/{userprofilesId}/advertiserLandingPages */ export const updateApiUserprofilesUserprofilesIdAdvertiserLandingPages = async (args: UpdateApiUserprofilesUserprofilesIdAdvertiserLandingPagesArgs, options?: UpdateApiUserprofilesUserprofilesIdAdvertiserLandingPagesOptions) => { const {baseUrl = "https://dfareporting.googleapis.com/dfareporting/v5", 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(/\/+$/, '')}/userprofiles/${encodeURIComponent(String(args.userprofilesId))}/advertiserLandingPages${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(landingPage, await res.json()) };