-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmicroWorker.js
More file actions
50 lines (43 loc) · 1.07 KB
/
Copy pathmicroWorker.js
File metadata and controls
50 lines (43 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
var self = microWorker;
module.exports = self;
var request = require('request');
var adapter = require('./_common/shippable/Adapter.js');
function microWorker() {
var bag = {
shippableAdapter: new adapter(config.apiToken),
who: util.format('bat|%s ', self.name)
};
logger.info(bag.who, 'Inside');
async.series([
_getAccounts.bind(null, bag)
],
function (err) {
if (err) {
logger.warn(bag.who, 'Failed');
}
else {
logger.verbose(bag.accounts);
logger.info(bag.who, 'Completed');
}
}
);
}
function _getAccounts(bag, next) {
var who = bag.who + '|' + _getAccounts.name;
logger.verbose(who, 'Inside');
bag.shippableAdapter.getAccounts('',
function (err, accounts) {
if (err) {
logger.warn(who, util.format('Failed to get accounts'), err);
return next(true);
}
if (_.isEmpty(accounts)) {
logger.warn(who, util.format('No accounts found'));
return next(true);
}
bag.accounts = accounts;
return next();
}
);
}