diff --git a/config.h b/config.h index 7ad336d..7eb5478 100644 --- a/config.h +++ b/config.h @@ -1 +1 @@ -#define CURRENT_VERSION 1.0.14 +#define CURRENT_VERSION 1.0.15 diff --git a/include/Huobi/QuerySubUserDepositRequest.h b/include/Huobi/QuerySubUserDepositRequest.h new file mode 100644 index 0000000..4d9f013 --- /dev/null +++ b/include/Huobi/QuerySubUserDepositRequest.h @@ -0,0 +1,18 @@ +// +// Created by 袁雪琪 on 2020/5/13. +// +#ifndef HUOBICLIENT_QUERYSUBUSERDEPOSITREQUEST_H +#define HUOBICLIENT_QUERYSUBUSERDEPOSITREQUEST_H + +#include + +struct QuerySubUserDepositRequest { + long subUid; + std::string currency; + long startTime; + long endTime; + std::string sort; + int limit; + long fromId; +}; +#endif //HUOBICLIENT_QUERYSUBUSERDEPOSITREQUEST_H diff --git a/include/Huobi/RequestClient.h b/include/Huobi/RequestClient.h index 84ff0f8..01bb454 100644 --- a/include/Huobi/RequestClient.h +++ b/include/Huobi/RequestClient.h @@ -62,6 +62,8 @@ #include "Huobi/Ticker.h" #include "Huobi/AccountLedger.h" #include "Huobi/AccountLedgerRequest.h" +#include "Huobi/QuerySubUserDepositRequest.h" + #include "RequestOptions.h" namespace Huobi { @@ -511,6 +513,10 @@ namespace Huobi { virtual std::vector getAccountLedger(AccountLedgerRequest& accountLedgerRequest) = 0; + virtual std::vector getSubUserDepositAddress(long subUid, const char *currency) = 0; + + virtual std::vector querySubUserDeposit(QuerySubUserDepositRequest &request) = 0; + }; diff --git a/src/RestApiImpl.cpp b/src/RestApiImpl.cpp index dc0fc13..297b24d 100644 --- a/src/RestApiImpl.cpp +++ b/src/RestApiImpl.cpp @@ -1795,9 +1795,70 @@ namespace Huobi { return res; } - template - RestApi* RestApiImpl::createRequestByPostWithSignature(const char* adress, UrlParamsBuilder& builder) { - RestApi* res = new RestApi; + RestApi> *RestApiImpl::getSubUserDepositAddress(long subUid, const char *currency) { + UrlParamsBuilder builder; + builder.putUrl("currency", currency) + .putUrl("subUid", subUid); + + auto res = createRequestByGetWithSignature>("/v2/sub-user/deposit-address", + builder); + + res->jsonParser = [this](const JsonWrapper &json) { + JsonWrapper data = json.getJsonObjectOrArray("data"); + std::vector depositAddressVec; + for (int i = 0; i < data.size(); i++) { + JsonWrapper item = data.getJsonObjectAt(i); + DepositAddress depositAddress; + depositAddress.address = item.getString("address"); + depositAddress.addressTag = item.getString("addressTag"); + depositAddress.chain = item.getString("chain"); + depositAddress.currency = item.getString("currency"); + depositAddressVec.push_back(depositAddress); + } + return depositAddressVec; + }; + return res; + } + + + RestApi> *RestApiImpl::querySubUserDeposit(QuerySubUserDepositRequest &request) { + UrlParamsBuilder builder; + builder.putUrl("currency", request.currency) + .putUrl("subUid", request.subUid) + .putUrl("startTime", request.startTime) + .putUrl("endTime", request.endTime) + .putUrl("sort", request.sort) + .putUrl("limit", request.limit) + .putUrl("fromId", request.fromId); + auto res = createRequestByGetWithSignature>("/v2/sub-user/query-deposit", builder); + res->jsonParser = [this](const JsonWrapper &json) { + std::vector lstdeposit; + JsonWrapper data = json.getJsonObjectOrArray("data"); + for (int i = 0; i < data.size(); i++) { + JsonWrapper item = data.getJsonObjectAt(i); + Deposit deposit; + deposit.id = item.getLong("id"); + deposit.currency = item.getString("currency"); + deposit.txHash = item.getString("txHash"); + deposit.amount = item.getDecimal("amount"); + deposit.address = item.getString("address"); + deposit.addressTag = item.getString("addressTag"); + deposit.depositState = DepositState::lookup(item.getString("state")); + deposit.createdTimestamp = item.getLong("createdTime"); + deposit.updatedTimestamp = item.getLong("updatedTime"); + deposit.chain = item.getString("chain"); + lstdeposit.push_back(deposit); + } + return lstdeposit; + }; + + return res; + } + + + template + RestApi *RestApiImpl::createRequestByPostWithSignature(const char *adress, UrlParamsBuilder &builder) { + RestApi *res = new RestApi; res->method = "POST"; std::string temp = adress; temp += "?"; diff --git a/src/RestApiImpl.h b/src/RestApiImpl.h index e93ee6c..9f4427d 100644 --- a/src/RestApiImpl.h +++ b/src/RestApiImpl.h @@ -3,6 +3,7 @@ #include #include +#include #include "RestApi.h" #include "AccountsInfoMap.h" @@ -210,6 +211,10 @@ namespace Huobi { RestApi>*getMarketTickers(); RestApi>*getAccountLedger(AccountLedgerRequest& accountLedgerRequest); + RestApi> *getSubUserDepositAddress(long subUid, const char *currency); + + RestApi> *querySubUserDeposit(QuerySubUserDepositRequest &request); + }; } #endif /* RESTAPIIMPL_H */ diff --git a/src/SyncClientImpl.cpp b/src/SyncClientImpl.cpp index 209e06f..554147f 100644 --- a/src/SyncClientImpl.cpp +++ b/src/SyncClientImpl.cpp @@ -367,6 +367,14 @@ namespace Huobi { return RestApiInvoke::callSync(impl->getAccountLedger(accountLedgerRequest)); } + std::vector SyncClientImpl::getSubUserDepositAddress(long subUid, const char *currency) { + return RestApiInvoke::callSync(impl->getSubUserDepositAddress(subUid, currency)); + } + + std::vector SyncClientImpl::querySubUserDeposit(QuerySubUserDepositRequest &request) { + return RestApiInvoke::callSync(impl->querySubUserDeposit(request)); + + } } \ No newline at end of file diff --git a/src/SyncClientImpl.h b/src/SyncClientImpl.h index 424f688..c26a5da 100644 --- a/src/SyncClientImpl.h +++ b/src/SyncClientImpl.h @@ -88,8 +88,15 @@ namespace Huobi { std::vector getLoanInfo(); std::vector getCrossMarginLoanInfo(); std::string getSystemStatus(); + std::vector getMarketTickers(); - std::vector getAccountLedger(AccountLedgerRequest& accountLedgerRequest); + + std::vector getAccountLedger(AccountLedgerRequest &accountLedgerRequest); + + std::vector getSubUserDepositAddress(long subUid, const char *currency); + + std::vector querySubUserDeposit(QuerySubUserDepositRequest &request); + }; }