1.1.2 • Published 2 years ago

@cbauch/christopher_bauch_sdk v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Christopher_Bauch_SDK

An Node SDK for The One API, a Lord of the Rings API

Overview

Christopher_Bauch_SDK provides a single class "TheOneAPI". As the name implies, this class contains functions to call The One API. It also contains helper functions and objects to assist in creating filters, pagination strings, and sorting strings.

Helpers

  1. FilterOperation - An object with all the operations that filters can provide, all require an attribute, but only some require a comparison value.
  2. SortDirection - An object defining ascending and descending attributes to use when creating sorting strings.
  3. createFilter - A helper function that creates filter strings that can be passed to api calls in arrays. Takes an attribute to filter, a FilterOperation, and in some cases a filter/comparison value
  4. createPaginationStringWithOffset - A helper function that creates a pagination string that can be passed to api calls. This one uses limit and offset.
  5. createPaginationStringWithPage - A helper function that creates a pagination string that can be passed to api calls. This one uses limit and page number.
  6. createSorting - A helper function to create sorting strings. Takes an attribute to sort by and SortDirection.

Operations

  1. searchBooks - Searches through Lord of the Rings books.
  2. searchChapters - Searches through chapters in the Lord of the Rings books.
  3. searchMovies - Searches through Lord of the Rings movies.
  4. searchQuotes - Searches through Lord of the Rings quotes from the movies.
  5. searchCharacters - Searches through Lord of the Rings characters.

Installation

  1. Install using npm:
npm install @cbauch/christopher_bauch_sdk
  1. Import TheOneAPI object into your code:
const TheOneAPI = require('@cbauch/christopher_bauch_sdk');
  1. Call functions and use helpers:
const authToken = 'Your_API_Token'
TheOneAPI.searchBooks(
    authToken, 
    TheOneAPI.createFilter("name", TheOneAPI.FilterOperation.MatchIncludeOrRegex, "The Fellowship Of The Ring")
).then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
});

Tests

  1. Clone the git repo
git clone https://github.com/cbauch/Christopher_Bauch_SDK.git
cd Christopher_Bauch_SDK
  1. Jest other dependencies must be installed to run the tests.
npm update
  1. The tests can be run with the command:
npm test
1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago