exchange/wrapper: add GetServerTime() for exchange analytics (#938)

* exchange/wrapper: add GetServerTime() for exchange analytics

* binance: fix linter issue

* glorious: nits

* glorious: nits rides again

* thrasher: nits implement huobi

* thrasher: nits add to exchange_wrapper_issues cmd
This commit is contained in:
Ryan O'Hara-Reid
2022-05-06 11:38:59 +10:00
committed by GitHub
parent c6ad429827
commit d735effc8e
24 changed files with 230 additions and 28 deletions

View File

@@ -273,10 +273,9 @@ func (c *CoinbasePro) GetCurrencies(ctx context.Context) ([]Currency, error) {
return currencies, c.SendHTTPRequest(ctx, exchange.RestSpot, coinbaseproCurrencies, &currencies)
}
// GetServerTime returns the API server time
func (c *CoinbasePro) GetServerTime(ctx context.Context) (ServerTime, error) {
// GetCurrentServerTime returns the API server time
func (c *CoinbasePro) GetCurrentServerTime(ctx context.Context) (ServerTime, error) {
serverTime := ServerTime{}
return serverTime, c.SendHTTPRequest(ctx, exchange.RestSpot, coinbaseproTime, &serverTime)
}

View File

@@ -144,13 +144,25 @@ func TestGetCurrencies(t *testing.T) {
}
}
func TestGetServerTime(t *testing.T) {
_, err := c.GetServerTime(context.Background())
func TestGetCurrentServerTime(t *testing.T) {
_, err := c.GetCurrentServerTime(context.Background())
if err != nil {
t.Error("GetServerTime() error", err)
}
}
func TestWrapperGetServerTime(t *testing.T) {
t.Parallel()
st, err := c.GetServerTime(context.Background(), asset.Spot)
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
if st.IsZero() {
t.Fatal("expected a time")
}
}
func TestAuthRequests(t *testing.T) {
if !areTestAPIKeysSet() {
t.Skip("API keys not set, skipping test")

View File

@@ -1019,3 +1019,12 @@ func (c *CoinbasePro) ValidateCredentials(ctx context.Context, assetType asset.I
_, err := c.UpdateAccountInfo(ctx, assetType)
return c.CheckTransientError(err)
}
// GetServerTime returns the current exchange server time.
func (c *CoinbasePro) GetServerTime(ctx context.Context, _ asset.Item) (time.Time, error) {
st, err := c.GetCurrentServerTime(ctx)
if err != nil {
return time.Time{}, err
}
return st.ISO, nil
}