src/changetip.js
function (data, path, params, method, deferred) {
        var options, query_params, req,
            dataString = JSON.stringify(data);

        query_params = querystring.stringify(params);

        options = {
            host: this.host,
            port: 443,
            path: '/v' + this.api_version + '/' + path + '/?api_key=' + this.api_key + (query_params ? ('&' + query_params) : ''),
            method: method,
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': dataString.length
            }
        };

        if (!this.dev_mode) {
            req = https.request(options, function (res) {
                res.setEncoding('utf-8');

                var response = '', result;

                res.on('data', function (response_data) {
                    response += response_data;
                });

                res.on('end', function () {
                    result = JSON.parse(response);
                    deferred.resolve(result);
                });
            });

            req.write(dataString);
            req.end();
        } else {
            deferred.resolve({status:"dev_mode", data: data, params: params, path: options.path});
        }
    }
function (data, path, params, method, deferred) {
        var options, query_params, req,
            dataString = JSON.stringify(data);

        query_params = querystring.stringify(params);

        options = {
            host: this.host,
            port: 443,
            path: '/v' + this.api_version + '/' + path + '/?api_key=' + this.api_key + (query_params ? ('&' + query_params) : ''),
            method: method,
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': dataString.length
            }
        };

        if (!this.dev_mode) {
            req = https.request(options, function (res) {
                res.setEncoding('utf-8');

                var response = '', result;

                res.on('data', function (response_data) {
                    response += response_data;
                });

                res.on('end', function () {
                    result = JSON.parse(response);
                    deferred.resolve(result);
                });
            });

            req.write(dataString);
            req.end();
        } else {
            deferred.resolve({status:"dev_mode", data: data, params: params, path: options.path});
        }
    }
function ( data , path , params , method , deferred ) { var options , query_params , req , dataString = JSON . stringify ( data ) ; query_params = querystring . stringify ( params ) ; options = { host : this . host , port : 443 , path : '/v' + this . api_version + '/' + path + '/?api_key=' + this . api_key + ( query_params ? ( '&' + query_params ) : '' ) , method : method , headers : { 'Content-Type' : 'application/json' , 'Content-Length' : dataString . length } } ; if ( ! this . dev_mode ) { req = https . request ( options , function ( res ) { res . setEncoding ( 'utf-8' ) ; var response = '' , result ; res . on ( 'data' , function ( response_data ) { response += response_data ; } ) ; res . on ( 'end' , function ( ) { result = JSON . parse ( response ) ; deferred . resolve ( result ) ; } ) ; } ) ; req . write ( dataString ) ; req . end ( ) ; } else { deferred . resolve ( { status : "dev_mode" , data : data , params : params , path : options . path } ) ; } }
Sends a request
@param {Object} data JSON Object with data payload
@param {String} path API Path
@param {Object} params Query Parameters to be sent along with this request
@param {Methods} method HTTP Method
@param deferred Deferred Object
@param deferred.promise Deferred Promise Object
@param deferred.resolve Deferred success function
@param deferred.reject Deferred rejection function
@private
Sends a request