2023-11-06 01:44:54 +02:00
|
|
|
package bybit_connector
|
|
|
|
|
2023-11-06 02:08:54 +02:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
2024-06-03 23:07:14 +03:00
|
|
|
|
|
|
|
"gitea.computernetthings.ru/yash/bybit.go.api/handlers"
|
2023-11-06 02:08:54 +02:00
|
|
|
)
|
|
|
|
|
2023-11-06 01:44:54 +02:00
|
|
|
type UserServiceClient struct {
|
|
|
|
c *Client
|
|
|
|
params map[string]interface{}
|
|
|
|
}
|
2023-11-06 02:08:54 +02:00
|
|
|
|
|
|
|
func (s *UserServiceClient) CreateSubMember(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
|
|
|
method: http.MethodPost,
|
|
|
|
endpoint: "/v5/user/create-sub-member",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) CreateSubApiKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
|
|
|
method: http.MethodPost,
|
|
|
|
endpoint: "/v5/user/create-sub-api",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) FreezeSubUID(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
|
|
|
method: http.MethodPost,
|
|
|
|
endpoint: "/v5/user/frozen-sub-member",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) ModifyMasterAPIKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
|
|
|
method: http.MethodPost,
|
|
|
|
endpoint: "/v5/user/update-api",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) ModifySubAPIKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
|
|
|
method: http.MethodPost,
|
|
|
|
endpoint: "/v5/user/update-sub-api",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) DeleteSubUID(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
|
|
|
method: http.MethodPost,
|
|
|
|
endpoint: "/v5/user/del-submember",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) DeleteMasterAPIKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
|
|
|
method: http.MethodPost,
|
|
|
|
endpoint: "/v5/user/delete-api",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) DeleteSubAPIKey(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
|
|
|
method: http.MethodPost,
|
|
|
|
endpoint: "/v5/user/delete-sub-api",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) GetSubUidList(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
2023-12-10 16:25:04 +02:00
|
|
|
method: http.MethodGet,
|
2023-11-06 02:08:54 +02:00
|
|
|
endpoint: "/v5/user/query-sub-members",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) GetAPIKeyInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
r := &request{
|
2023-12-10 16:25:04 +02:00
|
|
|
method: http.MethodGet,
|
2023-11-06 02:08:54 +02:00
|
|
|
endpoint: "/v5/user/query-api",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
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 *UserServiceClient) GetUidWalletType(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
2023-12-10 16:25:04 +02:00
|
|
|
method: http.MethodGet,
|
2023-11-06 02:08:54 +02:00
|
|
|
endpoint: "/v5/user/get-member-type",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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 *UserServiceClient) GetAffiliateUserInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
|
|
|
if err = handlers.ValidateParams(s.params); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
r := &request{
|
2023-12-10 16:25:04 +02:00
|
|
|
method: http.MethodGet,
|
2023-11-06 02:08:54 +02:00
|
|
|
endpoint: "/v5/user/aff-customer-info",
|
|
|
|
secType: secTypeSigned,
|
|
|
|
}
|
|
|
|
r.setParams(s.params)
|
|
|
|
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
|
|
|
|
}
|