Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add agent endpoints #1450

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions Binance.Net/Binance.Net.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@
<member name="P:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApi.Trading">
<inheritdoc />
</member>
<member name="P:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApi.Agent">
<inheritdoc />
</member>
<member name="P:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApi.ExchangeName">
<inheritdoc />
</member>
Expand Down Expand Up @@ -397,6 +400,9 @@
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApiAccount.GetDownloadLinkForTradeHistoryAsync(System.String,System.Nullable{System.Int64},System.Threading.CancellationToken)">
<inheritdoc />
</member>
<member name="T:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApiAgent">
<inheritdoc />
</member>
<member name="T:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApiExchangeData">
<inheritdoc />
</member>
Expand Down Expand Up @@ -1168,6 +1174,9 @@
<member name="P:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApi.Trading">
<inheritdoc />
</member>
<member name="P:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApi.Agent">
<inheritdoc />
</member>
<member name="P:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApi.ExchangeName">
<inheritdoc />
</member>
Expand Down Expand Up @@ -1430,6 +1439,9 @@
<member name="M:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApiAccount.GetCommissionRatesAsync(System.String,System.Nullable{System.Int32},System.Threading.CancellationToken)">
<inheritdoc />
</member>
<member name="T:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApiAgent">
<inheritdoc />
</member>
<member name="T:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApiExchangeData">
<inheritdoc />
</member>
Expand Down Expand Up @@ -1937,6 +1949,9 @@
<member name="P:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApi.Trading">
<inheritdoc />
</member>
<member name="P:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApi.Agent">
<inheritdoc />
</member>
<member name="P:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApi.ExchangeName">
<inheritdoc />
</member>
Expand Down Expand Up @@ -2073,6 +2088,9 @@
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApiAccount.GetAccountConfigurationAsync(System.Nullable{System.Int64},System.Threading.CancellationToken)">
<inheritdoc />
</member>
<member name="T:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApiAgent">
<inheritdoc />
</member>
<member name="T:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApiExchangeData">
<inheritdoc />
</member>
Expand Down Expand Up @@ -3626,6 +3644,21 @@
Terminated
</summary>
</member>
<member name="T:Binance.Net.Enums.IfNewUserMarginedFuturesType">
<summary>
Margined futures type
</summary>
</member>
<member name="F:Binance.Net.Enums.IfNewUserMarginedFuturesType.USDT_margined_Futures">
<summary>
Processing
</summary>
</member>
<member name="F:Binance.Net.Enums.IfNewUserMarginedFuturesType.Coin_margined_Futures">
<summary>
Canceled
</summary>
</member>
<member name="T:Binance.Net.Enums.IncomeType">
<summary>
Type of futures income
Expand Down Expand Up @@ -5595,6 +5628,11 @@
Get the shared rest requests client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApi.Agent">
<summary>
Endpoints related to query user data.
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApiAccount">
<summary>
Binance COIN-M futures account endpoints. Account endpoints include balance info, withdraw/deposit info and requesting and account settings
Expand Down Expand Up @@ -5830,6 +5868,22 @@
<param name="ct">Cancellation token</param>
<returns></returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApiAgent">
<summary>
Binance Coin futures account endpoints, query user data.
</summary>
</member>
<member name="M:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApiAgent.IfNewUser(System.String,System.Nullable{System.Int32},System.Threading.CancellationToken)">
<summary>
Query Client If The New User.
<para><a href="https://binance-docs.github.io/apiAgent-API-EN/api_rebate_endpoints_futures_EN/" /></para>
<para><a href="https://binance-docs.github.io/apiAgent-API-CN/api_rebate_endpoints_futures_CN/" /></para>
</summary>
<param name="brokerId">Api Broker Id</param>
<param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param>
<param name="ct">Cancellation token</param>
<returns>USER DATA</returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApiExchangeData">
<summary>
Binance COIN-M futures exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status.
Expand Down Expand Up @@ -8643,6 +8697,11 @@
Get the shared rest requests client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApi.Agent">
<summary>
Endpoints related to query user data.
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApiAccount">
<summary>
Binance Spot account endpoints. Account endpoints include balance info, withdraw/deposit info and requesting and account settings
Expand Down Expand Up @@ -9468,6 +9527,22 @@
<param name="ct">Cancellation token</param>
<returns></returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApiAgent">
<summary>
Binance Spot agent endpoints, query user data.
</summary>
</member>
<member name="M:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApiAgent.IfNewUser(System.String,System.Nullable{System.Int32},System.Threading.CancellationToken)">
<summary>
Query Client If The New User.
<para><a href="https://binance-docs.github.io/apiAgent-API-EN/api_rebate_endpoints_spot_EN/#_1" /></para>
<para><a href="https://binance-docs.github.io/apiAgent-API-CN/api_rebate_endpoints_spot_CN/#_1" /></para>
</summary>
<param name="apiAgentCode">Api Agent Code</param>
<param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param>
<param name="ct">Cancellation token</param>
<returns>USER DATA</returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApiExchangeData">
<summary>
Binance Spot exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status.
Expand Down Expand Up @@ -11387,6 +11462,11 @@
Get the shared rest requests client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApi.Agent">
<summary>
Endpoints related to query user data.
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount">
<summary>
Binance USD-M futures account endpoints. Account endpoints include balance info, withdraw/deposit info and requesting and account settings
Expand Down Expand Up @@ -11703,6 +11783,22 @@
<param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param>
<param name="ct">Cancellation token</param>
</member>
<member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAgent">
<summary>
Binance USD-M futures account endpoints, query user data.
</summary>
</member>
<member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAgent.IfNewUser(System.String,System.Nullable{System.Int32},System.Threading.CancellationToken)">
<summary>
Query Client If The New User.
<para><a href="https://binance-docs.github.io/apiAgent-API-EN/api_rebate_endpoints_futures_EN/" /></para>
<para><a href="https://binance-docs.github.io/apiAgent-API-CN/api_rebate_endpoints_futures_CN/" /></para>
</summary>
<param name="brokerId">Api Broker Id</param>
<param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param>
<param name="ct">Cancellation token</param>
<returns>USER DATA</returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiExchangeData">
<summary>
Binance USD-M futures exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status.
Expand Down Expand Up @@ -17141,6 +17237,31 @@
Unrealized profit
</summary>
</member>
<member name="T:Binance.Net.Objects.Models.Spot.BinanceIfNewUser">
<summary>
If the new user info
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Spot.BinanceIfNewUser.ApiAgentCode">
<summary>
Api Agen tCode
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Spot.BinanceIfNewUser.RebateWorking">
<summary>
If the apiAgentCode is working
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Spot.BinanceIfNewUser.ifNewUser">
<summary>
If new user
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Spot.BinanceIfNewUser.ReferrerId">
<summary>
Referrer Id
</summary>
</member>
<member name="T:Binance.Net.Objects.Models.Spot.BinanceIpRestriction">
<summary>
IP restriction info
Expand Down Expand Up @@ -27739,6 +27860,26 @@
<member name="P:Binance.Net.Objects.Models.Futures.BinanceFuturesUsdtKline.TakerBuyQuoteVolume">
<inheritdoc/>
</member>
<member name="T:Binance.Net.Objects.Models.Futures.BinanceIfNewUser">
<summary>
If the new user info
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.BinanceIfNewUser.BrokerId">
<summary>
Broker Id
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.BinanceIfNewUser.RebateWorking">
<summary>
If the apiAgentCode is working
</summary>
</member>
<member name="P:Binance.Net.Objects.Models.Futures.BinanceIfNewUser.ifNewUser">
<summary>
If new user
</summary>
</member>
<member name="T:Binance.Net.Objects.Models.Futures.BinancePositionBase">
<summary>
Base position info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ internal partial class BinanceRestClientCoinFuturesApi : RestApiClient, IBinance
/// <inheritdoc />
public IBinanceRestClientCoinFuturesApiTrading Trading { get; }
/// <inheritdoc />
public IBinanceRestClientCoinFuturesApiAgent Agent { get; }
/// <inheritdoc />
public string ExchangeName => "Binance";
#endregion

