mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
394 lines
14 KiB
TypeScript
394 lines
14 KiB
TypeScript
/*
|
|
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
|
*/
|
|
|
|
import * as z from "zod";
|
|
|
|
export const GetPinServerList = ["https://plex.tv/api/v2"] as const;
|
|
|
|
export type GetPinRequest = {
|
|
/**
|
|
* Determines the kind of code returned by the API call
|
|
*
|
|
* @remarks
|
|
* Strong codes are used for Pin authentication flows
|
|
* Non-Strong codes are used for `Plex.tv/link`
|
|
*
|
|
*/
|
|
strong?: boolean | undefined;
|
|
/**
|
|
* The unique identifier for the client application
|
|
*
|
|
* @remarks
|
|
* This is used to track the client application and its usage
|
|
* (UUID, serial number, or other number unique per device)
|
|
*
|
|
*/
|
|
xPlexClientIdentifier?: string | undefined;
|
|
};
|
|
|
|
export type Location = {
|
|
code?: string | undefined;
|
|
europeanUnionMember?: boolean | undefined;
|
|
continentCode?: string | undefined;
|
|
country?: string | undefined;
|
|
city?: string | undefined;
|
|
timeZone?: string | undefined;
|
|
postalCode?: number | undefined;
|
|
inPrivacyRestrictedCountry?: boolean | undefined;
|
|
subdivisions?: string | undefined;
|
|
coordinates?: string | undefined;
|
|
};
|
|
|
|
/**
|
|
* The Pin
|
|
*/
|
|
export type GetPinResponseBody = {
|
|
/**
|
|
* PinID for use with authentication
|
|
*/
|
|
id?: number | undefined;
|
|
code?: string | undefined;
|
|
product?: string | undefined;
|
|
trusted?: boolean | undefined;
|
|
/**
|
|
* a link to a QR code hosted on plex.tv
|
|
*
|
|
* @remarks
|
|
* The QR code redirects to the relevant `plex.tv/link` authentication page
|
|
* Which then prompts the user for the 4 Digit Link Pin
|
|
*
|
|
*/
|
|
qr?: string | undefined;
|
|
clientIdentifier?: string | undefined;
|
|
location?: Location | undefined;
|
|
expiresIn?: number | undefined;
|
|
createdAt?: Date | undefined;
|
|
expiresAt?: Date | undefined;
|
|
authToken?: string | undefined;
|
|
newRegistration?: string | undefined;
|
|
};
|
|
|
|
export type GetPinResponse = {
|
|
/**
|
|
* 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;
|
|
/**
|
|
* The Pin
|
|
*/
|
|
object?: GetPinResponseBody | undefined;
|
|
};
|
|
|
|
/** @internal */
|
|
export namespace GetPinRequest$ {
|
|
export type Inbound = {
|
|
strong?: boolean | undefined;
|
|
"X-Plex-Client-Identifier"?: string | undefined;
|
|
};
|
|
|
|
export const inboundSchema: z.ZodType<GetPinRequest, z.ZodTypeDef, Inbound> = z
|
|
.object({
|
|
strong: z.boolean().default(false),
|
|
"X-Plex-Client-Identifier": z.string().optional(),
|
|
})
|
|
.transform((v) => {
|
|
return {
|
|
strong: v.strong,
|
|
...(v["X-Plex-Client-Identifier"] === undefined
|
|
? null
|
|
: { xPlexClientIdentifier: v["X-Plex-Client-Identifier"] }),
|
|
};
|
|
});
|
|
|
|
export type Outbound = {
|
|
strong: boolean;
|
|
"X-Plex-Client-Identifier"?: string | undefined;
|
|
};
|
|
|
|
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetPinRequest> = z
|
|
.object({
|
|
strong: z.boolean().default(false),
|
|
xPlexClientIdentifier: z.string().optional(),
|
|
})
|
|
.transform((v) => {
|
|
return {
|
|
strong: v.strong,
|
|
...(v.xPlexClientIdentifier === undefined
|
|
? null
|
|
: { "X-Plex-Client-Identifier": v.xPlexClientIdentifier }),
|
|
};
|
|
});
|
|
}
|
|
|
|
/** @internal */
|
|
export namespace Location$ {
|
|
export type Inbound = {
|
|
code?: string | undefined;
|
|
european_union_member?: boolean | undefined;
|
|
continent_code?: string | undefined;
|
|
country?: string | undefined;
|
|
city?: string | undefined;
|
|
time_zone?: string | undefined;
|
|
postal_code?: number | undefined;
|
|
in_privacy_restricted_country?: boolean | undefined;
|
|
subdivisions?: string | undefined;
|
|
coordinates?: string | undefined;
|
|
};
|
|
|
|
export const inboundSchema: z.ZodType<Location, z.ZodTypeDef, Inbound> = z
|
|
.object({
|
|
code: z.string().optional(),
|
|
european_union_member: z.boolean().optional(),
|
|
continent_code: z.string().optional(),
|
|
country: z.string().optional(),
|
|
city: z.string().optional(),
|
|
time_zone: z.string().optional(),
|
|
postal_code: z.number().optional(),
|
|
in_privacy_restricted_country: z.boolean().optional(),
|
|
subdivisions: z.string().optional(),
|
|
coordinates: z.string().optional(),
|
|
})
|
|
.transform((v) => {
|
|
return {
|
|
...(v.code === undefined ? null : { code: v.code }),
|
|
...(v.european_union_member === undefined
|
|
? null
|
|
: { europeanUnionMember: v.european_union_member }),
|
|
...(v.continent_code === undefined ? null : { continentCode: v.continent_code }),
|
|
...(v.country === undefined ? null : { country: v.country }),
|
|
...(v.city === undefined ? null : { city: v.city }),
|
|
...(v.time_zone === undefined ? null : { timeZone: v.time_zone }),
|
|
...(v.postal_code === undefined ? null : { postalCode: v.postal_code }),
|
|
...(v.in_privacy_restricted_country === undefined
|
|
? null
|
|
: { inPrivacyRestrictedCountry: v.in_privacy_restricted_country }),
|
|
...(v.subdivisions === undefined ? null : { subdivisions: v.subdivisions }),
|
|
...(v.coordinates === undefined ? null : { coordinates: v.coordinates }),
|
|
};
|
|
});
|
|
|
|
export type Outbound = {
|
|
code?: string | undefined;
|
|
european_union_member?: boolean | undefined;
|
|
continent_code?: string | undefined;
|
|
country?: string | undefined;
|
|
city?: string | undefined;
|
|
time_zone?: string | undefined;
|
|
postal_code?: number | undefined;
|
|
in_privacy_restricted_country?: boolean | undefined;
|
|
subdivisions?: string | undefined;
|
|
coordinates?: string | undefined;
|
|
};
|
|
|
|
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, Location> = z
|
|
.object({
|
|
code: z.string().optional(),
|
|
europeanUnionMember: z.boolean().optional(),
|
|
continentCode: z.string().optional(),
|
|
country: z.string().optional(),
|
|
city: z.string().optional(),
|
|
timeZone: z.string().optional(),
|
|
postalCode: z.number().optional(),
|
|
inPrivacyRestrictedCountry: z.boolean().optional(),
|
|
subdivisions: z.string().optional(),
|
|
coordinates: z.string().optional(),
|
|
})
|
|
.transform((v) => {
|
|
return {
|
|
...(v.code === undefined ? null : { code: v.code }),
|
|
...(v.europeanUnionMember === undefined
|
|
? null
|
|
: { european_union_member: v.europeanUnionMember }),
|
|
...(v.continentCode === undefined ? null : { continent_code: v.continentCode }),
|
|
...(v.country === undefined ? null : { country: v.country }),
|
|
...(v.city === undefined ? null : { city: v.city }),
|
|
...(v.timeZone === undefined ? null : { time_zone: v.timeZone }),
|
|
...(v.postalCode === undefined ? null : { postal_code: v.postalCode }),
|
|
...(v.inPrivacyRestrictedCountry === undefined
|
|
? null
|
|
: { in_privacy_restricted_country: v.inPrivacyRestrictedCountry }),
|
|
...(v.subdivisions === undefined ? null : { subdivisions: v.subdivisions }),
|
|
...(v.coordinates === undefined ? null : { coordinates: v.coordinates }),
|
|
};
|
|
});
|
|
}
|
|
|
|
/** @internal */
|
|
export namespace GetPinResponseBody$ {
|
|
export type Inbound = {
|
|
id?: number | undefined;
|
|
code?: string | undefined;
|
|
product?: string | undefined;
|
|
trusted?: boolean | undefined;
|
|
qr?: string | undefined;
|
|
clientIdentifier?: string | undefined;
|
|
location?: Location$.Inbound | undefined;
|
|
expiresIn?: number | undefined;
|
|
createdAt?: string | undefined;
|
|
expiresAt?: string | undefined;
|
|
authToken?: string | undefined;
|
|
newRegistration?: string | undefined;
|
|
};
|
|
|
|
export const inboundSchema: z.ZodType<GetPinResponseBody, z.ZodTypeDef, Inbound> = z
|
|
.object({
|
|
id: z.number().optional(),
|
|
code: z.string().optional(),
|
|
product: z.string().optional(),
|
|
trusted: z.boolean().optional(),
|
|
qr: z.string().optional(),
|
|
clientIdentifier: z.string().optional(),
|
|
location: z.lazy(() => Location$.inboundSchema).optional(),
|
|
expiresIn: z.number().optional(),
|
|
createdAt: z
|
|
.string()
|
|
.datetime({ offset: true })
|
|
.transform((v) => new Date(v))
|
|
.optional(),
|
|
expiresAt: z
|
|
.string()
|
|
.datetime({ offset: true })
|
|
.transform((v) => new Date(v))
|
|
.optional(),
|
|
authToken: z.string().optional(),
|
|
newRegistration: z.string().optional(),
|
|
})
|
|
.transform((v) => {
|
|
return {
|
|
...(v.id === undefined ? null : { id: v.id }),
|
|
...(v.code === undefined ? null : { code: v.code }),
|
|
...(v.product === undefined ? null : { product: v.product }),
|
|
...(v.trusted === undefined ? null : { trusted: v.trusted }),
|
|
...(v.qr === undefined ? null : { qr: v.qr }),
|
|
...(v.clientIdentifier === undefined
|
|
? null
|
|
: { clientIdentifier: v.clientIdentifier }),
|
|
...(v.location === undefined ? null : { location: v.location }),
|
|
...(v.expiresIn === undefined ? null : { expiresIn: v.expiresIn }),
|
|
...(v.createdAt === undefined ? null : { createdAt: v.createdAt }),
|
|
...(v.expiresAt === undefined ? null : { expiresAt: v.expiresAt }),
|
|
...(v.authToken === undefined ? null : { authToken: v.authToken }),
|
|
...(v.newRegistration === undefined
|
|
? null
|
|
: { newRegistration: v.newRegistration }),
|
|
};
|
|
});
|
|
|
|
export type Outbound = {
|
|
id?: number | undefined;
|
|
code?: string | undefined;
|
|
product?: string | undefined;
|
|
trusted?: boolean | undefined;
|
|
qr?: string | undefined;
|
|
clientIdentifier?: string | undefined;
|
|
location?: Location$.Outbound | undefined;
|
|
expiresIn?: number | undefined;
|
|
createdAt?: string | undefined;
|
|
expiresAt?: string | undefined;
|
|
authToken?: string | undefined;
|
|
newRegistration?: string | undefined;
|
|
};
|
|
|
|
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetPinResponseBody> = z
|
|
.object({
|
|
id: z.number().optional(),
|
|
code: z.string().optional(),
|
|
product: z.string().optional(),
|
|
trusted: z.boolean().optional(),
|
|
qr: z.string().optional(),
|
|
clientIdentifier: z.string().optional(),
|
|
location: z.lazy(() => Location$.outboundSchema).optional(),
|
|
expiresIn: z.number().optional(),
|
|
createdAt: z
|
|
.date()
|
|
.transform((v) => v.toISOString())
|
|
.optional(),
|
|
expiresAt: z
|
|
.date()
|
|
.transform((v) => v.toISOString())
|
|
.optional(),
|
|
authToken: z.string().optional(),
|
|
newRegistration: z.string().optional(),
|
|
})
|
|
.transform((v) => {
|
|
return {
|
|
...(v.id === undefined ? null : { id: v.id }),
|
|
...(v.code === undefined ? null : { code: v.code }),
|
|
...(v.product === undefined ? null : { product: v.product }),
|
|
...(v.trusted === undefined ? null : { trusted: v.trusted }),
|
|
...(v.qr === undefined ? null : { qr: v.qr }),
|
|
...(v.clientIdentifier === undefined
|
|
? null
|
|
: { clientIdentifier: v.clientIdentifier }),
|
|
...(v.location === undefined ? null : { location: v.location }),
|
|
...(v.expiresIn === undefined ? null : { expiresIn: v.expiresIn }),
|
|
...(v.createdAt === undefined ? null : { createdAt: v.createdAt }),
|
|
...(v.expiresAt === undefined ? null : { expiresAt: v.expiresAt }),
|
|
...(v.authToken === undefined ? null : { authToken: v.authToken }),
|
|
...(v.newRegistration === undefined
|
|
? null
|
|
: { newRegistration: v.newRegistration }),
|
|
};
|
|
});
|
|
}
|
|
|
|
/** @internal */
|
|
export namespace GetPinResponse$ {
|
|
export type Inbound = {
|
|
ContentType: string;
|
|
StatusCode: number;
|
|
RawResponse: Response;
|
|
object?: GetPinResponseBody$.Inbound | undefined;
|
|
};
|
|
|
|
export const inboundSchema: z.ZodType<GetPinResponse, z.ZodTypeDef, Inbound> = z
|
|
.object({
|
|
ContentType: z.string(),
|
|
StatusCode: z.number().int(),
|
|
RawResponse: z.instanceof(Response),
|
|
object: z.lazy(() => GetPinResponseBody$.inboundSchema).optional(),
|
|
})
|
|
.transform((v) => {
|
|
return {
|
|
contentType: v.ContentType,
|
|
statusCode: v.StatusCode,
|
|
rawResponse: v.RawResponse,
|
|
...(v.object === undefined ? null : { object: v.object }),
|
|
};
|
|
});
|
|
|
|
export type Outbound = {
|
|
ContentType: string;
|
|
StatusCode: number;
|
|
RawResponse: never;
|
|
object?: GetPinResponseBody$.Outbound | undefined;
|
|
};
|
|
|
|
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetPinResponse> = z
|
|
.object({
|
|
contentType: z.string(),
|
|
statusCode: z.number().int(),
|
|
rawResponse: z.instanceof(Response).transform(() => {
|
|
throw new Error("Response cannot be serialized");
|
|
}),
|
|
object: z.lazy(() => GetPinResponseBody$.outboundSchema).optional(),
|
|
})
|
|
.transform((v) => {
|
|
return {
|
|
ContentType: v.contentType,
|
|
StatusCode: v.statusCode,
|
|
RawResponse: v.rawResponse,
|
|
...(v.object === undefined ? null : { object: v.object }),
|
|
};
|
|
});
|
|
}
|