Skip to content

Commit

Permalink
[Bug] Fix Withdraw Crypto GUID (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougdellolio authored Mar 6, 2018
1 parent 6676832 commit 03b9fc6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion GDAXClient/Services/Deposits/DepositsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<CoinbaseResponse> DepositCoinbaseFundsAsync(string coinbaseAcc
{
amount = amount,
currency = currency.ToString().ToUpper(),
coinbase_account_id = new Guid(coinbaseAccountId)
coinbase_account_id = coinbaseAccountId
});

var httpResponseMessage = await SendHttpRequestMessageAsync(HttpMethod.Post, authenticator, "/deposits/coinbase-account", newCoinbaseDeposit);
Expand Down
23 changes: 16 additions & 7 deletions GDAXClient/Services/Products/ProductsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public async Task<IEnumerable<Product>> GetAllProductsAsync()
return productsResponse;
}

public async Task<ProductsOrderBookResponse> GetProductOrderBookAsync(ProductType productPair, ProductLevel productLevel = ProductLevel.One)
public async Task<ProductsOrderBookResponse> GetProductOrderBookAsync(
ProductType productPair,
ProductLevel productLevel = ProductLevel.One)
{
var httpResponseMessage = await SendHttpRequestMessageAsync(HttpMethod.Get, authenticator, $"/products/{productPair.ToDasherizedUpper()}/book/?level={(int)productLevel}");
var contentBody = await httpClient.ReadAsStringAsync(httpResponseMessage).ConfigureAwait(false);
Expand Down Expand Up @@ -84,9 +86,13 @@ public async Task<IList<IList<ProductTrade>>> GetTradesAsync(
return httpResponseMessage;
}

public async Task<IList<Candle>> GetHistoricRatesAsync(ProductType productPair, DateTime start, DateTime end, CandleGranularity granularity)
public async Task<IList<Candle>> GetHistoricRatesAsync(
ProductType productPair,
DateTime start,
DateTime end,
CandleGranularity granularity)
{
const int maxPeriods = 350; // From GDAX docs
const int maxPeriods = 350;

var rc = new List<Candle>();

Expand All @@ -108,7 +114,11 @@ public async Task<IList<Candle>> GetHistoricRatesAsync(ProductType productPair,
return rc;
}

private async Task<IList<Candle>> GetHistoricRatesAsync(ProductType productPair, DateTime start, DateTime end, int granularity)
private async Task<IList<Candle>> GetHistoricRatesAsync(
ProductType productPair,
DateTime start,
DateTime end,
int granularity)
{
var isoStart = start.ToString("s");
var isoEnd = end.ToString("s");
Expand All @@ -120,9 +130,8 @@ private async Task<IList<Candle>> GetHistoricRatesAsync(ProductType productPair,

var httpResponseMessage = await SendHttpRequestMessageAsync(HttpMethod.Get, authenticator, $"/products/{productPair.ToDasherizedUpper()}/candles" + queryString);
var contentBody = await httpClient.ReadAsStringAsync(httpResponseMessage).ConfigureAwait(false);
var productHistoryResponse = JsonConvert.DeserializeObject<IList<Candle>>(contentBody
// Ensure we don't lose any precision
, new JsonSerializerSettings {FloatParseHandling = FloatParseHandling.Decimal});
var productHistoryResponse = JsonConvert.DeserializeObject<IList<Candle>>(contentBody,
new JsonSerializerSettings { FloatParseHandling = FloatParseHandling.Decimal });

return productHistoryResponse;
}
Expand Down
2 changes: 1 addition & 1 deletion GDAXClient/Services/Withdrawals/Models/Coinbase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class Coinbase

public string currency { get; set; }

public Guid coinbase_account_id { get; set; }
public string coinbase_account_id { get; set; }
}
}
6 changes: 2 additions & 4 deletions GDAXClient/Services/Withdrawals/Models/Crypto.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;

namespace GDAXClient.Services.Withdrawals.Models
namespace GDAXClient.Services.Withdrawals.Models
{
public class Crypto
{
public decimal amount { get; set; }

public string currency { get; set; }

public Guid crypto_address { get; set; }
public string crypto_address { get; set; }
}
}
6 changes: 2 additions & 4 deletions GDAXClient/Services/Withdrawals/Models/Withdrawal.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;

namespace GDAXClient.Services.Withdrawals.Models
namespace GDAXClient.Services.Withdrawals.Models
{
public class Withdrawal
{
public decimal amount { get; set; }

public string currency { get; set; }

public Guid payment_method_id { get; set; }
public string payment_method_id { get; set; }
}
}
24 changes: 16 additions & 8 deletions GDAXClient/Services/Withdrawals/WithdrawalsService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Net.Http;
using System.Net.Http;
using System.Threading.Tasks;
using GDAXClient.Authentication;
using GDAXClient.HttpClient;
Expand Down Expand Up @@ -27,13 +26,16 @@ public WithdrawalsService(
this.authenticator = authenticator;
}

public async Task<WithdrawalResponse> WithdrawFundsAsync(string paymentMethodId, decimal amount, Currency currency)
public async Task<WithdrawalResponse> WithdrawFundsAsync(
string paymentMethodId,
decimal amount,
Currency currency)
{
var newWithdrawal = JsonConvert.SerializeObject(new Withdrawal
{
amount = amount,
currency = currency.ToString().ToUpper(),
payment_method_id = new Guid(paymentMethodId)
payment_method_id = paymentMethodId
});

var httpResponseMessage = await SendHttpRequestMessageAsync(HttpMethod.Post, authenticator, "/withdrawals/payment-method", newWithdrawal);
Expand All @@ -43,13 +45,16 @@ public async Task<WithdrawalResponse> WithdrawFundsAsync(string paymentMethodId,
return withdrawalResponse;
}

public async Task<CoinbaseResponse> WithdrawToCoinbaseAsync(string coinbase_account_id, decimal amount, Currency currency)
public async Task<CoinbaseResponse> WithdrawToCoinbaseAsync(
string coinbaseAccountId,
decimal amount,
Currency currency)
{
var newCoinbaseWithdrawal = JsonConvert.SerializeObject(new Coinbase
{
amount = amount,
currency = currency.ToString().ToUpper(),
coinbase_account_id = new Guid(coinbase_account_id)
coinbase_account_id = coinbaseAccountId
});

var httpResponseMessage = await SendHttpRequestMessageAsync(HttpMethod.Post, authenticator, "/withdrawals/coinbase-account", newCoinbaseWithdrawal);
Expand All @@ -59,13 +64,16 @@ public async Task<CoinbaseResponse> WithdrawToCoinbaseAsync(string coinbase_acco
return coinbaseResponse;
}

public async Task<CryptoResponse> WithdrawToCryptoAsync(string crypto_address, decimal amount, Currency currency)
public async Task<CryptoResponse> WithdrawToCryptoAsync(
string cryptoAddress,
decimal amount,
Currency currency)
{
var newCryptoWithdrawal = JsonConvert.SerializeObject(new Crypto
{
amount = amount,
currency = currency.ToString().ToUpper(),
crypto_address = new Guid(crypto_address)
crypto_address = cryptoAddress
});

var httpResponseMessage = await SendHttpRequestMessageAsync(HttpMethod.Post, authenticator, "/withdrawals/crypto", newCryptoWithdrawal);
Expand Down

0 comments on commit 03b9fc6

Please sign in to comment.