Skip to content

Commit fe29bb7

Browse files
author
kushal
committed
Add optional params for list transfers api
1 parent cdc56b9 commit fe29bb7

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

bitgo-java-api/src/main/java/com/bitso/bitgo/v2/BitGoClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Optional<SendCoinsResponse> sendMany(String coin, String walletId, String wallet
8383
Optional<Map<String, Object>> getWalletTransferSeqId(String coin, String walletId, String sequenceId) throws IOException;
8484

8585
/**
86-
* See https://www.bitgo.com/api/v2/#list-wallet-transactions
86+
* See https://www.bitgo.com/api/v2/#operation/v2.wallet.listtransfers
8787
*
8888
* @param coin
8989
* @param walletId
@@ -92,7 +92,7 @@ Optional<SendCoinsResponse> sendMany(String coin, String walletId, String wallet
9292
* @return
9393
* @throws IOException
9494
*/
95-
WalletTransferResponse listWalletTransfers(String coin, String walletId, String nextBatchPrevId, int limit) throws IOException;
95+
WalletTransferResponse listWalletTransfers(String coin, String walletId, String nextBatchPrevId, int limit, Map<String, Object> optionalParameters) throws IOException;
9696

9797
/**
9898
* See https://www.bitgo.com/api/v2/?shell#unlock

bitgo-java-api/src/main/java/com/bitso/bitgo/v2/BitGoClientImpl.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,23 @@ public Optional<Map<String, Object>> getWalletTransferSeqId(String coin, String
238238
}
239239

240240
@Override
241-
public WalletTransferResponse listWalletTransfers(String coin, String walletId, String prevId, int limit) throws IOException {
241+
public WalletTransferResponse listWalletTransfers(String coin, String walletId, String prevId, int limit, Map<String, Object> optionalParameters) throws IOException {
242242
if (limit > 250) limit = 250;
243243
if (limit < 0) limit = 0;
244244
String url = baseUrl + LIST_WALLET_TRANSFER_URL.replace("$COIN", coin).replace("$WALLET", walletId) + "?limit=" + limit;
245245

246-
Map<String, String> reqPropMap = null;
246+
Map<String, String> props = null;
247247
if (prevId != null) {
248-
reqPropMap = new HashMap<>();
249-
reqPropMap.put("prevId", prevId);
248+
props = new HashMap<>();
249+
props.put("prevId", prevId);
250250
}
251-
HttpURLConnection conn = httpGetRetry500(url, reqPropMap);
251+
if (optionalParameters != null && optionalParameters.size() > 0) {
252+
if (props == null) props = new HashMap<>();
253+
for (final Map.Entry<String, Object> entry : optionalParameters.entrySet()) {
254+
props.put(entry.getKey(), entry.getValue().toString());
255+
}
256+
}
257+
HttpURLConnection conn = httpGetRetry500(url, props);
252258

253259
final WalletTransferResponse resp = SerializationUtil.mapper.readValue(conn.getInputStream(), WalletTransferResponse.class);
254260
log.trace("listWalletTransactions response: {}", resp);

bitgo-java-api/src/test/java/com/bitso/bitgo/util/TestClientV2.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
/**
2424
* Simple client tests.
2525
*
26+
* docker run -it -p 3080:3080 bitgosdk/express:latest
27+
*
2628
* @author Enrique Zamudio
2729
* Date: 5/8/17 8:04 PM
2830
*/
@@ -124,9 +126,9 @@ public void currentUserProfile() throws IOException {
124126

125127
@Test
126128
public void listWalletTransfers() throws IOException {
127-
final WalletTransferResponse resp = client.listWalletTransfers(COIN, WALLET_ID, null, 250);
129+
final WalletTransferResponse resp = client.listWalletTransfers(COIN, WALLET_ID, null, 250, Map.of("dateGte", 1536189990165L));
128130
System.out.println("list.size() = " + resp.getTransfers().size());
129-
assertTrue(resp.getTransfers().size() > 10);
131+
assertTrue(resp.getTransfers().size() == 3);
130132
// System.out.println(resp);
131133
// for (int i = 0; i < 30; i++) {
132134
// resp.getTransfers().remove(0);

0 commit comments

Comments
 (0)