1.0.0 • Published 2 years ago

@egorguzenko/lord-sdk-guzenko v1.0.0

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
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

MethodsArgsDescription
getAllBooksreturns an array of books
getBookByIdidreturns the specific book
getBookByIdWithChapteridreturns an array of chapters of the specific book
getAllMoviesreturns an array of movies
getMovieByIdidreturns the specific movie
getMovieByIdWithQuoteidreturns an array of quotes of the specific movie
getAllCharactersreturns an array of characters
getCharacterByIdidreturns the specific character
getCharacterByIdWithQuoteidreturns an array of quotes of the specific character
getAllQuotesreturns an array of quotes
getQuoteByIdidreturns the specific quote
getAllChaptersreturns an array of chapters
getChapterByIdidreturns the specific chapter

Description of the parination methods

MethodsArgsDescription
booksPaginationconfigreturn limit, page or offset for all books
moviesPaginationconfigreturn limit, page or offset for all movies
charactersPaginationconfigreturn limit, page or offset for all characters
quotesPaginationconfigreturn limit, page or offset for all quotes
chaptersPaginationconfigreturn 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

MethodsArgsDescription
sortBookssortingFields, conditionreturn sorted data for all books
sortMoviessortingFields, conditionreturn sorted data for all movies
sortCharacterssortingFields, conditionreturn sorted data for all characters
sortQuotessortingFields, conditionreturn sorted datafor all quotes
sortChapterssortingFields, conditionreturn sorted data for all chapters

Description of the filtration methods

MethodsArgsDescription
booksFilterconfigreturns filtered data for all books
sortMoviesconfigreturns filtered data for all movies
charactersFilterconfigreturns filtered data data for all characters
quotesFilterconfigreturns filtered data all quotes
chapterFilterconfigreturns 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
}
1.0.0

2 years ago