/// <summary>
        /// Redeem flexible product
        /// </summary>
        /// <param name="productId">Id of the product</param>
        /// <param name="type">Redeem type</param>
        /// <param name="amount">The amount to redeem</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></returns>
        public async Task <WebCallResult <object> > RedeemFlexibleProductAsync(string productId, decimal amount, RedeemType type, long?receiveWindow = null, CancellationToken ct = default)
        {
            productId.ValidateNotNull(nameof(productId));

            var timestampResult = await _baseClient.CheckAutoTimestamp(ct).ConfigureAwait(false);

            if (!timestampResult)
            {
                return(new WebCallResult <object>(timestampResult.ResponseStatusCode, timestampResult.ResponseHeaders, null, timestampResult.Error));
            }

            var parameters = new Dictionary <string, object>
            {
                { "productId", productId },
                { "type", JsonConvert.SerializeObject(type, new RedeemTypeConverter(false)) },
                { "amount", amount.ToString(CultureInfo.InvariantCulture) },
                { "timestamp", _baseClient.GetTimestamp() }
            };

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

            return(await _baseClient.SendRequestInternal <object>(_baseClient.GetUrl(false, redeemFlexibleProductEndpoint, "sapi", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false));
        }
 /// <summary>
 /// Get the redemption quota left for a product
 /// </summary>
 /// <param name="productId">Id of the product</param>
 /// <param name="type">Type</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>Quota left</returns>
 public WebCallResult <BinanceRedemptionQuotaLeft> GetLeftDailyRedemptionQuotaOfFlexibleProduct(string productId, RedeemType type,
                                                                                                long?receiveWindow = null, CancellationToken ct = default)
 => GetLeftDailyRedemptionQuotaOfFlexibleProductAsync(productId, type, receiveWindow, ct).Result;
 /// <summary>
 /// Redeem flexible product
 /// </summary>
 /// <param name="productId">Id of the product</param>
 /// <param name="type">Redeem type</param>
 /// <param name="amount">The amount to redeem</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></returns>
 public WebCallResult <object> RedeemFlexibleProduct(string productId,
                                                     decimal amount, RedeemType type, long?receiveWindow = null, CancellationToken ct = default)
 => RedeemFlexibleProductAsync(productId, amount, type, receiveWindow, ct).Result;
Beispiel #4
0
 public Redeem(string customerId, RedeemType redeemType, ClientDetails clientDetails, SessionDetails sessionDetails) :
     base(customerId, clientDetails, sessionDetails)
 {
     RedeemType = redeemType;
 }