Compare commits

...

5 Commits

Author SHA1 Message Date
speakeasybot
a1f6c6f515 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.166.1 2024-02-05 14:25:14 +00:00
speakeasy-bot
022d345196 🐝 Add license. 2024-02-01 16:30:24 +00:00
speakeasy-bot
6cec42bef1 🐝 Update gen.yaml 2024-02-01 16:30:23 +00:00
speakeasy-bot
eaa84306f6 🐝 Update workflow file 2024-02-01 16:30:22 +00:00
speakeasybot
45ee7680a7 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.161.0 2024-02-01 00:28:42 +00:00
20 changed files with 360 additions and 359 deletions

View File

@@ -1,12 +1,12 @@
lockVersion: 2.0.0 lockVersion: 2.0.0
id: 16f22cbf-f23f-4419-8924-3a4b06381947 id: 16f22cbf-f23f-4419-8924-3a4b06381947
management: management:
docChecksum: 94439465ae5d544f0e52b00719af05ee docChecksum: 099fc5bbb987ae7e391f7f07b4212860
docVersion: 0.0.3 docVersion: 0.0.3
speakeasyVersion: internal speakeasyVersion: internal
generationVersion: 2.239.4 generationVersion: 2.249.1
releaseVersion: 0.6.0 releaseVersion: 0.7.0
configChecksum: 42a58e9ba53ecd70c05120ba0c5c2d36 configChecksum: b3d1de88036ff1f77a38604e4ce3ffa1
repoURL: https://github.com/LukeHagar/plexjs.git repoURL: https://github.com/LukeHagar/plexjs.git
repoSubDirectory: . repoSubDirectory: .
installationURL: https://github.com/LukeHagar/plexjs installationURL: https://github.com/LukeHagar/plexjs
@@ -14,13 +14,13 @@ management:
features: features:
typescript: typescript:
constsAndDefaults: 0.1.1 constsAndDefaults: 0.1.1
core: 3.4.7 core: 3.4.8
flattening: 2.81.1 flattening: 2.81.1
globalSecurity: 2.82.2 globalSecurity: 2.82.2
globalServerURLs: 2.82.1 globalServerURLs: 2.82.1
methodServerURLs: 2.82.1 methodServerURLs: 2.82.1
nameOverrides: 2.81.1 nameOverrides: 2.81.1
unions: 2.85.0 unions: 2.85.1
generatedFiles: generatedFiles:
- src/sdk/server.ts - src/sdk/server.ts
- src/sdk/media.ts - src/sdk/media.ts
@@ -30,7 +30,6 @@ generatedFiles:
- src/sdk/search.ts - src/sdk/search.ts
- src/sdk/library.ts - src/sdk/library.ts
- src/sdk/log.ts - src/sdk/log.ts
- src/sdk/tv.ts
- src/sdk/plex.ts - src/sdk/plex.ts
- src/sdk/playlists.ts - src/sdk/playlists.ts
- src/sdk/security.ts - src/sdk/security.ts
@@ -324,7 +323,7 @@ generatedFiles:
- docs/models/operations/getlibraryitemsresponse.md - docs/models/operations/getlibraryitemsresponse.md
- docs/models/operations/refreshlibraryrequest.md - docs/models/operations/refreshlibraryrequest.md
- docs/models/operations/refreshlibraryresponse.md - docs/models/operations/refreshlibraryresponse.md
- docs/models/operations/typet.md - docs/models/operations/type.md
- docs/models/operations/searchlibraryrequest.md - docs/models/operations/searchlibraryrequest.md
- docs/models/operations/searchlibrarymetadata.md - docs/models/operations/searchlibrarymetadata.md
- docs/models/operations/searchlibrarymediacontainer.md - docs/models/operations/searchlibrarymediacontainer.md
@@ -583,7 +582,6 @@ generatedFiles:
- docs/sdks/library/README.md - docs/sdks/library/README.md
- docs/sdks/log/README.md - docs/sdks/log/README.md
- docs/sdks/plex/README.md - docs/sdks/plex/README.md
- docs/sdks/tv/README.md
- docs/sdks/playlists/README.md - docs/sdks/playlists/README.md
- docs/sdks/security/README.md - docs/sdks/security/README.md
- docs/sdks/sessions/README.md - docs/sdks/sessions/README.md

View File

