import {z} from 'zod' export type GetApiUserprofilesUserprofilesIdFloodlightConfigurationsArgs = {userprofilesId: string, ids?: Array | undefined}; export type GetApiUserprofilesUserprofilesIdFloodlightConfigurationsOptions = {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 customViewabilityMetricConfiguration = z.object({audible: z.boolean().optional(), timeMillis: z.number().int().optional(), timePercent: z.number().int().optional(), viewabilityPercent: z.number().int().optional()}); export const customViewabilityMetric = z.object({configuration: customViewabilityMetricConfiguration.optional(), id: z.string().optional(), name: z.string().optional()}); export const lookbackConfiguration = z.object({clickDuration: z.number().int().optional(), postImpressionActivitiesDuration: z.number().int().optional()}); export const omnitureSettings = z.object({omnitureCostDataEnabled: z.boolean().optional(), omnitureIntegrationEnabled: z.boolean().optional()}); export const tagSettings = z.object({dynamicTagEnabled: z.boolean().optional(), imageTagEnabled: z.boolean().optional()}); export const thirdPartyAuthenticationToken = z.object({name: z.string().optional(), value: z.string().optional()}); export const userDefinedVariableConfiguration = z.object({dataType: z.enum(["STRING", "NUMBER"]).optional(), reportName: z.string().optional(), variableType: z.enum(["U1", "U2", "U3", "U4", "U5", "U6", "U7", "U8", "U9", "U10", "U11", "U12", "U13", "U14", "U15", "U16", "U17", "U18", "U19", "U20", "U21", "U22", "U23", "U24", "U25", "U26", "U27", "U28", "U29", "U30", "U31", "U32", "U33", "U34", "U35", "U36", "U37", "U38", "U39", "U40", "U41", "U42", "U43", "U44", "U45", "U46", "U47", "U48", "U49", "U50", "U51", "U52", "U53", "U54", "U55", "U56", "U57", "U58", "U59", "U60", "U61", "U62", "U63", "U64", "U65", "U66", "U67", "U68", "U69", "U70", "U71", "U72", "U73", "U74", "U75", "U76", "U77", "U78", "U79", "U80", "U81", "U82", "U83", "U84", "U85", "U86", "U87", "U88", "U89", "U90", "U91", "U92", "U93", "U94", "U95", "U96", "U97", "U98", "U99", "U100"]).optional()}); export const floodlightConfiguration = z.object({accountId: z.string().optional(), advertiserId: z.string().optional(), advertiserIdDimensionValue: dimensionValue.optional(), analyticsDataSharingEnabled: z.boolean().optional(), customViewabilityMetric: customViewabilityMetric.optional(), exposureToConversionEnabled: z.boolean().optional(), firstDayOfWeek: z.enum(["SUNDAY", "MONDAY"]).optional(), id: z.string().optional(), idDimensionValue: dimensionValue.optional(), inAppAttributionTrackingEnabled: z.boolean().optional(), kind: z.string().optional(), lookbackConfiguration: lookbackConfiguration.optional(), naturalSearchConversionAttributionOption: z.enum(["EXCLUDE_NATURAL_SEARCH_CONVERSION_ATTRIBUTION", "INCLUDE_NATURAL_SEARCH_CONVERSION_ATTRIBUTION", "INCLUDE_NATURAL_SEARCH_TIERED_CONVERSION_ATTRIBUTION"]).optional(), omnitureSettings: omnitureSettings.optional(), subaccountId: z.string().optional(), tagSettings: tagSettings.optional(), thirdPartyAuthenticationTokens: z.array(thirdPartyAuthenticationToken).optional(), userDefinedVariableConfigurations: z.array(userDefinedVariableConfiguration).optional()}); export const floodlightConfigurationsListResponse = z.object({floodlightConfigurations: z.array(floodlightConfiguration).optional(), kind: 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 }; /** * Retrieves a list of floodlight configurations, possibly filtered. * * GET /userprofiles/{userprofilesId}/floodlightConfigurations */ export const getApiUserprofilesUserprofilesIdFloodlightConfigurations = async (args: GetApiUserprofilesUserprofilesIdFloodlightConfigurationsArgs, options?: GetApiUserprofilesUserprofilesIdFloodlightConfigurationsOptions) => { 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") for (const item of args.ids ?? []) query.append("ids", String(item)) 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))}/floodlightConfigurations${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(floodlightConfigurationsListResponse, await res.json()) };