nikhil-joshi-lotr-sdk-2
v1.0.1
Published
SDK to access the Lord of the rings APIs
Downloads
8
Readme
Lord of the Rings SDK
NPM Package link
Installation:
Using npm:
npm i nikhil-joshi-lotr-sdk-2
Usage:
In Node.js:
// 'require' Syntax
// Get the default api function export to initialize the lib
const api = require('nikhil-joshi-lotr-sdk-2')
// Initialize the lib with the auth token
api('authorization-token')
const {movies, quotes} = require('nikhil-joshi-lotr-sdk-2')
// Example api call
movies.getAll().then(res => {
console.log(res.data)
})
quotes.getAll().then(res => {
console.log(res.data)
})
// 'import' syntax
import api, {movies, quotes} from 'nikhil-joshi-lotr-sdk-2'
// Initialize the lib with the auth token
api('authorization-token')
movies.getAll().then(res => {
console.log(res.data)
})
quotes.getAll().then(res => {
console.log(res.data)
})
Optional Params:
- Some of the methods take an optional params
object argument. The details of the supported keys are as follows:
limit
- Total items to return. Defaults to10
page
- The page number of the datasetoffset
- The data offsetsortKey
- The field in the data set to sort on.sortDirection
-asc
ordesc
. Defaults toasc
match
: Object with options to match or unmatch on a specific keykey
- The field in the datasetvalue
- The value to matchnegate
- Iftrue
, returns allnot
matching values
include
key
- The field in the datasetvalue
- The values to include (comma-separated)
exclude
key
- The field in the datasetvalue
- The values to exclude (comma-separated)
existsKey
- The field name in the data set. If specified, only the items that contains the specified key will be returned.doesnotExistKey
- The field name in the data set. If specified, only the items that does not contain the specified key will be returned.regex
key
- The field in the datasetvalue
- The regex for the fieldnegate
- Iftrue
, returns allnot
matching the regex
compare
key
- The field in the dataset for comparisonvalue
- The value for the comparisonoperator
- The comparison operator. See all possible values below.gt
- corresponds to '>',lt
- corresponds to '<',eq
- corresponds to '=',geq
- corresponds to '>=',leq
- corresponds to '<=',
Tests:
Running the unit tests:
npm run test