the-one-sdk-sbm
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Lord of the Rings SDK

Getting started

Install

To install a SDK, simply run the following command

npm install the-one-sdk-sbm

Initializing

You need to set up an access token at: https://the-one-api.dev/account

You can use mine, but keep it a secret 🤫: SQb886IdnjD6GPZB3FsH

then import and initialize an instance of the SDK on your code:

import {TheOne} from 'the-one-sdk-sbm'

const TheOneSDK = new TheOne(access_token)

Examples

Getting a list of all movies

const page = 1
const result = await TheOneSDK.movies.list(page)
//You can iterate through all movies on the paginator or access the pagination information.
console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.movies.forEach((movie) => console.log(movie.name)) //print all movie names

You can also filter the list by any attribute of the movie

const page = 1

const result = await TheOneSDK.movies.list(page,
    {
        attr: 'budgetInMillions',
        operator: '>=',
        value:'200'
    }, {
        attr: 'name',
        operator: 'contains',
        value: 'Lord'
    })

Getting a specific movie

const movieId = "5cd95395de30eff6ebccde5b"
const movie = await TheOneSDK.movies.get(movieId)
console.log(movie.name)

getting a list of quotes from a specific movie

const movieId = "5cd95395de30eff6ebccde5b"
const page = 1
const result = await TheOneSDK.movies.getQuotes(movieId, page)

console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.quotes.forEach((quote) => console.log(quote.dialog)) //print all quotes

Getting a list of all quotes

const page = 1
const result = await TheOneSDK.quotes.list(page)
//the result structure is the same than when getting a list of quotes for a movie
console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.quotes.forEach((quote) => console.log(quote.dialog)) //print all quotes

You can also filter the list by any attribute of the quote

const page = 1

const result = await TheOneSDK.quotes.list(page,
    {
        attr: 'dialog',
        operator: 'notContains',
        value:'Ring'
    })

Getting a specific quote

const quoteId = "5cd96e05de30eff6ebcce9ba"
const quote = await TheOneSDK.quotes.get(quoteId)
console.log(quote.dialog)

Types

Movie = {
    _id: string,
    name: string,
    runtimeInMinutes: number,
    budgetInMillions: number,
    boxOfficeRevenueInMillions: number,
    academyAwardNominations: number,
    academyAwardWins: number,
    rottenTomatoesScore: number,
}

MovieQuote = {
    _id: number,
    dialog: string,
    movie: string,
    character: string,
}

Paginator = {
    total: number,
    results: number,
    limit: number,
    offset: number,
    page: number,
    pages: number
}

MovieQuotePaginator = {
    quotes: MovieQuote[],
    paginator: Paginator
}

MoviePaginator = {
    movies: Movie[],
    paginator: Paginator
}

Filter = {
    attr: string,
    operator: '=' | '!=' | '<' | '<=' | '>' | '>=' | 'contains' | 'notContains'
    value: any
}

Dependents (0)

Package Sidebar

Install

npm i the-one-sdk-sbm

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

47.3 kB

Total Files

17

Last publish

Collaborators

  • pulga