/* * 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"; /** * Ordering. Default is ID ASC. When using cursor pagination (see cursor param), * * @remarks * only `id` and `created` are supported. All other sort_by options (`position`, `title`, `updated`) * require offset pagination. */ export const GetChannelEpisodesSortBy = { Position: "position", Title: "title", Created: "created", Updated: "updated", Id: "id", } as const; /** * Ordering. Default is ID ASC. When using cursor pagination (see cursor param), * * @remarks * only `id` and `created` are supported. All other sort_by options (`position`, `title`, `updated`) * require offset pagination. */ export type GetChannelEpisodesSortBy = ClosedEnum< typeof GetChannelEpisodesSortBy >; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ export const GetChannelEpisodesSortDirection = { Zero: 0, One: 1, } as const; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ export type GetChannelEpisodesSortDirection = ClosedEnum< typeof GetChannelEpisodesSortDirection >; /** * 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 GetChannelEpisodesEnabled = { 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 GetChannelEpisodesEnabled = ClosedEnum< typeof GetChannelEpisodesEnabled >; /** * 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 GetChannelEpisodesCursor = { /** * 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?: GetChannelEpisodesEnabled | 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; }; export type GetChannelEpisodesRequest = { /** * The hashed ID of the channel to grab channel episodes from. */ channelId?: string | undefined; /** * Ordering. Default is ID ASC. When using cursor pagination (see cursor param), * * @remarks * only `id` and `created` are supported. All other sort_by options (`position`, `title`, `updated`) * require offset pagination. */ sortBy?: GetChannelEpisodesSortBy | undefined; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ sortDirection?: GetChannelEpisodesSortDirection | undefined; /** * 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?: GetChannelEpisodesCursor | undefined; /** * Filter by media id */ mediaId?: Array | undefined; /** * Filter by hashed id */ hashedIds?: Array | undefined; /** * Filter by published status. */ published?: boolean | undefined; /** * Filter by channel episode name/title. */ title?: string | undefined; }; /** * A channel episode represents a media that has been added to a channel. Only published * * @remarks * episodes are displayed in a channel. */ export type GetChannelEpisodesResponse = { /** * A unique alphanumeric identifier for the channel episode's channel. */ channelHashedId: string; /** * The date when the channel episode was originally created. */ created: Date; /** * A cursor for stable pagination based on current `sort_by` order. You can pass this to `cursor[before]` or `cursor[after]` as a parameter to fetch the records before or after this record in the same sort order. This is only populated if records were fetched with `cursor[enabled]`, or `cursor[before]` or `cursor[after]`. */ cursor?: string | null | undefined; /** * The channel episode's description or episode notes. */ description: string; /** * A short summary of the episode that is displayed when space is limited. */ summary: string; /** * A unique alphanumeric identifier for the channel episode. */ hashedId: string; /** * A unique alphanumeric identifier for the channel episode's media. */ mediaHashedId: string; /** * Whether the channel episode has been published or is still in draft form. */ published: boolean; /** * The date and time when the episode is scheduled to be published in UTC timezone (only present when publish_status is 'scheduled'). */ publishAt?: Date | undefined; /** * The title of the channel episode */ title: string | null; /** * The date when the channel was last updated. */ updated: Date; }; /** @internal */ export const GetChannelEpisodesSortBy$outboundSchema: z.ZodNativeEnum< typeof GetChannelEpisodesSortBy > = z.nativeEnum(GetChannelEpisodesSortBy); /** @internal */ export const GetChannelEpisodesSortDirection$outboundSchema: z.ZodNativeEnum< typeof GetChannelEpisodesSortDirection > = z.nativeEnum(GetChannelEpisodesSortDirection); /** @internal */ export const GetChannelEpisodesEnabled$outboundSchema: z.ZodNativeEnum< typeof GetChannelEpisodesEnabled > = z.nativeEnum(GetChannelEpisodesEnabled); /** @internal */ export type GetChannelEpisodesCursor$Outbound = { enabled?: number | undefined; before?: string | undefined; after?: string | undefined; }; /** @internal */ export const GetChannelEpisodesCursor$outboundSchema: z.ZodType< GetChannelEpisodesCursor$Outbound, z.ZodTypeDef, GetChannelEpisodesCursor > = z.object({ enabled: GetChannelEpisodesEnabled$outboundSchema.optional(), before: z.string().optional(), after: z.string().optional(), }); export function getChannelEpisodesCursorToJSON( getChannelEpisodesCursor: GetChannelEpisodesCursor, ): string { return JSON.stringify( GetChannelEpisodesCursor$outboundSchema.parse(getChannelEpisodesCursor), ); } /** @internal */ export type GetChannelEpisodesRequest$Outbound = { channel_id?: string | undefined; sort_by?: string | undefined; sort_direction?: number | undefined; page?: number | undefined; per_page?: number | undefined; cursor?: GetChannelEpisodesCursor$Outbound | undefined; "media_id[]"?: Array | undefined; "hashed_ids[]"?: Array | undefined; published?: boolean | undefined; title?: string | undefined; }; /** @internal */ export const GetChannelEpisodesRequest$outboundSchema: z.ZodType< GetChannelEpisodesRequest$Outbound, z.ZodTypeDef, GetChannelEpisodesRequest > = z.object({ channelId: z.string().optional(), sortBy: GetChannelEpisodesSortBy$outboundSchema.optional(), sortDirection: GetChannelEpisodesSortDirection$outboundSchema.optional(), page: z.number().int().optional(), perPage: z.number().int().optional(), cursor: z.lazy(() => GetChannelEpisodesCursor$outboundSchema).optional(), mediaId: z.array(z.string()).optional(), hashedIds: z.array(z.string()).optional(), published: z.boolean().optional(), title: z.string().optional(), }).transform((v) => { return remap$(v, { channelId: "channel_id", sortBy: "sort_by", sortDirection: "sort_direction", perPage: "per_page", mediaId: "media_id[]", hashedIds: "hashed_ids[]", }); }); export function getChannelEpisodesRequestToJSON( getChannelEpisodesRequest: GetChannelEpisodesRequest, ): string { return JSON.stringify( GetChannelEpisodesRequest$outboundSchema.parse(getChannelEpisodesRequest), ); } /** @internal */ export const GetChannelEpisodesResponse$inboundSchema: z.ZodType< GetChannelEpisodesResponse, z.ZodTypeDef, unknown > = z.object({ channel_hashed_id: z.string(), created: z.string().datetime({ offset: true }).transform(v => new Date(v)), cursor: z.nullable(z.string()).optional(), description: z.string(), summary: z.string(), hashed_id: z.string(), media_hashed_id: z.string(), published: z.boolean(), publish_at: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), title: z.nullable(z.string()), updated: z.string().datetime({ offset: true }).transform(v => new Date(v)), }).transform((v) => { return remap$(v, { "channel_hashed_id": "channelHashedId", "hashed_id": "hashedId", "media_hashed_id": "mediaHashedId", "publish_at": "publishAt", }); }); export function getChannelEpisodesResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetChannelEpisodesResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetChannelEpisodesResponse' from JSON`, ); }