@@ -111,11 +111,10 @@ run();
* [logMultiLine](docs/sdks/log/README.md#logmultiline) - Logging a multi-line message * [logMultiLine](docs/sdks/log/README.md#logmultiline) - Logging a multi-line message
* [enablePaperTrail](docs/sdks/log/README.md#enablepapertrail) - Enabling Papertrail * [enablePaperTrail](docs/sdks/log/README.md#enablepapertrail) - Enabling Papertrail
### [plex](docs/sdks/plex/README.md)
### [plex.tv](docs/sdks/tv/README.md) * [getPin](docs/sdks/plex/README.md#getpin) - Get a Pin
* [getToken](docs/sdks/plex/README.md#gettoken) - Get Access Token
* [getPin](docs/sdks/tv/README.md#getpin) - Get a Pin
* [getToken](docs/sdks/tv/README.md#gettoken) - Get Access Token
### [playlists](docs/sdks/playlists/README.md) ### [playlists](docs/sdks/playlists/README.md)
@@ -272,7 +271,7 @@ async function run() {
const xPlexClientIdentifier = "string"; const xPlexClientIdentifier = "string";
const strong = false; const strong = false;
const result = await sdk.plex.tv.getPin(xPlexClientIdentifier, strong, { const result = await sdk.plex.getPin(xPlexClientIdentifier, strong, {
serverURL: "https://plex.tv/api/v2", serverURL: "https://plex.tv/api/v2",
}); });

View File

@@ -158,4 +158,24 @@ Based on:
### Generated ### Generated
- [typescript v0.6.0] . - [typescript v0.6.0] .
### Releases ### Releases
- [NPM v0.6.0] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.6.0 - . - [NPM v0.6.0] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.6.0 - .
## 2024-02-01 00:27:20
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.161.0 (2.245.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.6.1] .
### Releases
- [NPM v0.6.1] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.6.1 - .
## 2024-02-05 14:23:50
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.166.1 (2.249.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.7.0] .
### Releases
- [NPM v0.7.0] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.7.0 - .

View File

@@ -3,7 +3,7 @@
## Fields ## Fields
| Field | Type | Required | Description | | Field | Type | Required | Description |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | Plex Authentication Token | | `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> | | `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |

View File

@@ -3,7 +3,7 @@
## Fields ## Fields
| Field | Type | Required | Description | | Field | Type | Required | Description |
| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | | `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | Plex Authentication Token | | `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |

View File

@@ -3,7 +3,7 @@
## Fields ## Fields
| Field | Type | Required | Description | | Field | Type | Required | Description |
| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- |
| `sectionId` | *number* | :heavy_check_mark: | the Id of the library to query | | `sectionId` | *number* | :heavy_check_mark: | the Id of the library to query |
| `type` | [operations.TypeT](../../models/operations/typet.md) | :heavy_check_mark: | Plex content type to search for | | `type` | [operations.Type](../../models/operations/type.md) | :heavy_check_mark: | Plex content type to search for |

View File

@@ -1,4 +1,4 @@
# TypeT # Type
Plex content type to search for Plex content type to search for

View File

@@ -422,7 +422,7 @@ Each type in the library comes with a set of filters and sorts, aiding in buildi
```typescript ```typescript
import { PlexAPI } from "@lukehagar/plexjs"; import { PlexAPI } from "@lukehagar/plexjs";
import { TypeT } from "@lukehagar/plexjs/models/operations"; import { Type } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
@@ -430,7 +430,7 @@ async function run() {
}); });
const sectionId = 933505; const sectionId = 933505;
const type = TypeT.Four; const type = Type.Four;
const result = await sdk.library.searchLibrary(sectionId, type); const result = await sdk.library.searchLibrary(sectionId, type);
@@ -446,7 +446,7 @@ run();
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `sectionId` | *number* | :heavy_check_mark: | the Id of the library to query | | `sectionId` | *number* | :heavy_check_mark: | the Id of the library to query |
| `type` | [operations.TypeT](../../models/operations/typet.md) | :heavy_check_mark: | Plex content type to search for | | `type` | [operations.Type](../../models/operations/type.md) | :heavy_check_mark: | Plex content type to search for |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |

View File

@@ -1,5 +1,106 @@
# Plex # Plex
(*plex*) (*plex*)
## Overview
API Calls that perform operations directly against https://Plex.tv
### Available Operations ### Available Operations
* [getPin](#getpin) - Get a Pin
* [getToken](#gettoken) - Get Access Token
## getPin
Retrieve a Pin from Plex.tv for authentication flows
### Example Usage
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
const xPlexClientIdentifier = "string";
const strong = false;
const result = await sdk.plex.getPin(xPlexClientIdentifier, strong);
// Handle the result
console.log(result)
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
### Response
**Promise<[operations.GetPinResponse](../../models/operations/getpinresponse.md)>**
### Errors
| Error Object | Status Code | Content Type |
| ------------------------- | ------------------------- | ------------------------- |
| errors.GetPinResponseBody | 400 | application/json |
| errors.SDKError | 4xx-5xx | */* |
## getToken
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
### Example Usage
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
const pinID = "string";
const xPlexClientIdentifier = "string";
const result = await sdk.plex.getToken(pinID, xPlexClientIdentifier);
// Handle the result
console.log(result)
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
### Response
**Promise<[operations.GetTokenResponse](../../models/operations/gettokenresponse.md)>**
### Errors
| Error Object | Status Code | Content Type |
| --------------------------- | --------------------------- | --------------------------- |
| errors.GetTokenResponseBody | 400 | application/json |
| errors.SDKError | 4xx-5xx | */* |

View File

@@ -1,101 +0,0 @@
# Tv
(*plex.tv*)
### Available Operations
* [getPin](#getpin) - Get a Pin
* [getToken](#gettoken) - Get Access Token
## getPin
Retrieve a Pin from Plex.tv for authentication flows
### Example Usage
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
const xPlexClientIdentifier = "string";
const strong = false;
const result = await sdk.plex.tv.getPin(xPlexClientIdentifier, strong);
// Handle the result
console.log(result)
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | Plex Authentication Token |
| `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
### Response
**Promise<[operations.GetPinResponse](../../models/operations/getpinresponse.md)>**
### Errors
| Error Object | Status Code | Content Type |
| ------------------------- | ------------------------- | ------------------------- |
| errors.GetPinResponseBody | 400 | application/json |
| errors.SDKError | 4xx-5xx | */* |
## getToken
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
### Example Usage
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
const pinID = "string";
const xPlexClientIdentifier = "string";
const result = await sdk.plex.tv.getToken(pinID, xPlexClientIdentifier);
// Handle the result
console.log(result)
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | Plex Authentication Token |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
### Response
**Promise<[operations.GetTokenResponse](../../models/operations/gettokenresponse.md)>**
### Errors
| Error Object | Status Code | Content Type |
| --------------------------- | --------------------------- | --------------------------- |
| errors.GetTokenResponseBody | 400 | application/json |
| errors.SDKError | 4xx-5xx | */* |

View File

@@ -7,8 +7,9 @@ generation:
useClassNamesForArrayFields: true useClassNamesForArrayFields: true
fixes: fixes:
nameResolutionDec2023: false nameResolutionDec2023: false
parameterOrderingFeb2024: false
typescript: typescript:
version: 0.6.0 version: 0.7.0
author: LukeHagar author: LukeHagar
clientServerStatusCodesAsErrors: true clientServerStatusCodesAsErrors: true
flattenGlobalSecurity: true flattenGlobalSecurity: true

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@lukehagar/plexjs", "name": "@lukehagar/plexjs",
"version": "0.6.0", "version": "0.7.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lukehagar/plexjs", "name": "@lukehagar/plexjs",
"version": "0.6.0", "version": "0.7.0",
"dependencies": { "dependencies": {
"decimal.js": "^10.4.3", "decimal.js": "^10.4.3",
"jsonpath": "^1.1.1" "jsonpath": "^1.1.1"

View File

@@ -1,7 +1,7 @@
{ {
"type": "commonjs", "type": "commonjs",
"name": "@lukehagar/plexjs", "name": "@lukehagar/plexjs",
"version": "0.6.0", "version": "0.7.0",
"author": "LukeHagar", "author": "LukeHagar",
"main": "./index.js", "main": "./index.js",
"sideEffects": false, "sideEffects": false,

View File

@@ -79,7 +79,7 @@ export function serverURLFromOptions(options: SDKOptions): URL {
export const SDK_METADATA = Object.freeze({ export const SDK_METADATA = Object.freeze({
language: "typescript", language: "typescript",
openapiDocVersion: "0.0.3", openapiDocVersion: "0.0.3",
sdkVersion: "0.6.0", sdkVersion: "0.7.0",
genVersion: "2.239.4", genVersion: "2.249.1",
userAgent: "speakeasy-sdk/typescript 0.6.0 2.239.4 0.0.3 @lukehagar/plexjs", userAgent: "speakeasy-sdk/typescript 0.7.0 2.249.1 0.0.3 @lukehagar/plexjs",
}); });

View File

@@ -8,7 +8,12 @@ export const GetPinServerList = ["https://plex.tv/api/v2"] as const;
export type GetPinRequest = { export type GetPinRequest = {
/** /**
* Plex Authentication Token * 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; xPlexClientIdentifier: string;
/** /**

View File

@@ -12,7 +12,12 @@ export type GetTokenRequest = {
*/ */
pinID: string; pinID: string;
/** /**
* Plex Authentication Token * 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; xPlexClientIdentifier: string;
}; };

View File

@@ -7,7 +7,7 @@ import { z } from "zod";
/** /**
* Plex content type to search for * Plex content type to search for
*/ */
export enum TypeT { export enum Type {
One = 1, One = 1,
Two = 2, Two = 2,
Three = 3, Three = 3,
@@ -22,7 +22,7 @@ export type SearchLibraryRequest = {
/** /**
* Plex content type to search for * Plex content type to search for
*/ */
type: TypeT; type: Type;
}; };
export type SearchLibraryMetadata = { export type SearchLibraryMetadata = {
@@ -91,19 +91,19 @@ export type SearchLibraryResponse = {
}; };
/** @internal */ /** @internal */
export const TypeT$ = z.nativeEnum(TypeT); export const Type$ = z.nativeEnum(Type);
/** @internal */ /** @internal */
export namespace SearchLibraryRequest$ { export namespace SearchLibraryRequest$ {
export type Inbound = { export type Inbound = {
sectionId: number; sectionId: number;
type: TypeT; type: Type;
}; };
export const inboundSchema: z.ZodType<SearchLibraryRequest, z.ZodTypeDef, Inbound> = z export const inboundSchema: z.ZodType<SearchLibraryRequest, z.ZodTypeDef, Inbound> = z
.object({ .object({
sectionId: z.number().int(), sectionId: z.number().int(),
type: TypeT$, type: Type$,
}) })
.transform((v) => { .transform((v) => {
return { return {
@@ -114,13 +114,13 @@ export namespace SearchLibraryRequest$ {
export type Outbound = { export type Outbound = {
sectionId: number; sectionId: number;
type: TypeT; type: Type;
}; };
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, SearchLibraryRequest> = z export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, SearchLibraryRequest> = z
.object({ .object({
sectionId: z.number().int(), sectionId: z.number().int(),
type: TypeT$, type: Type$,
}) })
.transform((v) => { .transform((v) => {
return { return {

View File

@@ -609,7 +609,7 @@ export class Library extends ClientSDK {
*/ */
async searchLibrary( async searchLibrary(
sectionId: number, sectionId: number,
type: operations.TypeT, type: operations.Type,
options?: RequestOptions options?: RequestOptions
): Promise<operations.SearchLibraryResponse> { ): Promise<operations.SearchLibraryResponse> {
const input$: operations.SearchLibraryRequest = { const input$: operations.SearchLibraryRequest = {

View File

@@ -2,10 +2,12 @@
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
*/ */
import { SDKOptions, serverURLFromOptions } from "../lib/config"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config";
import * as enc$ from "../lib/encodings";
import { HTTPClient } from "../lib/http"; import { HTTPClient } from "../lib/http";
import { ClientSDK } from "../lib/sdks"; import { ClientSDK, RequestOptions } from "../lib/sdks";
import { Tv } from "./tv"; import * as errors from "../models/errors";
import * as operations from "../models/operations";
export class Plex extends ClientSDK { export class Plex extends ClientSDK {
private readonly options$: SDKOptions; private readonly options$: SDKOptions;
@@ -19,9 +21,184 @@ export class Plex extends ClientSDK {
this.options$ = options; this.options$ = options;
void this.options$; void this.options$;
} }
/**
* Get a Pin
*
* @remarks
* Retrieve a Pin from Plex.tv for authentication flows
*/
async getPin(
xPlexClientIdentifier: string,
strong?: boolean | undefined,
options?: RequestOptions & { serverURL?: string }
): Promise<operations.GetPinResponse> {
const input$: operations.GetPinRequest = {
xPlexClientIdentifier: xPlexClientIdentifier,
strong: strong,
};
const headers$ = new Headers();
headers$.set("user-agent", SDK_METADATA.userAgent);
headers$.set("Accept", "application/json");
private _tv?: Tv; const payload$ = operations.GetPinRequest$.outboundSchema.parse(input$);
get tv() { const body$ = null;
return (this._tv ??= new Tv(this.options$));
const path$ = this.templateURLComponent("/pins")();
const query$ = [
enc$.encodeForm("strong", payload$.strong, { explode: true, charEncoding: "percent" }),
]
.filter(Boolean)
.join("&");
headers$.set(
"X-Plex-Client-Identifier",
enc$.encodeSimple("X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"], {
explode: false,
charEncoding: "none",
})
);
const baseURL$ =
options?.serverURL ||
this.templateURLComponent(operations.GetPinServerList[0], {
charEncoding: "percent",
})();
let security$;
if (typeof this.options$.accessToken === "function") {
security$ = { accessToken: await this.options$.accessToken() };
} else if (this.options$.accessToken) {
security$ = { accessToken: this.options$.accessToken };
} else {
security$ = {};
}
const securitySettings$ = this.resolveGlobalSecurity(security$);
const response = await this.fetch$(
{
security: securitySettings$,
method: "POST",
baseURL: baseURL$,
path: path$,
headers: headers$,
query: query$,
body: body$,
},
options
);
const responseFields$ = {
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
StatusCode: response.status,
RawResponse: response,
};
if (this.matchResponse(response, 200, "application/json")) {
const responseBody = await response.json();
const result = operations.GetPinResponse$.inboundSchema.parse({
...responseFields$,
object: responseBody,
});
return result;
} else if (this.matchResponse(response, 400, "application/json")) {
const responseBody = await response.json();
const result = errors.GetPinResponseBody$.inboundSchema.parse({
...responseFields$,
...responseBody,
});
throw result;
} else {
const responseBody = await response.text();
throw new errors.SDKError("Unexpected API response", response, responseBody);
}
}
/**
* Get Access Token
*
* @remarks
* Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
*/
async getToken(
pinID: string,
xPlexClientIdentifier: string,
options?: RequestOptions & { serverURL?: string }
): Promise<operations.GetTokenResponse> {
const input$: operations.GetTokenRequest = {
pinID: pinID,
xPlexClientIdentifier: xPlexClientIdentifier,
};
const headers$ = new Headers();
headers$.set("user-agent", SDK_METADATA.userAgent);
headers$.set("Accept", "application/json");
const payload$ = operations.GetTokenRequest$.outboundSchema.parse(input$);
const body$ = null;
const pathParams$ = {
pinID: enc$.encodeSimple("pinID", payload$.pinID, {
explode: false,
charEncoding: "percent",
}),
};
const path$ = this.templateURLComponent("/pins/{pinID}")(pathParams$);
headers$.set(
"X-Plex-Client-Identifier",
enc$.encodeSimple("X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"], {
explode: false,
charEncoding: "none",
})
);
const baseURL$ =
options?.serverURL ||
this.templateURLComponent(operations.GetTokenServerList[0], {
charEncoding: "percent",
})();
let security$;
if (typeof this.options$.accessToken === "function") {
security$ = { accessToken: await this.options$.accessToken() };
} else if (this.options$.accessToken) {
security$ = { accessToken: this.options$.accessToken };
} else {
security$ = {};
}
const securitySettings$ = this.resolveGlobalSecurity(security$);
const response = await this.fetch$(
{
security: securitySettings$,
method: "GET",
baseURL: baseURL$,
path: path$,
headers: headers$,
body: body$,
},
options
);
const responseFields$ = {
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
StatusCode: response.status,
RawResponse: response,
};
if (this.matchStatusCode(response, 200)) {
// fallthrough
} else if (this.matchResponse(response, 400, "application/json")) {
const responseBody = await response.json();
const result = errors.GetTokenResponseBody$.inboundSchema.parse({
...responseFields$,
...responseBody,
});
throw result;
} else {
const responseBody = await response.text();
throw new errors.SDKError("Unexpected API response", response, responseBody);
}
return operations.GetTokenResponse$.inboundSchema.parse(responseFields$);
} }
} }

View File

@@ -1,204 +0,0 @@
/*
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
*/
import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config";
import * as enc$ from "../lib/encodings";
import { HTTPClient } from "../lib/http";
import { ClientSDK, RequestOptions } from "../lib/sdks";
import * as errors from "../models/errors";
import * as operations from "../models/operations";
export class Tv extends ClientSDK {
private readonly options$: SDKOptions;
constructor(options: SDKOptions = {}) {
super({
client: options.httpClient || new HTTPClient(),
baseURL: serverURLFromOptions(options),
});
this.options$ = options;
void this.options$;
}
/**
* Get a Pin
*
* @remarks
* Retrieve a Pin from Plex.tv for authentication flows
*/
async getPin(
xPlexClientIdentifier: string,
strong?: boolean | undefined,
options?: RequestOptions & { serverURL?: string }
): Promise<operations.GetPinResponse> {
const input$: operations.GetPinRequest = {
xPlexClientIdentifier: xPlexClientIdentifier,
strong: strong,
};
const headers$ = new Headers();
headers$.set("user-agent", SDK_METADATA.userAgent);
headers$.set("Accept", "application/json");
const payload$ = operations.GetPinRequest$.outboundSchema.parse(input$);
const body$ = null;
const path$ = this.templateURLComponent("/pins")();
const query$ = [
enc$.encodeForm("strong", payload$.strong, { explode: true, charEncoding: "percent" }),
]
.filter(Boolean)
.join("&");
headers$.set(
"X-Plex-Client-Identifier",
enc$.encodeSimple("X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"], {
explode: false,
charEncoding: "none",
})
);
const baseURL$ =
options?.serverURL ||
this.templateURLComponent(operations.GetPinServerList[0], {
charEncoding: "percent",
})();
let security$;
if (typeof this.options$.accessToken === "function") {
security$ = { accessToken: await this.options$.accessToken() };
} else if (this.options$.accessToken) {
security$ = { accessToken: this.options$.accessToken };
} else {
security$ = {};
}
const securitySettings$ = this.resolveGlobalSecurity(security$);
const response = await this.fetch$(
{
security: securitySettings$,
method: "POST",
baseURL: baseURL$,
path: path$,
headers: headers$,
query: query$,
body: body$,
},
options
);
const responseFields$ = {
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
StatusCode: response.status,
RawResponse: response,
};
if (this.matchResponse(response, 200, "application/json")) {
const responseBody = await response.json();
const result = operations.GetPinResponse$.inboundSchema.parse({
...responseFields$,
object: responseBody,
});
return result;
} else if (this.matchResponse(response, 400, "application/json")) {
const responseBody = await response.json();
const result = errors.GetPinResponseBody$.inboundSchema.parse({
...responseFields$,
...responseBody,
});
throw result;
} else {
const responseBody = await response.text();
throw new errors.SDKError("Unexpected API response", response, responseBody);
}
}
/**
* Get Access Token
*
* @remarks
* Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
*/
async getToken(
pinID: string,
xPlexClientIdentifier: string,
options?: RequestOptions & { serverURL?: string }
): Promise<operations.GetTokenResponse> {
const input$: operations.GetTokenRequest = {
pinID: pinID,
xPlexClientIdentifier: xPlexClientIdentifier,
};
const headers$ = new Headers();
headers$.set("user-agent", SDK_METADATA.userAgent);
headers$.set("Accept", "application/json");
const payload$ = operations.GetTokenRequest$.outboundSchema.parse(input$);
const body$ = null;
const pathParams$ = {
pinID: enc$.encodeSimple("pinID", payload$.pinID, {
explode: false,
charEncoding: "percent",
}),
};
const path$ = this.templateURLComponent("/pins/{pinID}")(pathParams$);
headers$.set(
"X-Plex-Client-Identifier",
enc$.encodeSimple("X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"], {
explode: false,
charEncoding: "none",
})
);
const baseURL$ =
options?.serverURL ||
this.templateURLComponent(operations.GetTokenServerList[0], {
charEncoding: "percent",
})();
let security$;
if (typeof this.options$.accessToken === "function") {
security$ = { accessToken: await this.options$.accessToken() };
} else if (this.options$.accessToken) {
security$ = { accessToken: this.options$.accessToken };
} else {
security$ = {};
}
const securitySettings$ = this.resolveGlobalSecurity(security$);
const response = await this.fetch$(
{
security: securitySettings$,
method: "GET",
baseURL: baseURL$,
path: path$,
headers: headers$,
body: body$,
},
options
);
const responseFields$ = {
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
StatusCode: response.status,
RawResponse: response,
};
if (this.matchStatusCode(response, 200)) {
// fallthrough
} else if (this.matchResponse(response, 400, "application/json")) {
const responseBody = await response.json();
const result = errors.GetTokenResponseBody$.inboundSchema.parse({
...responseFields$,
...responseBody,
});
throw result;
} else {
const responseBody = await response.text();
throw new errors.SDKError("Unexpected API response", response, responseBody);
}
return operations.GetTokenResponse$.inboundSchema.parse(responseFields$);
}
}