mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
add tag task and varioius cleanup
This commit is contained in:
@@ -4,26 +4,25 @@ const makeTask = require('../tasks/make_task');
|
||||
const normalizeJamones = require('./normalize-jamones');
|
||||
|
||||
|
||||
function retrieveUrl(logger, url, method, auth, qs, body) {
|
||||
logger.debug(`body: ${body}`);
|
||||
const opts = {url, method, auth, qs, json: true};
|
||||
if (body) {
|
||||
logger.debug('adding body');
|
||||
Object.assign(opts, {body});
|
||||
}
|
||||
function retrieveUrl(logger, url, method, auth, obj) {
|
||||
const opts = {url, method, auth, json: true};
|
||||
if (method === 'GET') Object.assign(opts, {qs: obj});
|
||||
else Object.assign(opts, {body: obj});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
request(opts, (err, response, body) => {
|
||||
if (err) throw err;
|
||||
if (body) logger.debug({body}, 'retrieveUrl: customer returned an application');
|
||||
resolve(body);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function retrieveApp(logger, url, method, auth, qs, body) {
|
||||
async function retrieveApp(logger, url, method, auth, obj) {
|
||||
let json;
|
||||
|
||||
if (typeof url === 'object') json = url;
|
||||
else json = await retrieveUrl(logger, url, method, auth, qs, body);
|
||||
else json = await retrieveUrl(logger, url, method, auth, obj);
|
||||
return normalizeJamones(logger, json).map((tdata) => makeTask(logger, tdata));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user