This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (62 loc) · 1.89 KB
/
index.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Jaired Jawed ([email protected])
* Sep 22, 2018
* Azlo API Wrapper v0.12
*/
var request = require('request');
var baseURL = 'https://developer-api.azlo.com/v1';
/**
*
* @summary Azlo Api Wrapper
* @param {String} apiKey The Api Key of the user
*/
module.exports = function (apiKey) {
var baseRequest = {
method: 'GET',
json: true,
headers: {
Authorization: apiKey,
},
};
return {
accounts: {
list: function (queryParams, callback = null) {
baseRequest.url = `${baseURL}/accounts?unmask=${queryParams.unmask}`;
var getAccounts = function(resolve, reject) {
request(baseRequest, function (error, response, body) {
if (error) {
reject(error);
} else {
resolve(body);
}
});
};
return callback && typeof callback === 'function' ?
getAccounts(callback.bind(null, undefined), callback) : new Promise(getAccounts);
},
},
tranactions: {
list: function (accountId, queryParams, callback = null) {
baseRequest.url = `${baseURL}/accounts/${accountId}/transactions
?posted_date_from=${queryParams.postedDateFrom}
&posted_date_to=${queryParams.postedDateTo}
&amount_from=${queryParams.amountFrom}
&amount_to=${queryParams.amountTo}
&start=${queryParams.start}
&limit${queryParams.limit}
`;
var getAccountTransactions = function(resolve, reject) {
request(baseRequest, function(error, response, body) {
if (error) {
reject(error);
} else {
resolve(body);
}
});
};
return callback && typeof callback === 'function' ?
getAccountTransactions(callback.bind(null, undefined), callback) : new Promise(getAccountTransactions);
},
},
};
};