mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 20:47:46 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1f6c6f515 | ||
|
|
022d345196 | ||
|
|
6cec42bef1 | ||
|
|
eaa84306f6 |
@@ -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.245.1
|
generationVersion: 2.249.1
|
||||||
releaseVersion: 0.6.1
|
releaseVersion: 0.7.0
|
||||||
configChecksum: 17b196f8440d03f46824f0af095f9927
|
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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
10
RELEASES.md
10
RELEASES.md
@@ -169,3 +169,13 @@ Based on:
|
|||||||
- [typescript v0.6.1] .
|
- [typescript v0.6.1] .
|
||||||
### Releases
|
### Releases
|
||||||
- [NPM v0.6.1] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.6.1 - .
|
- [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 - .
|
||||||
@@ -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/> |
|
||||||
@@ -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/> |
|
||||||
@@ -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 | */* |
|
||||||
|
|||||||
@@ -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 | */* |
|
|
||||||
3
gen.yaml
3
gen.yaml
@@ -7,8 +7,9 @@ generation:
|
|||||||
useClassNamesForArrayFields: true
|
useClassNamesForArrayFields: true
|
||||||
fixes:
|
fixes:
|
||||||
nameResolutionDec2023: false
|
nameResolutionDec2023: false
|
||||||
|
parameterOrderingFeb2024: false
|
||||||
typescript:
|
typescript:
|
||||||
version: 0.6.1
|
version: 0.7.0
|
||||||
author: LukeHagar
|
author: LukeHagar
|
||||||
clientServerStatusCodesAsErrors: true
|
clientServerStatusCodesAsErrors: true
|
||||||
flattenGlobalSecurity: true
|
flattenGlobalSecurity: true
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.6.1",
|
"version": "0.7.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.6.1",
|
"version": "0.7.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"decimal.js": "^10.4.3",
|
"decimal.js": "^10.4.3",
|
||||||
"jsonpath": "^1.1.1"
|
"jsonpath": "^1.1.1"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.6.1",
|
"version": "0.7.0",
|
||||||
"author": "LukeHagar",
|
"author": "LukeHagar",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@@ -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.1",
|
sdkVersion: "0.7.0",
|
||||||
genVersion: "2.245.1",
|
genVersion: "2.249.1",
|
||||||
userAgent: "speakeasy-sdk/typescript 0.6.1 2.245.1 0.0.3 @lukehagar/plexjs",
|
userAgent: "speakeasy-sdk/typescript 0.7.0 2.249.1 0.0.3 @lukehagar/plexjs",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|||||||
189
src/sdk/plex.ts
189
src/sdk/plex.ts
@@ -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$);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
204
src/sdk/tv.ts
204
src/sdk/tv.ts
@@ -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$);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user