// Package market provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/deepmap/oapi-codegen version v1.9.0 DO NOT EDIT. package market import ( "bytes" "compress/gzip" "context" "encoding/base64" "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "path" "strings" "github.com/deepmap/oapi-codegen/pkg/runtime" "github.com/getkin/kin-openapi/openapi3" ) // GetApiV5MarketBooksParams defines parameters for GetApiV5MarketBooks. type GetApiV5MarketBooksParams struct { // 产品ID,如:`BTC-USDT` InstId string `json:"instId"` // 深度档位数量
最大值可传400,即买卖深度共800条
不填写此参数,默认返回1档深度数据 Sz *string `json:"sz,omitempty"` } // GetApiV5MarketCandlesParams defines parameters for GetApiV5MarketCandles. type GetApiV5MarketCandlesParams struct { // 产品ID,如:`BTC-USDT` InstId string `json:"instId"` // 时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y] Bar *string `json:"bar,omitempty"` // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` After *string `json:"after,omitempty"` // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` Before *string `json:"before,omitempty"` // 分页返回的结果集数量,最大为100,不填默认返回100条 Limit *string `json:"limit,omitempty"` } // GetApiV5MarketHistoryCandlesParams defines parameters for GetApiV5MarketHistoryCandles. type GetApiV5MarketHistoryCandlesParams struct { // 产品ID,如:`BTC-USDT` InstId string `json:"instId"` // 时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y] Bar *string `json:"bar,omitempty"` // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` After *string `json:"after,omitempty"` // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` Before *string `json:"before,omitempty"` // 分页返回的结果集数量,最大为100,不填默认返回100条 Limit *string `json:"limit,omitempty"` } // GetApiV5MarketIndexCandlesParams defines parameters for GetApiV5MarketIndexCandles. type GetApiV5MarketIndexCandlesParams struct { // 现货指数,如:`BTC-USD` InstId string `json:"instId"` // 时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y] Bar *string `json:"bar,omitempty"` // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` After *string `json:"after,omitempty"` // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` Before *string `json:"before,omitempty"` // 分页返回的结果集数量,最大为100,不填默认返回100条 Limit *string `json:"limit,omitempty"` } // GetApiV5MarketIndexComponentsParams defines parameters for GetApiV5MarketIndexComponents. type GetApiV5MarketIndexComponentsParams struct { // 指数,如:`BTC-USDT` Index string `json:"index"` } // GetApiV5MarketIndexTickersParams defines parameters for GetApiV5MarketIndexTickers. type GetApiV5MarketIndexTickersParams struct { // 指数,如:`BTC-USD`
`instId`和`quoteCcy`必须填写一个 InstId *string `json:"instId,omitempty"` // 指数计价单位
目前只有`USD`/`USDT`/`BTC`为计价单位的指数 QuoteCcy *string `json:"quoteCcy,omitempty"` } // GetApiV5MarketMarkPriceCandlesParams defines parameters for GetApiV5MarketMarkPriceCandles. type GetApiV5MarketMarkPriceCandlesParams struct { // 现货指数,如:`BTC-USD-SWAP` InstId string `json:"instId"` // 时间粒度,默认值`1m`
如 [1m/3m/5m/15m/30m/1H/2H/4H/6H/12H/1D/1W/1M/3M/6M/1Y] Bar *string `json:"bar,omitempty"` // 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的`ts` After *string `json:"after,omitempty"` // 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的`ts` Before *string `json:"before,omitempty"` // 分页返回的结果集数量,最大为100,不填默认返回100条 Limit *string `json:"limit,omitempty"` } // GetApiV5MarketTickerParams defines parameters for GetApiV5MarketTicker. type GetApiV5MarketTickerParams struct { // 产品ID,如:`BTC-USD-SWAP` InstId string `json:"instId"` } // GetApiV5MarketTickersParams defines parameters for GetApiV5MarketTickers. type GetApiV5MarketTickersParams struct { // 产品类型
`SPOT`:币币
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权 InstType string `json:"instType"` // 合约标的指数
仅适用于`交割/永续/期权`,如 `BTC-USD` Uly *string `json:"uly,omitempty"` } // GetApiV5MarketTradesParams defines parameters for GetApiV5MarketTrades. type GetApiV5MarketTradesParams struct { // 产品ID,如:`BTC-USDT` InstId string `json:"instId"` // 分页返回的结果集数量,最大为500,不填默认返回100条 Limit *string `json:"limit,omitempty"` } // RequestEditorFn is the function signature for the RequestEditor callback function type RequestEditorFn func(ctx context.Context, req *http.Request) error // Doer performs HTTP requests. // // The standard http.Client implements this interface. type HttpRequestDoer interface { Do(req *http.Request) (*http.Response, error) } // Client which conforms to the OpenAPI3 specification for this service. type Client struct { // The endpoint of the server conforming to this interface, with scheme, // https://api.deepmap.com for example. This can contain a path relative // to the server, such as https://api.deepmap.com/dev-test, and all the // paths in the swagger spec will be appended to the server. Server string // Doer for performing requests, typically a *http.Client with any // customized settings, such as certificate chains. Client HttpRequestDoer // A list of callbacks for modifying requests which are generated before sending over // the network. RequestEditors []RequestEditorFn } // ClientOption allows setting custom parameters during construction type ClientOption func(*Client) error // Creates a new Client, with reasonable defaults func NewClient(server string, opts ...ClientOption) (*Client, error) { // create a client with sane default values client := Client{ Server: server, } // mutate client and add all optional params for _, o := range opts { if err := o(&client); err != nil { return nil, err } } // ensure the server URL always has a trailing slash if !strings.HasSuffix(client.Server, "/") { client.Server += "/" } // create httpClient, if not already present if client.Client == nil { client.Client = &http.Client{} } return &client, nil } // WithHTTPClient allows overriding the default Doer, which is // automatically created using http.Client. This is useful for tests. func WithHTTPClient(doer HttpRequestDoer) ClientOption { return func(c *Client) error { c.Client = doer return nil } } // WithRequestEditorFn allows setting up a callback function, which will be // called right before sending the request. This can be used to mutate the request. func WithRequestEditorFn(fn RequestEditorFn) ClientOption { return func(c *Client) error { c.RequestEditors = append(c.RequestEditors, fn) return nil } } // The interface specification for the client above. type ClientInterface interface { // GetApiV5MarketBooks request GetApiV5MarketBooks(ctx context.Context, params *GetApiV5MarketBooksParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketCandles request GetApiV5MarketCandles(ctx context.Context, params *GetApiV5MarketCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketHistoryCandles request GetApiV5MarketHistoryCandles(ctx context.Context, params *GetApiV5MarketHistoryCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketIndexCandles request GetApiV5MarketIndexCandles(ctx context.Context, params *GetApiV5MarketIndexCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketIndexComponents request GetApiV5MarketIndexComponents(ctx context.Context, params *GetApiV5MarketIndexComponentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketIndexTickers request GetApiV5MarketIndexTickers(ctx context.Context, params *GetApiV5MarketIndexTickersParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketMarkPriceCandles request GetApiV5MarketMarkPriceCandles(ctx context.Context, params *GetApiV5MarketMarkPriceCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketOpenOracle request GetApiV5MarketOpenOracle(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketPlatform24Volume request GetApiV5MarketPlatform24Volume(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketTicker request GetApiV5MarketTicker(ctx context.Context, params *GetApiV5MarketTickerParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketTickers request GetApiV5MarketTickers(ctx context.Context, params *GetApiV5MarketTickersParams, reqEditors ...RequestEditorFn) (*http.Response, error) // GetApiV5MarketTrades request GetApiV5MarketTrades(ctx context.Context, params *GetApiV5MarketTradesParams, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) GetApiV5MarketBooks(ctx context.Context, params *GetApiV5MarketBooksParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketBooksRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketCandles(ctx context.Context, params *GetApiV5MarketCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketCandlesRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketHistoryCandles(ctx context.Context, params *GetApiV5MarketHistoryCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketHistoryCandlesRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketIndexCandles(ctx context.Context, params *GetApiV5MarketIndexCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketIndexCandlesRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketIndexComponents(ctx context.Context, params *GetApiV5MarketIndexComponentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketIndexComponentsRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketIndexTickers(ctx context.Context, params *GetApiV5MarketIndexTickersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketIndexTickersRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketMarkPriceCandles(ctx context.Context, params *GetApiV5MarketMarkPriceCandlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketMarkPriceCandlesRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketOpenOracle(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketOpenOracleRequest(c.Server) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketPlatform24Volume(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketPlatform24VolumeRequest(c.Server) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketTicker(ctx context.Context, params *GetApiV5MarketTickerParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketTickerRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketTickers(ctx context.Context, params *GetApiV5MarketTickersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketTickersRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) GetApiV5MarketTrades(ctx context.Context, params *GetApiV5MarketTradesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetApiV5MarketTradesRequest(c.Server, params) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } // NewGetApiV5MarketBooksRequest generates requests for GetApiV5MarketBooks func NewGetApiV5MarketBooksRequest(server string, params *GetApiV5MarketBooksParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/books") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } if params.Sz != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "sz", runtime.ParamLocationQuery, *params.Sz); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketCandlesRequest generates requests for GetApiV5MarketCandles func NewGetApiV5MarketCandlesRequest(server string, params *GetApiV5MarketCandlesParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/candles") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } if params.Bar != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bar", runtime.ParamLocationQuery, *params.Bar); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.After != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.Before != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.Limit != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketHistoryCandlesRequest generates requests for GetApiV5MarketHistoryCandles func NewGetApiV5MarketHistoryCandlesRequest(server string, params *GetApiV5MarketHistoryCandlesParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/history-candles") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } if params.Bar != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bar", runtime.ParamLocationQuery, *params.Bar); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.After != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.Before != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.Limit != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketIndexCandlesRequest generates requests for GetApiV5MarketIndexCandles func NewGetApiV5MarketIndexCandlesRequest(server string, params *GetApiV5MarketIndexCandlesParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/index-candles") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } if params.Bar != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bar", runtime.ParamLocationQuery, *params.Bar); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.After != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.Before != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.Limit != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketIndexComponentsRequest generates requests for GetApiV5MarketIndexComponents func NewGetApiV5MarketIndexComponentsRequest(server string, params *GetApiV5MarketIndexComponentsParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/index-components") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "index", runtime.ParamLocationQuery, params.Index); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketIndexTickersRequest generates requests for GetApiV5MarketIndexTickers func NewGetApiV5MarketIndexTickersRequest(server string, params *GetApiV5MarketIndexTickersParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/index-tickers") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if params.InstId != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, *params.InstId); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.QuoteCcy != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "quoteCcy", runtime.ParamLocationQuery, *params.QuoteCcy); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketMarkPriceCandlesRequest generates requests for GetApiV5MarketMarkPriceCandles func NewGetApiV5MarketMarkPriceCandlesRequest(server string, params *GetApiV5MarketMarkPriceCandlesParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/mark-price-candles") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } if params.Bar != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bar", runtime.ParamLocationQuery, *params.Bar); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.After != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.Before != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "before", runtime.ParamLocationQuery, *params.Before); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } if params.Limit != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketOpenOracleRequest generates requests for GetApiV5MarketOpenOracle func NewGetApiV5MarketOpenOracleRequest(server string) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/open-oracle") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketPlatform24VolumeRequest generates requests for GetApiV5MarketPlatform24Volume func NewGetApiV5MarketPlatform24VolumeRequest(server string) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/platform-24-volume") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketTickerRequest generates requests for GetApiV5MarketTicker func NewGetApiV5MarketTickerRequest(server string, params *GetApiV5MarketTickerParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/ticker") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketTickersRequest generates requests for GetApiV5MarketTickers func NewGetApiV5MarketTickersRequest(server string, params *GetApiV5MarketTickersParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/tickers") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instType", runtime.ParamLocationQuery, params.InstType); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } if params.Uly != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "uly", runtime.ParamLocationQuery, *params.Uly); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewGetApiV5MarketTradesRequest generates requests for GetApiV5MarketTrades func NewGetApiV5MarketTradesRequest(server string, params *GetApiV5MarketTradesParams) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/api/v5/market/trades") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } queryValues := queryURL.Query() if queryFrag, err := runtime.StyleParamWithLocation("form", true, "instId", runtime.ParamLocationQuery, params.InstId); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } if params.Limit != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err } else { for k, v := range parsed { for _, v2 := range v { queryValues.Add(k, v2) } } } } queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { for _, r := range c.RequestEditors { if err := r(ctx, req); err != nil { return err } } for _, r := range additionalEditors { if err := r(ctx, req); err != nil { return err } } return nil } // ClientWithResponses builds on ClientInterface to offer response payloads type ClientWithResponses struct { ClientInterface } // NewClientWithResponses creates a new ClientWithResponses, which wraps // Client with return type handling func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { client, err := NewClient(server, opts...) if err != nil { return nil, err } return &ClientWithResponses{client}, nil } // WithBaseURL overrides the baseURL. func WithBaseURL(baseURL string) ClientOption { return func(c *Client) error { newBaseURL, err := url.Parse(baseURL) if err != nil { return err } c.Server = newBaseURL.String() return nil } } // ClientWithResponsesInterface is the interface specification for the client with responses above. type ClientWithResponsesInterface interface { // GetApiV5MarketBooks request GetApiV5MarketBooksWithResponse(ctx context.Context, params *GetApiV5MarketBooksParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketBooksResponse, error) // GetApiV5MarketCandles request GetApiV5MarketCandlesWithResponse(ctx context.Context, params *GetApiV5MarketCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketCandlesResponse, error) // GetApiV5MarketHistoryCandles request GetApiV5MarketHistoryCandlesWithResponse(ctx context.Context, params *GetApiV5MarketHistoryCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketHistoryCandlesResponse, error) // GetApiV5MarketIndexCandles request GetApiV5MarketIndexCandlesWithResponse(ctx context.Context, params *GetApiV5MarketIndexCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexCandlesResponse, error) // GetApiV5MarketIndexComponents request GetApiV5MarketIndexComponentsWithResponse(ctx context.Context, params *GetApiV5MarketIndexComponentsParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexComponentsResponse, error) // GetApiV5MarketIndexTickers request GetApiV5MarketIndexTickersWithResponse(ctx context.Context, params *GetApiV5MarketIndexTickersParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexTickersResponse, error) // GetApiV5MarketMarkPriceCandles request GetApiV5MarketMarkPriceCandlesWithResponse(ctx context.Context, params *GetApiV5MarketMarkPriceCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketMarkPriceCandlesResponse, error) // GetApiV5MarketOpenOracle request GetApiV5MarketOpenOracleWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5MarketOpenOracleResponse, error) // GetApiV5MarketPlatform24Volume request GetApiV5MarketPlatform24VolumeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5MarketPlatform24VolumeResponse, error) // GetApiV5MarketTicker request GetApiV5MarketTickerWithResponse(ctx context.Context, params *GetApiV5MarketTickerParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTickerResponse, error) // GetApiV5MarketTickers request GetApiV5MarketTickersWithResponse(ctx context.Context, params *GetApiV5MarketTickersParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTickersResponse, error) // GetApiV5MarketTrades request GetApiV5MarketTradesWithResponse(ctx context.Context, params *GetApiV5MarketTradesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTradesResponse, error) } type GetApiV5MarketBooksResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketBooksResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketBooksResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketCandlesResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketCandlesResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketCandlesResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketHistoryCandlesResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketHistoryCandlesResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketHistoryCandlesResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketIndexCandlesResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketIndexCandlesResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketIndexCandlesResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketIndexComponentsResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketIndexComponentsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketIndexComponentsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketIndexTickersResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketIndexTickersResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketIndexTickersResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketMarkPriceCandlesResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketMarkPriceCandlesResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketMarkPriceCandlesResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketOpenOracleResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketOpenOracleResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketOpenOracleResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketPlatform24VolumeResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketPlatform24VolumeResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketPlatform24VolumeResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketTickerResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketTickerResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketTickerResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketTickersResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketTickersResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketTickersResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type GetApiV5MarketTradesResponse struct { Body []byte HTTPResponse *http.Response JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status func (r GetApiV5MarketTradesResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r GetApiV5MarketTradesResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } // GetApiV5MarketBooksWithResponse request returning *GetApiV5MarketBooksResponse func (c *ClientWithResponses) GetApiV5MarketBooksWithResponse(ctx context.Context, params *GetApiV5MarketBooksParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketBooksResponse, error) { rsp, err := c.GetApiV5MarketBooks(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketBooksResponse(rsp) } // GetApiV5MarketCandlesWithResponse request returning *GetApiV5MarketCandlesResponse func (c *ClientWithResponses) GetApiV5MarketCandlesWithResponse(ctx context.Context, params *GetApiV5MarketCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketCandlesResponse, error) { rsp, err := c.GetApiV5MarketCandles(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketCandlesResponse(rsp) } // GetApiV5MarketHistoryCandlesWithResponse request returning *GetApiV5MarketHistoryCandlesResponse func (c *ClientWithResponses) GetApiV5MarketHistoryCandlesWithResponse(ctx context.Context, params *GetApiV5MarketHistoryCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketHistoryCandlesResponse, error) { rsp, err := c.GetApiV5MarketHistoryCandles(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketHistoryCandlesResponse(rsp) } // GetApiV5MarketIndexCandlesWithResponse request returning *GetApiV5MarketIndexCandlesResponse func (c *ClientWithResponses) GetApiV5MarketIndexCandlesWithResponse(ctx context.Context, params *GetApiV5MarketIndexCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexCandlesResponse, error) { rsp, err := c.GetApiV5MarketIndexCandles(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketIndexCandlesResponse(rsp) } // GetApiV5MarketIndexComponentsWithResponse request returning *GetApiV5MarketIndexComponentsResponse func (c *ClientWithResponses) GetApiV5MarketIndexComponentsWithResponse(ctx context.Context, params *GetApiV5MarketIndexComponentsParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexComponentsResponse, error) { rsp, err := c.GetApiV5MarketIndexComponents(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketIndexComponentsResponse(rsp) } // GetApiV5MarketIndexTickersWithResponse request returning *GetApiV5MarketIndexTickersResponse func (c *ClientWithResponses) GetApiV5MarketIndexTickersWithResponse(ctx context.Context, params *GetApiV5MarketIndexTickersParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketIndexTickersResponse, error) { rsp, err := c.GetApiV5MarketIndexTickers(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketIndexTickersResponse(rsp) } // GetApiV5MarketMarkPriceCandlesWithResponse request returning *GetApiV5MarketMarkPriceCandlesResponse func (c *ClientWithResponses) GetApiV5MarketMarkPriceCandlesWithResponse(ctx context.Context, params *GetApiV5MarketMarkPriceCandlesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketMarkPriceCandlesResponse, error) { rsp, err := c.GetApiV5MarketMarkPriceCandles(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketMarkPriceCandlesResponse(rsp) } // GetApiV5MarketOpenOracleWithResponse request returning *GetApiV5MarketOpenOracleResponse func (c *ClientWithResponses) GetApiV5MarketOpenOracleWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5MarketOpenOracleResponse, error) { rsp, err := c.GetApiV5MarketOpenOracle(ctx, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketOpenOracleResponse(rsp) } // GetApiV5MarketPlatform24VolumeWithResponse request returning *GetApiV5MarketPlatform24VolumeResponse func (c *ClientWithResponses) GetApiV5MarketPlatform24VolumeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetApiV5MarketPlatform24VolumeResponse, error) { rsp, err := c.GetApiV5MarketPlatform24Volume(ctx, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketPlatform24VolumeResponse(rsp) } // GetApiV5MarketTickerWithResponse request returning *GetApiV5MarketTickerResponse func (c *ClientWithResponses) GetApiV5MarketTickerWithResponse(ctx context.Context, params *GetApiV5MarketTickerParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTickerResponse, error) { rsp, err := c.GetApiV5MarketTicker(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketTickerResponse(rsp) } // GetApiV5MarketTickersWithResponse request returning *GetApiV5MarketTickersResponse func (c *ClientWithResponses) GetApiV5MarketTickersWithResponse(ctx context.Context, params *GetApiV5MarketTickersParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTickersResponse, error) { rsp, err := c.GetApiV5MarketTickers(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketTickersResponse(rsp) } // GetApiV5MarketTradesWithResponse request returning *GetApiV5MarketTradesResponse func (c *ClientWithResponses) GetApiV5MarketTradesWithResponse(ctx context.Context, params *GetApiV5MarketTradesParams, reqEditors ...RequestEditorFn) (*GetApiV5MarketTradesResponse, error) { rsp, err := c.GetApiV5MarketTrades(ctx, params, reqEditors...) if err != nil { return nil, err } return ParseGetApiV5MarketTradesResponse(rsp) } // ParseGetApiV5MarketBooksResponse parses an HTTP response from a GetApiV5MarketBooksWithResponse call func ParseGetApiV5MarketBooksResponse(rsp *http.Response) (*GetApiV5MarketBooksResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketBooksResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketCandlesResponse parses an HTTP response from a GetApiV5MarketCandlesWithResponse call func ParseGetApiV5MarketCandlesResponse(rsp *http.Response) (*GetApiV5MarketCandlesResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketCandlesResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketHistoryCandlesResponse parses an HTTP response from a GetApiV5MarketHistoryCandlesWithResponse call func ParseGetApiV5MarketHistoryCandlesResponse(rsp *http.Response) (*GetApiV5MarketHistoryCandlesResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketHistoryCandlesResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketIndexCandlesResponse parses an HTTP response from a GetApiV5MarketIndexCandlesWithResponse call func ParseGetApiV5MarketIndexCandlesResponse(rsp *http.Response) (*GetApiV5MarketIndexCandlesResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketIndexCandlesResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketIndexComponentsResponse parses an HTTP response from a GetApiV5MarketIndexComponentsWithResponse call func ParseGetApiV5MarketIndexComponentsResponse(rsp *http.Response) (*GetApiV5MarketIndexComponentsResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketIndexComponentsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketIndexTickersResponse parses an HTTP response from a GetApiV5MarketIndexTickersWithResponse call func ParseGetApiV5MarketIndexTickersResponse(rsp *http.Response) (*GetApiV5MarketIndexTickersResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketIndexTickersResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketMarkPriceCandlesResponse parses an HTTP response from a GetApiV5MarketMarkPriceCandlesWithResponse call func ParseGetApiV5MarketMarkPriceCandlesResponse(rsp *http.Response) (*GetApiV5MarketMarkPriceCandlesResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketMarkPriceCandlesResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketOpenOracleResponse parses an HTTP response from a GetApiV5MarketOpenOracleWithResponse call func ParseGetApiV5MarketOpenOracleResponse(rsp *http.Response) (*GetApiV5MarketOpenOracleResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketOpenOracleResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketPlatform24VolumeResponse parses an HTTP response from a GetApiV5MarketPlatform24VolumeWithResponse call func ParseGetApiV5MarketPlatform24VolumeResponse(rsp *http.Response) (*GetApiV5MarketPlatform24VolumeResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketPlatform24VolumeResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketTickerResponse parses an HTTP response from a GetApiV5MarketTickerWithResponse call func ParseGetApiV5MarketTickerResponse(rsp *http.Response) (*GetApiV5MarketTickerResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketTickerResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketTickersResponse parses an HTTP response from a GetApiV5MarketTickersWithResponse call func ParseGetApiV5MarketTickersResponse(rsp *http.Response) (*GetApiV5MarketTickersResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketTickersResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParseGetApiV5MarketTradesResponse parses an HTTP response from a GetApiV5MarketTradesWithResponse call func ParseGetApiV5MarketTradesResponse(rsp *http.Response) (*GetApiV5MarketTradesResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &GetApiV5MarketTradesResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ "H4sIAAAAAAAC/+xa+1Pbxvb/V5j9/tYx1uot+bfm8b0wvbkwhbRzhz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", } // GetSwagger returns the content of the embedded swagger specification file // or error if failed to decode func decodeSpec() ([]byte, error) { zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) if err != nil { return nil, fmt.Errorf("error base64 decoding spec: %s", err) } zr, err := gzip.NewReader(bytes.NewReader(zipped)) if err != nil { return nil, fmt.Errorf("error decompressing spec: %s", err) } var buf bytes.Buffer _, err = buf.ReadFrom(zr) if err != nil { return nil, fmt.Errorf("error decompressing spec: %s", err) } return buf.Bytes(), nil } var rawSpec = decodeSpecCached() // a naive cached of a decoded swagger spec func decodeSpecCached() func() ([]byte, error) { data, err := decodeSpec() return func() ([]byte, error) { return data, err } } // Constructs a synthetic filesystem for resolving external references when loading openapi specifications. func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { var res = make(map[string]func() ([]byte, error)) if len(pathToFile) > 0 { res[pathToFile] = rawSpec } return res } // GetSwagger returns the Swagger specification corresponding to the generated code // in this file. The external references of Swagger specification are resolved. // The logic of resolving external references is tightly connected to "import-mapping" feature. // Externally referenced files must be embedded in the corresponding golang packages. // Urls can be supported but this task was out of the scope. func GetSwagger() (swagger *openapi3.T, err error) { var resolvePath = PathToRawSpec("") loader := openapi3.NewLoader() loader.IsExternalRefsAllowed = true loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { var pathToFile = url.String() pathToFile = path.Clean(pathToFile) getSpec, ok := resolvePath[pathToFile] if !ok { err1 := fmt.Errorf("path not found: %s", pathToFile) return nil, err1 } return getSpec() } var specData []byte specData, err = rawSpec() if err != nil { return } swagger, err = loader.LoadFromData(specData) if err != nil { return } return }