Commit b8d75723 authored by Aaron Tidwell's avatar Aaron Tidwell

workaround for node bug

parent 2086a8da
......@@ -8,6 +8,11 @@
var util = require('util');
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) {
Client.call(this, options); // call parent constructor
};
......@@ -53,11 +58,20 @@ Participants.prototype.destroy = function(obj) {
this.makeRequest(obj);
};
/***********BUSTED*********/
// [Error: Parse Error] bytesParsed: 0, code: 'HPE_INVALID_CONSTANT'
Participants.prototype.randomize = function(obj) {
obj.path = 'v1/tournaments/'+obj.id+'/participants/randomize';
delete obj.id;
obj.method = 'PUT';
this.makeRequest(obj);
//workaround to exec CURL, not the best
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');
function process(error, stdout, stderr) {
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 client = challonge.createClient({
username: 'tidwell',
apiKey: require('./../key.js'),
format: 'json'
});
......@@ -202,7 +203,7 @@ function mupdate() {
index();
//index();
//create();
//show();
//update();
......@@ -216,7 +217,7 @@ index();
//pshow();
//pupdate();
//pdestroy();
//prandomize();
prandomize();
//mindex();
//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