Expand All @@ -56,6 +58,7 @@ internal BinanceRestClientCoinFuturesApi(ILogger logger, HttpClient? httpClient,
Account = new BinanceRestClientCoinFuturesApiAccount(this);
ExchangeData = new BinanceRestClientCoinFuturesApiExchangeData(logger, this);
Trading = new BinanceRestClientCoinFuturesApiTrading(logger, this);
Agent = new BinanceRestClientCoinFuturesApiAgent(this);

RequestBodyEmptyContent = "";
RequestBodyFormat = RequestBodyFormat.FormData;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Binance.Net.Enums;
using Binance.Net.Interfaces.Clients.CoinFuturesApi;
using Binance.Net.Objects.Models.Futures;

namespace Binance.Net.Clients.CoinFuturesApi
{
/// <inheritdoc />
internal class BinanceRestClientCoinFuturesApiAgent : IBinanceRestClientCoinFuturesApiAgent
{
private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache();

private readonly BinanceRestClientCoinFuturesApi _baseClient;

internal BinanceRestClientCoinFuturesApiAgent(BinanceRestClientCoinFuturesApi baseClient)
{
_baseClient = baseClient;
}

#region If New User

public async Task<WebCallResult<BinanceIfNewUser>> IfNewUser(string brokerId, int? receiveWindow = null, CancellationToken ct = default)
{
brokerId.ValidateNotNull(nameof(brokerId));

var parameters = new ParameterCollection();
parameters.AddOptional("brokerId", brokerId.ToString(CultureInfo.InvariantCulture));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be parameters.Add("brokerId", brokerId);
It's not optional and it's already a string

parameters.AddOptional("type", (int)IfNewUserMarginedFuturesType.Coin_margined_Futures);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use parameters.AddEnum("type", IfNewUserMarginedFuturesType.Coin_margined_Futures); instead

parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? _baseClient.ClientOptions.ReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture));

var request = _definitions.GetOrCreate(HttpMethod.Get, "fapi/v1/apiReferral/ifNewUser", BinanceExchange.RateLimiter.SpotRestIp, 100, true);
JKorf marked this conversation as resolved.
Show resolved Hide resolved
return await _baseClient.SendAsync<BinanceIfNewUser>(request, parameters, ct).ConfigureAwait(false);
}

#endregion

}
}
3 changes: 3 additions & 0 deletions Binance.Net/Clients/SpotApi/BinanceRestClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ internal partial class BinanceRestClientSpotApi : RestApiClient, IBinanceRestCli
/// <inheritdoc />
public IBinanceRestClientSpotApiTrading Trading { get; }
/// <inheritdoc />
public IBinanceRestClientSpotApiAgent Agent { get; }
/// <inheritdoc />
public string ExchangeName => "Binance";
#endregion

