UNPKG

md-movie-utils

Version:

The ultimate utility to get any information about a movie

161 lines (121 loc) 6.32 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Source: clients/base.client.js | </title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/tui-doc.css"> <link type="text/css" rel="stylesheet" href=".docs.styles.css"> </head> <body> <nav class="lnb" id="lnb"> <div class="logo" style="width: 162px; height: 76px"> <img src="https://github.com/dibosh/md-movie-utils/raw/master/md-movie-utils-icon-invert.png" width="100%" height="100%"> </div> <div class="title"> <h1><a href="index.html" class="link"> </a></h1> </div> <div class="search-container" id="search-container"> <input type="text" placeholder="Search"> <ul></ul> </div> <div class="lnb-api hidden"><h3>Classes</h3><ul><li><a href="BaseClient.html">BaseClient</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="BaseClient_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="BaseClient.html#get">get</a></li><li><a href="BaseClient.html#search">search</a></li></ul></div></li><li><a href="MovieDBClient.html">MovieDBClient</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="MovieDBClient_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="MovieDBClient.html#.getInstance">getInstance</a></li><li><a href="MovieDBClient.html#get">get</a></li><li><a href="MovieDBClient.html#getByIMDBId">getByIMDBId</a></li><li><a href="MovieDBClient.html#getByTitleAndYear">getByTitleAndYear</a></li><li><a href="MovieDBClient.html#getDetails">getDetails</a></li><li><a href="MovieDBClient.html#search">search</a></li></ul></div></li><li><a href="OMDBAPIClient.html">OMDBAPIClient</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="OMDBAPIClient_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="OMDBAPIClient.html#.getInstance">getInstance</a></li><li><a href="OMDBAPIClient.html#get">get</a></li><li><a href="OMDBAPIClient.html#getByIMDBId">getByIMDBId</a></li><li><a href="OMDBAPIClient.html#getByTitleAndYear">getByTitleAndYear</a></li><li><a href="OMDBAPIClient.html#search">search</a></li></ul></div></li><li><a href="Parser.html">Parser</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="Parser_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="Parser.html#parseFromTorrentFileName">parseFromTorrentFileName</a></li><li><a href="Parser.html#parseMovieNameAndYear">parseMovieNameAndYear</a></li></ul></div></li></ul></div><div class="lnb-api hidden"><h3>Global</h3><ul><li><a href="global.html#toCamelCase">toCamelCase</a></li></ul></div> </nav> <div id="resizer"></div> <div class="main" id="main"> <section> <article> <pre class="prettyprint source linenums"><code>let axios = require('axios'); class BaseClient { /** * Initialize a specific client. * @param {string} apiKey client specific api key * @param {string} baseUrl client specific base url */ constructor(apiKey, baseUrl) { if (!apiKey) { throw new Error('API Key not provided.'); } this._apiKey = apiKey; this._httpManager = axios.create({ baseURL: baseUrl }); } get authParam() { throw new Error('Not implemented'); } get httpManager() { return this._httpManager; } get requestKeyMap() { throw new Error('Not implemented'); } /** * Get a movie by looking up using different params (e.g. title, imdb id, year etc.) * @param {object} options */ get(options) { throw new Error('Not implemented'); } /** * Search for a movie. * @param {object} options */ search(options) { throw new Error('Not implemented'); } _makeHTTPGET(url, params, headers, responseTransformer) { let paramsWithAuth = Object.assign({}, params); paramsWithAuth[this.authParam] = this._apiKey; let responseTransformers = [JSON.parse]; if (responseTransformer) { responseTransformers.push(responseTransformer); } return this.httpManager({ method: 'get', url: url, params: paramsWithAuth, headers: headers, transformResponse: responseTransformers }); } _translateIncomingRequestOptions(options) { let translated = {}; Object.keys(options).forEach((key) => { if (options[key] &amp;&amp; this.requestKeyMap[key]) { translated[this.requestKeyMap[key]] = options[key]; } }); return translated; } } module.exports = BaseClient; </code></pre> </article> </section> </div> <footer> <img class="logo" src="https://github.com/dibosh/md-movie-utils/raw/master/md-movie-utils-icon-invert.png" style="width: 162px; height: 76px"> <div class="footer-text">If you liked the module, don't forget to hit a star on github: https://github.com/dibosh/md-movie-utils</div> </footer> <script>prettyPrint();</script> <script src="scripts/jquery.min.js"></script> <script src="scripts/tui-doc.js"></script> <script src="scripts/linenumber.js"></script> <script> var id = '_sub'.replace(/"/g, '_'); var selectedApi = document.getElementById(id); // do not use jquery selector var $selectedApi = $(selectedApi); $selectedApi.removeClass('hidden'); $selectedApi.parent().find('.glyphicon').removeClass('glyphicon-plus').addClass('glyphicon-minus'); showLnbApi(); </script> </body> </html>