Skip to content

Commit

Permalink
version 1.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanxueqi committed May 13, 2020
1 parent 996cc01 commit 3c09ca2
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define CURRENT_VERSION 1.0.14
#define CURRENT_VERSION 1.0.15
18 changes: 18 additions & 0 deletions include/Huobi/QuerySubUserDepositRequest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Created by 袁雪琪 on 2020/5/13.
//
#ifndef HUOBICLIENT_QUERYSUBUSERDEPOSITREQUEST_H
#define HUOBICLIENT_QUERYSUBUSERDEPOSITREQUEST_H

#include <cstring>

struct QuerySubUserDepositRequest {
long subUid;
std::string currency;
long startTime;
long endTime;
std::string sort;
int limit;
long fromId;
};
#endif //HUOBICLIENT_QUERYSUBUSERDEPOSITREQUEST_H
6 changes: 6 additions & 0 deletions include/Huobi/RequestClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -511,6 +513,10 @@ namespace Huobi {

virtual std::vector<AccountLedger> getAccountLedger(AccountLedgerRequest& accountLedgerRequest) = 0;

virtual std::vector<DepositAddress> getSubUserDepositAddress(long subUid, const char *currency) = 0;

virtual std::vector<Deposit> querySubUserDeposit(QuerySubUserDepositRequest &request) = 0;


};

Expand Down
67 changes: 64 additions & 3 deletions src/RestApiImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,9 +1795,70 @@ namespace Huobi {
return res;
}

template <typename T>
RestApi<T>* RestApiImpl::createRequestByPostWithSignature(const char* adress, UrlParamsBuilder& builder) {
RestApi<T>* res = new RestApi<T>;
RestApi<std::vector<DepositAddress>> *RestApiImpl::getSubUserDepositAddress(long subUid, const char *currency) {
UrlParamsBuilder builder;
builder.putUrl("currency", currency)
.putUrl("subUid", subUid);

auto res = createRequestByGetWithSignature<std::vector<DepositAddress >>("/v2/sub-user/deposit-address",
builder);

res->jsonParser = [this](const JsonWrapper &json) {
JsonWrapper data = json.getJsonObjectOrArray("data");
std::vector<DepositAddress> 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<std::vector<Deposit>> *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<std::vector<Deposit >>("/v2/sub-user/query-deposit", builder);
res->jsonParser = [this](const JsonWrapper &json) {
std::vector<Deposit> 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<typename T>
RestApi<T> *RestApiImpl::createRequestByPostWithSignature(const char *adress, UrlParamsBuilder &builder) {
RestApi<T> *res = new RestApi<T>;
res->method = "POST";
std::string temp = adress;
temp += "?";
Expand Down
5 changes: 5 additions & 0 deletions src/RestApiImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <string>
#include <vector>
#include <Huobi/QuerySubUserDepositRequest.h>

#include "RestApi.h"
#include "AccountsInfoMap.h"
Expand Down Expand Up @@ -210,6 +211,10 @@ namespace Huobi {
RestApi<std::vector<Ticker>>*getMarketTickers();
RestApi<std::vector<AccountLedger>>*getAccountLedger(AccountLedgerRequest& accountLedgerRequest);

RestApi<std::vector<DepositAddress>> *getSubUserDepositAddress(long subUid, const char *currency);

RestApi<std::vector<Deposit>> *querySubUserDeposit(QuerySubUserDepositRequest &request);

};
}
#endif /* RESTAPIIMPL_H */
8 changes: 8 additions & 0 deletions src/SyncClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,14 @@ namespace Huobi {
return RestApiInvoke::callSync(impl->getAccountLedger(accountLedgerRequest));
}

std::vector<DepositAddress> SyncClientImpl::getSubUserDepositAddress(long subUid, const char *currency) {
return RestApiInvoke::callSync(impl->getSubUserDepositAddress(subUid, currency));
}

std::vector<Deposit> SyncClientImpl::querySubUserDeposit(QuerySubUserDepositRequest &request) {
return RestApiInvoke::callSync(impl->querySubUserDeposit(request));

}


}
9 changes: 8 additions & 1 deletion src/SyncClientImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,15 @@ namespace Huobi {
std::vector<MarginLoanInfo> getLoanInfo();
std::vector<CrossMarginLoanInfo> getCrossMarginLoanInfo();
std::string getSystemStatus();

std::vector<Ticker> getMarketTickers();
std::vector<AccountLedger> getAccountLedger(AccountLedgerRequest& accountLedgerRequest);

std::vector<AccountLedger> getAccountLedger(AccountLedgerRequest &accountLedgerRequest);

std::vector<DepositAddress> getSubUserDepositAddress(long subUid, const char *currency);

std::vector<Deposit> querySubUserDeposit(QuerySubUserDepositRequest &request);

};
}

Expand Down

0 comments on commit 3c09ca2

Please sign in to comment.