Files
sdk/api_market.go

651 lines
22 KiB
Go

/*
Hanzo Cloud API
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
API version: v1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hanzoai
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
)
// MarketAPIService MarketAPI service
type MarketAPIService service
type MarketAPIGetMarketChainsRequest struct {
ctx context.Context
ApiService *MarketAPIService
}
func (r MarketAPIGetMarketChainsRequest) Execute() (*MarketRoster, *http.Response, error) {
return r.ApiService.GetMarketChainsExecute(r)
}
/*
GetMarketChains Answers every chain this deployment can read, what is deployed on each, and what its automated market maker amounts to.
Answers every chain this deployment can read, what is deployed on each, and what
its automated market maker amounts to.
One call. It reads the chain registry, then every chain's indexer for its figures
and its most recent active day, all at once — where a client doing it itself makes
one registry request and two more per chain.
THE ROW IS THE UNIT OF TRUTH. Each carries its own reach, so one indexer being
unreachable costs one row its figures and leaves the rest answered. A chain with no
market maker deployed — the registry names no factory for it — answers `read` with
totals of nothing, which is a fact about that chain and is not the same as a chain
nobody could ask.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return MarketAPIGetMarketChainsRequest
*/
func (a *MarketAPIService) GetMarketChains(ctx context.Context) MarketAPIGetMarketChainsRequest {
return MarketAPIGetMarketChainsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return MarketRoster
func (a *MarketAPIService) GetMarketChainsExecute(r MarketAPIGetMarketChainsRequest) (*MarketRoster, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *MarketRoster
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MarketAPIService.GetMarketChains")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/market/chains"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type MarketAPIGetMarketPoolsRequest struct {
ctx context.Context
ApiService *MarketAPIService
chain *string
}
// Chain is the chain's slug — `cchain`, `zoo` — as `chains` reports it. It is the indexer's word for the chain and NOT the chain id: `96369`, `C` and `c-chain` all name nothing.
func (r MarketAPIGetMarketPoolsRequest) Chain(chain string) MarketAPIGetMarketPoolsRequest {
r.chain = &chain
return r
}
func (r MarketAPIGetMarketPoolsRequest) Execute() (*MarketPools, *http.Response, error) {
return r.ApiService.GetMarketPoolsExecute(r)
}
/*
GetMarketPools Answers the automated market makers on one chain: their two tokens, their fee tier, and what has moved through each.
Answers the automated market makers on one chain: their two tokens, their fee tier,
and what has moved through each.
The two price fields on a pool are the ratio its own reserves stand at, as the
indexer computed them. They are not a price ON either token and not a mark: nothing
here derives one, ranks the pools, or names a route through them.
A chain with no market maker deployed answers `read` with no pools. That is the
chain's real condition, and it is deliberately not the same answer as an indexer
that could not be asked.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return MarketAPIGetMarketPoolsRequest
*/
func (a *MarketAPIService) GetMarketPools(ctx context.Context) MarketAPIGetMarketPoolsRequest {
return MarketAPIGetMarketPoolsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return MarketPools
func (a *MarketAPIService) GetMarketPoolsExecute(r MarketAPIGetMarketPoolsRequest) (*MarketPools, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *MarketPools
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MarketAPIService.GetMarketPools")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/market/pools"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.chain != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "chain", r.chain, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type MarketAPIGetMarketSurveyRequest struct {
ctx context.Context
ApiService *MarketAPIService
chain *string
}
// Chain is the chain's slug — `cchain`, `zoo` — as `chains` reports it. It is the indexer's word for the chain and NOT the chain id: `96369`, `C` and `c-chain` all name nothing.
func (r MarketAPIGetMarketSurveyRequest) Chain(chain string) MarketAPIGetMarketSurveyRequest {
r.chain = &chain
return r
}
func (r MarketAPIGetMarketSurveyRequest) Execute() (*MarketSurvey, *http.Response, error) {
return r.ApiService.GetMarketSurveyExecute(r)
}
/*
GetMarketSurvey Answers which of the four settlement precompiles carry code on one chain.
Answers which of the four settlement precompiles carry code on one chain.
An address with no code answers a call with empty data rather than an error, so
"this chain has no view precompile" and "this market was never opened" reach a
caller as the same silence — and only the second is a fact about a market. This
says which it is, by asking the node for the code at each address.
It reads presence and nothing else. No market, no quote, no depth and no order is
requested here, and `eth_getCode` is the only method this operation ever sends.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return MarketAPIGetMarketSurveyRequest
*/
func (a *MarketAPIService) GetMarketSurvey(ctx context.Context) MarketAPIGetMarketSurveyRequest {
return MarketAPIGetMarketSurveyRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return MarketSurvey
func (a *MarketAPIService) GetMarketSurveyExecute(r MarketAPIGetMarketSurveyRequest) (*MarketSurvey, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *MarketSurvey
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MarketAPIService.GetMarketSurvey")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/market/survey"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.chain != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "chain", r.chain, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type MarketAPIGetMarketTokenRequest struct {
ctx context.Context
ApiService *MarketAPIService
chain *string
at *string
}
func (r MarketAPIGetMarketTokenRequest) Chain(chain string) MarketAPIGetMarketTokenRequest {
r.chain = &chain
return r
}
// At is the token's contract address.
func (r MarketAPIGetMarketTokenRequest) At(at string) MarketAPIGetMarketTokenRequest {
r.at = &at
return r
}
func (r MarketAPIGetMarketTokenRequest) Execute() (*MarketHistory, *http.Response, error) {
return r.ApiService.GetMarketTokenExecute(r)
}
/*
GetMarketToken Answers one token's daily history — open, high, low, close, price and volume per UTC day, oldest first.
Answers one token's daily history — open, high, low, close, price and volume per
UTC day, oldest first.
Every figure is the indexer's own arithmetic, passed through as the decimal string
it computed. Nothing here rounds one, converts one, or fills a gap: a day the
indexer holds no figure for arrives with that field absent, which says "not
indexed" where a zero would say "worth nothing".
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return MarketAPIGetMarketTokenRequest
*/
func (a *MarketAPIService) GetMarketToken(ctx context.Context) MarketAPIGetMarketTokenRequest {
return MarketAPIGetMarketTokenRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return MarketHistory
func (a *MarketAPIService) GetMarketTokenExecute(r MarketAPIGetMarketTokenRequest) (*MarketHistory, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *MarketHistory
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MarketAPIService.GetMarketToken")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/market/token"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.chain != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "chain", r.chain, "form", "")
}
if r.at != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "at", r.at, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type MarketAPIGetMarketTokensRequest struct {
ctx context.Context
ApiService *MarketAPIService
chain *string
}
// Chain is the chain's slug — `cchain`, `zoo` — as `chains` reports it. It is the indexer's word for the chain and NOT the chain id: `96369`, `C` and `c-chain` all name nothing.
func (r MarketAPIGetMarketTokensRequest) Chain(chain string) MarketAPIGetMarketTokensRequest {
r.chain = &chain
return r
}
func (r MarketAPIGetMarketTokensRequest) Execute() (*MarketTokens, *http.Response, error) {
return r.ApiService.GetMarketTokensExecute(r)
}
/*
GetMarketTokens Answers the tokens one chain's indexer has seen, with the decimals a caller needs to read any amount of one correctly.
Answers the tokens one chain's indexer has seen, with the decimals a caller needs
to read any amount of one correctly.
This is what the indexer INGESTED, which is not the same as what exists on the
chain: a token nothing has traded has no row here, and this is not a registry of
what is permitted or listed.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return MarketAPIGetMarketTokensRequest
*/
func (a *MarketAPIService) GetMarketTokens(ctx context.Context) MarketAPIGetMarketTokensRequest {
return MarketAPIGetMarketTokensRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return MarketTokens
func (a *MarketAPIService) GetMarketTokensExecute(r MarketAPIGetMarketTokensRequest) (*MarketTokens, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *MarketTokens
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MarketAPIService.GetMarketTokens")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/market/tokens"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.chain != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "chain", r.chain, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}