Skip to content

Commit

Permalink
Update based on API update in April 2020
Browse files Browse the repository at this point in the history
  • Loading branch information
eynzhang committed May 11, 2020
1 parent bcc302c commit ee97bde
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Huobi.SDK.Core.Test/Huobi.SDK.Core.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>2.0.0</ReleaseVersion>
<ReleaseVersion>2.2.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
29 changes: 29 additions & 0 deletions Huobi.SDK.Core/Client/WalletClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ public async Task<GetDepositAddressResponse> GetDepositAddressAsync(GetRequest r
return await HttpRequest.GetAsync<GetDepositAddressResponse>(url);
}

/// <summary>
/// Parent user get sub user deposit address of corresponding chain, for a specific crypto currency (except IOTA)
/// </summary>
/// <param name="subUserId">Sub user id</param>
/// <param name="currency">Crytpo currency</param>
/// <returns>GetDepositAddressResponse</returns>
public async Task<GetDepositAddressResponse> GetSubUserDepositAddressAsync(string subUserId, string currency)
{
GetRequest request = new GetRequest()
.AddParam("subUid", subUserId)
.AddParam("currency", currency);

string url = _urlBuilder.Build(GET_METHOD, "/v2/sub-user/deposit-address", request);

return await HttpRequest.GetAsync<GetDepositAddressResponse>(url);
}

/// <summary>
/// Query withdraw quota for currencies
/// </summary>
Expand Down Expand Up @@ -87,5 +104,17 @@ public async Task<GetDepositWithdrawHistoryResponse> GetDepositWithdrawHistoryAs

return await HttpRequest.GetAsync<GetDepositWithdrawHistoryResponse>(url);
}

/// <summary>
/// Parent user get sub user deposit history
/// </summary>
/// <param name="request"></param>
/// <returns>GetDepositWithdrawHistoryResponse</returns>
public async Task<GetSubUserDepositHistoryResponse> GetSubUserDepositHistoryAsync(GetRequest request)
{
string url = _urlBuilder.Build(GET_METHOD, "/v2/sub-user/query-deposit", request);

return await HttpRequest.GetAsync<GetSubUserDepositHistoryResponse>(url);
}
}
}
2 changes: 1 addition & 1 deletion Huobi.SDK.Core/Huobi.SDK.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<ReleaseVersion>2.0.0</ReleaseVersion>
<ReleaseVersion>2.2.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Huobi.SDK.Example/Huobi.SDK.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ReleaseVersion>2.0.0</ReleaseVersion>
<ReleaseVersion>2.2.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
52 changes: 51 additions & 1 deletion Huobi.SDK.Example/WalletClientExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ public static void RunAll()
{
GetDepoistAddress();

GetSubUserDepositAddress();

GetWithdrawQuota();

WithdrawCurrency();

CancelWithdrawCurrency();

GetDepositWithdrawHistory();

GetSubUserDepositHistory();
}

private static void GetDepoistAddress()
Expand All @@ -36,11 +40,36 @@ private static void GetDepoistAddress()

if (result != null && result.data != null)
{
AppLogger.Info($"Get deposit address, id={result.data.Length}");
foreach (var a in result.data)
{
AppLogger.Info($"currency: {a.currency}, addr: {a.address}, chain: {a.chain}");
}
AppLogger.Info($"There are total {result.data.Length} addresses");
}
}

private static void GetSubUserDepositAddress()
{
var walletClient = new WalletClient(Config.AccessKey, Config.SecretKey);

_logger.Start();
var result = walletClient.GetSubUserDepositAddressAsync(Config.SubUserId, "btc").Result;
_logger.StopAndLog();

if (result != null)
{
if (result.data != null)
{
AppLogger.Info($"Get sub user deposit address, id={result.data.Length}");
foreach (var a in result.data)
{
AppLogger.Info($"currency: {a.currency}, addr: {a.address}, chain: {a.chain}");
}
}
else
{
AppLogger.Error($"Get sub user deposit address error: code={result.code}, message={result.message}");
}
}
}

Expand Down Expand Up @@ -140,5 +169,26 @@ private static void GetDepositWithdrawHistory()
AppLogger.Info($"There are {result.data.Length} deposit and withdraw history");
}
}

private static void GetSubUserDepositHistory()
{
var walletClient = new WalletClient(Config.AccessKey, Config.SecretKey);

_logger.Start();
var request = new GetRequest()
.AddParam("subUid", Config.SubUserId);

var result = walletClient.GetSubUserDepositHistoryAsync(request).Result;
_logger.StopAndLog();

if (result != null && result.data != null)
{
AppLogger.Info($"Get sub user deposit history, count={result.data.Length}");
foreach (var h in result.data)
{
AppLogger.Info($"Deposit history, id={h.id}, currency={h.currency}, amount={h.amount}, address={h.address}, updatedAt={h.updateTime}");
}
}
}
}
}
2 changes: 1 addition & 1 deletion Huobi.SDK.Log/Huobi.SDK.Log.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<ReleaseVersion>2.0.0</ReleaseVersion>
<ReleaseVersion>2.2.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Huobi.SDK.Model/Huobi.SDK.Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<ReleaseVersion>2.0.0</ReleaseVersion>
<ReleaseVersion>2.2.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions Huobi.SDK.Model/Response/Wallet/GetDepositAddressResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public class GetDepositAddressResponse
/// </summary>
public int code;

/// <summary>
/// Error message (if any)
/// </summary>
public string message;

/// <summary>
/// Response body
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
namespace Huobi.SDK.Model.Response.Wallet
{
public class GetSubUserDepositHistoryResponse
{
/// <summary>
/// Status code
/// </summary>
public int code;

/// <summary>
/// Error message (if any)
/// </summary>
public string message;

/// <summary>
/// Response body
/// </summary>
public DepositHistory[] data;

/// <summary>
/// First record in next page (only valid if exceeded page size)
/// </summary>
public long nextId;

public class DepositHistory
{
/// <summary>
/// Deposit id
/// </summary>
public long id;

/// <summary>
/// Cryptocurrency
/// </summary>
public string currency;

/// <summary>
/// The on-chain transaction hash
/// </summary>
public string txHash;

/// <summary>
/// Block chain name
/// </summary>
public string chain;

/// <summary>
/// The number of crypto asset transferred
/// </summary>
public decimal amount;

/// <summary>
/// The deposit source address
/// </summary>
public string address;

/// <summary>
/// The deposit source address tag
/// </summary>
public string addressTag;

/// <summary>
/// The state of this transfer
/// Possible values: unknown, confirming, confirmed, safe, orphan
/// </summary>
public string state;

/// <summary>
/// The timestamp in milliseconds for the transfer creation
/// </summary>
public long createTime;

/// <summary>
/// The timestamp in milliseconds for the transfer's latest update
/// </summary>
public long updateTime;
}
}
}
2 changes: 1 addition & 1 deletion Huobi.SDK.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ Global
{F0292069-B195-47C1-8671-A3695FDC59EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 2.0.0
version = 2.2.0
EndGlobalSection
EndGlobal

0 comments on commit ee97bde

Please sign in to comment.