diff --git a/pkg/exchange/bitget/bitgetapi/client_test.go b/pkg/exchange/bitget/bitgetapi/client_test.go index 8b7afda37..3bf42f08a 100644 --- a/pkg/exchange/bitget/bitgetapi/client_test.go +++ b/pkg/exchange/bitget/bitgetapi/client_test.go @@ -35,3 +35,13 @@ func TestClient_GetAccountAssetsRequest(t *testing.T) { assert.NoError(t, err) t.Logf("assets: %+v", assets) } + +func TestClient_GetTickerRequest(t *testing.T) { + client := getTestClientOrSkip(t) + ctx := context.Background() + req := client.NewGetTickerRequest() + req.Symbol("BTCUSDT_SPBL") + ticker, err := req.Do(ctx) + assert.NoError(t, err) + t.Logf("ticker: %+v", ticker) +} diff --git a/pkg/exchange/bitget/bitgetapi/get_ticker_request.go b/pkg/exchange/bitget/bitgetapi/get_ticker_request.go index 8bbd98ba2..4df022e5f 100644 --- a/pkg/exchange/bitget/bitgetapi/get_ticker_request.go +++ b/pkg/exchange/bitget/bitgetapi/get_ticker_request.go @@ -31,6 +31,8 @@ type Ticker struct { //go:generate GetRequest -url "/api/spot/v1/market/ticker" -type GetTickerRequest -responseDataType .Ticker type GetTickerRequest struct { client requestgen.APIClient + + symbol string `param:"symbol"` } func (c *RestClient) NewGetTickerRequest() *GetTickerRequest { diff --git a/pkg/exchange/bitget/bitgetapi/get_ticker_request_requestgen.go b/pkg/exchange/bitget/bitgetapi/get_ticker_request_requestgen.go index 1f6e1bed6..bfb10ddcf 100644 --- a/pkg/exchange/bitget/bitgetapi/get_ticker_request_requestgen.go +++ b/pkg/exchange/bitget/bitgetapi/get_ticker_request_requestgen.go @@ -11,6 +11,11 @@ import ( "regexp" ) +func (g *GetTickerRequest) Symbol(symbol string) *GetTickerRequest { + g.symbol = symbol + return g +} + // GetQueryParameters builds and checks the query parameters and returns url.Values func (g *GetTickerRequest) GetQueryParameters() (url.Values, error) { var params = map[string]interface{}{} @@ -26,6 +31,11 @@ func (g *GetTickerRequest) GetQueryParameters() (url.Values, error) { // GetParameters builds and checks the parameters and return the result in a map object func (g *GetTickerRequest) GetParameters() (map[string]interface{}, error) { var params = map[string]interface{}{} + // check symbol field -> json key symbol + symbol := g.symbol + + // assign parameter of symbol + params["symbol"] = symbol return params, nil } @@ -111,9 +121,12 @@ func (g *GetTickerRequest) GetSlugsMap() (map[string]string, error) { func (g *GetTickerRequest) Do(ctx context.Context) (*Ticker, error) { - // no body params + // empty params for GET operation var params interface{} - query := url.Values{} + query, err := g.GetParametersQuery() + if err != nil { + return nil, err + } apiURL := "/api/spot/v1/market/ticker"