/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export enum BreakdownBy { PlaybackId = "playbackId", Device = "device", Browser = "browser", Country = "country", } export type GetRealtimeViewershipNowRequest = { /** * The playback ID to filter the query results. This can be a canonical * * @remarks * playback ID from Livepeer assets or streams, or dStorage identifiers * for assets */ playbackId?: string | undefined; /** * The creator ID to filter the query results */ creatorId?: string | undefined; /** * The list of fields to break down the query results. Specify this * * @remarks * query-string multiple times to break down by multiple fields. */ breakdownBy?: Array | undefined; }; export type GetRealtimeViewershipNowResponse = { /** * HTTP response content type for this operation */ contentType: string; /** * HTTP response status code for this operation */ statusCode: number; /** * Raw HTTP response; suitable for custom response parsing */ rawResponse: Response; /** * A list of Metric objects */ data?: Array | undefined; /** * Error */ error?: components.ErrorT | undefined; }; /** @internal */ export const BreakdownBy$inboundSchema: z.ZodNativeEnum = z .nativeEnum(BreakdownBy); /** @internal */ export const BreakdownBy$outboundSchema: z.ZodNativeEnum = BreakdownBy$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BreakdownBy$ { /** @deprecated use `BreakdownBy$inboundSchema` instead. */ export const inboundSchema = BreakdownBy$inboundSchema; /** @deprecated use `BreakdownBy$outboundSchema` instead. */ export const outboundSchema = BreakdownBy$outboundSchema; } /** @internal */ export const GetRealtimeViewershipNowRequest$inboundSchema: z.ZodType< GetRealtimeViewershipNowRequest, z.ZodTypeDef, unknown > = z.object({ playbackId: z.string().optional(), creatorId: z.string().optional(), "breakdownBy[]": z.array(BreakdownBy$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "breakdownBy[]": "breakdownBy", }); }); /** @internal */ export type GetRealtimeViewershipNowRequest$Outbound = { playbackId?: string | undefined; creatorId?: string | undefined; "breakdownBy[]"?: Array | undefined; }; /** @internal */ export const GetRealtimeViewershipNowRequest$outboundSchema: z.ZodType< GetRealtimeViewershipNowRequest$Outbound, z.ZodTypeDef, GetRealtimeViewershipNowRequest > = z.object({ playbackId: z.string().optional(), creatorId: z.string().optional(), breakdownBy: z.array(BreakdownBy$outboundSchema).optional(), }).transform((v) => { return remap$(v, { breakdownBy: "breakdownBy[]", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetRealtimeViewershipNowRequest$ { /** @deprecated use `GetRealtimeViewershipNowRequest$inboundSchema` instead. */ export const inboundSchema = GetRealtimeViewershipNowRequest$inboundSchema; /** @deprecated use `GetRealtimeViewershipNowRequest$outboundSchema` instead. */ export const outboundSchema = GetRealtimeViewershipNowRequest$outboundSchema; /** @deprecated use `GetRealtimeViewershipNowRequest$Outbound` instead. */ export type Outbound = GetRealtimeViewershipNowRequest$Outbound; } export function getRealtimeViewershipNowRequestToJSON( getRealtimeViewershipNowRequest: GetRealtimeViewershipNowRequest, ): string { return JSON.stringify( GetRealtimeViewershipNowRequest$outboundSchema.parse( getRealtimeViewershipNowRequest, ), ); } export function getRealtimeViewershipNowRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetRealtimeViewershipNowRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetRealtimeViewershipNowRequest' from JSON`, ); } /** @internal */ export const GetRealtimeViewershipNowResponse$inboundSchema: z.ZodType< GetRealtimeViewershipNowResponse, z.ZodTypeDef, unknown > = z.object({ ContentType: z.string(), StatusCode: z.number().int(), RawResponse: z.instanceof(Response), data: z.array(components.RealtimeViewershipMetric$inboundSchema).optional(), error: components.ErrorT$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "ContentType": "contentType", "StatusCode": "statusCode", "RawResponse": "rawResponse", }); }); /** @internal */ export type GetRealtimeViewershipNowResponse$Outbound = { ContentType: string; StatusCode: number; RawResponse: never; data?: Array | undefined; error?: components.ErrorT$Outbound | undefined; }; /** @internal */ export const GetRealtimeViewershipNowResponse$outboundSchema: z.ZodType< GetRealtimeViewershipNowResponse$Outbound, z.ZodTypeDef, GetRealtimeViewershipNowResponse > = z.object({ contentType: z.string(), statusCode: z.number().int(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }), data: z.array(components.RealtimeViewershipMetric$outboundSchema).optional(), error: components.ErrorT$outboundSchema.optional(), }).transform((v) => { return remap$(v, { contentType: "ContentType", statusCode: "StatusCode", rawResponse: "RawResponse", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetRealtimeViewershipNowResponse$ { /** @deprecated use `GetRealtimeViewershipNowResponse$inboundSchema` instead. */ export const inboundSchema = GetRealtimeViewershipNowResponse$inboundSchema; /** @deprecated use `GetRealtimeViewershipNowResponse$outboundSchema` instead. */ export const outboundSchema = GetRealtimeViewershipNowResponse$outboundSchema; /** @deprecated use `GetRealtimeViewershipNowResponse$Outbound` instead. */ export type Outbound = GetRealtimeViewershipNowResponse$Outbound; } export function getRealtimeViewershipNowResponseToJSON( getRealtimeViewershipNowResponse: GetRealtimeViewershipNowResponse, ): string { return JSON.stringify( GetRealtimeViewershipNowResponse$outboundSchema.parse( getRealtimeViewershipNowResponse, ), ); } export function getRealtimeViewershipNowResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetRealtimeViewershipNowResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetRealtimeViewershipNowResponse' from JSON`, ); }