Expand All @@ -57,6 +59,7 @@ internal BinanceRestClientSpotApi(ILogger logger, HttpClient? httpClient, Binanc
Account = new BinanceRestClientSpotApiAccount(this);
ExchangeData = new BinanceRestClientSpotApiExchangeData(logger, this);
Trading = new BinanceRestClientSpotApiTrading(logger, this);
Agent = new BinanceRestClientSpotApiAgent(this);

RequestBodyEmptyContent = "";
RequestBodyFormat = RequestBodyFormat.FormData;
Expand Down
34 changes: 34 additions & 0 deletions Binance.Net/Clients/SpotApi/BinanceRestClientSpotApiAgent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Binance.Net.Interfaces.Clients.SpotApi;
using Binance.Net.Objects.Models.Spot;

namespace Binance.Net.Clients.SpotApi
{
/// <inheritdoc />
internal class BinanceRestClientSpotApiAgent : IBinanceRestClientSpotApiAgent
{
private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache();

private readonly BinanceRestClientSpotApi _baseClient;

internal BinanceRestClientSpotApiAgent(BinanceRestClientSpotApi baseClient)
{
_baseClient = baseClient;
}

#region If New User

public async Task<WebCallResult<BinanceIfNewUser>> IfNewUser(string apiAgentCode, int? receiveWindow = null, CancellationToken ct = default)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments

{
apiAgentCode.ValidateNotNull(nameof(apiAgentCode));

var parameters = new ParameterCollection();
parameters.AddOptional("apiAgentCode", apiAgentCode.ToString(CultureInfo.InvariantCulture));
parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? _baseClient.ClientOptions.ReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture));

var request = _definitions.GetOrCreate(HttpMethod.Get, "sapi/v1/apiReferral/ifNewUser", BinanceExchange.RateLimiter.SpotRestIp, 100, true);
return await _baseClient.SendAsync<BinanceIfNewUser>(request, parameters, ct).ConfigureAwait(false);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ internal partial class BinanceRestClientUsdFuturesApi : RestApiClient, IBinanceR
/// <inheritdoc />
public IBinanceRestClientUsdFuturesApiTrading Trading { get; }
/// <inheritdoc />
public IBinanceRestClientUsdFuturesApiAgent Agent { get; }
/// <inheritdoc />
public string ExchangeName => "Binance";
#endregion

Expand All @@ -59,6 +61,7 @@ internal BinanceRestClientUsdFuturesApi(ILogger logger, HttpClient? httpClient,
Account = new BinanceRestClientUsdFuturesApiAccount(this);
ExchangeData = new BinanceRestClientUsdFuturesApiExchangeData(logger, this);
Trading = new BinanceRestClientUsdFuturesApiTrading(logger, this);
Agent = new BinanceRestClientUsdFuturesApiAgent(this);

RequestBodyEmptyContent = "";
RequestBodyFormat = RequestBodyFormat.FormData;
Expand Down
Loading
Loading