Files
plexjs/src/sdk/models/errors/getmediametadata.ts

346 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 GetMediaMetaDataLibraryErrors = {
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 GetMediaMetaDataUnauthorizedData = {
errors?: Array<GetMediaMetaDataLibraryErrors> | 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 GetMediaMetaDataUnauthorized extends PlexAPIError {
errors?: Array<GetMediaMetaDataLibraryErrors> | undefined;
/** The original data that was passed to this error instance. */
data$: GetMediaMetaDataUnauthorizedData;
constructor(
err: GetMediaMetaDataUnauthorizedData,
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 = "GetMediaMetaDataUnauthorized";
}
}
export type GetMediaMetaDataErrors = {
code?: number | undefined;
message?: string | undefined;
status?: number | undefined;
};
/**
* Bad Request - A parameter was not specified, or was specified incorrectly.
*/
export type GetMediaMetaDataBadRequestData = {
errors?: Array<GetMediaMetaDataErrors> | 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 GetMediaMetaDataBadRequest extends PlexAPIError {
errors?: Array<GetMediaMetaDataErrors> | undefined;
/** The original data that was passed to this error instance. */
data$: GetMediaMetaDataBadRequestData;
constructor(
err: GetMediaMetaDataBadRequestData,
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 = "GetMediaMetaDataBadRequest";
}
}
/** @internal */
export const GetMediaMetaDataLibraryErrors$inboundSchema: z.ZodType<
GetMediaMetaDataLibraryErrors,
z.ZodTypeDef,
unknown
> = z.object({
code: z.number().int().optional(),
message: z.string().optional(),
status: z.number().int().optional(),
});
/** @internal */
export type GetMediaMetaDataLibraryErrors$Outbound = {
code?: number | undefined;
message?: string | undefined;
status?: number | undefined;
};
/** @internal */
export const GetMediaMetaDataLibraryErrors$outboundSchema: z.ZodType<
GetMediaMetaDataLibraryErrors$Outbound,
z.ZodTypeDef,
GetMediaMetaDataLibraryErrors
> = 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 GetMediaMetaDataLibraryErrors$ {
/** @deprecated use `GetMediaMetaDataLibraryErrors$inboundSchema` instead. */
export const inboundSchema = GetMediaMetaDataLibraryErrors$inboundSchema;
/** @deprecated use `GetMediaMetaDataLibraryErrors$outboundSchema` instead. */
export const outboundSchema = GetMediaMetaDataLibraryErrors$outboundSchema;
/** @deprecated use `GetMediaMetaDataLibraryErrors$Outbound` instead. */
export type Outbound = GetMediaMetaDataLibraryErrors$Outbound;
}
export function getMediaMetaDataLibraryErrorsToJSON(
getMediaMetaDataLibraryErrors: GetMediaMetaDataLibraryErrors,
): string {
return JSON.stringify(
GetMediaMetaDataLibraryErrors$outboundSchema.parse(
getMediaMetaDataLibraryErrors,
),
);
}
export function getMediaMetaDataLibraryErrorsFromJSON(
jsonString: string,
): SafeParseResult<GetMediaMetaDataLibraryErrors, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetMediaMetaDataLibraryErrors$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetMediaMetaDataLibraryErrors' from JSON`,
);
}
/** @internal */
export const GetMediaMetaDataUnauthorized$inboundSchema: z.ZodType<
GetMediaMetaDataUnauthorized,
z.ZodTypeDef,
unknown
> = z.object({
errors: z.array(z.lazy(() => GetMediaMetaDataLibraryErrors$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 GetMediaMetaDataUnauthorized(remapped, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});
/** @internal */
export type GetMediaMetaDataUnauthorized$Outbound = {
errors?: Array<GetMediaMetaDataLibraryErrors$Outbound> | undefined;
RawResponse?: never | undefined;
};
/** @internal */
export const GetMediaMetaDataUnauthorized$outboundSchema: z.ZodType<
GetMediaMetaDataUnauthorized$Outbound,
z.ZodTypeDef,
GetMediaMetaDataUnauthorized
> = z.instanceof(GetMediaMetaDataUnauthorized)
.transform(v => v.data$)
.pipe(
z.object({
errors: z.array(
z.lazy(() => GetMediaMetaDataLibraryErrors$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 GetMediaMetaDataUnauthorized$ {
/** @deprecated use `GetMediaMetaDataUnauthorized$inboundSchema` instead. */
export const inboundSchema = GetMediaMetaDataUnauthorized$inboundSchema;
/** @deprecated use `GetMediaMetaDataUnauthorized$outboundSchema` instead. */
export const outboundSchema = GetMediaMetaDataUnauthorized$outboundSchema;
/** @deprecated use `GetMediaMetaDataUnauthorized$Outbound` instead. */
export type Outbound = GetMediaMetaDataUnauthorized$Outbound;
}
/** @internal */
export const GetMediaMetaDataErrors$inboundSchema: z.ZodType<
GetMediaMetaDataErrors,
z.ZodTypeDef,
unknown
> = z.object({
code: z.number().int().optional(),
message: z.string().optional(),
status: z.number().int().optional(),
});
/** @internal */
export type GetMediaMetaDataErrors$Outbound = {
code?: number | undefined;
message?: string | undefined;
status?: number | undefined;
};
/** @internal */
export const GetMediaMetaDataErrors$outboundSchema: z.ZodType<
GetMediaMetaDataErrors$Outbound,
z.ZodTypeDef,
GetMediaMetaDataErrors
> = 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 GetMediaMetaDataErrors$ {
/** @deprecated use `GetMediaMetaDataErrors$inboundSchema` instead. */
export const inboundSchema = GetMediaMetaDataErrors$inboundSchema;
/** @deprecated use `GetMediaMetaDataErrors$outboundSchema` instead. */
export const outboundSchema = GetMediaMetaDataErrors$outboundSchema;
/** @deprecated use `GetMediaMetaDataErrors$Outbound` instead. */
export type Outbound = GetMediaMetaDataErrors$Outbound;
}
export function getMediaMetaDataErrorsToJSON(
getMediaMetaDataErrors: GetMediaMetaDataErrors,
): string {
return JSON.stringify(
GetMediaMetaDataErrors$outboundSchema.parse(getMediaMetaDataErrors),
);
}
export function getMediaMetaDataErrorsFromJSON(
jsonString: string,
): SafeParseResult<GetMediaMetaDataErrors, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetMediaMetaDataErrors$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetMediaMetaDataErrors' from JSON`,
);
}
/** @internal */
export const GetMediaMetaDataBadRequest$inboundSchema: z.ZodType<
GetMediaMetaDataBadRequest,
z.ZodTypeDef,
unknown
> = z.object({
errors: z.array(z.lazy(() => GetMediaMetaDataErrors$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 GetMediaMetaDataBadRequest(remapped, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});
/** @internal */
export type GetMediaMetaDataBadRequest$Outbound = {
errors?: Array<GetMediaMetaDataErrors$Outbound> | undefined;
RawResponse?: never | undefined;
};
/** @internal */
export const GetMediaMetaDataBadRequest$outboundSchema: z.ZodType<
GetMediaMetaDataBadRequest$Outbound,
z.ZodTypeDef,
GetMediaMetaDataBadRequest
> = z.instanceof(GetMediaMetaDataBadRequest)
.transform(v => v.data$)
.pipe(
z.object({
errors: z.array(z.lazy(() => GetMediaMetaDataErrors$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 GetMediaMetaDataBadRequest$ {
/** @deprecated use `GetMediaMetaDataBadRequest$inboundSchema` instead. */
export const inboundSchema = GetMediaMetaDataBadRequest$inboundSchema;
/** @deprecated use `GetMediaMetaDataBadRequest$outboundSchema` instead. */
export const outboundSchema = GetMediaMetaDataBadRequest$outboundSchema;
/** @deprecated use `GetMediaMetaDataBadRequest$Outbound` instead. */
export type Outbound = GetMediaMetaDataBadRequest$Outbound;
}