Files
plexjs/docs/sdks/rate/README.md

112 lines
6.4 KiB
Markdown

# Rate
(*rate*)
## Overview
Operations for rating media items (thumbs up/down, star ratings, etc.)
### Available Operations
* [setRating](#setrating) - Rate an item
## setRating
Set the rating on an item.
This API does respond to the GET verb but applications should use PUT
### Example Usage
<!-- UsageSnippet language="typescript" operationID="setRating" method="put" path="/:/rate" -->
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";
const plexAPI = new PlexAPI({
accepts: Accepts.ApplicationXml,
clientIdentifier: "abc123",
product: "Plex for Roku",
version: "2.4.1",
platform: "Roku",
platformVersion: "4.3 build 1057",
device: "Roku 3",
model: "4200X",
deviceVendor: "Roku",
deviceName: "Living Room TV",
marketplace: "googlePlay",
token: "<YOUR_API_KEY_HERE>",
});
async function run() {
await plexAPI.rate.setRating({
identifier: "<value>",
key: "<key>",
rating: 8722.46,
});
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { rateSetRating } from "@lukehagar/plexjs/funcs/rateSetRating.js";
import { Accepts } from "@lukehagar/plexjs/models/shared";
// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
accepts: Accepts.ApplicationXml,
clientIdentifier: "abc123",
product: "Plex for Roku",
version: "2.4.1",
platform: "Roku",
platformVersion: "4.3 build 1057",
device: "Roku 3",
model: "4200X",
deviceVendor: "Roku",
deviceName: "Living Room TV",
marketplace: "googlePlay",
token: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await rateSetRating(plexAPI, {
identifier: "<value>",
key: "<key>",
rating: 8722.46,
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("rateSetRating failed:", res.error);
}
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.SetRatingRequest](../../models/operations/setratingrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `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.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<void\>**
### Errors
| Error Type | Status Code | Content Type |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4XX, 5XX | \*/\* |