maxapi: move GetMarginInterestRatesRequest api to a file

This commit is contained in:
c9s 2023-05-04 17:18:42 +08:00
parent e9f711278e
commit 40f6295d91
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
4 changed files with 33 additions and 22 deletions

View File

@ -0,0 +1,27 @@
package v3
//go:generate -command GetRequest requestgen -method GET
//go:generate -command PostRequest requestgen -method POST
//go:generate -command DeleteRequest requestgen -method DELETE
import (
"github.com/c9s/requestgen"
"github.com/c9s/bbgo/pkg/fixedpoint"
)
type MarginInterestRate struct {
HourlyInterestRate fixedpoint.Value `json:"hourly_interest_rate"`
NextHourlyInterestRate fixedpoint.Value `json:"next_hourly_interest_rate"`
}
type MarginInterestRateMap map[string]MarginInterestRate
//go:generate GetRequest -url "/api/v3/wallet/m/interest_rates" -type GetMarginInterestRatesRequest -responseType .MarginInterestRateMap
type GetMarginInterestRatesRequest struct {
client requestgen.APIClient
}
func (s *Client) NewGetMarginInterestRatesRequest() *GetMarginInterestRatesRequest {
return &GetMarginInterestRatesRequest{client: s.Client}
}

View File

@ -109,7 +109,7 @@ func (g *GetMarginInterestRatesRequest) GetSlugsMap() (map[string]string, error)
return slugs, nil
}
func (g *GetMarginInterestRatesRequest) Do(ctx context.Context) (*MarginInterestRateMap, error) {
func (g *GetMarginInterestRatesRequest) Do(ctx context.Context) (MarginInterestRateMap, error) {
// no body params
var params interface{}
@ -131,5 +131,5 @@ func (g *GetMarginInterestRatesRequest) Do(ctx context.Context) (*MarginInterest
if err := response.DecodeJSON(&apiResponse); err != nil {
return nil, err
}
return &apiResponse, nil
return apiResponse, nil
}

View File

@ -15,26 +15,10 @@ type MarginService struct {
Client *maxapi.RestClient
}
func (s *Client) NewGetMarginInterestRatesRequest() *GetMarginInterestRatesRequest {
return &GetMarginInterestRatesRequest{client: s.Client}
}
func (s *Client) NewGetMarginBorrowingLimitsRequest() *GetMarginBorrowingLimitsRequest {
return &GetMarginBorrowingLimitsRequest{client: s.Client}
}
type MarginInterestRate struct {
HourlyInterestRate fixedpoint.Value `json:"hourly_interest_rate"`
NextHourlyInterestRate fixedpoint.Value `json:"next_hourly_interest_rate"`
}
type MarginInterestRateMap map[string]MarginInterestRate
//go:generate GetRequest -url "/api/v3/wallet/m/interest_rates" -type GetMarginInterestRatesRequest -responseType .MarginInterestRateMap
type GetMarginInterestRatesRequest struct {
client requestgen.APIClient
}
type MarginBorrowingLimitMap map[string]fixedpoint.Value
//go:generate GetRequest -url "/api/v3/wallet/m/limits" -type GetMarginBorrowingLimitsRequest -responseType .MarginBorrowingLimitMap

View File

@ -6,10 +6,6 @@ package v3
import "github.com/c9s/requestgen"
func (s *Client) NewMarginRepayRequest() *MarginRepayRequest {
return &MarginRepayRequest{client: s.Client}
}
//go:generate PostRequest -url "/api/v3/wallet/m/repayment" -type MarginRepayRequest -responseType .RepaymentRecord
type MarginRepayRequest struct {
client requestgen.AuthenticatedAPIClient
@ -17,3 +13,7 @@ type MarginRepayRequest struct {
currency string `param:"currency,required"`
amount string `param:"amount"`
}
func (s *Client) NewMarginRepayRequest() *MarginRepayRequest {
return &MarginRepayRequest{client: s.Client}
}