Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 11ab267

Browse files
author
kushal256
authored
Get Transfer: return real object, not a map (#10)
* Get Transfer: return real object, not a map * change return value to Optional<Transfer> * remove commented code
1 parent 7dea4bc commit 11ab267

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.bitso.bitgo.v2;
22

33
import com.bitso.bitgo.v2.entity.SendCoinsResponse;
4+
import com.bitso.bitgo.v2.entity.Transfer;
45
import com.bitso.bitgo.v2.entity.Wallet;
56
import com.bitso.bitgo.v2.entity.WalletTransferResponse;
67

@@ -66,11 +67,11 @@ Optional<SendCoinsResponse> sendMany(String coin, String walletId, String wallet
6667
*
6768
* @param coin
6869
* @param walletId
69-
* @param walletTransferId
70+
* @param txid
7071
* @return
7172
* @throws IOException
7273
*/
73-
Optional<Map<String, Object>> getWalletTransferId(String coin, String walletId, String walletTransferId) throws IOException;
74+
Optional<Transfer> getWalletTransferId(String coin, String walletId, String txid) throws IOException;
7475

7576
/**
7677
* See https://www.bitgo.com/api/v2/?shell#get-wallet-transfer-by-sequence-id

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.bitso.bitgo.util.SerializationUtil;
55
import com.bitso.bitgo.v2.entity.ListWalletResponse;
66
import com.bitso.bitgo.v2.entity.SendCoinsResponse;
7+
import com.bitso.bitgo.v2.entity.Transfer;
78
import com.bitso.bitgo.v2.entity.Wallet;
89
import com.bitso.bitgo.v2.entity.WalletTransferResponse;
910
import com.fasterxml.jackson.core.type.TypeReference;
@@ -217,11 +218,10 @@ public Optional<Map<String, Object>> getCurrentUserProfile() throws IOException
217218
}
218219

219220
@Override
220-
public Optional<Map<String, Object>> getWalletTransferId(String coin, String walletId, String walletTransferId) throws IOException {
221-
String url = baseUrl + GET_WALLET_TRANSFER_URL.replace("$COIN", coin).replace("$WALLET", walletId).replace("$TRANSFER", walletTransferId);
221+
public Optional<Transfer> getWalletTransferId(String coin, String walletId, String txid) throws IOException {
222+
String url = baseUrl + GET_WALLET_TRANSFER_URL.replace("$COIN", coin).replace("$WALLET", walletId).replace("$TRANSFER", txid);
222223
HttpURLConnection conn = httpGet(url);
223-
Map<String, Object> resp = SerializationUtil.mapper.readValue(conn.getInputStream(), new TypeReference<Map<String, Object>>() {
224-
});
224+
Transfer resp = SerializationUtil.mapper.readValue(conn.getInputStream(), Transfer.class);
225225
log.trace("getWalletTransferId response: {}", resp);
226226
return Optional.of(resp);
227227
}
@@ -261,6 +261,8 @@ public WalletTransferResponse listWalletTransfers(String coin, String walletId,
261261
return resp;
262262
}
263263

264+
265+
264266
@Override
265267
public int unlock(String otp, Long durationSecs) throws IOException {
266268
String url = baseUrl + UNLOCK_URL;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.bitso.bitgo.v2.BitGoClient;
44
import com.bitso.bitgo.v2.BitGoClientImpl;
55
import com.bitso.bitgo.v2.entity.SendCoinsResponse;
6+
import com.bitso.bitgo.v2.entity.Transfer;
67
import com.bitso.bitgo.v2.entity.Wallet;
78
import com.bitso.bitgo.v2.entity.WalletTransferResponse;
89
import lombok.extern.slf4j.Slf4j;
@@ -134,7 +135,12 @@ public void listWalletTransfers() throws IOException {
134135
// resp.getTransfers().remove(0);
135136
// }
136137
System.out.println("resp json = " + SerializationUtil.mapper.writeValueAsString(resp));
138+
}
137139

138-
140+
@Test
141+
public void getWalletTransfers() throws IOException {
142+
final Optional<Transfer> resp = client.getWalletTransferId(COIN, WALLET_ID, "cdaa330f5717556d873506ee5bb283b3703f9b2a73899577ce3530ae2c75e0ea");
143+
System.out.println("resp = " + resp.get());
144+
System.out.println("resp json = " + SerializationUtil.mapper.writeValueAsString(resp.get()));
139145
}
140146
}

0 commit comments

Comments
 (0)