Created
December 18, 2014 18:01
-
-
Save bsingr/843716a06f04869f73aa to your computer and use it in GitHub Desktop.
hibiscus xmlrpc nodejs client example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// call the hibiscus xml rpc from nodejs | |
// see http://www.willuhn.de/wiki/doku.php?id=develop:xmlrpc#xml-rpc-aufrufe_im_detail | |
// install: | |
// npm install --save xmlrpc underscore | |
// run: | |
// node client-example.js | |
var xmlrpc = require('xmlrpc'), | |
_ = require('underscore'), | |
defaultOptions = { | |
host: 'localhost', | |
port: 8080, | |
rejectUnauthorized: false, // skip ssl cert verify | |
auth: 'myuser:mypass' // your hibiscus credentials | |
}; | |
function createSecureClient(customOptions) { | |
return xmlrpc.createSecureClient(_.extend(defaultOptions, customOptions)); | |
} | |
function Account() { | |
var client = createSecureClient({ path: '/xmlrpc/hibiscus.xmlrpc.konto' }); | |
this.find = function(callback) { | |
client.methodCall('hibiscus.xmlrpc.konto.find', [], callback); | |
} | |
return this; | |
} | |
function Turnover() { | |
var client = createSecureClient({ path: '/xmlrpc/hibiscus.xmlrpc.umsatz' }); | |
this.list = function(params, callback) { | |
client.methodCall('hibiscus.xmlrpc.umsatz.list', [params], callback); | |
} | |
return this; | |
} | |
Account().find(function(error, value) { | |
console.log(error); | |
console.log(value); | |
}); | |
Turnover().list({ | |
"datum:min": "01.01.2010", | |
"datum:max": "01.12.2014"}, function (error, value) { | |
console.log(error); | |
console.log(value); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment