Commit b8d75723 authored by Aaron Tidwell's avatar Aaron Tidwell

workaround for node bug

parent 2086a8da
...@@ -8,6 +8,11 @@ ...@@ -8,6 +8,11 @@
var util = require('util'); var util = require('util');
var Client = require('./client').Client; var Client = require('./client').Client;
//used for the randomize workaround
var sys = require('sys')
var exec = require('child_process').exec;
var Participants = exports.Participants = function(options) { var Participants = exports.Participants = function(options) {
Client.call(this, options); // call parent constructor Client.call(this, options); // call parent constructor
}; };
...@@ -53,11 +58,20 @@ Participants.prototype.destroy = function(obj) { ...@@ -53,11 +58,20 @@ Participants.prototype.destroy = function(obj) {
this.makeRequest(obj); this.makeRequest(obj);
}; };
/***********BUSTED*********/
// [Error: Parse Error] bytesParsed: 0, code: 'HPE_INVALID_CONSTANT'
Participants.prototype.randomize = function(obj) { Participants.prototype.randomize = function(obj) {
obj.path = 'v1/tournaments/'+obj.id+'/participants/randomize'; //workaround to exec CURL, not the best
delete obj.id; var cmd = 'curl -d "" https://'+this.options.get('username')+':'+this.options.get('apiKey')+'@api.challonge.com/v1/tournaments/'+obj.id+'/participants/randomize.'+this.options.get('format');
obj.method = 'PUT'; function process(error, stdout, stderr) {
this.makeRequest(obj); var data = JSON.parse(stdout);
obj.callback(null, data);
}
exec(cmd, process);
/***********BUSTED*********/
// [Error: Parse Error] bytesParsed: 0, code: 'HPE_INVALID_CONSTANT'
// obj.path = 'v1/tournaments/'+obj.id+'/participants/randomize';
// delete obj.id;
// obj.method = 'PUT';
// this.makeRequest(obj);
} }
\ No newline at end of file
var challonge = require('./../'); var challonge = require('./../');
var client = challonge.createClient({ var client = challonge.createClient({
username: 'tidwell',
apiKey: require('./../key.js'), apiKey: require('./../key.js'),
format: 'json' format: 'json'
}); });
...@@ -202,7 +203,7 @@ function mupdate() { ...@@ -202,7 +203,7 @@ function mupdate() {
index(); //index();
//create(); //create();
//show(); //show();
//update(); //update();
...@@ -216,7 +217,7 @@ index(); ...@@ -216,7 +217,7 @@ index();
//pshow(); //pshow();
//pupdate(); //pupdate();
//pdestroy(); //pdestroy();
//prandomize(); prandomize();
//mindex(); //mindex();
//mshow(); //mshow();
......
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