Commit bb3c7441 authored by Ozoux's avatar Ozoux

First commit

parents
var url_invoice = "https://invoice.indie.host/"
var token = ""
var Rest = require('node-rest-client').Client;
var rest = new Rest();
var clients, invoices;
var args = {
parameters: {
per_page: 500,
page: 7
},
headers: {
"X-Ninja-Token": token,
"X-Requested-With": "XMLHttpRequest"
}
};
var client_name = function(client) {
if ( client.name) {
return client.name;
} else {
return client.contacts[0].first_name + ' ' + client.contacts[0].last_name
}
}
var client = function(clients, invoice) {
return clients.find(function(client) {
return client.id === invoice.client_id;
})
}
rest.registerMethod("clients", url_invoice + "api/v1/clients", "GET");
rest.methods.clients(args, function (data, response) {
pages = data.meta.pagination.total_pages;
for (var page = 1; page <= pages; page++) {
var args_page = {
parameters: {
per_page: 500,
page: page
},
headers: {
"X-Ninja-Token": token,
"X-Requested-With": "XMLHttpRequest"
}
};
rest.methods.clients(args_page, function (data, response) {
clients = data.data;
domains = clients.map(function(client) {
if (client.custom_value1 != null) {
return client.custom_value1;
}
}).filter(function(domain) {
if(typeof domain==='string'){
return domain;
}
});
domains.forEach(function(domain) {
console.log(domain);
});
//console.log(clients.length + ' clients to manage');
});
}
});
{
"name": "check-billing-compliance",
"version": "1.0.0",
"description": "check-billing-compliance",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://git.indie.host/meta/check-billing-compliance.git"
},
"keywords": [
"financas",
"IVA",
"IRS"
],
"author": "Pierre Ozoux",
"license": "GPL-3.0",
"dependencies": {
"node-rest-client": "^2.0.1",
"request": "^2.78.0",
}
}
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