/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Filtering parameter to narrow down the list of visitors. */ export const Filter = { HasName: "has_name", HasEmail: "has_email", IdentifiedByEmailGate: "identified_by_email_gate", } as const; /** * Filtering parameter to narrow down the list of visitors. */ export type Filter = ClosedEnum; export type GetStatsVisitorsRequest = { /** * The page of results based on the per_page parameter. */ page?: number | undefined; /** * The maximum number of results to return, capped at 100. */ perPage?: number | undefined; /** * Filtering parameter to narrow down the list of visitors. */ filter?: Filter | undefined; /** * Search for visitors based on name or email address. */ search?: string | undefined; }; export type GetStatsVisitorsOrg = { name?: string | null | undefined; title?: string | null | undefined; }; export type GetStatsVisitorsVisitorIdentity = { name?: string | undefined; email?: string | null | undefined; org?: GetStatsVisitorsOrg | undefined; }; export type GetStatsVisitorsUserAgentDetails = { browser?: string | undefined; browserVersion?: string | undefined; platform?: string | undefined; mobile?: boolean | undefined; }; export type GetStatsVisitorsResponse = { /** * A unique identifier for the visitor. */ visitorKey?: string | undefined; /** * When the visitor was created. */ createdAt?: Date | undefined; /** * The last time the visitor played a video. */ lastActiveAt?: Date | undefined; /** * The event key for the last video play action. */ lastEventKey?: string | undefined; /** * The total number of videos loaded by the visitor. */ loadCount?: number | undefined; /** * The total number of videos played by the visitor. */ playCount?: number | undefined; visitorIdentity?: GetStatsVisitorsVisitorIdentity | undefined; userAgentDetails?: GetStatsVisitorsUserAgentDetails | undefined; }; /** @internal */ export const Filter$outboundSchema: z.ZodNativeEnum = z .nativeEnum(Filter); /** @internal */ export type GetStatsVisitorsRequest$Outbound = { page?: number | undefined; per_page?: number | undefined; filter?: string | undefined; search?: string | undefined; }; /** @internal */ export const GetStatsVisitorsRequest$outboundSchema: z.ZodType< GetStatsVisitorsRequest$Outbound, z.ZodTypeDef, GetStatsVisitorsRequest > = z.object({ page: z.number().int().optional(), perPage: z.number().int().optional(), filter: Filter$outboundSchema.optional(), search: z.string().optional(), }).transform((v) => { return remap$(v, { perPage: "per_page", }); }); export function getStatsVisitorsRequestToJSON( getStatsVisitorsRequest: GetStatsVisitorsRequest, ): string { return JSON.stringify( GetStatsVisitorsRequest$outboundSchema.parse(getStatsVisitorsRequest), ); } /** @internal */ export const GetStatsVisitorsOrg$inboundSchema: z.ZodType< GetStatsVisitorsOrg, z.ZodTypeDef, unknown > = z.object({ name: z.nullable(z.string()).optional(), title: z.nullable(z.string()).optional(), }); export function getStatsVisitorsOrgFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsVisitorsOrg$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsVisitorsOrg' from JSON`, ); } /** @internal */ export const GetStatsVisitorsVisitorIdentity$inboundSchema: z.ZodType< GetStatsVisitorsVisitorIdentity, z.ZodTypeDef, unknown > = z.object({ name: z.string().optional(), email: z.nullable(z.string()).optional(), org: z.lazy(() => GetStatsVisitorsOrg$inboundSchema).optional(), }); export function getStatsVisitorsVisitorIdentityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsVisitorsVisitorIdentity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsVisitorsVisitorIdentity' from JSON`, ); } /** @internal */ export const GetStatsVisitorsUserAgentDetails$inboundSchema: z.ZodType< GetStatsVisitorsUserAgentDetails, 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 getStatsVisitorsUserAgentDetailsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsVisitorsUserAgentDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsVisitorsUserAgentDetails' from JSON`, ); } /** @internal */ export const GetStatsVisitorsResponse$inboundSchema: z.ZodType< GetStatsVisitorsResponse, z.ZodTypeDef, unknown > = z.object({ visitor_key: z.string().optional(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), last_active_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), last_event_key: z.string().optional(), load_count: z.number().int().optional(), play_count: z.number().int().optional(), visitor_identity: z.lazy(() => GetStatsVisitorsVisitorIdentity$inboundSchema) .optional(), user_agent_details: z.lazy(() => GetStatsVisitorsUserAgentDetails$inboundSchema ).optional(), }).transform((v) => { return remap$(v, { "visitor_key": "visitorKey", "created_at": "createdAt", "last_active_at": "lastActiveAt", "last_event_key": "lastEventKey", "load_count": "loadCount", "play_count": "playCount", "visitor_identity": "visitorIdentity", "user_agent_details": "userAgentDetails", }); }); export function getStatsVisitorsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsVisitorsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsVisitorsResponse' from JSON`, ); }