<commit_before>//Retrieve pending deposits and withdrawals from REST api
//uses code from https://www.npmjs.org/package/node-rest-client
//Bunch of unused stuff kept for future reference

//This module retrieves deposits and withdrawals on request *after* listener.js sees a relevant transaction.
//An event-bsed model rather than simply polling the api.


var Client = require('node-rest-client').Client;

// direct way
client = new Client();

args ={
        data:{test:"hello"}, // data passed to REST method (only useful in POST, PUT or PATCH methods)
        path:{"id":120}, // path substitution var
        parameters:{arg1:"hello",arg2:"world"}, // query parameter substitution vars
        headers:{"test-header":"client-api"} // request headers
      };


//client.get("http://remote.site/rest/json/${id}/method?arg1=hello&arg2=world", args, 
client.get("http://localhost:5990/v1", args, 

            function(data, response){
            // parsed response body as js object
            console.log(data);
            // raw response
            console.log(response);
});


// registering remote methods
//client.registerMethod("jsonMethod", "http://remote.site/rest/json/${id}/method", "GET");
client.registerMethod("jsonMethod", "http://localhost:5990/v1", "GET");



/* this would construct the following URL before invocation
 *
 * http://remote.site/rest/json/120/method?arg1=hello&arg2=world
 *
 */ 
client.methods.jsonMethod(args,function(data,response){
    // parsed response body as js object
    console.log(data);
    // raw response
    console.log(response);
});<commit_msg>Update rest-comms.js<commit_after>//Retrieve pending deposits and withdrawals from REST api
//uses code from https://www.npmjs.org/package/node-rest-client
//Bunch of unused stuff kept for future reference

//This module retrieves deposits and withdrawals on request *after* listener.js received a ledger close
//An event-bsed model rather than simply polling the api.


var Client = require('node-rest-client').Client;


client = new Client();

args ={
        path:{"id":120}, // will be either pending_withdrawals or deposits. later. unused right now.
        parameters:{arg1:"hello",arg2:"world"}, // query parameter substitution vars
        headers:{"Accepts":"application/json"} // request headers
      };





//use later during withdrawal testing.
//client.registerMethod("jsonMethod", "http://remote.site/rest/json/${id}/method", "GET");
client.registerMethod("jsonMethod", "http://localhost:5990/v1", "GET");

client.methods.jsonMethod(args,function(data,response){
    // parsed response body as js object
    //console.log(data);
    //data is still a string. make object.
    jsData = JSON.parse(data);
    console.log(jsData);
    console.log('---------------------\n\n');
    console.log('endpoints :', jsData.endpoints);
    console.log('data.endpoints.server_connected :', jsData.endpoints.server_connected);
});

    
    
    // raw response
    //console.log(response);

//client.get("http://remote.site/rest/json/${id}/method?arg1=hello&arg2=world", args, 
/*client.get("http://localhost:5990/v1", args, 

            function(data, response){
            // parsed response body as js object
            console.log(data);
            // raw response
            console.log(response);
});
*/
{'fraction_non_alphanumeric': 0.1525015069318867, 'fraction_numerical': 0.011754068716094032, 'mean_word_length': 3.2119289340101522, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6666410', 'n_tokens_mistral': 968, 'n_tokens_neox': 921, 'n_words': 246}