Skip to content

Commit edb36da

Browse files
author
T. Ismael Verdugo
committed
feat: adds endpoint fees hash
1 parent 0c1667e commit edb36da

File tree

3 files changed

+53
-21
lines changed

3 files changed

+53
-21
lines changed

src/main/java/com/cryptomarket/sdk/rest/CryptomarketRestClient.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,21 @@ public String getEstimateWithdrawalFee(String currency, String amount, @Nullable
14011401
*/
14021402
public List<Fee> getBulkEstimateWithdrawalFees(List<FeeRequest> feeRequests) throws CryptomarketSDKException;
14031403

1404+
1405+
/**
1406+
* Gets the hash of withdrawal fees
1407+
* <p>
1408+
* Requires the "Payment information" API key Access Right
1409+
* <p>
1410+
* https://api.exchange.cryptomkt.com/#get-withdrawal-fees-hash
1411+
*
1412+
* @return the fees hash
1413+
* @throws CryptomarketSDKException
1414+
*/
1415+
public String getFeesHash() throws CryptomarketSDKException;
1416+
1417+
1418+
14041419
/**
14051420
* Get an estimate of the deposit fee
14061421
* <p>

src/main/java/com/cryptomarket/sdk/rest/CryptomarketRestClientImpl.java

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
import com.cryptomarket.sdk.requests.OrderListRequest;
5555
import com.cryptomarket.sdk.requests.WithdrawRequest;
5656

57+
import kotlin.OverloadResolutionByLambdaReturnType;
58+
5759
public class CryptomarketRestClientImpl implements CryptomarketRestClient {
5860
CloseableHttpClient httpClient;
5961
Adapter adapter = new Adapter();
@@ -912,7 +914,6 @@ public List<Fee> getEstimateWithdrawalFees(List<FeeRequest> feeRequests) throws
912914
return adapter.listFromJson(jsonResponse, Fee.class);
913915
}
914916

915-
916917
@Override
917918
public List<Fee> getBulkEstimateWithdrawalFees(List<FeeRequest> feeRequests) throws CryptomarketSDKException {
918919
var payload = adapter.listToJson(feeRequests, FeeRequest.class);
@@ -922,33 +923,42 @@ public List<Fee> getBulkEstimateWithdrawalFees(List<FeeRequest> feeRequests) thr
922923
return adapter.listFromJson(jsonResponse, Fee.class);
923924
}
924925

926+
@OverloadResolutionByLambdaReturnType
927+
public String getFeesHash() throws CryptomarketSDKException {
928+
String jsonResponse = httpClient.get("wallet/crypto/fee/withdraw/hash", null);
929+
return adapter.objectFromJsonValue(jsonResponse, "hash", String.class);
930+
}
931+
925932
// @Override
926-
// public String getEstimateDepositFee(String currency, String amount, String networkCode)
927-
// throws CryptomarketSDKException {
928-
// return getEstimateDepositFee(new ParamsBuilder()
929-
// .currency(currency)
930-
// .networkCode(networkCode)
931-
// .amount(amount));
933+
// public String getEstimateDepositFee(String currency, String amount, String
934+
// networkCode)
935+
// throws CryptomarketSDKException {
936+
// return getEstimateDepositFee(new ParamsBuilder()
937+
// .currency(currency)
938+
// .networkCode(networkCode)
939+
// .amount(amount));
932940
// }
933941

934942
// @Override
935-
// public String getEstimateDepositFee(ParamsBuilder paramsBuilder) throws CryptomarketSDKException {
936-
// paramsBuilder.checkRequired(Arrays.asList(
937-
// ArgNames.CURRENCY,
938-
// ArgNames.AMOUNT));
939-
// String jsonResponse = httpClient.get(
940-
// "wallet/crypto/fee/deposit/estimate",
941-
// paramsBuilder.build());
942-
// return adapter.objectFromJsonValue(jsonResponse, "fee", String.class);
943+
// public String getEstimateDepositFee(ParamsBuilder paramsBuilder) throws
944+
// CryptomarketSDKException {
945+
// paramsBuilder.checkRequired(Arrays.asList(
946+
// ArgNames.CURRENCY,
947+
// ArgNames.AMOUNT));
948+
// String jsonResponse = httpClient.get(
949+
// "wallet/crypto/fee/deposit/estimate",
950+
// paramsBuilder.build());
951+
// return adapter.objectFromJsonValue(jsonResponse, "fee", String.class);
943952
// }
944953

945954
// @Override
946-
// public List<Fee> getBulkEstimateDepositFees(List<FeeRequest> feeRequests) throws CryptomarketSDKException {
947-
// var payload = adapter.listToJson(feeRequests, FeeRequest.class);
948-
// String jsonResponse = httpClient.post(
949-
// "wallet/crypto/fee/deposit/estimate/bulk",
950-
// payload);
951-
// return adapter.listFromJson(jsonResponse, Fee.class);
955+
// public List<Fee> getBulkEstimateDepositFees(List<FeeRequest> feeRequests)
956+
// throws CryptomarketSDKException {
957+
// var payload = adapter.listToJson(feeRequests, FeeRequest.class);
958+
// String jsonResponse = httpClient.post(
959+
// "wallet/crypto/fee/deposit/estimate/bulk",
960+
// payload);
961+
// return adapter.listFromJson(jsonResponse, Fee.class);
952962
// }
953963

954964
@Override

src/test/java/com/cryptomarket/sdk/TestRestClientWalletManagement.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ public void testGetEstimateWithdrawFee() throws CryptomarketSDKException {
142142
fail();
143143
}
144144
}
145+
@Test
146+
public void testGetEstimateWithdrawFeesHash() throws CryptomarketSDKException {
147+
String estimate = client.getFeesHash();
148+
if (estimate.equals("")) {
149+
fail();
150+
}
151+
}
145152

146153
// @Test
147154
// public void testGetEstimateDepositFees() throws CryptomarketSDKException {

0 commit comments

Comments
 (0)