mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-09 12:37:46 +00:00
349 lines
11 KiB
TypeScript
349 lines
11 KiB
TypeScript
/*
|
|
* 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 GetPlaylistContentsPlaylistsErrors = {
|
|
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 GetPlaylistContentsUnauthorizedData = {
|
|
errors?: Array<GetPlaylistContentsPlaylistsErrors> | 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 GetPlaylistContentsUnauthorized extends PlexAPIError {
|
|
errors?: Array<GetPlaylistContentsPlaylistsErrors> | undefined;
|
|
|
|
/** The original data that was passed to this error instance. */
|
|
data$: GetPlaylistContentsUnauthorizedData;
|
|
|
|
constructor(
|
|
err: GetPlaylistContentsUnauthorizedData,
|
|
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 = "GetPlaylistContentsUnauthorized";
|
|
}
|
|
}
|
|
|
|
export type GetPlaylistContentsErrors = {
|
|
code?: number | undefined;
|
|
message?: string | undefined;
|
|
status?: number | undefined;
|
|
};
|
|
|
|
/**
|
|
* Bad Request - A parameter was not specified, or was specified incorrectly.
|
|
*/
|
|
export type GetPlaylistContentsBadRequestData = {
|
|
errors?: Array<GetPlaylistContentsErrors> | 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 GetPlaylistContentsBadRequest extends PlexAPIError {
|
|
errors?: Array<GetPlaylistContentsErrors> | undefined;
|
|
|
|
/** The original data that was passed to this error instance. */
|
|
data$: GetPlaylistContentsBadRequestData;
|
|
|
|
constructor(
|
|
err: GetPlaylistContentsBadRequestData,
|
|
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 = "GetPlaylistContentsBadRequest";
|
|
}
|
|
}
|
|
|
|
/** @internal */
|
|
export const GetPlaylistContentsPlaylistsErrors$inboundSchema: z.ZodType<
|
|
GetPlaylistContentsPlaylistsErrors,
|
|
z.ZodTypeDef,
|
|
unknown
|
|
> = z.object({
|
|
code: z.number().int().optional(),
|
|
message: z.string().optional(),
|
|
status: z.number().int().optional(),
|
|
});
|
|
|
|
/** @internal */
|
|
export type GetPlaylistContentsPlaylistsErrors$Outbound = {
|
|
code?: number | undefined;
|
|
message?: string | undefined;
|
|
status?: number | undefined;
|
|
};
|
|
|
|
/** @internal */
|
|
export const GetPlaylistContentsPlaylistsErrors$outboundSchema: z.ZodType<
|
|
GetPlaylistContentsPlaylistsErrors$Outbound,
|
|
z.ZodTypeDef,
|
|
GetPlaylistContentsPlaylistsErrors
|
|
> = 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 GetPlaylistContentsPlaylistsErrors$ {
|
|
/** @deprecated use `GetPlaylistContentsPlaylistsErrors$inboundSchema` instead. */
|
|
export const inboundSchema = GetPlaylistContentsPlaylistsErrors$inboundSchema;
|
|
/** @deprecated use `GetPlaylistContentsPlaylistsErrors$outboundSchema` instead. */
|
|
export const outboundSchema =
|
|
GetPlaylistContentsPlaylistsErrors$outboundSchema;
|
|
/** @deprecated use `GetPlaylistContentsPlaylistsErrors$Outbound` instead. */
|
|
export type Outbound = GetPlaylistContentsPlaylistsErrors$Outbound;
|
|
}
|
|
|
|
export function getPlaylistContentsPlaylistsErrorsToJSON(
|
|
getPlaylistContentsPlaylistsErrors: GetPlaylistContentsPlaylistsErrors,
|
|
): string {
|
|
return JSON.stringify(
|
|
GetPlaylistContentsPlaylistsErrors$outboundSchema.parse(
|
|
getPlaylistContentsPlaylistsErrors,
|
|
),
|
|
);
|
|
}
|
|
|
|
export function getPlaylistContentsPlaylistsErrorsFromJSON(
|
|
jsonString: string,
|
|
): SafeParseResult<GetPlaylistContentsPlaylistsErrors, SDKValidationError> {
|
|
return safeParse(
|
|
jsonString,
|
|
(x) =>
|
|
GetPlaylistContentsPlaylistsErrors$inboundSchema.parse(JSON.parse(x)),
|
|
`Failed to parse 'GetPlaylistContentsPlaylistsErrors' from JSON`,
|
|
);
|
|
}
|
|
|
|
/** @internal */
|
|
export const GetPlaylistContentsUnauthorized$inboundSchema: z.ZodType<
|
|
GetPlaylistContentsUnauthorized,
|
|
z.ZodTypeDef,
|
|
unknown
|
|
> = z.object({
|
|
errors: z.array(
|
|
z.lazy(() => GetPlaylistContentsPlaylistsErrors$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 GetPlaylistContentsUnauthorized(remapped, {
|
|
request: v.request$,
|
|
response: v.response$,
|
|
body: v.body$,
|
|
});
|
|
});
|
|
|
|
/** @internal */
|
|
export type GetPlaylistContentsUnauthorized$Outbound = {
|
|
errors?: Array<GetPlaylistContentsPlaylistsErrors$Outbound> | undefined;
|
|
RawResponse?: never | undefined;
|
|
};
|
|
|
|
/** @internal */
|
|
export const GetPlaylistContentsUnauthorized$outboundSchema: z.ZodType<
|
|
GetPlaylistContentsUnauthorized$Outbound,
|
|
z.ZodTypeDef,
|
|
GetPlaylistContentsUnauthorized
|
|
> = z.instanceof(GetPlaylistContentsUnauthorized)
|
|
.transform(v => v.data$)
|
|
.pipe(
|
|
z.object({
|
|
errors: z.array(
|
|
z.lazy(() => GetPlaylistContentsPlaylistsErrors$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 GetPlaylistContentsUnauthorized$ {
|
|
/** @deprecated use `GetPlaylistContentsUnauthorized$inboundSchema` instead. */
|
|
export const inboundSchema = GetPlaylistContentsUnauthorized$inboundSchema;
|
|
/** @deprecated use `GetPlaylistContentsUnauthorized$outboundSchema` instead. */
|
|
export const outboundSchema = GetPlaylistContentsUnauthorized$outboundSchema;
|
|
/** @deprecated use `GetPlaylistContentsUnauthorized$Outbound` instead. */
|
|
export type Outbound = GetPlaylistContentsUnauthorized$Outbound;
|
|
}
|
|
|
|
/** @internal */
|
|
export const GetPlaylistContentsErrors$inboundSchema: z.ZodType<
|
|
GetPlaylistContentsErrors,
|
|
z.ZodTypeDef,
|
|
unknown
|
|
> = z.object({
|
|
code: z.number().int().optional(),
|
|
message: z.string().optional(),
|
|
status: z.number().int().optional(),
|
|
});
|
|
|
|
/** @internal */
|
|
export type GetPlaylistContentsErrors$Outbound = {
|
|
code?: number | undefined;
|
|
message?: string | undefined;
|
|
status?: number | undefined;
|
|
};
|
|
|
|
/** @internal */
|
|
export const GetPlaylistContentsErrors$outboundSchema: z.ZodType<
|
|
GetPlaylistContentsErrors$Outbound,
|
|
z.ZodTypeDef,
|
|
GetPlaylistContentsErrors
|
|
> = 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 GetPlaylistContentsErrors$ {
|
|
/** @deprecated use `GetPlaylistContentsErrors$inboundSchema` instead. */
|
|
export const inboundSchema = GetPlaylistContentsErrors$inboundSchema;
|
|
/** @deprecated use `GetPlaylistContentsErrors$outboundSchema` instead. */
|
|
export const outboundSchema = GetPlaylistContentsErrors$outboundSchema;
|
|
/** @deprecated use `GetPlaylistContentsErrors$Outbound` instead. */
|
|
export type Outbound = GetPlaylistContentsErrors$Outbound;
|
|
}
|
|
|
|
export function getPlaylistContentsErrorsToJSON(
|
|
getPlaylistContentsErrors: GetPlaylistContentsErrors,
|
|
): string {
|
|
return JSON.stringify(
|
|
GetPlaylistContentsErrors$outboundSchema.parse(getPlaylistContentsErrors),
|
|
);
|
|
}
|
|
|
|
export function getPlaylistContentsErrorsFromJSON(
|
|
jsonString: string,
|
|
): SafeParseResult<GetPlaylistContentsErrors, SDKValidationError> {
|
|
return safeParse(
|
|
jsonString,
|
|
(x) => GetPlaylistContentsErrors$inboundSchema.parse(JSON.parse(x)),
|
|
`Failed to parse 'GetPlaylistContentsErrors' from JSON`,
|
|
);
|
|
}
|
|
|
|
/** @internal */
|
|
export const GetPlaylistContentsBadRequest$inboundSchema: z.ZodType<
|
|
GetPlaylistContentsBadRequest,
|
|
z.ZodTypeDef,
|
|
unknown
|
|
> = z.object({
|
|
errors: z.array(z.lazy(() => GetPlaylistContentsErrors$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 GetPlaylistContentsBadRequest(remapped, {
|
|
request: v.request$,
|
|
response: v.response$,
|
|
body: v.body$,
|
|
});
|
|
});
|
|
|
|
/** @internal */
|
|
export type GetPlaylistContentsBadRequest$Outbound = {
|
|
errors?: Array<GetPlaylistContentsErrors$Outbound> | undefined;
|
|
RawResponse?: never | undefined;
|
|
};
|
|
|
|
/** @internal */
|
|
export const GetPlaylistContentsBadRequest$outboundSchema: z.ZodType<
|
|
GetPlaylistContentsBadRequest$Outbound,
|
|
z.ZodTypeDef,
|
|
GetPlaylistContentsBadRequest
|
|
> = z.instanceof(GetPlaylistContentsBadRequest)
|
|
.transform(v => v.data$)
|
|
.pipe(
|
|
z.object({
|
|
errors: z.array(z.lazy(() => GetPlaylistContentsErrors$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 GetPlaylistContentsBadRequest$ {
|
|
/** @deprecated use `GetPlaylistContentsBadRequest$inboundSchema` instead. */
|
|
export const inboundSchema = GetPlaylistContentsBadRequest$inboundSchema;
|
|
/** @deprecated use `GetPlaylistContentsBadRequest$outboundSchema` instead. */
|
|
export const outboundSchema = GetPlaylistContentsBadRequest$outboundSchema;
|
|
/** @deprecated use `GetPlaylistContentsBadRequest$Outbound` instead. */
|
|
export type Outbound = GetPlaylistContentsBadRequest$Outbound;
|
|
}
|