bybit.go.api/asset.go

494 lines
12 KiB
Go
Raw Normal View History

2023-11-06 01:44:54 +02:00
package bybit_connector
import (
"context"
"net/http"
2024-06-03 23:07:14 +03:00
"gitea.computernetthings.ru/yash/bybit.go.api/handlers"
2023-11-06 01:44:54 +02:00
)
type AssetClient struct {
c *Client
params map[string]interface{}
}
func (s *AssetClient) GetAssetOrderRecord(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/exchange/order-record",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetAssetInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/transfer/query-asset-info",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetDeliveryRecord(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/delivery-record",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetUsdcSettlement(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/settlement-record",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetAllCoinsBalance(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/transfer/query-account-coins-balance",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetSingleCoinsBalance(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
2024-02-22 19:19:26 +02:00
if err = handlers.ValidateParams(s.params); err != nil {
return nil, err
}
2023-11-06 01:44:54 +02:00
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/transfer/query-account-coin-balance",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetTransferableCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
2024-02-22 19:19:26 +02:00
if err = handlers.ValidateParams(s.params); err != nil {
return nil, err
}
2023-11-06 01:44:54 +02:00
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/transfer/query-transfer-coin-list",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) CreateInternalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
2024-02-22 19:19:26 +02:00
if err = handlers.ValidateParams(s.params); err != nil {
return nil, err
}
2023-11-06 01:44:54 +02:00
r := &request{
method: http.MethodPost,
endpoint: "/v5/asset/transfer/inter-transfer",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) CreateUniversalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
2024-02-22 19:19:26 +02:00
if err = handlers.ValidateParams(s.params); err != nil {
return nil, err
}
2023-11-06 01:44:54 +02:00
r := &request{
method: http.MethodPost,
endpoint: "/v5/asset/transfer/universal-transfer",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) SetDepositAccount(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
2024-02-22 19:19:26 +02:00
if err = handlers.ValidateParams(s.params); err != nil {
return nil, err
}
2023-11-06 01:44:54 +02:00
r := &request{
method: http.MethodPost,
endpoint: "/v5/asset/deposit/deposit-to-account",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) WithdrawAsset(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
2024-02-22 19:19:26 +02:00
if err = handlers.ValidateParams(s.params); err != nil {
return nil, err
}
2023-11-06 01:44:54 +02:00
r := &request{
method: http.MethodPost,
endpoint: "/v5/asset/withdraw/create",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) CancelWithdrawAsset(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
2024-02-22 19:19:26 +02:00
if err = handlers.ValidateParams(s.params); err != nil {
return nil, err
}
2023-11-06 01:44:54 +02:00
r := &request{
method: http.MethodPost,
endpoint: "/v5/asset/withdraw/cancel",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetInternalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
2024-02-22 19:19:26 +02:00
if err = handlers.ValidateParams(s.params); err != nil {
return nil, err
}
2023-11-06 01:44:54 +02:00
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/transfer/query-inter-transfer-list",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetUniversalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/transfer/query-universal-transfer-list",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetSubUids(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/transfer/query-sub-member-list",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetAllowedDepositCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/deposit/query-allowed-list",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/deposit/query-record",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetSubDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/deposit/query-sub-member-record",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetInternalDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/deposit/query-internal-record",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetMasterDepositAddress(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/deposit/query-address",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetSubDepositAddress(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/deposit/query-sub-member-address",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetCoinInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/coin/query-info",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
func (s *AssetClient) GetWithdrawalAmount(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/withdraw/withdrawable-amount",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
2024-06-03 23:07:14 +03:00
2023-11-06 01:44:54 +02:00
func (s *AssetClient) GetWithdrawalRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/v5/asset/withdraw/query-record",
secType: secTypeSigned,
}
2024-02-22 19:19:26 +02:00
r.setParams(s.params)
2023-11-06 01:44:54 +02:00
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ServerResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}