dl-opal-client
v0.0.6
Published
Dreamlab OPAL request library
Downloads
4
Keywords
Readme
Example usage.
var dlOpalClient = require('dl-opal-client');
// ------------------------------------------------------------------
// Example use
//
dlOpalClient.call({
identity: 'test.onetapi.pl', // (optional) - override application identity
interface: 'api.ucs.onetapi.pl', // OPAL interface
method: 'getPublicationPackageByUuid', // OPAL method
params: { // JSON-RPC params
"uuid":"5fc2bf98-2225-5489-9182-79727d26dcea"
},
options: { // (optional) - options for underlying request library
'headers':{ // how to inject header
'x-accelerator':'afterburner'
},
endpoint: { // override opal gateway, if so, all fields required
'host':'onetapi.pl', //
'port': 80, //
'https': false
},
timeout: 1000 // override timeout to 1000 ms
}
}, function(error, data) {
console.log('==> Error:', error, 'data:', data);
}
);
// ------------------------------------------------------------------
// Example #2
//
dlOpalClient.call({
interface: 'api.ucs.onetapi.pl', // OPAL interface
method: 'getPublicationPackageByUuid', // OPAL method
params: { // JSON-RPC params
"uuid":"5fc2bf98-2225-5489-9182-79727d26dcea"
},
options: { // OPTIONAL - options for underlying request library
endpoint: { // override opal gateway
'host':'onetapi.pl',
'port': 443,
'https': true
},
rejectUnauthorized: false // required in case of self-signed certs
}
}, function(error, data) {
console.log('==> Error:', error, 'data:', data);
}
);
// ------------------------------------------------------------------
// Example #3 - REST/HTTP request
dlOpalClient.sendHTTP({
interface: 'somerest.onetapi.pl', // OPAL interface
uri: '/getCustomers',
method: 'POST', // HTTP method
payload: 'Hello http world!', // HTTP payload
options: { // OPTIONAL - options for underlying request library
endpoint: { // override opal gateway
'host':'localhost',
'port': 80,
'https': false
},
rejectUnauthorized: false // required in case of self-signed certs
}
}, function(error, data) {
console.log('==> Error:', error, 'data:', data);
}
);