diff --git a/CHANGELOG.md b/CHANGELOG.md index 894e040..e987316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 2.1.0 +- Fix null values being returned as empty objects (#24) +- Add processCheckIns and abortCheckIn methods to tournament api + ### 2.0 - Bump node engine to node >= 6.0.x - Fix challonge.createClient massageProperties is tautologically true (#2) diff --git a/docs/Client.html b/docs/Client.html index abad158..260654d 100644 --- a/docs/Client.html +++ b/docs/Client.html @@ -22,7 +22,7 @@
@@ -383,7 +383,7 @@
Properties

diff --git a/docs/Matches.html b/docs/Matches.html index d7a74ff..25507b2 100644 --- a/docs/Matches.html +++ b/docs/Matches.html @@ -22,7 +22,7 @@
@@ -945,7 +945,7 @@
Properties

- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/Participants.html b/docs/Participants.html index 1287d46..3f8883c 100644 --- a/docs/Participants.html +++ b/docs/Participants.html @@ -22,7 +22,7 @@
@@ -1645,7 +1645,7 @@
Properties

- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/Tournaments.html b/docs/Tournaments.html index e356544..e53e79f 100644 --- a/docs/Tournaments.html +++ b/docs/Tournaments.html @@ -22,7 +22,7 @@
@@ -115,6 +115,8 @@

new Tourna start POST tournaments/:tournament/start finalize POST tournaments/:tournament/finalize reset POST tournaments/:tournament/reset + process_check_ins POST tournaments/:tournament/process_check_ins + abort_check_in POST tournaments/:tournament/abort_check_in

@@ -213,6 +215,226 @@

Methods

+ +

abortCheckIn(obj)

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ When your tournament is in a 'checking_in' or 'checked_in' state, there's no way to edit the tournament's start time (start_at) or check-in duration (check_in_duration). You must first abort check-in, then you may edit those attributes. +
+        Makes all participants active and clears their checked_in_at times.
+        Transitions the tournament state from 'checking_in' or 'checked_in' to 'pending'
+     
+ See the Challonge API Doc for a full list of object properties. +
+ + + + + + + + + +
Example
+ +
client.tournaments.abortCheckIn({
+  id: 'my-tournament-url',
+  callback: (err, data) => {
+    console.log(err, data);
+  }
+});
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +object + + + + params to pass to the api request +
Properties
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + The url of the tournament to abortCheckIn
callback + + +function + + + + A method to call when the API returns. Arguments are (error, data)
+ +
+ + + + + + + + + + + + + + + + + + + +

create(obj)

@@ -226,7 +448,7 @@

createSource:
@@ -446,7 +668,7 @@

destroySource:
@@ -662,7 +884,7 @@

finalizeSource:
@@ -878,7 +1100,7 @@

indexSource:
@@ -1008,6 +1230,228 @@
Parameters:
+ +

processCheckIns(obj)

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ This should be invoked after a tournament's check-in window closes before the tournament is started. +
+        Marks participants who have not checked in as inactive.
+        Moves inactive participants to bottom seeds (ordered by original seed).
+        Transitions the tournament state from 'checking_in' to 'checked_in'
+        NOTE: Checked in participants on the waiting list will be promoted if slots become available.
+	  
+ See the Challonge API Doc for a full list of object properties. +
+ + + + + + + + + +
Example
+ +
client.tournaments.processCheckIns({
+  id: 'my-tournament-url',
+  callback: (err, data) => {
+    console.log(err, data);
+  }
+});
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +object + + + + params to pass to the api request +
Properties
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + The url of the tournament to processCheckIns
callback + + +function + + + + A method to call when the API returns. Arguments are (error, data)
+ +
+ + + + + + + + + + + + + + + + + + + +

reset(obj)

@@ -1021,7 +1465,7 @@

resetSource:
@@ -1237,7 +1681,7 @@

showSource:
@@ -1453,7 +1897,7 @@

startSource:
@@ -1669,7 +2113,7 @@

updateSource:
@@ -1912,7 +2356,7 @@
Properties

- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/api_client.js.html b/docs/api_client.js.html index 2b1206f..25dca8a 100644 --- a/docs/api_client.js.html +++ b/docs/api_client.js.html @@ -22,7 +22,7 @@
@@ -175,7 +175,7 @@

api/client.js


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/api_error-handler.js.html b/docs/api_error-handler.js.html index acfa8c4..f4c052f 100644 --- a/docs/api_error-handler.js.html +++ b/docs/api_error-handler.js.html @@ -22,7 +22,7 @@
@@ -120,7 +120,7 @@

api/error-handler.js


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/api_matches.js.html b/docs/api_matches.js.html index a0d3f7d..8b3d2ff 100644 --- a/docs/api_matches.js.html +++ b/docs/api_matches.js.html @@ -22,7 +22,7 @@
@@ -158,7 +158,7 @@

api/matches.js


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/api_participants.js.html b/docs/api_participants.js.html index f8ed136..3282e97 100644 --- a/docs/api_participants.js.html +++ b/docs/api_participants.js.html @@ -22,7 +22,7 @@
@@ -246,7 +246,7 @@

api/participants.js


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/api_tournaments.js.html b/docs/api_tournaments.js.html index 3391fc5..a21a2fe 100644 --- a/docs/api_tournaments.js.html +++ b/docs/api_tournaments.js.html @@ -22,7 +22,7 @@
@@ -54,6 +54,8 @@

api/tournaments.js

* start POST tournaments/:tournament/start * finalize POST tournaments/:tournament/finalize * reset POST tournaments/:tournament/reset + * process_check_ins POST tournaments/:tournament/process_check_ins + * abort_check_in POST tournaments/:tournament/abort_check_in * </pre> */ const Tournaments = exports.Tournaments = function(options) { @@ -285,6 +287,68 @@

api/tournaments.js

obj.method = 'POST'; this.makeRequest(obj); }; + +/** + * @function + * @memberof Tournaments + * @param {object} obj params to pass to the api request + * @param {string} obj.id The url of the tournament to processCheckIns + * @param {function} obj.callback A method to call when the API returns. Arguments are (error, data) + * @description + * This should be invoked after a tournament's check-in window closes before the tournament is started. + * <pre> + Marks participants who have not checked in as inactive. + Moves inactive participants to bottom seeds (ordered by original seed). + Transitions the tournament state from 'checking_in' to 'checked_in' + NOTE: Checked in participants on the waiting list will be promoted if slots become available. + </pre> + * See the {@link http://api.challonge.com/v1/documents/tournaments/process_check_ins|Challonge API Doc} for a full list of object properties. + * @example + +client.tournaments.processCheckIns({ + id: 'my-tournament-url', + callback: (err, data) => { + console.log(err, data); + } +}); + + */ +Tournaments.prototype.processCheckIns = function(obj) { + obj.path = '/' + this.options.get('subdomain') + obj.id + '/process_check_ins'; + delete obj.id; + obj.method = 'POST'; + this.makeRequest(obj); +}; + +/** + * @function + * @memberof Tournaments + * @param {object} obj params to pass to the api request + * @param {string} obj.id The url of the tournament to abortCheckIn + * @param {function} obj.callback A method to call when the API returns. Arguments are (error, data) + * @description + * When your tournament is in a 'checking_in' or 'checked_in' state, there's no way to edit the tournament's start time (start_at) or check-in duration (check_in_duration). You must first abort check-in, then you may edit those attributes. + * <pre> + Makes all participants active and clears their checked_in_at times. + Transitions the tournament state from 'checking_in' or 'checked_in' to 'pending' + </pre> + * See the {@link http://api.challonge.com/v1/documents/tournaments/abort_check_in|Challonge API Doc} for a full list of object properties. + * @example + +client.tournaments.abortCheckIn({ + id: 'my-tournament-url', + callback: (err, data) => { + console.log(err, data); + } +}); + + */ +Tournaments.prototype.abortCheckIn = function(obj) { + obj.path = '/' + this.options.get('subdomain') + obj.id + '/abort_check_in'; + delete obj.id; + obj.method = 'POST'; + this.makeRequest(obj); +}; @@ -297,7 +361,7 @@

api/tournaments.js


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/challonge.js.html b/docs/challonge.js.html index 0c51118..915287e 100644 --- a/docs/challonge.js.html +++ b/docs/challonge.js.html @@ -22,7 +22,7 @@
@@ -89,7 +89,7 @@

challonge.js


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/global.html b/docs/global.html index a9f5f02..91718e2 100644 --- a/docs/global.html +++ b/docs/global.html @@ -22,7 +22,7 @@
@@ -450,7 +450,7 @@
Returns:

- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/index.html b/docs/index.html index 8291a86..333902c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -22,7 +22,7 @@
@@ -103,7 +103,7 @@

Branching

master is the active development branch


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/module-ErrorHandler.html b/docs/module-ErrorHandler.html index 3b3cb75..e3c4a49 100644 --- a/docs/module-ErrorHandler.html +++ b/docs/module-ErrorHandler.html @@ -22,7 +22,7 @@
@@ -366,7 +366,7 @@
Parameters:

- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/module-Util.html b/docs/module-Util.html index 4ab4175..9a8c78a 100644 --- a/docs/module-Util.html +++ b/docs/module-Util.html @@ -22,7 +22,7 @@
@@ -857,7 +857,7 @@
Returns:

- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/param-serializer.js.html b/docs/param-serializer.js.html index 811afd5..fae0928 100644 --- a/docs/param-serializer.js.html +++ b/docs/param-serializer.js.html @@ -22,7 +22,7 @@
@@ -107,7 +107,7 @@

param-serializer.js


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/docs/util.js.html b/docs/util.js.html index 9f1be3f..166d700 100644 --- a/docs/util.js.html +++ b/docs/util.js.html @@ -22,7 +22,7 @@
@@ -85,7 +85,7 @@

util.js

} Object.keys(obj).forEach((prop) => { - if (typeof obj[prop] === 'object') { + if (typeof obj[prop] === 'object' && obj[prop]) { const convertObj = newObject[conversionFn(prop)] = {}; convert(obj[prop], conversionFn, convertObj); } else { @@ -121,7 +121,7 @@

util.js


- Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 01:36:24 GMT-0400 (EDT) using the docdash theme. + Documentation generated by JSDoc 3.4.3 on Mon Mar 20 2017 22:51:32 GMT-0400 (EDT) using the docdash theme.
diff --git a/lib/api/tournaments.js b/lib/api/tournaments.js index 7ceb2af..4a55c71 100644 --- a/lib/api/tournaments.js +++ b/lib/api/tournaments.js @@ -15,6 +15,8 @@ const Client = require('./client').Client; * start POST tournaments/:tournament/start * finalize POST tournaments/:tournament/finalize * reset POST tournaments/:tournament/reset + * process_check_ins POST tournaments/:tournament/process_check_ins + * abort_check_in POST tournaments/:tournament/abort_check_in * */ const Tournaments = exports.Tournaments = function(options) { @@ -246,3 +248,65 @@ Tournaments.prototype.reset = function(obj) { obj.method = 'POST'; this.makeRequest(obj); }; + +/** + * @function + * @memberof Tournaments + * @param {object} obj params to pass to the api request + * @param {string} obj.id The url of the tournament to processCheckIns + * @param {function} obj.callback A method to call when the API returns. Arguments are (error, data) + * @description + * This should be invoked after a tournament's check-in window closes before the tournament is started. + *
+        Marks participants who have not checked in as inactive.
+        Moves inactive participants to bottom seeds (ordered by original seed).
+        Transitions the tournament state from 'checking_in' to 'checked_in'
+        NOTE: Checked in participants on the waiting list will be promoted if slots become available.
+	  
+ * See the {@link http://api.challonge.com/v1/documents/tournaments/process_check_ins|Challonge API Doc} for a full list of object properties. + * @example + +client.tournaments.processCheckIns({ + id: 'my-tournament-url', + callback: (err, data) => { + console.log(err, data); + } +}); + + */ +Tournaments.prototype.processCheckIns = function(obj) { + obj.path = '/' + this.options.get('subdomain') + obj.id + '/process_check_ins'; + delete obj.id; + obj.method = 'POST'; + this.makeRequest(obj); +}; + +/** + * @function + * @memberof Tournaments + * @param {object} obj params to pass to the api request + * @param {string} obj.id The url of the tournament to abortCheckIn + * @param {function} obj.callback A method to call when the API returns. Arguments are (error, data) + * @description + * When your tournament is in a 'checking_in' or 'checked_in' state, there's no way to edit the tournament's start time (start_at) or check-in duration (check_in_duration). You must first abort check-in, then you may edit those attributes. + *
+        Makes all participants active and clears their checked_in_at times.
+        Transitions the tournament state from 'checking_in' or 'checked_in' to 'pending'
+     
+ * See the {@link http://api.challonge.com/v1/documents/tournaments/abort_check_in|Challonge API Doc} for a full list of object properties. + * @example + +client.tournaments.abortCheckIn({ + id: 'my-tournament-url', + callback: (err, data) => { + console.log(err, data); + } +}); + + */ +Tournaments.prototype.abortCheckIn = function(obj) { + obj.path = '/' + this.options.get('subdomain') + obj.id + '/abort_check_in'; + delete obj.id; + obj.method = 'POST'; + this.makeRequest(obj); +}; diff --git a/lib/api/tournaments.spec.js b/lib/api/tournaments.spec.js index 777c14d..95bb2b7 100644 --- a/lib/api/tournaments.spec.js +++ b/lib/api/tournaments.spec.js @@ -261,4 +261,58 @@ describe('tournaments endpoints', () => { }); }); }); + + // process_check_ins POST tournaments/:tournament/process_check_ins + describe('process_check_ins', () => { + it('should create an appropriate url without a subdomain', () => { + tournamentsInstance.makeRequest = (obj) => { + expect(obj).toEqual({ + path: '/25/process_check_ins', + method: 'POST' + }); + }; + tournamentsInstance.processCheckIns({ + id: 25 + }); + }); + it('should create an appropriate url with a subdomain', () => { + tournamentsInstance.options.subdomain = 'somedomain-'; + tournamentsInstance.makeRequest = (obj) => { + expect(obj).toEqual({ + path: '/somedomain-25/process_check_ins', + method: 'POST' + }); + }; + tournamentsInstance.processCheckIns({ + id: 25 + }); + }); + }); + + // process_check_ins POST tournaments/:tournament/process_check_ins + describe('abort_check_in', () => { + it('should create an appropriate url without a subdomain', () => { + tournamentsInstance.makeRequest = (obj) => { + expect(obj).toEqual({ + path: '/25/abort_check_in', + method: 'POST' + }); + }; + tournamentsInstance.abortCheckIn({ + id: 25 + }); + }); + it('should create an appropriate url with a subdomain', () => { + tournamentsInstance.options.subdomain = 'somedomain-'; + tournamentsInstance.makeRequest = (obj) => { + expect(obj).toEqual({ + path: '/somedomain-25/abort_check_in', + method: 'POST' + }); + }; + tournamentsInstance.abortCheckIn({ + id: 25 + }); + }); + }); }); diff --git a/lib/util.js b/lib/util.js index 07e9843..4743e76 100644 --- a/lib/util.js +++ b/lib/util.js @@ -46,7 +46,7 @@ function convert(obj, conversionFn, newObject) { } Object.keys(obj).forEach((prop) => { - if (typeof obj[prop] === 'object') { + if (typeof obj[prop] === 'object' && obj[prop]) { const convertObj = newObject[conversionFn(prop)] = {}; convert(obj[prop], conversionFn, convertObj); } else { diff --git a/lib/util.spec.js b/lib/util.spec.js index 25cfb83..f729dae 100644 --- a/lib/util.spec.js +++ b/lib/util.spec.js @@ -140,6 +140,18 @@ describe('util methods', () => { }); }); + it('should work with a null value', () => { + expect(util.convert({ + top_prop: { + middle_prop: null + } + }, util.underscoreToCamel)).toEqual({ + topProp: { + middleProp: null + } + }); + }); + it('should work with both top and nested properties', () => { expect(util.convert({ top_prop: { diff --git a/package.json b/package.json index 01b937e..4e7f551 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Wrapper for the challong api", "author": "Aaron Tiwell ", "main": "./lib/challonge.js", - "version": "2.0.0", + "version": "2.1.0", "contributors": [ { "name": "Ricardo Reis",