1.0.0 • Published 2 years ago
The Lord of the Rings SDK
Instance example
import { createApiClient } from './api/index.js';
const BASE_URL = 'https://the-one-api.dev/v2';
const accessToken = 'V3KHIsNAcokFARi6HxC4';
const lordofTheRingsSDK = new LordofTheRingsSDK(BASE_URL, accessToken)
Example
lordofTheRingsSDK.getAllBooks();
lordofTheRingsSDK.charactersPagination({
limit: { number: 4 },
});
lordofTheRingsSDK.sortMovies('academyAwardWins', 'asc');
lordofTheRingsSDK.moviesFilter({
typeOfFiltration: 'lessThan',
filterName: 'academyAwardWins',
values: 10
});
Description of the methods
Methods | Args | Description |
---|
getAllBooks | | returns an array of books |
getBookById | id | returns the specific book |
getBookByIdWithChapter | id | returns an array of chapters of the specific book |
getAllMovies | | returns an array of movies |
getMovieById | id | returns the specific movie |
getMovieByIdWithQuote | id | returns an array of quotes of the specific movie |
getAllCharacters | | returns an array of characters |
getCharacterById | id | returns the specific character |
getCharacterByIdWithQuote | id | returns an array of quotes of the specific character |
getAllQuotes | | returns an array of quotes |
getQuoteById | id | returns the specific quote |
getAllChapters | | returns an array of chapters |
getChapterById | id | returns the specific chapter |
Description of the parination methods
Methods | Args | Description |
---|
booksPagination | config | return limit, page or offset for all books |
moviesPagination | config | return limit, page or offset for all movies |
charactersPagination | config | return limit, page or offset for all characters |
quotesPagination | config | return limit, page or offset for all quotes |
chaptersPagination | config | return limit, page or offset for all chapters |
Config example for parination methods
{
limit: { number: 4 },
page: { number: 2},
offset: { number: 1}
}
Description of the sorting methods
Methods | Args | Description |
---|
sortBooks | sortingFields, condition | return sorted data for all books |
sortMovies | sortingFields, condition | return sorted data for all movies |
sortCharacters | sortingFields, condition | return sorted data for all characters |
sortQuotes | sortingFields, condition | return sorted datafor all quotes |
sortChapters | sortingFields, condition | return sorted data for all chapters |
Description of the filtration methods
Methods | Args | Description |
---|
booksFilter | config | returns filtered data for all books |
sortMovies | config | returns filtered data for all movies |
charactersFilter | config | returns filtered data data for all characters |
quotesFilter | config | returns filtered data all quotes |
chapterFilter | config | returns filtered data for all chapters |
Config example for filtration methods
const TYPES_OF_FILTRATION = {
match: '=',
negateMatch: '!=',
include: '=',
exclude: '!=',
exists: '',
notExist: '!',
lessThan: '<',
greaterThan: '>',
equalTo: '>=',
existWithRegexp: '=',
notExistWithRegexp: '!='
};
{
typeOfFiltration: 'lessThan',
filterName: 'academyAwardWins',
values: 10
}