/* * 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 type GetPublicViewershipMetricsRequest = { /** * 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; }; /** * A simplified metric object about aggregate viewership of an * * @remarks * asset. Either playbackId or dStorageUrl will be set. */ export type GetPublicViewershipMetricsData = { /** * The playback ID associated with the metric. */ playbackId?: string | undefined; /** * The URL of the distributed storage used for the asset */ dStorageUrl?: string | undefined; /** * The number of views for the stream/asset. */ viewCount?: number | undefined; /** * The total playtime in minutes for the stream/asset. */ playtimeMins?: number | undefined; }; export type GetPublicViewershipMetricsResponse = { /** * 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 single Metric object with the viewCount and playtimeMins metrics. */ data?: GetPublicViewershipMetricsData | undefined; /** * Error */ error?: components.ErrorT | undefined; }; /** @internal */ export const GetPublicViewershipMetricsRequest$inboundSchema: z.ZodType< GetPublicViewershipMetricsRequest, z.ZodTypeDef, unknown > = z.object({ playbackId: z.string(), }); /** @internal */ export type GetPublicViewershipMetricsRequest$Outbound = { playbackId: string; }; /** @internal */ export const GetPublicViewershipMetricsRequest$outboundSchema: z.ZodType< GetPublicViewershipMetricsRequest$Outbound, z.ZodTypeDef, GetPublicViewershipMetricsRequest > = z.object({ playbackId: z.string(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetPublicViewershipMetricsRequest$ { /** @deprecated use `GetPublicViewershipMetricsRequest$inboundSchema` instead. */ export const inboundSchema = GetPublicViewershipMetricsRequest$inboundSchema; /** @deprecated use `GetPublicViewershipMetricsRequest$outboundSchema` instead. */ export const outboundSchema = GetPublicViewershipMetricsRequest$outboundSchema; /** @deprecated use `GetPublicViewershipMetricsRequest$Outbound` instead. */ export type Outbound = GetPublicViewershipMetricsRequest$Outbound; } export function getPublicViewershipMetricsRequestToJSON( getPublicViewershipMetricsRequest: GetPublicViewershipMetricsRequest, ): string { return JSON.stringify( GetPublicViewershipMetricsRequest$outboundSchema.parse( getPublicViewershipMetricsRequest, ), ); } export function getPublicViewershipMetricsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetPublicViewershipMetricsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetPublicViewershipMetricsRequest' from JSON`, ); } /** @internal */ export const GetPublicViewershipMetricsData$inboundSchema: z.ZodType< GetPublicViewershipMetricsData, z.ZodTypeDef, unknown > = z.object({ playbackId: z.string().optional(), dStorageUrl: z.string().optional(), viewCount: z.number().int().optional(), playtimeMins: z.number().optional(), }); /** @internal */ export type GetPublicViewershipMetricsData$Outbound = { playbackId?: string | undefined; dStorageUrl?: string | undefined; viewCount?: number | undefined; playtimeMins?: number | undefined; }; /** @internal */ export const GetPublicViewershipMetricsData$outboundSchema: z.ZodType< GetPublicViewershipMetricsData$Outbound, z.ZodTypeDef, GetPublicViewershipMetricsData > = z.object({ playbackId: z.string().optional(), dStorageUrl: z.string().optional(), viewCount: z.number().int().optional(), playtimeMins: z.number().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetPublicViewershipMetricsData$ { /** @deprecated use `GetPublicViewershipMetricsData$inboundSchema` instead. */ export const inboundSchema = GetPublicViewershipMetricsData$inboundSchema; /** @deprecated use `GetPublicViewershipMetricsData$outboundSchema` instead. */ export const outboundSchema = GetPublicViewershipMetricsData$outboundSchema; /** @deprecated use `GetPublicViewershipMetricsData$Outbound` instead. */ export type Outbound = GetPublicViewershipMetricsData$Outbound; } export function getPublicViewershipMetricsDataToJSON( getPublicViewershipMetricsData: GetPublicViewershipMetricsData, ): string { return JSON.stringify( GetPublicViewershipMetricsData$outboundSchema.parse( getPublicViewershipMetricsData, ), ); } export function getPublicViewershipMetricsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetPublicViewershipMetricsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetPublicViewershipMetricsData' from JSON`, ); } /** @internal */ export const GetPublicViewershipMetricsResponse$inboundSchema: z.ZodType< GetPublicViewershipMetricsResponse, z.ZodTypeDef, unknown > = z.object({ ContentType: z.string(), StatusCode: z.number().int(), RawResponse: z.instanceof(Response), data: z.lazy(() => GetPublicViewershipMetricsData$inboundSchema).optional(), error: components.ErrorT$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "ContentType": "contentType", "StatusCode": "statusCode", "RawResponse": "rawResponse", }); }); /** @internal */ export type GetPublicViewershipMetricsResponse$Outbound = { ContentType: string; StatusCode: number; RawResponse: never; data?: GetPublicViewershipMetricsData$Outbound | undefined; error?: components.ErrorT$Outbound | undefined; }; /** @internal */ export const GetPublicViewershipMetricsResponse$outboundSchema: z.ZodType< GetPublicViewershipMetricsResponse$Outbound, z.ZodTypeDef, GetPublicViewershipMetricsResponse > = z.object({ contentType: z.string(), statusCode: z.number().int(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }), data: z.lazy(() => GetPublicViewershipMetricsData$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 GetPublicViewershipMetricsResponse$ { /** @deprecated use `GetPublicViewershipMetricsResponse$inboundSchema` instead. */ export const inboundSchema = GetPublicViewershipMetricsResponse$inboundSchema; /** @deprecated use `GetPublicViewershipMetricsResponse$outboundSchema` instead. */ export const outboundSchema = GetPublicViewershipMetricsResponse$outboundSchema; /** @deprecated use `GetPublicViewershipMetricsResponse$Outbound` instead. */ export type Outbound = GetPublicViewershipMetricsResponse$Outbound; } export function getPublicViewershipMetricsResponseToJSON( getPublicViewershipMetricsResponse: GetPublicViewershipMetricsResponse, ): string { return JSON.stringify( GetPublicViewershipMetricsResponse$outboundSchema.parse( getPublicViewershipMetricsResponse, ), ); } export function getPublicViewershipMetricsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetPublicViewershipMetricsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetPublicViewershipMetricsResponse' from JSON`, ); }