/* * 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 { PlexAPIError } from "./plexapierror.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type GetTimelineVideoErrors = { code?: number | undefined; message?: string | undefined; status?: number | undefined; }; /** * Unauthorized - Returned if the X-Plex-Token is missing from the header or query. */ export type GetTimelineUnauthorizedData = { errors?: Array | undefined; /** * Raw HTTP response; suitable for custom response parsing */ rawResponse?: Response | undefined; }; /** * Unauthorized - Returned if the X-Plex-Token is missing from the header or query. */ export class GetTimelineUnauthorized extends PlexAPIError { errors?: Array | undefined; /** The original data that was passed to this error instance. */ data$: GetTimelineUnauthorizedData; constructor( err: GetTimelineUnauthorizedData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; if (err.errors != null) this.errors = err.errors; this.name = "GetTimelineUnauthorized"; } } export type GetTimelineErrors = { code?: number | undefined; message?: string | undefined; status?: number | undefined; }; /** * Bad Request - A parameter was not specified, or was specified incorrectly. */ export type GetTimelineBadRequestData = { errors?: Array | undefined; /** * Raw HTTP response; suitable for custom response parsing */ rawResponse?: Response | undefined; }; /** * Bad Request - A parameter was not specified, or was specified incorrectly. */ export class GetTimelineBadRequest extends PlexAPIError { errors?: Array | undefined; /** The original data that was passed to this error instance. */ data$: GetTimelineBadRequestData; constructor( err: GetTimelineBadRequestData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; if (err.errors != null) this.errors = err.errors; this.name = "GetTimelineBadRequest"; } } /** @internal */ export const GetTimelineVideoErrors$inboundSchema: z.ZodType< GetTimelineVideoErrors, z.ZodTypeDef, unknown > = z.object({ code: z.number().int().optional(), message: z.string().optional(), status: z.number().int().optional(), }); /** @internal */ export type GetTimelineVideoErrors$Outbound = { code?: number | undefined; message?: string | undefined; status?: number | undefined; }; /** @internal */ export const GetTimelineVideoErrors$outboundSchema: z.ZodType< GetTimelineVideoErrors$Outbound, z.ZodTypeDef, GetTimelineVideoErrors > = z.object({ code: z.number().int().optional(), message: z.string().optional(), status: z.number().int().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetTimelineVideoErrors$ { /** @deprecated use `GetTimelineVideoErrors$inboundSchema` instead. */ export const inboundSchema = GetTimelineVideoErrors$inboundSchema; /** @deprecated use `GetTimelineVideoErrors$outboundSchema` instead. */ export const outboundSchema = GetTimelineVideoErrors$outboundSchema; /** @deprecated use `GetTimelineVideoErrors$Outbound` instead. */ export type Outbound = GetTimelineVideoErrors$Outbound; } export function getTimelineVideoErrorsToJSON( getTimelineVideoErrors: GetTimelineVideoErrors, ): string { return JSON.stringify( GetTimelineVideoErrors$outboundSchema.parse(getTimelineVideoErrors), ); } export function getTimelineVideoErrorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetTimelineVideoErrors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTimelineVideoErrors' from JSON`, ); } /** @internal */ export const GetTimelineUnauthorized$inboundSchema: z.ZodType< GetTimelineUnauthorized, z.ZodTypeDef, unknown > = z.object({ errors: z.array(z.lazy(() => GetTimelineVideoErrors$inboundSchema)) .optional(), RawResponse: z.instanceof(Response).optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { const remapped = remap$(v, { "RawResponse": "rawResponse", }); return new GetTimelineUnauthorized(remapped, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type GetTimelineUnauthorized$Outbound = { errors?: Array | undefined; RawResponse?: never | undefined; }; /** @internal */ export const GetTimelineUnauthorized$outboundSchema: z.ZodType< GetTimelineUnauthorized$Outbound, z.ZodTypeDef, GetTimelineUnauthorized > = z.instanceof(GetTimelineUnauthorized) .transform(v => v.data$) .pipe( z.object({ errors: z.array(z.lazy(() => GetTimelineVideoErrors$outboundSchema)) .optional(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }).optional(), }).transform((v) => { return remap$(v, { 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 GetTimelineUnauthorized$ { /** @deprecated use `GetTimelineUnauthorized$inboundSchema` instead. */ export const inboundSchema = GetTimelineUnauthorized$inboundSchema; /** @deprecated use `GetTimelineUnauthorized$outboundSchema` instead. */ export const outboundSchema = GetTimelineUnauthorized$outboundSchema; /** @deprecated use `GetTimelineUnauthorized$Outbound` instead. */ export type Outbound = GetTimelineUnauthorized$Outbound; } /** @internal */ export const GetTimelineErrors$inboundSchema: z.ZodType< GetTimelineErrors, z.ZodTypeDef, unknown > = z.object({ code: z.number().int().optional(), message: z.string().optional(), status: z.number().int().optional(), }); /** @internal */ export type GetTimelineErrors$Outbound = { code?: number | undefined; message?: string | undefined; status?: number | undefined; }; /** @internal */ export const GetTimelineErrors$outboundSchema: z.ZodType< GetTimelineErrors$Outbound, z.ZodTypeDef, GetTimelineErrors > = z.object({ code: z.number().int().optional(), message: z.string().optional(), status: z.number().int().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetTimelineErrors$ { /** @deprecated use `GetTimelineErrors$inboundSchema` instead. */ export const inboundSchema = GetTimelineErrors$inboundSchema; /** @deprecated use `GetTimelineErrors$outboundSchema` instead. */ export const outboundSchema = GetTimelineErrors$outboundSchema; /** @deprecated use `GetTimelineErrors$Outbound` instead. */ export type Outbound = GetTimelineErrors$Outbound; } export function getTimelineErrorsToJSON( getTimelineErrors: GetTimelineErrors, ): string { return JSON.stringify( GetTimelineErrors$outboundSchema.parse(getTimelineErrors), ); } export function getTimelineErrorsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetTimelineErrors$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTimelineErrors' from JSON`, ); } /** @internal */ export const GetTimelineBadRequest$inboundSchema: z.ZodType< GetTimelineBadRequest, z.ZodTypeDef, unknown > = z.object({ errors: z.array(z.lazy(() => GetTimelineErrors$inboundSchema)).optional(), RawResponse: z.instanceof(Response).optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { const remapped = remap$(v, { "RawResponse": "rawResponse", }); return new GetTimelineBadRequest(remapped, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type GetTimelineBadRequest$Outbound = { errors?: Array | undefined; RawResponse?: never | undefined; }; /** @internal */ export const GetTimelineBadRequest$outboundSchema: z.ZodType< GetTimelineBadRequest$Outbound, z.ZodTypeDef, GetTimelineBadRequest > = z.instanceof(GetTimelineBadRequest) .transform(v => v.data$) .pipe( z.object({ errors: z.array(z.lazy(() => GetTimelineErrors$outboundSchema)) .optional(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }).optional(), }).transform((v) => { return remap$(v, { 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 GetTimelineBadRequest$ { /** @deprecated use `GetTimelineBadRequest$inboundSchema` instead. */ export const inboundSchema = GetTimelineBadRequest$inboundSchema; /** @deprecated use `GetTimelineBadRequest$outboundSchema` instead. */ export const outboundSchema = GetTimelineBadRequest$outboundSchema; /** @deprecated use `GetTimelineBadRequest$Outbound` instead. */ export type Outbound = GetTimelineBadRequest$Outbound; }