reshuffle-moviesanywhere-connector
Version:
Reshuffle connectors for Movies Anywhere
167 lines (115 loc) • 4.12 kB
Markdown
[](https://github.com/reshufflehq/reshuffle-moviesanywhere-connector) |
[](https://www.npmjs.com/package/reshuffle-moviesanywhere-connector) |
[](https://github.com/reshufflehq/reshuffle-moviesanywhere-connector/tree/master/examples)
`npm install reshuffle-moviesanywhere-connector`
This package contains a [Reshuffle](https://github.com/reshufflehq/reshuffle)
connector to Movies Anywhere, providing access to movie data per the
[](https://api.moviesanywhere.com/v1/title/docs/index.html).
The following actions return title information in the `TitleData` structure,
as defined by the Movies Anywhere API. If the connector is configured with an
API token, the returned data will include trailer information.
The following example creates an API endpoint for retrieving movie data using
its [EIDR](https://eidr.org) ID. You can try
**10.5240/DF48-AB62-4486-C185-9E1B-4** or find EIDR IDs using the
[](https://github.com/reshufflehq/reshuffle-eidr-connector):
```js
const { Reshuffle, HttpConnector } = require('reshuffle')
const { MoviesAnywhereConnector } = require('reshuffle-moviesanywhere-connector')
const app = new Reshuffle()
const ma = new MoviesAnywhereConnector(app)
const http = new HttpConnector(app)
http.on({ method: 'GET', path: '/' }, async (event) => {
const eidr = event.req.query.eidr
if (!/^10\.5240\/([0-9A-F]{4}-){5}[0-9A-Z]$/.test(eidr)) {
return event.res.status(400).send(`Invalid EIDR ID: ${eidr}`)
}
const data = await ma.getTitleByEIDR(eidr)
return event.res.json(data)
})
app.start(8000)
```
[](
_Connector actions_:
[](
[](
[](
[](
[](
```js
const app = new Reshuffle()
const moviesAnywhereConnector = new MoviesAnywhereConnector(app)
```
_Definition:_
```
() => {
count: number,
results: TitleData[],
}
```
_Usage:_
```js
const { count, results } = await moviesAnywhereConnector.getAllTitles()
```
Retrieve all title information stored by Movies Anywhere.
_Definition:_
```
(
id: string
) => TitleData
```
_Usage:_
```js
const id = '7c1d0438-a71d-40a7-8567-6a4f714355cd'
const titleData = await moviesAnywhereConnector.getTitleById(id)
```
Get the title information associated with a given Movies Anywhere ID.
_Definition:_
```
(
eidr: string
) => TitleData
```
_Usage:_
```js
const eidr = '10.5240/CEFE-FECA-CBD0-F72A-E650-H'
const titleData = await moviesAnywhereConnector.getTitleByEIDR(eidr)
```
Get the title information associated with a given EIDR ID, as specified by
the [EIDR API](http://eidr.org/documents/EIDR_2.1_REST_API.pdf).
_Definition:_
```
(
studio: 'Disney' | 'Fox' | 'Lionsgate' | 'Sony' | 'Universal' | 'WB'
) => {
count: number,
results: TitleData[],
}
```
_Usage:_
```js
const studio = 'Universal'
const { count, results } =
await moviesAnywhereConnector.getTitlesByStudio(studio)
```
Retrieve all title information for movies released by the specified studio.
_Definition:_
```ts
(userId: string) => tranasactions: Object[]
```
_Usage:_
```js
const transactions =
await moviesAnywhereConnector.getTransactionsByUser('myid')
```
Retrieve the transaction (purchase) history for the specified user. The
specified `userId` must be pre-registered with Movies Anywhere.