/* * 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 GetChannelsEnabled = { 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 GetChannelsEnabled = 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 GetChannelsCursor = { /** * 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?: GetChannelsEnabled | 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; }; /** * Ordering. Default is ID ASC. * * @remarks * Note: Only 'id' and 'created' are supported when using cursor pagination. */ export const GetChannelsSortBy = { Created: "created", Id: "id", Updated: "updated", Name: "name", } as const; /** * Ordering. Default is ID ASC. * * @remarks * Note: Only 'id' and 'created' are supported when using cursor pagination. */ export type GetChannelsSortBy = ClosedEnum; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ export const GetChannelsSortDirection = { Zero: 0, One: 1, } as const; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ export type GetChannelsSortDirection = ClosedEnum< typeof GetChannelsSortDirection >; export type GetChannelsRequest = { /** * 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?: GetChannelsCursor | undefined; /** * Page number to retrieve */ page?: number | undefined; /** * Number of channels per page */ perPage?: number | undefined; /** * Ordering. Default is ID ASC. * * @remarks * Note: Only 'id' and 'created' are supported when using cursor pagination. */ sortBy?: GetChannelsSortBy | undefined; /** * Ordering Sort Direction (0 = desc, 1 = asc; default is 1) */ sortDirection?: GetChannelsSortDirection | undefined; /** * Find all of the channels limited to these hashed_ids. */ hashedIds?: Array | undefined; }; /** * A Channel lets you take a collection of video (or audio) and embed them * * @remarks * on your site, as well as distribute through podcasting. */ export type GetChannelsResponse = { /** * The numeric id of the channel. */ id: number; /** * The date when the channel was originally created. */ created: Date; /** * The channel's description. */ description: string; /** * A unique alphanumeric identifier for this channel. */ hashedId: string; /** * The number of medias in the channel. */ mediaCount: number; /** * The display name for the channel */ name: string; /** * The date when the channel was last updated. */ updated: 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; }; /** @internal */ export const GetChannelsEnabled$outboundSchema: z.ZodNativeEnum< typeof GetChannelsEnabled > = z.nativeEnum(GetChannelsEnabled); /** @internal */ export type GetChannelsCursor$Outbound = { enabled?: number | undefined; before?: string | undefined; after?: string | undefined; }; /** @internal */ export const GetChannelsCursor$outboundSchema: z.ZodType< GetChannelsCursor$Outbound, z.ZodTypeDef, GetChannelsCursor > = z.object({ enabled: GetChannelsEnabled$outboundSchema.optional(), before: z.string().optional(), after: z.string().optional(), }); export function getChannelsCursorToJSON( getChannelsCursor: GetChannelsCursor, ): string { return JSON.stringify( GetChannelsCursor$outboundSchema.parse(getChannelsCursor), ); } /** @internal */ export const GetChannelsSortBy$outboundSchema: z.ZodNativeEnum< typeof GetChannelsSortBy > = z.nativeEnum(GetChannelsSortBy); /** @internal */ export const GetChannelsSortDirection$outboundSchema: z.ZodNativeEnum< typeof GetChannelsSortDirection > = z.nativeEnum(GetChannelsSortDirection); /** @internal */ export type GetChannelsRequest$Outbound = { cursor?: GetChannelsCursor$Outbound | undefined; page?: number | undefined; per_page?: number | undefined; sort_by?: string | undefined; sort_direction?: number | undefined; "hashed_ids[]"?: Array | undefined; }; /** @internal */ export const GetChannelsRequest$outboundSchema: z.ZodType< GetChannelsRequest$Outbound, z.ZodTypeDef, GetChannelsRequest > = z.object({ cursor: z.lazy(() => GetChannelsCursor$outboundSchema).optional(), page: z.number().int().optional(), perPage: z.number().int().optional(), sortBy: GetChannelsSortBy$outboundSchema.optional(), sortDirection: GetChannelsSortDirection$outboundSchema.optional(), hashedIds: z.array(z.string()).optional(), }).transform((v) => { return remap$(v, { perPage: "per_page", sortBy: "sort_by", sortDirection: "sort_direction", hashedIds: "hashed_ids[]", }); }); export function getChannelsRequestToJSON( getChannelsRequest: GetChannelsRequest, ): string { return JSON.stringify( GetChannelsRequest$outboundSchema.parse(getChannelsRequest), ); } /** @internal */ export const GetChannelsResponse$inboundSchema: z.ZodType< GetChannelsResponse, z.ZodTypeDef, unknown > = z.object({ id: z.number().int(), created: z.string().datetime({ offset: true }).transform(v => new Date(v)), description: z.string(), hashed_id: z.string(), media_count: z.number().int(), name: z.string(), updated: z.string().datetime({ offset: true }).transform(v => new Date(v)), cursor: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", "media_count": "mediaCount", }); }); export function getChannelsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetChannelsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetChannelsResponse' from JSON`, ); }