Commit fde1c051 authored by Aaron Tidwell's avatar Aaron Tidwell

Add documentation

parent ff8ec03e
......@@ -9,16 +9,15 @@ $ npm install challonge --save
### Get all tournaments on your account
```js
var challonge = require('challonge');
const challonge = require('challonge');
var client = challonge.createClient({
const client = challonge.createClient({
apiKey: '***yourAPIKey***'
});
client.tournaments.index({
callback: function(err, data){
if (err) { console.log(err); return; }
console.log(data);
callback: (err, data) => {
console.log(err, data);
}
});
......@@ -26,10 +25,10 @@ client.tournaments.index({
### Create a tournament
```js
var challonge = require('challonge');
const challonge = require('challonge');
// create a new instance of the client
var client = challonge.createClient({
const client = challonge.createClient({
apiKey: '***yourAPIKey***',
});
......@@ -40,9 +39,8 @@ client.tournaments.create({
url: 'new_tournament_url',
tournamentType: 'single elimination',
},
callback: function(err, data){
if (err) { console.log(err); return; }
console.log(data);
callback: (err, data) => {
console.log(err, data);
}
});
```
......@@ -70,7 +68,7 @@ For API calls that require nested params (eg: http://api.challonge.com/v1/docume
url: 'new_tournament_url',
tournamentType: 'single elimination',
},
callback: function(err, data){}
callback: (err, data) => {}
}
```
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Client - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches.html">Matches</a><ul class='methods'><li data-type='method'><a href="Matches.html#index">index</a></li><li data-type='method'><a href="Matches.html#show">show</a></li><li data-type='method'><a href="Matches.html#update">update</a></li></ul></li><li><a href="Participants.html">Participants</a><ul class='methods'><li data-type='method'><a href="Participants.html#create">create</a></li><li data-type='method'><a href="Participants.html#destroy">destroy</a></li><li data-type='method'><a href="Participants.html#index">index</a></li><li data-type='method'><a href="Participants.html#randomize">randomize</a></li><li data-type='method'><a href="Participants.html#show">show</a></li><li data-type='method'><a href="Participants.html#update">update</a></li></ul></li><li><a href="Tournaments.html">Tournaments</a><ul class='methods'><li data-type='method'><a href="Tournaments.html#create">create</a></li><li data-type='method'><a href="Tournaments.html#destroy">destroy</a></li><li data-type='method'><a href="Tournaments.html#finalize">finalize</a></li><li data-type='method'><a href="Tournaments.html#index">index</a></li><li data-type='method'><a href="Tournaments.html#reset">reset</a></li><li data-type='method'><a href="Tournaments.html#show">show</a></li><li data-type='method'><a href="Tournaments.html#start">start</a></li><li data-type='method'><a href="Tournaments.html#update">update</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a><ul class='methods'><li data-type='method'><a href="module-ErrorHandler.html#.handle">handle</a></li></ul></li><li><a href="module-Util.html">Util</a><ul class='methods'><li data-type='method'><a href="module-Util.html#.serializeToQSParams">serializeToQSParams</a></li><li data-type='method'><a href="module-Util.html#~camelToUnderscore">camelToUnderscore</a></li><li data-type='method'><a href="module-Util.html#~convert">convert</a></li><li data-type='method'><a href="module-Util.html#~underscoreToCamel">underscoreToCamel</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">Client</h1>
<section>
<header>
<h2>
Client
<sup class="variation">options</sup>
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Client"><span class="type-signature"></span>new Client<span class="signature">(options)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_client.js.html">api/client.js</a>, <a href="api_client.js.html#line6">line 6</a>
</li></ul></dd>
</dl>
<div class="description">
Constructor function for the Client base responsible for communicating with Challonge API
You should never need to call new Client(). Instead, call challonge.createClient() and it will create
a new instance and set defaults.
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>const challonge = require('challonge');
const client = challonge.createClient({
apiKey: '***yourAPIKey***'
});</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">configuration options for this instance</td>
</tr>
</tbody>
</table>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 01:16:37 GMT-0400 (EDT) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Matches</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">Class: Matches</h1>
<section>
<header>
<h2>Matches
<sup class="variation">options</sup>
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Matches"><span class="type-signature"></span>new Matches<span class="signature">(options)</span><span class="type-signature"></span></h4>
<div class="description">
Constructor function for the class to query Matches endpoints
<pre>
index GET tournaments/:tournament/matches
show GET tournaments/:tournament/matches/:match_id
update PUT tournaments/:tournament/matches/:match_id
</pre>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">configuration options for this instance</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_matches.js.html">api/matches.js</a>, <a href="api_matches.js.html#line4">line 4</a>
</li></ul></dd>
</dl>
</div>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a></li><li><a href="module-Util.html">Util</a></li></ul><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches_.html">Matches</a></li><li><a href="Participants.html">Participants</a></li><li><a href="Tournaments.html">Tournaments</a></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 00:31:48 GMT-0400 (EDT)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>api/client.js - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches.html">Matches</a><ul class='methods'><li data-type='method'><a href="Matches.html#index">index</a></li><li data-type='method'><a href="Matches.html#show">show</a></li><li data-type='method'><a href="Matches.html#update">update</a></li></ul></li><li><a href="Participants.html">Participants</a><ul class='methods'><li data-type='method'><a href="Participants.html#create">create</a></li><li data-type='method'><a href="Participants.html#destroy">destroy</a></li><li data-type='method'><a href="Participants.html#index">index</a></li><li data-type='method'><a href="Participants.html#randomize">randomize</a></li><li data-type='method'><a href="Participants.html#show">show</a></li><li data-type='method'><a href="Participants.html#update">update</a></li></ul></li><li><a href="Tournaments.html">Tournaments</a><ul class='methods'><li data-type='method'><a href="Tournaments.html#create">create</a></li><li data-type='method'><a href="Tournaments.html#destroy">destroy</a></li><li data-type='method'><a href="Tournaments.html#finalize">finalize</a></li><li data-type='method'><a href="Tournaments.html#index">index</a></li><li data-type='method'><a href="Tournaments.html#reset">reset</a></li><li data-type='method'><a href="Tournaments.html#show">show</a></li><li data-type='method'><a href="Tournaments.html#start">start</a></li><li data-type='method'><a href="Tournaments.html#update">update</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a><ul class='methods'><li data-type='method'><a href="module-ErrorHandler.html#.handle">handle</a></li></ul></li><li><a href="module-Util.html">Util</a><ul class='methods'><li data-type='method'><a href="module-Util.html#.serializeToQSParams">serializeToQSParams</a></li><li data-type='method'><a href="module-Util.html#~camelToUnderscore">camelToUnderscore</a></li><li data-type='method'><a href="module-Util.html#~convert">convert</a></li><li data-type='method'><a href="module-Util.html#~underscoreToCamel">underscoreToCamel</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">api/client.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const qs = require('querystring');
const https = require('https');
const errorHandler = require('./error-handler');
const util = require('../util');
/**
* @class Client(options)
* @param {object} options configuration options for this instance
* @description
* Constructor function for the Client base responsible for communicating with Challonge API
* You should never need to call new Client(). Instead, call challonge.createClient() and it will create
* a new instance and set defaults.
* @example
const challonge = require('challonge');
const client = challonge.createClient({
apiKey: '***yourAPIKey***'
});
*/
const Client = exports.Client = function(options) {
this.options = options || {};
// defaults - todo convert to an object merge
if (!this.options.version) {
this.options.version = 1;
}
if (typeof this.options.massageProperties === 'undefined') {
this.options.massageProperties = true;
}
if (!this.options.format) {
this.options.format = 'json';
}
this.setSubdomain(this.options.subdomain);
// add a getter to the options passed in - DO NOT mess with instance configs in resources
if (typeof this.options.get !== 'function') {
this.options.get = function(key) { // not an arrow function to maintain "this" reference
return this[key];
};
}
};
Client.prototype.setSubdomain = function(subdomain) {
// generate the subdomain URL string if there is one
if (!subdomain) {
this.options.subdomain = '';
} else if (subdomain[subdomain.length - 1] !== '-') {
this.options.subdomain = subdomain + '-';
} else {
this.options.subdomain = subdomain;
}
};
// cleans the passed in object, generates the API url/query-string, makes the request, delegates errors and calls callbacks
Client.prototype.makeRequest = function(obj) {
const self = this;
const propertiesToDelete = ['callback', 'path', 'method'];
// cache vars that are to be removed
const callback = obj.callback;
const method = obj.method;
let path = obj.path;
// normalize the rest of the properties
obj = util.convert(obj, util.camelToUnderscore);
// Add on the api key
obj.api_key = this.options.get('apiKey');
obj.cache_bust = Math.random();
// remove internal properties
propertiesToDelete.forEach((prop) => {
delete obj[prop];
});
// generate path
const versionPaths = {
1: '/v1/tournaments'
};
const serialized = util.serializeToQSParams(obj);
path = versionPaths[this.options.get('version')] + (path ? path : '') + '.' + this.options.get('format') + '?' + serialized;
// create options for the https call
const options = {
hostname: 'api.challonge.com',
path: path,
method: method,
headers: {
'Content-Length': 0 // server throws nginx error without a content-length
}
};
const req = https.request(options, (res) => {
// store the chunked data as it comes back
let resData = '';
res.on('data', (chunk) => {
resData += chunk;
});
res.on('end', () => {
// error
if (res.statusCode !== 200) {
errorHandler.handle(res, resData, callback, self.options.get('format'));
return;
}
// 200 ok
if (self.options.get('format') == 'json') {
resData = JSON.parse(resData);
if (self.options.get('massageProperties')) {
resData = util.convert(resData, util.underscoreToCamel);
}
}
callback(null, resData); //no error, so no err object
});
});
req.end();
};
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 01:16:37 GMT-0400 (EDT) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>api/error-handler.js - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches.html">Matches</a><ul class='methods'><li data-type='method'><a href="Matches.html#index">index</a></li><li data-type='method'><a href="Matches.html#show">show</a></li><li data-type='method'><a href="Matches.html#update">update</a></li></ul></li><li><a href="Participants.html">Participants</a><ul class='methods'><li data-type='method'><a href="Participants.html#create">create</a></li><li data-type='method'><a href="Participants.html#destroy">destroy</a></li><li data-type='method'><a href="Participants.html#index">index</a></li><li data-type='method'><a href="Participants.html#randomize">randomize</a></li><li data-type='method'><a href="Participants.html#show">show</a></li><li data-type='method'><a href="Participants.html#update">update</a></li></ul></li><li><a href="Tournaments.html">Tournaments</a><ul class='methods'><li data-type='method'><a href="Tournaments.html#create">create</a></li><li data-type='method'><a href="Tournaments.html#destroy">destroy</a></li><li data-type='method'><a href="Tournaments.html#finalize">finalize</a></li><li data-type='method'><a href="Tournaments.html#index">index</a></li><li data-type='method'><a href="Tournaments.html#reset">reset</a></li><li data-type='method'><a href="Tournaments.html#show">show</a></li><li data-type='method'><a href="Tournaments.html#start">start</a></li><li data-type='method'><a href="Tournaments.html#update">update</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a><ul class='methods'><li data-type='method'><a href="module-ErrorHandler.html#.handle">handle</a></li></ul></li><li><a href="module-Util.html">Util</a><ul class='methods'><li data-type='method'><a href="module-Util.html#.serializeToQSParams">serializeToQSParams</a></li><li data-type='method'><a href="module-Util.html#~camelToUnderscore">camelToUnderscore</a></li><li data-type='method'><a href="module-Util.html#~convert">convert</a></li><li data-type='method'><a href="module-Util.html#~underscoreToCamel">underscoreToCamel</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">api/error-handler.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @module ErrorHandler
* @description
* Internally used to handle errors from the API
*/
/**
* @function
* @methodof ErrorHandler
*
* @param {object} res the http response object
* @param {object} resData the data contained in the response
* @param {Function} callback the users callback function to call
* @param {string} format the format of the response data (json, xml, etc)
* @description
* Handles HTTP response codes issued by the API.
* All other codes are the result of a request not reaching the application.
*/
exports.handle = function(res, resData, callback, format) {
let err;
// 401 - Invalid API key
if (res.statusCode === 401) {
err = {
error: true,
errors: [],
statusCode: res.statusCode,
text: 'Invalid API key'
};
callback(err, res);
return;
}
// 404 - Object not found within your account scope
if (res.statusCode === 404) {
err = {
error: true,
errors: [],
statusCode: res.statusCode,
text: 'Object not found within your account scope'
};
callback(err, res);
return;
}
// 422 - Validation error(s) for create or update method
if (res.statusCode === 422) {
if (format === 'json') {
resData = JSON.parse(resData);
}
err = {
error: true,
errors: resData.errors,
statusCode: res.statusCode,
text: resData
};
callback(err, res);
return;
}
// not an api-documented error
err = {
error: true,
errors: [],
statusCode: res.statusCode,
text: resData
};
// ship the response object back as the data
callback(err, res);
return;
};
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 01:16:37 GMT-0400 (EDT) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>api/matches.js - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches.html">Matches</a><ul class='methods'><li data-type='method'><a href="Matches.html#index">index</a></li><li data-type='method'><a href="Matches.html#show">show</a></li><li data-type='method'><a href="Matches.html#update">update</a></li></ul></li><li><a href="Participants.html">Participants</a><ul class='methods'><li data-type='method'><a href="Participants.html#create">create</a></li><li data-type='method'><a href="Participants.html#destroy">destroy</a></li><li data-type='method'><a href="Participants.html#index">index</a></li><li data-type='method'><a href="Participants.html#randomize">randomize</a></li><li data-type='method'><a href="Participants.html#show">show</a></li><li data-type='method'><a href="Participants.html#update">update</a></li></ul></li><li><a href="Tournaments.html">Tournaments</a><ul class='methods'><li data-type='method'><a href="Tournaments.html#create">create</a></li><li data-type='method'><a href="Tournaments.html#destroy">destroy</a></li><li data-type='method'><a href="Tournaments.html#finalize">finalize</a></li><li data-type='method'><a href="Tournaments.html#index">index</a></li><li data-type='method'><a href="Tournaments.html#reset">reset</a></li><li data-type='method'><a href="Tournaments.html#show">show</a></li><li data-type='method'><a href="Tournaments.html#start">start</a></li><li data-type='method'><a href="Tournaments.html#update">update</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a><ul class='methods'><li data-type='method'><a href="module-ErrorHandler.html#.handle">handle</a></li></ul></li><li><a href="module-Util.html">Util</a><ul class='methods'><li data-type='method'><a href="module-Util.html#.serializeToQSParams">serializeToQSParams</a></li><li data-type='method'><a href="module-Util.html#~camelToUnderscore">camelToUnderscore</a></li><li data-type='method'><a href="module-Util.html#~convert">convert</a></li><li data-type='method'><a href="module-Util.html#~underscoreToCamel">underscoreToCamel</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">api/matches.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const util = require('util');
const Client = require('./client').Client;
/**
* @class Matches
* @param {object} options configuration options for this instance
* @description
* Constructor function for the class to query Matches endpoints
* &lt;pre>
* index GET tournaments/:tournament/matches
* show GET tournaments/:tournament/matches/:match_id
* update PUT tournaments/:tournament/matches/:match_id
* &lt;/pre>
*/
const Matches = exports.Matches = function(options) {
Client.call(this, options); // call parent constructor
};
// inherit from Client base object
util.inherits(Matches, Client);
/**
* @function
* @memberof Matches
* @param {object} obj params to pass to the api request
* @param {string} obj.id The url of the tournament to get the matches from
* @param {function} obj.callback A method to call when the API returns. Arguments are (error, data)
* @description
* Retrieve a tournament's match list.
* See the {@link http://api.challonge.com/v1/documents/matches/index|Challonge API Doc} for a full list of object properties.
* @example
client.matches.index({
id: 'my-tournament-url',
callback: (err, data) => {
console.log(err, data);
}
});
*/
Matches.prototype.index = function(obj) {
obj.path = '/' + this.options.get('subdomain') + obj.id + '/matches';
delete obj.id;
obj.method = 'GET';
this.makeRequest(obj);
};
/**
* @function
* @memberof Matches
* @param {object} obj params to pass to the api request
* @param {string} obj.id The url of the tournament to get the match from
* @param {string} obj.matchId The id of the match to get
* @param {function} obj.callback A method to call when the API returns. Arguments are (error, data)
* @description
* Retrieve a single match record for a tournament.
* See the {@link http://api.challonge.com/v1/documents/matches/show|Challonge API Doc} for a full list of object properties.
* @example
client.matches.show({
id: 'my-tournament-url',
matchId: '12345678',
callback: (err, data) => {
console.log(err, data);
}
});
*/
Matches.prototype.show = function(obj) {
obj.path = '/' + this.options.get('subdomain') + obj.id + '/matches/' + obj.matchId;
delete obj.id;
delete obj.matchId;
obj.method = 'GET';
this.makeRequest(obj);
};
/**
* @function
* @memberof Matches
* @param {object} obj params to pass to the api request
* @param {string} obj.id The url of the tournament to update the match in
* @param {string} obj.matchId The id of the match to update
* @param {object} obj.match The match object with updates. See challonge docs for available properties.
* @param {function} obj.callback A method to call when the API returns. Arguments are (error, data)
* @description
* Update/submit the score(s) for a match.
* See the {@link http://api.challonge.com/v1/documents/matches/update|Challonge API Doc} for a full list of object properties.
* @example
client.matches.update({
id: 'my-tournament-url',
matchId: '12345678',
match: {
scoresCsv: '3-0',
winnerId: '678910'
},
callback: (err, data) => {
console.log(err, data);
}
});
*/
Matches.prototype.update = function(obj) {
obj.path = '/' + this.options.get('subdomain') + obj.id + '/matches/' + obj.matchId;
delete obj.id;
delete obj.matchId;
obj.method = 'PUT';
this.makeRequest(obj);
};
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 01:16:37 GMT-0400 (EDT) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>challonge.js - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches.html">Matches</a><ul class='methods'><li data-type='method'><a href="Matches.html#index">index</a></li><li data-type='method'><a href="Matches.html#show">show</a></li><li data-type='method'><a href="Matches.html#update">update</a></li></ul></li><li><a href="Participants.html">Participants</a><ul class='methods'><li data-type='method'><a href="Participants.html#create">create</a></li><li data-type='method'><a href="Participants.html#destroy">destroy</a></li><li data-type='method'><a href="Participants.html#index">index</a></li><li data-type='method'><a href="Participants.html#randomize">randomize</a></li><li data-type='method'><a href="Participants.html#show">show</a></li><li data-type='method'><a href="Participants.html#update">update</a></li></ul></li><li><a href="Tournaments.html">Tournaments</a><ul class='methods'><li data-type='method'><a href="Tournaments.html#create">create</a></li><li data-type='method'><a href="Tournaments.html#destroy">destroy</a></li><li data-type='method'><a href="Tournaments.html#finalize">finalize</a></li><li data-type='method'><a href="Tournaments.html#index">index</a></li><li data-type='method'><a href="Tournaments.html#reset">reset</a></li><li data-type='method'><a href="Tournaments.html#show">show</a></li><li data-type='method'><a href="Tournaments.html#start">start</a></li><li data-type='method'><a href="Tournaments.html#update">update</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a><ul class='methods'><li data-type='method'><a href="module-ErrorHandler.html#.handle">handle</a></li></ul></li><li><a href="module-Util.html">Util</a><ul class='methods'><li data-type='method'><a href="module-Util.html#.serializeToQSParams">serializeToQSParams</a></li><li data-type='method'><a href="module-Util.html#~camelToUnderscore">camelToUnderscore</a></li><li data-type='method'><a href="module-Util.html#~convert">convert</a></li><li data-type='method'><a href="module-Util.html#~underscoreToCamel">underscoreToCamel</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">challonge.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const endpoints = ['Client', 'Tournaments', 'Participants', 'Matches'];
endpoints.forEach(endpointName => {
exports[endpointName] = require('./api/' + endpointName.toLowerCase())[endpointName];
});
/**
* @function createClient(options)
* @methodof modules:Client
* @param {object} options configuration options for this instance
* @returns {object} new api client instance
* @description
* Generates a new API client.
*/
exports.createClient = function createClient(options) {
const client = {};
// require each lib in ./api and instantiate a new instance of each object, passing the options we were passed
endpoints.forEach(endpointName => {
// store for the user to reference via instance.resource
client[endpointName.toLowerCase()] = new exports[endpointName](options);
});
client.setSubdomain = subdomain => {
endpoints.forEach(endpointName => {
client[endpointName.toLowerCase()].setSubdomain(subdomain);
});
};
return client;
};
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 01:16:37 GMT-0400 (EDT) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Global - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches.html">Matches</a><ul class='methods'><li data-type='method'><a href="Matches.html#index">index</a></li><li data-type='method'><a href="Matches.html#show">show</a></li><li data-type='method'><a href="Matches.html#update">update</a></li></ul></li><li><a href="Participants.html">Participants</a><ul class='methods'><li data-type='method'><a href="Participants.html#create">create</a></li><li data-type='method'><a href="Participants.html#destroy">destroy</a></li><li data-type='method'><a href="Participants.html#index">index</a></li><li data-type='method'><a href="Participants.html#randomize">randomize</a></li><li data-type='method'><a href="Participants.html#show">show</a></li><li data-type='method'><a href="Participants.html#update">update</a></li></ul></li><li><a href="Tournaments.html">Tournaments</a><ul class='methods'><li data-type='method'><a href="Tournaments.html#create">create</a></li><li data-type='method'><a href="Tournaments.html#destroy">destroy</a></li><li data-type='method'><a href="Tournaments.html#finalize">finalize</a></li><li data-type='method'><a href="Tournaments.html#index">index</a></li><li data-type='method'><a href="Tournaments.html#reset">reset</a></li><li data-type='method'><a href="Tournaments.html#show">show</a></li><li data-type='method'><a href="Tournaments.html#start">start</a></li><li data-type='method'><a href="Tournaments.html#update">update</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a><ul class='methods'><li data-type='method'><a href="module-ErrorHandler.html#.handle">handle</a></li></ul></li><li><a href="module-Util.html">Util</a><ul class='methods'><li data-type='method'><a href="module-Util.html#.serializeToQSParams">serializeToQSParams</a></li><li data-type='method'><a href="module-Util.html#~camelToUnderscore">camelToUnderscore</a></li><li data-type='method'><a href="module-Util.html#~convert">convert</a></li><li data-type='method'><a href="module-Util.html#~underscoreToCamel">underscoreToCamel</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2>
</h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="createClientoptions"><span class="type-signature"></span>createClient<span class="signature">(options)</span><span class="type-signature"> &rarr; {object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="challonge.js.html">challonge.js</a>, <a href="challonge.js.html#line7">line 7</a>
</li></ul></dd>
</dl>
<div class="description">
Generates a new API client.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">configuration options for this instance</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
new api client instance
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 01:16:37 GMT-0400 (EDT) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Home - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches.html">Matches</a><ul class='methods'><li data-type='method'><a href="Matches.html#index">index</a></li><li data-type='method'><a href="Matches.html#show">show</a></li><li data-type='method'><a href="Matches.html#update">update</a></li></ul></li><li><a href="Participants.html">Participants</a><ul class='methods'><li data-type='method'><a href="Participants.html#create">create</a></li><li data-type='method'><a href="Participants.html#destroy">destroy</a></li><li data-type='method'><a href="Participants.html#index">index</a></li><li data-type='method'><a href="Participants.html#randomize">randomize</a></li><li data-type='method'><a href="Participants.html#show">show</a></li><li data-type='method'><a href="Participants.html#update">update</a></li></ul></li><li><a href="Tournaments.html">Tournaments</a><ul class='methods'><li data-type='method'><a href="Tournaments.html#create">create</a></li><li data-type='method'><a href="Tournaments.html#destroy">destroy</a></li><li data-type='method'><a href="Tournaments.html#finalize">finalize</a></li><li data-type='method'><a href="Tournaments.html#index">index</a></li><li data-type='method'><a href="Tournaments.html#reset">reset</a></li><li data-type='method'><a href="Tournaments.html#show">show</a></li><li data-type='method'><a href="Tournaments.html#start">start</a></li><li data-type='method'><a href="Tournaments.html#update">update</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a><ul class='methods'><li data-type='method'><a href="module-ErrorHandler.html#.handle">handle</a></li></ul></li><li><a href="module-Util.html">Util</a><ul class='methods'><li data-type='method'><a href="module-Util.html#.serializeToQSParams">serializeToQSParams</a></li><li data-type='method'><a href="module-Util.html#~camelToUnderscore">camelToUnderscore</a></li><li data-type='method'><a href="module-Util.html#~convert">convert</a></li><li data-type='method'><a href="module-Util.html#~underscoreToCamel">underscoreToCamel</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<div id="main">
<section class="readme">
<article><h2>Usage</h2><h3>Install</h3><pre class="prettyprint source lang-bash"><code>$ npm install challonge --save</code></pre><h3>Get all tournaments on your account</h3><pre class="prettyprint source lang-js"><code>const challonge = require('challonge');
const client = challonge.createClient({
apiKey: '***yourAPIKey***'
});
client.tournaments.index({
callback: (err, data) => {
console.log(err, data);
}
});</code></pre><h3>Create a tournament</h3><pre class="prettyprint source lang-js"><code>const challonge = require('challonge');
// create a new instance of the client
const client = challonge.createClient({
apiKey: '***yourAPIKey***',
});
// create a tournament
client.tournaments.create({
tournament: {
name: 'new_tournament_name',
url: 'new_tournament_url',
tournamentType: 'single elimination',
},
callback: (err, data) => {
console.log(err, data);
}
});</code></pre><h2>API Client</h2><p><em>createClient</em> takes one argument for configuration and returns an instance of the api client. The configuration object can contain the following options:</p>
<ul>
<li><p><code>apiKey</code> string (required) - Your challonge API Key</p>
</li>
<li><p><code>subdomain</code> string (optional) - Setting the subdomain automatically passes tournament[subdomain] and prefixes the subdomain to tournament urls. If you don't want to pass a subdomain to the constructor, and want to use an organization (or multiple organizations), you must use client.setSubdomain('subdomain') before making api calls.</p>
</li>
<li><p><code>format</code> string (optional) - The format of the response data. Defaults to 'json'. If set to 'json', will return javascript objects. 'xml' will return the raw text string.</p>
</li>
<li><p><code>massageProperties</code> boolean (optional) - If the response object should be massaged into camelCase properties when using json format. Defaults to true.</p>
</li>
</ul>
<p>The wrapper is organized into resource.method to match the API</p>
<p>For API calls that require nested params (eg: http://api.challonge.com/v1/documents/tournaments/create) properties should be specified as a nested object:</p>
<pre class="prettyprint source lang-js"><code>{
tournament: {
name: 'new_tournament_name',
url: 'new_tournament_url',
tournamentType: 'single elimination',
},
callback: (err, data) => {}
}</code></pre><p>All properties can be specified camelCase instead of using under_scores Both of the following are valid:</p>
<pre class="prettyprint source lang-js"><code>tournament: { tournamentType: 'single elimination' }</code></pre><pre class="prettyprint source lang-js"><code>tournament: { tournament_type: 'single elimination' }</code></pre><h2>Development</h2><h3>Install</h3><pre class="prettyprint source lang-bash"><code> $ git clone https://github.com/Tidwell/node-challonge
$ cd node-challonge
$ npm install</code></pre><h3>Run Tests</h3><p><a href="https://travis-ci.org/Tidwell/node-challonge"><img src="https://travis-ci.org/Tidwell/node-challonge.svg?branch=master" alt="Build Status"></a></p>
<pre class="prettyprint source lang-bash"><code>$ npm test</code></pre><h3>Run JsFmt/JsHint</h3><pre class="prettyprint source lang-bash"><code>$ npm run-script format</code></pre><pre class="prettyprint source lang-bash"><code>$ npm run-script lint</code></pre><h3>All (travis integration tests)</h3><pre class="prettyprint source lang-bash"><code>$ npm run-script integrate</code></pre><h3>Issue Tracking</h3><p>Issues are tracked on github: https://github.com/Tidwell/node-challonge/issues</p>
<p>The <a href="https://www.zenhub.com/">Zenhub Browser Plugin</a> is used to organize issues.</p>
<p>The structure of this api wrapper is ripped off from https://github.com/nodejitsu/nodejitsu-api</p>
<h3>Branching</h3><p><code>master</code> is the active development branch</p>
<p><code>live</code> is the latest published build on npm</p></article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 01:16:37 GMT-0400 (EDT) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>param-serializer.js - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Matches.html">Matches</a><ul class='methods'><li data-type='method'><a href="Matches.html#index">index</a></li><li data-type='method'><a href="Matches.html#show">show</a></li><li data-type='method'><a href="Matches.html#update">update</a></li></ul></li><li><a href="Participants.html">Participants</a><ul class='methods'><li data-type='method'><a href="Participants.html#create">create</a></li><li data-type='method'><a href="Participants.html#destroy">destroy</a></li><li data-type='method'><a href="Participants.html#index">index</a></li><li data-type='method'><a href="Participants.html#randomize">randomize</a></li><li data-type='method'><a href="Participants.html#show">show</a></li><li data-type='method'><a href="Participants.html#update">update</a></li></ul></li><li><a href="Tournaments.html">Tournaments</a><ul class='methods'><li data-type='method'><a href="Tournaments.html#create">create</a></li><li data-type='method'><a href="Tournaments.html#destroy">destroy</a></li><li data-type='method'><a href="Tournaments.html#finalize">finalize</a></li><li data-type='method'><a href="Tournaments.html#index">index</a></li><li data-type='method'><a href="Tournaments.html#reset">reset</a></li><li data-type='method'><a href="Tournaments.html#show">show</a></li><li data-type='method'><a href="Tournaments.html#start">start</a></li><li data-type='method'><a href="Tournaments.html#update">update</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-ErrorHandler.html">ErrorHandler</a><ul class='methods'><li data-type='method'><a href="module-ErrorHandler.html#.handle">handle</a></li></ul></li><li><a href="module-Util.html">Util</a><ul class='methods'><li data-type='method'><a href="module-Util.html#.serializeToQSParams">serializeToQSParams</a></li><li data-type='method'><a href="module-Util.html#~camelToUnderscore">camelToUnderscore</a></li><li data-type='method'><a href="module-Util.html#~convert">convert</a></li><li data-type='method'><a href="module-Util.html#~underscoreToCamel">underscoreToCamel</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#createClientoptions">createClient</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">param-serializer.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @function modules:Util#serialize
* @param {object} a a javascript object
* @return {string} the jquery-like querystring to send to the api
* @description
* Ripped from https://github.com/knowledgecode/jquery-param
*/
/* istanbul ignore next */
function serialize(a) {
const s = [];
const rbracket = /\[\]$/;
const isArray = function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
function add(k, v) {
v = typeof v === 'function' ? v() : v === null ? '' : v === undefined ? '' : v;
s[s.length] = encodeURIComponent(k) + '=' + encodeURIComponent(v);
}
function buildParams(prefix, obj) {
let i;
let len;
let key;
if (prefix) {
if (isArray(obj)) {
for (i = 0, len = obj.length; i &lt; len; i++) {
if (rbracket.test(prefix)) {
add(prefix, obj[i]);
} else {
buildParams(prefix + '[' + (typeof obj[i] === 'object' ? i : '') + ']', obj[i]);
}
}
} else if (obj &amp;&amp; String(obj) === '[object Object]') {
for (key in obj) {
buildParams(prefix + '[' + key + ']', obj[key]);
}
} else {
add(prefix, obj);
}
} else if (isArray(obj)) {
for (i = 0, len = obj.length; i &lt; len; i++) {
add(obj[i].name, obj[i].value);
}
} else {
for (key in obj) {
buildParams(key, obj[key]);
}
}
return s;
}
return decodeURIComponent(buildParams('', a).join('&amp;').replace(/%20/g, '+'));
}
module.exports = serialize;
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Mar 20 2017 01:16:37 GMT-0400 (EDT) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
/*global document */
(function() {
var source = document.getElementsByClassName('prettyprint source linenums');
var i = 0;
var lineNumber = 0;
var lineId;
var lines;
var totalLines;
var anchorHash;
if (source && source[0]) {
anchorHash = document.location.hash.substring(1);
lines = source[0].getElementsByTagName('li');
totalLines = lines.length;
for (; i < totalLines; i++) {
lineNumber++;
lineId = 'line' + lineNumber;
lines[i].id = lineId;
if (lineId === anchorHash) {
lines[i].className += ' selected';
}
}
}
})();
This diff is collapsed.
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* JSDoc prettify.js theme */
/* plain text */
.pln {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* string content */
.str {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a keyword */
.kwd {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a comment */
.com {
font-weight: normal;
font-style: italic;
}
/* a type name */
.typ {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* a literal value */
.lit {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* punctuation */
.pun {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* lisp open bracket */
.opn {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* lisp close bracket */
.clo {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a markup tag name */
.tag {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a markup attribute name */
.atn {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a markup attribute value */
.atv {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a declaration */
.dec {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a variable name */
.var {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* a function name */
.fun {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -8,6 +8,14 @@ const util = require('../util');
* @param {object} options configuration options for this instance
* @description
* Constructor function for the Client base responsible for communicating with Challonge API
* You should never need to call new Client(). Instead, call challonge.createClient() and it will create
* a new instance and set defaults.
* @example
const challonge = require('challonge');
const client = challonge.createClient({
apiKey: '***yourAPIKey***'
});
*/
const Client = exports.Client = function(options) {
this.options = options || {};
......
/**
* Response code handler
* @module ErrorHandler
* @description
* Internally used to handle errors from the API
*/
/**
* @function
* @methodof ErrorHandler
*
* @param {object} res the http response object
* @param {object} resData the data contained in the response
* @param {Function} callback the users callback function to call
* @param {string} format the format of the response data (json, xml, etc)
* @description
* The following HTTP response codes are issued by the API.
* Handles HTTP response codes issued by the API.
* All other codes are the result of a request not reaching the application.
*/
exports.handle = function(res, resData, callback, format) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6,6 +6,7 @@ endpoints.forEach(endpointName => {
/**
* @function createClient(options)
* @methodof modules:Client
* @param {object} options configuration options for this instance
* @returns {object} new api client instance
* @description
......
/**
* @function serialize
* @function modules:Util#serialize
* @param {object} a a javascript object
* @return {string} the jquery-like querystring to send to the api
* @description
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment