2021-12-10 13:43:40 +00:00
|
|
|
package kucoinapi
|
|
|
|
|
2021-12-30 17:23:16 +00:00
|
|
|
//go:generate -command GetRequest requestgen -method GET -responseType .APIResponse -responseDataField Data
|
2021-12-30 17:39:45 +00:00
|
|
|
//go:generate -command PostRequest requestgen -method POST -responseType .APIResponse -responseDataField Data
|
2021-12-30 17:23:16 +00:00
|
|
|
|
2021-12-29 14:06:21 +00:00
|
|
|
import (
|
2021-12-30 17:23:16 +00:00
|
|
|
"github.com/c9s/requestgen"
|
|
|
|
|
2021-12-29 14:06:21 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
|
|
|
)
|
2021-12-10 13:43:40 +00:00
|
|
|
|
|
|
|
type AccountService struct {
|
|
|
|
client *RestClient
|
|
|
|
}
|
|
|
|
|
2021-12-31 18:04:20 +00:00
|
|
|
func (s *AccountService) NewListSubAccountsRequest() *ListSubAccountsRequest {
|
|
|
|
return &ListSubAccountsRequest{client: s.client}
|
2021-12-30 17:23:16 +00:00
|
|
|
}
|
|
|
|
|
2021-12-31 18:04:20 +00:00
|
|
|
func (s *AccountService) NewListAccountsRequest() *ListAccountsRequest {
|
|
|
|
return &ListAccountsRequest{client: s.client}
|
2021-12-30 17:23:16 +00:00
|
|
|
}
|
|
|
|
|
2021-12-31 18:04:20 +00:00
|
|
|
func (s *AccountService) NewGetAccountRequest(accountID string) *GetAccountRequest {
|
|
|
|
return &GetAccountRequest{client: s.client, accountID: accountID}
|
2021-12-30 17:23:16 +00:00
|
|
|
}
|
|
|
|
|
2021-12-10 13:43:40 +00:00
|
|
|
type SubAccount struct {
|
|
|
|
UserID string `json:"userId"`
|
2021-12-21 16:30:16 +00:00
|
|
|
Name string `json:"subName"`
|
|
|
|
Type string `json:"type"`
|
2021-12-10 13:43:40 +00:00
|
|
|
Remark string `json:"remarks"`
|
|
|
|
}
|
|
|
|
|
2021-12-30 17:36:21 +00:00
|
|
|
//go:generate GetRequest -url "/api/v1/sub/user" -type ListSubAccountsRequest -responseDataType []SubAccount
|
|
|
|
type ListSubAccountsRequest struct {
|
2021-12-30 17:23:16 +00:00
|
|
|
client requestgen.AuthenticatedAPIClient
|
2021-12-10 16:25:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Account struct {
|
2021-12-21 16:30:16 +00:00
|
|
|
ID string `json:"id"`
|
|
|
|
Currency string `json:"currency"`
|
|
|
|
Type AccountType `json:"type"`
|
|
|
|
Balance fixedpoint.Value `json:"balance"`
|
2021-12-10 16:25:55 +00:00
|
|
|
Available fixedpoint.Value `json:"available"`
|
2021-12-21 16:30:16 +00:00
|
|
|
Holds fixedpoint.Value `json:"holds"`
|
2021-12-10 16:25:55 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 17:36:21 +00:00
|
|
|
//go:generate GetRequest -url "/api/v1/accounts" -type ListAccountsRequest -responseDataType []Account
|
|
|
|
type ListAccountsRequest struct {
|
2021-12-30 17:23:16 +00:00
|
|
|
client requestgen.AuthenticatedAPIClient
|
2021-12-10 16:34:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 17:36:21 +00:00
|
|
|
//go:generate GetRequest -url "/api/v1/accounts/:accountID" -type GetAccountRequest -responseDataType .Account
|
|
|
|
type GetAccountRequest struct {
|
2021-12-30 17:23:16 +00:00
|
|
|
client requestgen.AuthenticatedAPIClient
|
|
|
|
accountID string `param:"accountID,slug"`
|
2021-12-21 16:30:16 +00:00
|
|
|
}
|