lotr-movie-sdk
v1.0.16
Published
Lord of the rings movie SDK
Downloads
5
Readme
Lord of the rings MovieSDK
Welcome to the official Node.JS SDK for Lord of the Rings Movies. With the help of this SDk, you can easily fetch and find all the lord of the rings movies ever produced. In addition, this library helps you to get all quotes for a specific lord of the rings movies. Sounds interesting already? Let's get Started.
Table of contents
Install
$ npm i lotr-movie-sdk
Getting Started
You need to create an instance of the MovieSDK
class. The MovieSDK
instance must be instantiated with your clientSecret
and clientKey
. We have provided test credentials for both which are used below:
import MovieSDK from 'lotr-movie-sdk/api';
import { MovieConfiguration, MovieIDObject } from 'lotr-movie-sdk/types';
const movieConfig: MovieConfiguration = {
clientSecret: 'abcd',
clientKey: '1234'
};
const movie = new MovieSDK(movieConfig);
This SDK has some typescript types and interfaces defined to make development easy for you.
Get All Movies
const movies = await movie.getAll();
console.log(movies);
The above code snippet would output something like the following:
[
{
"_id": "5cd95395de30eff6ebccde56",
"name": "The Lord of the Rings Series",
"runtimeInMinutes": 558,
"budgetInMillions": 281,
"boxOfficeRevenueInMillions": 2917,
"academyAwardNominations": 30,
"academyAwardWins": 17,
"rottenTomatoesScore": 94
},
{
"_id": "5cd95395de30eff6ebccde57",
"name": "The Hobbit Series",
"runtimeInMinutes": 462,
"budgetInMillions": 675,
"boxOfficeRevenueInMillions": 2932,
"academyAwardNominations": 7,
"academyAwardWins": 1,
"rottenTomatoesScore": 66.33333333
}
]
Get Movies By ID
const movieIDObj: MovieIDObject = {
id: req.params.id
};
const movie = await movie.getById(movieIDObj);
console.log(movie);
The above code would output a response that looks the following:
[
{
"_id": "5cd95395de30eff6ebccde56",
"name": "The Lord of the Rings Series",
"runtimeInMinutes": 558,
"budgetInMillions": 281,
"boxOfficeRevenueInMillions": 2917,
"academyAwardNominations": 30,
"academyAwardWins": 17,
"rottenTomatoesScore": 94
}
]
Get Movie Quotes
const movieIDObj: MovieIDObject = {
id: req.params.id
};
const movieQuotes = await movie.getQuotes(movieIDObj);
console.log(movieQuotes);
The above code snippet would result in a response that looks like the following:
[
{
"_id": "5cd96e05de30eff6ebcce7e9",
"dialog": "Deagol!",
"movie": "5cd95395de30eff6ebccde5d",
"character": "5cd99d4bde30eff6ebccfe9e",
"id": "5cd96e05de30eff6ebcce7e9"
},
{
"_id": "5cd96e05de30eff6ebcce7ea",
"dialog": "Deagol!",
"movie": "5cd95395de30eff6ebccde5d",
"character": "5cd99d4bde30eff6ebccfe9e",
"id": "5cd96e05de30eff6ebcce7ea"
},
]
Test
Some tests were written for this SDK and they can be found in test/index.test.ts. To run these tests, simply use this command:
$ npm run test