mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
bitget: add more public api tests
This commit is contained in:
parent
c347a2423a
commit
3154961d72
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user