# Install

```bash
npm i sdk-lord-of-the-rings
```

# Usage

```js
import Lord from 'sdk-lord-of-the-rings';

const sdk = new Lord({ token: 'Bearer your-api-key-123' });

const response = await sdk.book.get();
console.log(response);
```

## Entities

### Book

> List of all "The Lord of the Rings" books

- await sdk.book.get();

> Request one specific book

- await sdk.book.getOne(id);

> Request all chapters of one specific book

- await sdk.book.chapters(bookId);

### Movie

> List of all movies, including the "The Lord of the Rings" and the "The Hobbit" trilogies

- await sdk.movie.get();

> Request one specific movie

- await sdk.movie.getOne(id);

> Request all movie quotes for one specific movie (only working for the LotR trilogy)

- await sdk.movie.quote(movieId);

### Character

> List of characters including metadata like name, gender, realm, race and more

- await sdk.character.get();

> Request one specific character

- await sdk.character.getOne(id);

> Request all movie quotes of one specific character

- await sdk.character.quote(characterId);

### Quote

> List of characters including metadata like name, gender, realm, race and more

- await sdk.quote.get();

> Request one specific character

- await sdk.quote.getOne(id);

### Chapter

> List of all book chapters

- await sdk.chapter.get();

> Request one specific book chapter

- await sdk.chapter.getOne(id);

## May I use pagination, sorting and filtering?

You can use this for all entities:

### Sort

```js
book.get({
    sort: {name: 'asc'}
});
```

### Pagination (offset)

```js
book.get({
    pagination: {limit: 20, offset: 10}
});
```

### Pagination (page)

```js
book.get({
    pagination: {limit: 20, page: 2}
});
```

### Filtration

```js
book.get({
    filter: {
            match: [{name: 'Gandalf'}],
            notMatch: [{name: 'Gandalf'}],

            include: [{name: ['Gandalf', 'Frodo']}],
            exclude: [{name: ['Gandalf', 'Frodo']}],

            exist: ['name'],
            notExist: ['name'],

            regex: [{name: 'Gandalf'}],
            notRegex: [{name: 'Gandalf'}],

            numberComparison: {
                gt: [{academyAwardWins: 100}],
                gte: [{academyAwardWins: 100}],
                lt: [{academyAwardWins: 100}],
                lte: [{academyAwardWins: 100}],
            }
    }
});
```

# API

Api available here: <https://the-one-api.dev/documentation>
