mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-10 04:20:58 +00:00
120 lines
3.5 KiB
TypeScript
120 lines
3.5 KiB
TypeScript
/*
|
|
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
|
*/
|
|
|
|
import { remap as remap$ } from "../../lib/primitives";
|
|
import * as z from "zod";
|
|
|
|
export type GetOnDeckErrors = {
|
|
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 GetOnDeckResponseBodyData = {
|
|
errors?: Array<GetOnDeckErrors> | 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 GetOnDeckResponseBody extends Error {
|
|
errors?: Array<GetOnDeckErrors> | undefined;
|
|
/**
|
|
* Raw HTTP response; suitable for custom response parsing
|
|
*/
|
|
rawResponse?: Response | undefined;
|
|
|
|
/** The original data that was passed to this error instance. */
|
|
data$: GetOnDeckResponseBodyData;
|
|
|
|
constructor(err: GetOnDeckResponseBodyData) {
|
|
super("");
|
|
this.data$ = err;
|
|
|
|
if (err.errors != null) {
|
|
this.errors = err.errors;
|
|
}
|
|
if (err.rawResponse != null) {
|
|
this.rawResponse = err.rawResponse;
|
|
}
|
|
|
|
this.message =
|
|
"message" in err && typeof err.message === "string"
|
|
? err.message
|
|
: "API error occurred";
|
|
|
|
this.name = "GetOnDeckResponseBody";
|
|
}
|
|
}
|
|
|
|
/** @internal */
|
|
export namespace GetOnDeckErrors$ {
|
|
export const inboundSchema: z.ZodType<GetOnDeckErrors, z.ZodTypeDef, unknown> = z.object({
|
|
code: z.number().optional(),
|
|
message: z.string().optional(),
|
|
status: z.number().optional(),
|
|
});
|
|
|
|
export type Outbound = {
|
|
code?: number | undefined;
|
|
message?: string | undefined;
|
|
status?: number | undefined;
|
|
};
|
|
|
|
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetOnDeckErrors> = z.object({
|
|
code: z.number().optional(),
|
|
message: z.string().optional(),
|
|
status: z.number().optional(),
|
|
});
|
|
}
|
|
|
|
/** @internal */
|
|
export namespace GetOnDeckResponseBody$ {
|
|
export const inboundSchema: z.ZodType<GetOnDeckResponseBody, z.ZodTypeDef, unknown> = z
|
|
.object({
|
|
errors: z.array(z.lazy(() => GetOnDeckErrors$.inboundSchema)).optional(),
|
|
RawResponse: z.instanceof(Response).optional(),
|
|
})
|
|
.transform((v) => {
|
|
const remapped = remap$(v, {
|
|
RawResponse: "rawResponse",
|
|
});
|
|
|
|
return new GetOnDeckResponseBody(remapped);
|
|
});
|
|
|
|
export type Outbound = {
|
|
errors?: Array<GetOnDeckErrors$.Outbound> | undefined;
|
|
RawResponse?: never | undefined;
|
|
};
|
|
|
|
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetOnDeckResponseBody> = z
|
|
.instanceof(GetOnDeckResponseBody)
|
|
.transform((v) => v.data$)
|
|
.pipe(
|
|
z
|
|
.object({
|
|
errors: z.array(z.lazy(() => GetOnDeckErrors$.outboundSchema)).optional(),
|
|
rawResponse: z
|
|
.instanceof(Response)
|
|
.transform(() => {
|
|
throw new Error("Response cannot be serialized");
|
|
})
|
|
.optional(),
|
|
})
|
|
.transform((v) => {
|
|
return remap$(v, {
|
|
rawResponse: "RawResponse",
|
|
});
|
|
})
|
|
);
|
|
}
|