/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetStatsEventsEventKeyRequest = { /** * The unique key of the event. */ eventKey: string; }; export type GetStatsEventsEventKeyThumbnail = { url?: string | undefined; width?: number | undefined; height?: number | undefined; fileSize?: number | undefined; contentType?: string | undefined; type?: string | undefined; }; /** * Type of conversion. */ export type GetStatsEventsEventKeyConversionType = number | string; /** * Additional data related to the conversion. */ export type GetStatsEventsEventKeyConversionData = { email?: string | undefined; firstName?: string | undefined; isNewLead?: boolean | undefined; lastName?: string | undefined; }; /** * Details about the user agent of the viewer. */ export type GetStatsEventsEventKeyUserAgentDetails = { browser?: string | undefined; browserVersion?: string | undefined; platform?: string | undefined; mobile?: boolean | undefined; }; /** * Successful response with the details of a single event. */ export type GetStatsEventsEventKeyResponse = { /** * Date and time when the event occurred. */ receivedAt?: Date | undefined; /** * Unique identifier for the event. */ eventKey?: string | undefined; /** * Identifier for the visitor. */ visitorKey?: string | undefined; /** * URL of the page where the video was viewed. */ embedUrl?: string | undefined; /** * Decimal number denoting how much of the video was watched. */ percentViewed?: number | undefined; /** * IP address of the viewer. */ ip?: string | undefined; /** * Organization associated with the IP address. */ org?: string | undefined; /** * Country based on IP. */ country?: string | undefined; /** * Region based on IP. */ region?: string | undefined; /** * City based on IP. */ city?: string | undefined; /** * Latitude based on IP. */ lat?: number | undefined; /** * Longitude based on IP. */ lon?: number | undefined; /** * Email of the viewer (if available). */ email?: string | null | undefined; /** * Identifier for the video that was watched. */ mediaId?: string | undefined; /** * Name of the video. */ mediaName?: string | undefined; /** * URL of the video in Wistia. */ mediaUrl?: string | undefined; /** * URL for the heatmap of the event. */ iframeHeatmapUrl?: string | undefined; thumbnail?: GetStatsEventsEventKeyThumbnail | undefined; /** * Type of conversion. */ conversionType?: number | string | undefined; /** * Additional data related to the conversion. */ conversionData?: GetStatsEventsEventKeyConversionData | undefined; /** * Details about the user agent of the viewer. */ userAgentDetails?: GetStatsEventsEventKeyUserAgentDetails | undefined; }; /** @internal */ export type GetStatsEventsEventKeyRequest$Outbound = { eventKey: string; }; /** @internal */ export const GetStatsEventsEventKeyRequest$outboundSchema: z.ZodType< GetStatsEventsEventKeyRequest$Outbound, z.ZodTypeDef, GetStatsEventsEventKeyRequest > = z.object({ eventKey: z.string(), }); export function getStatsEventsEventKeyRequestToJSON( getStatsEventsEventKeyRequest: GetStatsEventsEventKeyRequest, ): string { return JSON.stringify( GetStatsEventsEventKeyRequest$outboundSchema.parse( getStatsEventsEventKeyRequest, ), ); } /** @internal */ export const GetStatsEventsEventKeyThumbnail$inboundSchema: z.ZodType< GetStatsEventsEventKeyThumbnail, z.ZodTypeDef, unknown > = z.object({ url: z.string().optional(), width: z.number().int().optional(), height: z.number().int().optional(), fileSize: z.number().int().optional(), contentType: z.string().optional(), type: z.string().optional(), }); export function getStatsEventsEventKeyThumbnailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsEventKeyThumbnail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsEventKeyThumbnail' from JSON`, ); } /** @internal */ export const GetStatsEventsEventKeyConversionType$inboundSchema: z.ZodType< GetStatsEventsEventKeyConversionType, z.ZodTypeDef, unknown > = z.union([z.number().int(), z.string()]); export function getStatsEventsEventKeyConversionTypeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsEventKeyConversionType$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsEventKeyConversionType' from JSON`, ); } /** @internal */ export const GetStatsEventsEventKeyConversionData$inboundSchema: z.ZodType< GetStatsEventsEventKeyConversionData, z.ZodTypeDef, unknown > = z.object({ email: z.string().optional(), first_name: z.string().optional(), is_new_lead: z.boolean().optional(), last_name: z.string().optional(), }).transform((v) => { return remap$(v, { "first_name": "firstName", "is_new_lead": "isNewLead", "last_name": "lastName", }); }); export function getStatsEventsEventKeyConversionDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsEventKeyConversionData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsEventKeyConversionData' from JSON`, ); } /** @internal */ export const GetStatsEventsEventKeyUserAgentDetails$inboundSchema: z.ZodType< GetStatsEventsEventKeyUserAgentDetails, z.ZodTypeDef, unknown > = z.object({ browser: z.string().optional(), browser_version: z.string().optional(), platform: z.string().optional(), mobile: z.boolean().optional(), }).transform((v) => { return remap$(v, { "browser_version": "browserVersion", }); }); export function getStatsEventsEventKeyUserAgentDetailsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsEventKeyUserAgentDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsEventKeyUserAgentDetails' from JSON`, ); } /** @internal */ export const GetStatsEventsEventKeyResponse$inboundSchema: z.ZodType< GetStatsEventsEventKeyResponse, z.ZodTypeDef, unknown > = z.object({ received_at: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), event_key: z.string().optional(), visitor_key: z.string().optional(), embed_url: z.string().optional(), percent_viewed: z.number().optional(), ip: z.string().optional(), org: z.string().optional(), country: z.string().optional(), region: z.string().optional(), city: z.string().optional(), lat: z.number().optional(), lon: z.number().optional(), email: z.nullable(z.string()).optional(), media_id: z.string().optional(), media_name: z.string().optional(), media_url: z.string().optional(), iframe_heatmap_url: z.string().optional(), thumbnail: z.lazy(() => GetStatsEventsEventKeyThumbnail$inboundSchema) .optional(), conversion_type: z.union([z.number().int(), z.string()]).optional(), conversion_data: z.lazy(() => GetStatsEventsEventKeyConversionData$inboundSchema ).optional(), user_agent_details: z.lazy(() => GetStatsEventsEventKeyUserAgentDetails$inboundSchema ).optional(), }).transform((v) => { return remap$(v, { "received_at": "receivedAt", "event_key": "eventKey", "visitor_key": "visitorKey", "embed_url": "embedUrl", "percent_viewed": "percentViewed", "media_id": "mediaId", "media_name": "mediaName", "media_url": "mediaUrl", "iframe_heatmap_url": "iframeHeatmapUrl", "conversion_type": "conversionType", "conversion_data": "conversionData", "user_agent_details": "userAgentDetails", }); }); export function getStatsEventsEventKeyResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsEventKeyResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsEventKeyResponse' from JSON`, ); }