/* * 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 { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetStatsEventsRequest = { /** * An optional identifier for a specific video. */ mediaId?: string | undefined; /** * An optional identifier for a specific visitor. */ visitorKey?: string | undefined; /** * Maximum number of events to retrieve (capped at 100). */ perPage?: number | undefined; /** * The page of events to get data from. */ page?: number | undefined; /** * Start date in the format 'YYYY-MM-DD'. */ startDate?: RFCDate | undefined; /** * End date in the format 'YYYY-MM-DD'. */ endDate?: RFCDate | undefined; }; export type GetStatsEventsThumbnail = { url?: string | undefined; width?: number | undefined; height?: number | undefined; fileSize?: number | undefined; contentType?: string | undefined; type?: string | undefined; }; /** * Type of conversion. */ export type GetStatsEventsConversionType = number | string; /** * Additional data related to the conversion. */ export type GetStatsEventsConversionData = { email?: string | undefined; firstName?: string | undefined; isNewLead?: boolean | undefined; lastName?: string | undefined; }; /** * Details about the user agent of the viewer. */ export type GetStatsEventsUserAgentDetails = { browser?: string | undefined; browserVersion?: string | undefined; platform?: string | undefined; mobile?: boolean | undefined; }; export type GetStatsEventsResponse = { /** * 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?: GetStatsEventsThumbnail | undefined; /** * Type of conversion. */ conversionType?: number | string | undefined; /** * Additional data related to the conversion. */ conversionData?: GetStatsEventsConversionData | undefined; /** * Details about the user agent of the viewer. */ userAgentDetails?: GetStatsEventsUserAgentDetails | undefined; }; /** @internal */ export type GetStatsEventsRequest$Outbound = { media_id?: string | undefined; visitor_key?: string | undefined; per_page?: number | undefined; page?: number | undefined; start_date?: string | undefined; end_date?: string | undefined; }; /** @internal */ export const GetStatsEventsRequest$outboundSchema: z.ZodType< GetStatsEventsRequest$Outbound, z.ZodTypeDef, GetStatsEventsRequest > = z.object({ mediaId: z.string().optional(), visitorKey: z.string().optional(), perPage: z.number().int().optional(), page: z.number().int().optional(), startDate: z.instanceof(RFCDate).transform(v => v.toString()).optional(), endDate: z.instanceof(RFCDate).transform(v => v.toString()).optional(), }).transform((v) => { return remap$(v, { mediaId: "media_id", visitorKey: "visitor_key", perPage: "per_page", startDate: "start_date", endDate: "end_date", }); }); export function getStatsEventsRequestToJSON( getStatsEventsRequest: GetStatsEventsRequest, ): string { return JSON.stringify( GetStatsEventsRequest$outboundSchema.parse(getStatsEventsRequest), ); } /** @internal */ export const GetStatsEventsThumbnail$inboundSchema: z.ZodType< GetStatsEventsThumbnail, 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 getStatsEventsThumbnailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsThumbnail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsThumbnail' from JSON`, ); } /** @internal */ export const GetStatsEventsConversionType$inboundSchema: z.ZodType< GetStatsEventsConversionType, z.ZodTypeDef, unknown > = z.union([z.number().int(), z.string()]); export function getStatsEventsConversionTypeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsConversionType$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsConversionType' from JSON`, ); } /** @internal */ export const GetStatsEventsConversionData$inboundSchema: z.ZodType< GetStatsEventsConversionData, 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 getStatsEventsConversionDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsConversionData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsConversionData' from JSON`, ); } /** @internal */ export const GetStatsEventsUserAgentDetails$inboundSchema: z.ZodType< GetStatsEventsUserAgentDetails, 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 getStatsEventsUserAgentDetailsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsUserAgentDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsUserAgentDetails' from JSON`, ); } /** @internal */ export const GetStatsEventsResponse$inboundSchema: z.ZodType< GetStatsEventsResponse, 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(() => GetStatsEventsThumbnail$inboundSchema).optional(), conversion_type: z.union([z.number().int(), z.string()]).optional(), conversion_data: z.lazy(() => GetStatsEventsConversionData$inboundSchema) .optional(), user_agent_details: z.lazy(() => GetStatsEventsUserAgentDetails$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 getStatsEventsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsEventsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsEventsResponse' from JSON`, ); }