/* * 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"; /** * If `cursor[enabled]` is set to 1, the first result set will be fetched with cursor pagination enabled. This * * @remarks * values is ignored if `cursor[before]` or `cursor[after]` are set. */ export const GetWebinarsEnabled = { Zero: 0, One: 1, } as const; /** * If `cursor[enabled]` is set to 1, the first result set will be fetched with cursor pagination enabled. This * * @remarks * values is ignored if `cursor[before]` or `cursor[after]` are set. */ export type GetWebinarsEnabled = ClosedEnum; /** * If `cursor[enabled]` is set to 1 than cursor pagination is enabled and the * * @remarks * first set of records are fetched up to the `per_page`. Cursor * pagination will also be turned on if `cursor[before]` or `cursor[after]` * are set. Records returned will have a `cursor` property set which can be used to fetch more records in the same `sort_by` ordering. * The cursor value of the last record can be used to fetch records after the current result set and * the cursor of the first record can be used to fetch records before the result set. * * NOTE: a cursor value is only valid if the `sort_by` value hasn't changed from the * last fetch. For example, you cannot fetch using `sort_by` id and than pass that * cursor value to a `sort_by` name. */ export type GetWebinarsCursor = { /** * If `cursor[enabled]` is set to 1, the first result set will be fetched with cursor pagination enabled. This * * @remarks * values is ignored if `cursor[before]` or `cursor[after]` are set. */ enabled?: GetWebinarsEnabled | undefined; /** * If `cursor[before]` is set than cursor pagination is enabled and all records * * @remarks * before the cursor up to the `per_page` are returned. This feature is useful for * fetching "new records", for example, in a "pull to refersh" feature when showing records in a descending * order. */ before?: string | undefined; /** * If `cursor[after]` is set than cursor pagination is enabled and all records * * @remarks * after the cursor up to the `per_page` are returned. */ after?: string | undefined; }; /** * Field to sort by. When using cursor pagination (see cursor param), * * @remarks * only `id` and `scheduled_for` are supported. */ export const GetWebinarsSortBy = { ScheduledFor: "scheduled_for", Id: "id", } as const; /** * Field to sort by. When using cursor pagination (see cursor param), * * @remarks * only `id` and `scheduled_for` are supported. */ export type GetWebinarsSortBy = ClosedEnum; /** * Sort direction (0 = desc, 1 = asc; default is 1) */ export const GetWebinarsSortDirection = { Zero: 0, One: 1, } as const; /** * Sort direction (0 = desc, 1 = asc; default is 1) */ export type GetWebinarsSortDirection = ClosedEnum< typeof GetWebinarsSortDirection >; /** * Filter by whether the webinar has started. Use "true" for webinars that have started, "false" for webinars that have not started yet */ export const Started = { True: "true", False: "false", } as const; /** * Filter by whether the webinar has started. Use "true" for webinars that have started, "false" for webinars that have not started yet */ export type Started = ClosedEnum; export type GetWebinarsRequest = { /** * The page number to retrieve. This cannot be combined with `cursor`, * * @remarks * pagination. */ page?: number | undefined; /** * The number of medias per page. Use this for both offset pagination and cursor pagination. */ perPage?: number | undefined; /** * If `cursor[enabled]` is set to 1 than cursor pagination is enabled and the * * @remarks * first set of records are fetched up to the `per_page`. Cursor * pagination will also be turned on if `cursor[before]` or `cursor[after]` * are set. Records returned will have a `cursor` property set which can be used to fetch more records in the same `sort_by` ordering. * The cursor value of the last record can be used to fetch records after the current result set and * the cursor of the first record can be used to fetch records before the result set. * * NOTE: a cursor value is only valid if the `sort_by` value hasn't changed from the * last fetch. For example, you cannot fetch using `sort_by` id and than pass that * cursor value to a `sort_by` name. */ cursor?: GetWebinarsCursor | undefined; /** * Field to sort by. When using cursor pagination (see cursor param), * * @remarks * only `id` and `scheduled_for` are supported. */ sortBy?: GetWebinarsSortBy | undefined; /** * Sort direction (0 = desc, 1 = asc; default is 1) */ sortDirection?: GetWebinarsSortDirection | undefined; /** * Filter by specific webinars IDs */ hashedIds?: Array | undefined; /** * Filter by whether the webinar has started. Use "true" for webinars that have started, "false" for webinars that have not started yet */ started?: Started | undefined; }; /** * A webinar is an event which allows you to stream a video * * @remarks * to multiple participants. See our [Webinars Guide](https://support.wistia.com/en/articles/8288501-getting-started-with-webinars) * for more info. */ export type GetWebinarsResponse = { /** * The hashed ID of the webinar */ id: string; /** * The title of the webinar */ title: string; /** * The description of the webinar */ description?: string | null | undefined; /** * The scheduled start time in W3C format with timezone */ scheduledFor?: Date | null | undefined; /** * Duration of the webinar in minutes */ eventDuration?: number | null | undefined; /** * Current lifecycle status of the event */ lifecycleStatus: string; /** * Registration status of the event */ registrationStatus: string; /** * When the event was created (UTC) */ createdAt: Date; /** * When the event was last updated (UTC) */ updatedAt: Date; /** * Link for the audience to join the event */ audienceLink: string; /** * Link for the host to manage the event */ hostLink: string; /** * Link for panelists to join the event */ panelistLink: string; }; /** @internal */ export const GetWebinarsEnabled$outboundSchema: z.ZodNativeEnum< typeof GetWebinarsEnabled > = z.nativeEnum(GetWebinarsEnabled); /** @internal */ export type GetWebinarsCursor$Outbound = { enabled?: number | undefined; before?: string | undefined; after?: string | undefined; }; /** @internal */ export const GetWebinarsCursor$outboundSchema: z.ZodType< GetWebinarsCursor$Outbound, z.ZodTypeDef, GetWebinarsCursor > = z.object({ enabled: GetWebinarsEnabled$outboundSchema.optional(), before: z.string().optional(), after: z.string().optional(), }); export function getWebinarsCursorToJSON( getWebinarsCursor: GetWebinarsCursor, ): string { return JSON.stringify( GetWebinarsCursor$outboundSchema.parse(getWebinarsCursor), ); } /** @internal */ export const GetWebinarsSortBy$outboundSchema: z.ZodNativeEnum< typeof GetWebinarsSortBy > = z.nativeEnum(GetWebinarsSortBy); /** @internal */ export const GetWebinarsSortDirection$outboundSchema: z.ZodNativeEnum< typeof GetWebinarsSortDirection > = z.nativeEnum(GetWebinarsSortDirection); /** @internal */ export const Started$outboundSchema: z.ZodNativeEnum = z .nativeEnum(Started); /** @internal */ export type GetWebinarsRequest$Outbound = { page?: number | undefined; per_page?: number | undefined; cursor?: GetWebinarsCursor$Outbound | undefined; sort_by?: string | undefined; sort_direction?: number | undefined; "hashed_ids[]"?: Array | undefined; started?: string | undefined; }; /** @internal */ export const GetWebinarsRequest$outboundSchema: z.ZodType< GetWebinarsRequest$Outbound, z.ZodTypeDef, GetWebinarsRequest > = z.object({ page: z.number().int().optional(), perPage: z.number().int().optional(), cursor: z.lazy(() => GetWebinarsCursor$outboundSchema).optional(), sortBy: GetWebinarsSortBy$outboundSchema.optional(), sortDirection: GetWebinarsSortDirection$outboundSchema.optional(), hashedIds: z.array(z.string()).optional(), started: Started$outboundSchema.optional(), }).transform((v) => { return remap$(v, { perPage: "per_page", sortBy: "sort_by", sortDirection: "sort_direction", hashedIds: "hashed_ids[]", }); }); export function getWebinarsRequestToJSON( getWebinarsRequest: GetWebinarsRequest, ): string { return JSON.stringify( GetWebinarsRequest$outboundSchema.parse(getWebinarsRequest), ); } /** @internal */ export const GetWebinarsResponse$inboundSchema: z.ZodType< GetWebinarsResponse, z.ZodTypeDef, unknown > = z.object({ id: z.string(), title: z.string(), description: z.nullable(z.string()).optional(), scheduled_for: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), event_duration: z.nullable(z.number().int()).optional(), lifecycle_status: z.string(), registration_status: z.string(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), audience_link: z.string(), host_link: z.string(), panelist_link: z.string(), }).transform((v) => { return remap$(v, { "scheduled_for": "scheduledFor", "event_duration": "eventDuration", "lifecycle_status": "lifecycleStatus", "registration_status": "registrationStatus", "created_at": "createdAt", "updated_at": "updatedAt", "audience_link": "audienceLink", "host_link": "hostLink", "panelist_link": "panelistLink", }); }); export function getWebinarsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetWebinarsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetWebinarsResponse' from JSON`, ); }