import {z} from 'zod' export type DimensionValue = {dimensionName?: string | undefined, etag?: string | undefined, id?: string | undefined, kind?: string | undefined, matchType?: ('EXACT' | 'BEGINS_WITH' | 'CONTAINS' | 'WILDCARD_EXPRESSION') | undefined, value?: string | undefined}; export type FloodlightActivityDynamicTag = {id?: unknown | undefined, name?: string | undefined, tag?: string | undefined}; export type FloodlightActivityPublisherDynamicTag = {clickThrough?: boolean | undefined, directorySiteId?: unknown | undefined, dynamicTag?: FloodlightActivityDynamicTag | undefined, siteId?: unknown | undefined, siteIdDimensionValue?: DimensionValue | undefined, viewThrough?: boolean | undefined}; export type FloodlightActivity = {accountId?: unknown | undefined, advertiserId?: unknown | undefined, advertiserIdDimensionValue?: DimensionValue | undefined, attributionEnabled?: boolean | undefined, cacheBustingType?: ('JAVASCRIPT' | 'ACTIVE_SERVER_PAGE' | 'JSP' | 'PHP' | 'COLD_FUSION') | undefined, conversionCategory?: ('CONVERSION_CATEGORY_DEFAULT' | 'CONVERSION_CATEGORY_PURCHASE' | 'CONVERSION_CATEGORY_SIGNUP' | 'CONVERSION_CATEGORY_PAGE_VIEW' | 'CONVERSION_CATEGORY_DOWNLOAD' | 'CONVERSION_CATEGORY_ADD_TO_CART' | 'CONVERSION_CATEGORY_BEGIN_CHECKOUT' | 'CONVERSION_CATEGORY_SUBSCRIBE_PAID' | 'CONVERSION_CATEGORY_SUBMIT_LEAD_FORM' | 'CONVERSION_CATEGORY_BOOK_APPOINTMENT' | 'CONVERSION_CATEGORY_REQUEST_QUOTE' | 'CONVERSION_CATEGORY_GET_DIRECTIONS' | 'CONVERSION_CATEGORY_OUTBOUND_CLICK' | 'CONVERSION_CATEGORY_CONTACT' | 'CONVERSION_CATEGORY_QUALIFIED_LEAD' | 'CONVERSION_CATEGORY_CONVERTED_LEAD' | 'CONVERSION_CATEGORY_IN_APP_AD_REVENUE') | undefined, countingMethod?: ('STANDARD_COUNTING' | 'UNIQUE_COUNTING' | 'SESSION_COUNTING' | 'TRANSACTIONS_COUNTING' | 'ITEMS_SOLD_COUNTING') | undefined, defaultTags?: Array | undefined, expectedUrl?: string | undefined, floodlightActivityGroupId?: unknown | undefined, floodlightActivityGroupName?: string | undefined, floodlightActivityGroupTagString?: string | undefined, floodlightActivityGroupType?: ('COUNTER' | 'SALE') | undefined, floodlightConfigurationId?: unknown | undefined, floodlightConfigurationIdDimensionValue?: DimensionValue | undefined, floodlightTagType?: ('IFRAME' | 'IMAGE' | 'GLOBAL_SITE_TAG') | undefined, id?: unknown | undefined, idDimensionValue?: DimensionValue | undefined, kind?: string | undefined, name?: string | undefined, notes?: string | undefined, publisherTags?: Array | undefined, secure?: boolean | undefined, sslCompliant?: boolean | undefined, sslRequired?: boolean | undefined, status?: ('ACTIVE' | 'ARCHIVED_AND_DISABLED' | 'ARCHIVED' | 'DISABLED_POLICY') | undefined, subaccountId?: unknown | undefined, tagFormat?: ('HTML' | 'XHTML') | undefined, tagString?: string | undefined, userDefinedVariableTypes?: (Array<'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'>) | undefined}; export type CreateApiUserprofilesUserprofilesIdFloodlightActivitiesArgs = {userprofilesId: string, body: FloodlightActivity}; export type CreateApiUserprofilesUserprofilesIdFloodlightActivitiesOptions = {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 floodlightActivityDynamicTag = z.object({id: z.string().optional(), name: z.string().optional(), tag: z.string().optional()}); export const floodlightActivityPublisherDynamicTag = z.object({clickThrough: z.boolean().optional(), directorySiteId: z.string().optional(), dynamicTag: floodlightActivityDynamicTag.optional(), siteId: z.string().optional(), siteIdDimensionValue: dimensionValue.optional(), viewThrough: z.boolean().optional()}); export const floodlightActivity = z.object({accountId: z.string().optional(), advertiserId: z.string().optional(), advertiserIdDimensionValue: dimensionValue.optional(), attributionEnabled: z.boolean().optional(), cacheBustingType: z.enum(["JAVASCRIPT", "ACTIVE_SERVER_PAGE", "JSP", "PHP", "COLD_FUSION"]).optional(), conversionCategory: z.enum(["CONVERSION_CATEGORY_DEFAULT", "CONVERSION_CATEGORY_PURCHASE", "CONVERSION_CATEGORY_SIGNUP", "CONVERSION_CATEGORY_PAGE_VIEW", "CONVERSION_CATEGORY_DOWNLOAD", "CONVERSION_CATEGORY_ADD_TO_CART", "CONVERSION_CATEGORY_BEGIN_CHECKOUT", "CONVERSION_CATEGORY_SUBSCRIBE_PAID", "CONVERSION_CATEGORY_SUBMIT_LEAD_FORM", "CONVERSION_CATEGORY_BOOK_APPOINTMENT", "CONVERSION_CATEGORY_REQUEST_QUOTE", "CONVERSION_CATEGORY_GET_DIRECTIONS", "CONVERSION_CATEGORY_OUTBOUND_CLICK", "CONVERSION_CATEGORY_CONTACT", "CONVERSION_CATEGORY_QUALIFIED_LEAD", "CONVERSION_CATEGORY_CONVERTED_LEAD", "CONVERSION_CATEGORY_IN_APP_AD_REVENUE"]).optional(), countingMethod: z.enum(["STANDARD_COUNTING", "UNIQUE_COUNTING", "SESSION_COUNTING", "TRANSACTIONS_COUNTING", "ITEMS_SOLD_COUNTING"]).optional(), defaultTags: z.array(floodlightActivityDynamicTag).optional(), expectedUrl: z.string().optional(), floodlightActivityGroupId: z.string().optional(), floodlightActivityGroupName: z.string().optional(), floodlightActivityGroupTagString: z.string().optional(), floodlightActivityGroupType: z.enum(["COUNTER", "SALE"]).optional(), floodlightConfigurationId: z.string().optional(), floodlightConfigurationIdDimensionValue: dimensionValue.optional(), floodlightTagType: z.enum(["IFRAME", "IMAGE", "GLOBAL_SITE_TAG"]).optional(), id: z.string().optional(), idDimensionValue: dimensionValue.optional(), kind: z.string().optional(), name: z.string().optional(), notes: z.string().optional(), publisherTags: z.array(floodlightActivityPublisherDynamicTag).optional(), secure: z.boolean().optional(), sslCompliant: z.boolean().optional(), sslRequired: z.boolean().optional(), status: z.enum(["ACTIVE", "ARCHIVED_AND_DISABLED", "ARCHIVED", "DISABLED_POLICY"]).optional(), subaccountId: z.string().optional(), tagFormat: z.enum(["HTML", "XHTML"]).optional(), tagString: z.string().optional(), userDefinedVariableTypes: z.array(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 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 }; /** * Inserts a new floodlight activity. * * POST /userprofiles/{userprofilesId}/floodlightActivities */ export const createApiUserprofilesUserprofilesIdFloodlightActivities = async (args: CreateApiUserprofilesUserprofilesIdFloodlightActivitiesArgs, options?: CreateApiUserprofilesUserprofilesIdFloodlightActivitiesOptions) => { 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))}/floodlightActivities${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(floodlightActivity, await res.json()) };