@@ -48,7 +48,7 @@ app.post(
48
48
}
49
49
50
50
try {
51
- const accounts = await getAccounts ( accessKey , null , null , true ) ;
51
+ const accounts = await getAccounts ( accessKey , null , null , null , true ) ;
52
52
53
53
res . send ( {
54
54
status : 'ok' ,
@@ -91,7 +91,11 @@ app.post(
91
91
: startDate ;
92
92
let results ;
93
93
try {
94
- results = await getTransactions ( accessKey , new Date ( earliestStartDate ) ) ;
94
+ results = await getTransactions (
95
+ accessKey ,
96
+ Array . isArray ( accountId ) ? accountId : [ accountId ] ,
97
+ new Date ( earliestStartDate ) ,
98
+ ) ;
95
99
} catch ( e ) {
96
100
if ( e . message === 'Forbidden' ) {
97
101
invalidToken ( res ) ;
@@ -293,12 +297,12 @@ async function getAccessKey(base64Token) {
293
297
} ) ;
294
298
}
295
299
296
- async function getTransactions ( accessKey , startDate , endDate ) {
300
+ async function getTransactions ( accessKey , accounts , startDate , endDate ) {
297
301
const now = new Date ( ) ;
298
302
startDate = startDate || new Date ( now . getFullYear ( ) , now . getMonth ( ) , 1 ) ;
299
303
endDate = endDate || new Date ( now . getFullYear ( ) , now . getMonth ( ) + 1 , 1 ) ;
300
304
console . log ( `${ getDate ( startDate ) } - ${ getDate ( endDate ) } ` ) ;
301
- return await getAccounts ( accessKey , startDate , endDate ) ;
305
+ return await getAccounts ( accessKey , accounts , startDate , endDate ) ;
302
306
}
303
307
304
308
function getDate ( date ) {
@@ -311,6 +315,7 @@ function normalizeDate(date) {
311
315
312
316
async function getAccounts (
313
317
accessKey ,
318
+ accounts ,
314
319
startDate ,
315
320
endDate ,
316
321
noTransactions = false ,
@@ -337,6 +342,12 @@ async function getAccounts(
337
342
params . push ( `balances-only=1` ) ;
338
343
}
339
344
345
+ if ( accounts ) {
346
+ accounts . forEach ( ( id ) => {
347
+ params . push ( `account=${ encodeURIComponent ( id ) } ` ) ;
348
+ } ) ;
349
+ }
350
+
340
351
let queryString = '' ;
341
352
if ( params . length > 0 ) {
342
353
queryString += '?' + params . join ( '&' ) ;
0 commit comments