Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The key string is the Coinbase API key name/id, and the private key is the ECDSA

## Core Pattern: Result Handling

REST methods return `WebCallResult<T>`. WebSocket subscriptions return `CallResult<UpdateSubscription>`. Always check `.Success` before reading `.Data`.
REST methods return `HttpResult<T>`. WebSocket subscriptions return `WebSocketResult<UpdateSubscription>`. Always check `.Success` before reading `.Data`.

```csharp
var result = await restClient.AdvancedTradeApi.ExchangeData.GetSymbolAsync("ETH-USDT");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ true
"source_id": "string",
"target_id": "string",
"subscription_info": {
"free_trading_reset_date": "string",
"free_trading_reset_date": "",
"used_zero_fee_trading": {
"value": "123",
"currency": "string"
Expand Down Expand Up @@ -151,7 +151,7 @@ true
"applied_incentive": false,
"user_incentive_id": "string",
"code_val": "string",
"ends_at": "string",
"ends_at": "",
"fee_without_incentive": {
"value": "123",
"currency": "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ true
"source_id": "string",
"target_id": "string",
"subscription_info": {
"free_trading_reset_date": "string",
"free_trading_reset_date": "",
"used_zero_fee_trading": {
"value": "123",
"currency": "string"
Expand Down Expand Up @@ -151,7 +151,7 @@ true
"applied_incentive": false,
"user_incentive_id": "string",
"code_val": "string",
"ends_at": "string",
"ends_at": "",
"fee_without_incentive": {
"value": "123",
"currency": "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ true
"source_id": "string",
"target_id": "string",
"subscription_info": {
"free_trading_reset_date": "string",
"free_trading_reset_date": "",
"used_zero_fee_trading": {
"value": "123",
"currency": "string"
Expand Down Expand Up @@ -151,7 +151,7 @@ true
"applied_incentive": false,
"user_incentive_id": "string",
"code_val": "string",
"ends_at": "string",
"ends_at": "",
"fee_without_incentive": {
"value": "123",
"currency": "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ true
"avg_entry_price": "123",
"current_price": "123",
"unrealized_pnl": "123",
"expiry": "string",
"expiry": "",
"underlying_asset": "string",
"asset_img_url": "string",
"product_name": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ false
"base_currency_id": "BTC",
"fcm_trading_session_details": {
"is_session_open": true,
"open_time": "string",
"close_time": "string",
"open_time": "",
"close_time": "",
"session_state": "FCM_TRADING_SESSION_STATE_UNDEFINED",
"after_hours_order_entry_disabled": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ true
{
"price": "19000.00",
"size": "0.001",
"replace_accept_timestamp": "string"
"replace_accept_timestamp": ""
}
],
"leverage": "10",
Expand Down
2 changes: 1 addition & 1 deletion Coinbase.Net.UnitTests/RestRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task ValidateAdvancedTradeTradingCalls()
await tester.ValidateAsync(client => client.AdvancedTradeApi.Trading.GetPerpetualPositionAsync("123", "BTC-PERP-INTX"), "GetPerpetualPosition", "position");
}

private bool IsAuthenticated(WebCallResult result)
private bool IsAuthenticated(IHttpResult result)
{
return result.RequestHeaders.Any(x => x.Key == "Authorization");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ internal partial class CoinbaseRestClientAdvancedTradeApi : RestApiClient<Coinba
#endregion

#region constructor/destructor
internal CoinbaseRestClientAdvancedTradeApi(CoinbaseRestClient baseClient, ILogger logger, HttpClient? httpClient, CoinbaseRestOptions options)
: base(logger, httpClient, options.Environment.RestClientAddress, options, options.AdvancedTradeOptions)
internal CoinbaseRestClientAdvancedTradeApi(CoinbaseRestClient baseClient, ILoggerFactory? loggerFactory, HttpClient? httpClient, CoinbaseRestOptions options)
: base(loggerFactory, CoinbaseExchange.Metadata.Id, httpClient, options.Environment.RestClientAddress, options, options.AdvancedTradeOptions)
{
Account = new CoinbaseRestClientAdvancedTradeApiAccount(this);
ExchangeData = new CoinbaseRestClientAdvancedTradeApiExchangeData(logger, this);
Trading = new CoinbaseRestClientAdvancedTradeApiTrading(logger, this);

ArraySerialization = ArrayParametersSerialization.MultipleValues;
ExchangeData = new CoinbaseRestClientAdvancedTradeApiExchangeData(_logger, this);
Trading = new CoinbaseRestClientAdvancedTradeApiTrading(_logger, this);

StandardRequestHeaders = new Dictionary<string, string>
{
Expand All @@ -64,24 +62,18 @@ internal CoinbaseRestClientAdvancedTradeApi(CoinbaseRestClient baseClient, ILogg
protected override CoinbaseAuthenticationProvider CreateAuthenticationProvider(CoinbaseCredentials credentials)
=> new CoinbaseAuthenticationProvider(credentials);

internal Task<WebCallResult> SendAsync(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null)
=> SendToAddressAsync(BaseAddress, definition, parameters, cancellationToken, weight);

internal async Task<WebCallResult> SendToAddressAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null)
internal async Task<HttpResult> SendAsync(RequestDefinition definition, Parameters? parameters, CancellationToken cancellationToken, int? weight = null)
{
return await base.SendAsync(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false);
return await base.SendAsync<Unit>(definition, parameters, cancellationToken, null, weight).ConfigureAwait(false);
}

internal Task<WebCallResult<T>> SendAsync<T>(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) where T : class
=> SendToAddressAsync<T>(BaseAddress, definition, parameters, cancellationToken, weight);

internal async Task<WebCallResult<T>> SendToAddressAsync<T>(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) where T : class
internal async Task<HttpResult<T>> SendAsync<T>(RequestDefinition definition, Parameters? parameters, CancellationToken cancellationToken, int? weight = null) where T : class
{
return await base.SendAsync<T>(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false);
return await base.SendAsync<T>(definition, parameters, cancellationToken, null, weight).ConfigureAwait(false);
}

/// <inheritdoc />
protected override Task<WebCallResult<DateTime>> GetServerTimestampAsync()
protected override Task<HttpResult<DateTime>> GetServerTimestampAsync()
=> ExchangeData.GetServerTimeAsync();

/// <inheritdoc />
Expand Down
Loading
Loading