/* * 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 { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The time granularity for the timeseries data. */ export const GetAnalyticsWebinarsWebinarIdRegistrationGranularity = { Daily: "daily", Weekly: "weekly", Monthly: "monthly", } as const; /** * The time granularity for the timeseries data. */ export type GetAnalyticsWebinarsWebinarIdRegistrationGranularity = ClosedEnum< typeof GetAnalyticsWebinarsWebinarIdRegistrationGranularity >; export type GetAnalyticsWebinarsWebinarIdRegistrationRequest = { /** * The hashed ID of the webinar. */ webinarId: string; /** * The time granularity for the timeseries data. */ granularity: GetAnalyticsWebinarsWebinarIdRegistrationGranularity; /** * Whether to include on-demand viewing data after the live event ended. */ includePostEvent?: boolean | undefined; /** * Start date for the post-event analytics period in ISO 8601 format (YYYY-MM-DD). Inclusive — the range starts at the beginning of this date. Only used when include_post_event is true. */ postEventStartDate?: RFCDate | undefined; /** * End date for the post-event analytics period in ISO 8601 format (YYYY-MM-DD). Exclusive — the range ends before the beginning of this date. Only used when include_post_event is true. */ postEventEndDate?: RFCDate | undefined; }; export type GetAnalyticsWebinarsWebinarIdRegistrationResponse = { /** * The start of the time bucket in ISO 8601 format. */ timestamp?: Date | undefined; /** * The number of registrations in this time period. */ registrations?: number | null | undefined; /** * The number of registration page impressions in this time period. */ impressions?: number | null | undefined; /** * The number of on-demand registrations in this time period. */ onDemandRegistrations?: number | null | undefined; /** * The number of on-demand page impressions in this time period. */ onDemandImpressions?: number | null | undefined; /** * The completion rate for attendees in this time period (between 0 and 1). */ completionRate?: number | null | undefined; /** * The completion rate for on-demand viewers in this time period (between 0 and 1). */ onDemandCompletionRate?: number | null | undefined; }; /** @internal */ export const GetAnalyticsWebinarsWebinarIdRegistrationGranularity$outboundSchema: z.ZodNativeEnum = z.nativeEnum(GetAnalyticsWebinarsWebinarIdRegistrationGranularity); /** @internal */ export type GetAnalyticsWebinarsWebinarIdRegistrationRequest$Outbound = { webinarId: string; granularity: string; include_post_event: boolean; post_event_start_date?: string | undefined; post_event_end_date?: string | undefined; }; /** @internal */ export const GetAnalyticsWebinarsWebinarIdRegistrationRequest$outboundSchema: z.ZodType< GetAnalyticsWebinarsWebinarIdRegistrationRequest$Outbound, z.ZodTypeDef, GetAnalyticsWebinarsWebinarIdRegistrationRequest > = z.object({ webinarId: z.string(), granularity: GetAnalyticsWebinarsWebinarIdRegistrationGranularity$outboundSchema, includePostEvent: z.boolean().default(false), postEventStartDate: z.instanceof(RFCDate).transform(v => v.toString()) .optional(), postEventEndDate: z.instanceof(RFCDate).transform(v => v.toString()) .optional(), }).transform((v) => { return remap$(v, { includePostEvent: "include_post_event", postEventStartDate: "post_event_start_date", postEventEndDate: "post_event_end_date", }); }); export function getAnalyticsWebinarsWebinarIdRegistrationRequestToJSON( getAnalyticsWebinarsWebinarIdRegistrationRequest: GetAnalyticsWebinarsWebinarIdRegistrationRequest, ): string { return JSON.stringify( GetAnalyticsWebinarsWebinarIdRegistrationRequest$outboundSchema.parse( getAnalyticsWebinarsWebinarIdRegistrationRequest, ), ); } /** @internal */ export const GetAnalyticsWebinarsWebinarIdRegistrationResponse$inboundSchema: z.ZodType< GetAnalyticsWebinarsWebinarIdRegistrationResponse, z.ZodTypeDef, unknown > = z.object({ timestamp: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), registrations: z.nullable(z.number().int()).optional(), impressions: z.nullable(z.number().int()).optional(), on_demand_registrations: z.nullable(z.number().int()).optional(), on_demand_impressions: z.nullable(z.number().int()).optional(), completion_rate: z.nullable(z.number()).optional(), on_demand_completion_rate: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { "on_demand_registrations": "onDemandRegistrations", "on_demand_impressions": "onDemandImpressions", "completion_rate": "completionRate", "on_demand_completion_rate": "onDemandCompletionRate", }); }); export function getAnalyticsWebinarsWebinarIdRegistrationResponseFromJSON( jsonString: string, ): SafeParseResult< GetAnalyticsWebinarsWebinarIdRegistrationResponse, SDKValidationError > { return safeParse( jsonString, (x) => GetAnalyticsWebinarsWebinarIdRegistrationResponse$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetAnalyticsWebinarsWebinarIdRegistrationResponse' from JSON`, ); }