UNPKG

nodesu

Version:
118 lines (93 loc) 6.69 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: 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/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: Client.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>'use strict'; const Requester = require('./Requester') , Ratelimiting = require('./Ratelimiting') , UserComponent = require('./components/UserComponent') , BeatmapsComponent = require('./components/BeatmapsComponent') , ScoresComponent = require('./components/ScoresComponent') , ReplayComponent = require('./components/ReplayComponent') , MultiComponent = require('./components/MultiComponent') , ApiConstants = require('./Constants').API; /** * The main osu! API client. * @property {UserComponent} user The set of functions that are related to the User section. * @property {BeatmapComponent} beatmaps The set of functions that are related to the Beatmap section. * @property {ScoresComponent} scores The set of functions that are related to the Score section. * @property {ReplayComponent} replay The set of functions that are related to the Replay section. * @property {MultiComponent} multi The set of functions that are related to the Multiplayer section. * @property {String} apiKey The osu! API key in use. * @property {Boolean} disableRateLimiting Should ratelimiting be used throughout the client instance. * @property {Number} requestsPerMinute How many requests per minute are allowed if ratelimiting is used. * @property {Boolean} parseData If data should be parsed into our custom nodesu classes. (experimental and could be subject to break) */ class Client { /** * Creates the osu! API client instance. * @param {String} apiKey The osu! API key. - available from https://osu.ppy.sh/p/api * @param {Object} [options] Options for the instance. * @param {Boolean} [options.disableRateLimiting=false] Disabled ratelimiting through the client instance. * @param {Number} [options.requestsPerMinute=60] Requests per minute for the main limiting bucket if ratelimiting is enabled (note that the replay endpoint has a special 10/minute bucket). * @param {Boolean} [options.parseData=false] If data should be parsed into our custom nodesu classes (experimental and could be subject to break). * @param {String} [options.baseUrl="https://osu.ppy.sh/api"] osu! API base URL. May be changed for mocking purposes, or for using a rate-limiting proxy. * @return {Client} The osu! API client instance. */ constructor(apiKey, options) { this.apiKey = apiKey; if (!options) options = {}; this.disableRateLimiting = options.disableRateLimiting || false; this.requestsPerMinute = options.requestsPerMinute || 60; this.parseData = options.parseData || false; this.baseUrl = options.baseUrl || `https://${ApiConstants.HOST}${ApiConstants.BASE_PATH}`; this.requester = new Requester(this); if (!this.disableRateLimiting) this.ratelimiting = new Ratelimiting(this); // components this.user = new UserComponent(this); this.beatmaps = new BeatmapsComponent(this); this.scores = new ScoresComponent(this); this.replay = new ReplayComponent(this); this.multi = new MultiComponent(this); } /** * A direct raw API request with a payload of query string options. * @param {String} endpoint The API endpoint. * @param {Object} options An object of query string options. * @return {Promise&lt;Object>} The object returned from the API. */ raw(endpoint, options) { return this.requester.get(endpoint, options, true, true); } } module.exports = Client;</code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Components.html">Components</a></li><li><a href="module-CustomClasses.html">CustomClasses</a></li><li><a href="module-Enums.html">Enums</a></li><li><a href="module-Errors.html">Errors</a></li></ul><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="module-Components.BeatmapsComponent.html">BeatmapsComponent</a></li><li><a href="module-Components.MultiComponent.html">MultiComponent</a></li><li><a href="module-Components.ReplayComponent.html">ReplayComponent</a></li><li><a href="module-Components.ScoresComponent.html">ScoresComponent</a></li><li><a href="module-Components.UserComponent.html">UserComponent</a></li><li><a href="module-CustomClasses.Beatmap.html">Beatmap</a></li><li><a href="module-CustomClasses.BeatmapScore.html">BeatmapScore</a></li><li><a href="module-CustomClasses.Multi.html">Multi</a></li><li><a href="module-CustomClasses.MultiGame.html">MultiGame</a></li><li><a href="module-CustomClasses.MultiMatch.html">MultiMatch</a></li><li><a href="module-CustomClasses.MultiScore.html">MultiScore</a></li><li><a href="module-CustomClasses.ReplayData.html">ReplayData</a></li><li><a href="module-CustomClasses.Score.html">Score</a></li><li><a href="module-CustomClasses.User.html">User</a></li><li><a href="module-CustomClasses.UserEvent.html">UserEvent</a></li><li><a href="module-CustomClasses.UserScore.html">UserScore</a></li><li><a href="module-Errors.OsuApiError.html">OsuApiError</a></li><li><a href="Requester.html">Requester</a></li></ul><h3>Global</h3><ul><li><a href="global.html#ApprovalStatus">ApprovalStatus</a></li><li><a href="global.html#Converts">Converts</a></li><li><a href="global.html#Genre">Genre</a></li><li><a href="global.html#Language">Language</a></li><li><a href="global.html#LookupType">LookupType</a></li><li><a href="global.html#Mode">Mode</a></li><li><a href="global.html#Mods">Mods</a></li><li><a href="global.html#MultiScoringType">MultiScoringType</a></li><li><a href="global.html#MultiTeam">MultiTeam</a></li><li><a href="global.html#MultiTeamType">MultiTeamType</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a> on Sat Apr 11 2020 14:41:31 GMT+1000 (GMT+10:00) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>