client

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressGetBatchRequest

type AddressGetBatchRequest struct {
	// main chain coin name within 12 characters, the coin name platform shall prevail (if bnb_bsc please use eth)
	Coin string `json:"coin,omitempty"`
}

type AddressGetBatchResponse

type AddressGetBatchResponse struct {
	Response
	Data []string `json:"data"`
}

type AddressListData

type AddressListData struct {
	Count   int               `json:"count"`
	List    []AddressListItem `json:"list"`
	MaxPage int               `json:"max_page"`
	Page    int               `json:"page"`
}

type AddressListItem

type AddressListItem struct {
	Address string `json:"address"`
	UserId  string `json:"user_id"`
}

type AddressListRequest

type AddressListRequest struct {
	// address
	Address string `json:"address,omitempty"`
	// main chain coin name - see the description of the public information of supported coins (if bnb_bsc please use eth)
	Coin string `json:"coin,omitempty"`
	// 1<= N <=Max, if it exceeds Max, take Max, if it is less than 1, return 1
	Page int `json:"page,omitempty"`
	// 1=used, 2=not used
	IsUsed int `json:"is_used,omitempty"`
}

type AddressListResponse

type AddressListResponse struct {
	Response
	Data *AddressListData `json:"data"`
}

func (*AddressListResponse) UnmarshalJSON

func (rcv *AddressListResponse) UnmarshalJSON(bytes []byte) error

type AddressSyncStatusRequest

type AddressSyncStatusRequest struct {
	// address, within 128 characters
	Address string `json:"address,omitempty"`
	// Within 12 characters, the main chain currency of the address (if bnb_bsc, please pass eth)
	Coin string `json:"coin,omitempty"`
	// string within 40, user UID assigned by address
	UserId string `json:"user_id,omitempty"`
}

type AddressSyncStatusResponse

type AddressSyncStatusResponse struct {
	Response
	Data *AddressSyncStatusResponseDataItem `json:"data"`
}

func (*AddressSyncStatusResponse) UnmarshalJSON

func (rcv *AddressSyncStatusResponse) UnmarshalJSON(bytes []byte) error

type AddressSyncStatusResponseDataItem

type AddressSyncStatusResponseDataItem struct {
	Address string `json:"address"`
	Coin    string `json:"coin"`
	// fail part
	Msg         string `json:"msg,omitempty"`
	Status      string `json:"status,omitempty"`
	OldAddress  string `json:"old_address,omitempty"`
	OwnerUserId string `json:"owner_user_id,omitempty"`
}

type Client

type Client interface {
	Post(ctx context.Context, urlPath string, request interface{}, responseRcv interface{}) error

	// CoinList Coin related api for the merchant
	CoinList(context.Context, CoinListRequest) (CoinListResponse, error)

	// AddressGetBatch Return the new address to the merchant
	// The number of addresses obtained at a time is N (default 200), and merchants can request multiple times according to actual needs.
	// For accounts like EOS + memo mode, this interface only returns memo, with the interface: /address/coinAccount
	// Note: Platform eth, bnb_bsc (bsc main chain), ht_heco (heco main chain) are sharing the eth address, when requesting the address-related api please use eth as the parameter value of coin (coin=eth )
	AddressGetBatch(context.Context, AddressGetBatchRequest) (AddressGetBatchResponse, error)

	// AddressSyncStatus After the merchant assigns the address to the user, it must notify the platform to update the address usage status through the "Status Synchronization Interface".
	AddressSyncStatus(context.Context, AddressSyncStatusRequest) (AddressSyncStatusResponse, error)

	// AddressList Query address usage status, address ownership.
	AddressList(context.Context, AddressListRequest) (AddressListResponse, error)

	// Transfer The merchant initial a on-chain withdrawal request will use this API. In order to complete the withdrawl request, merchant need to prepare the callback API for risk control callback. ( Detail please refer to the Risk Control callback -> The second review of the withdrawal order)
	Transfer(context.Context, TransferRequest) (TransferResponse, error)
}

func NewClient

func NewClient(config Config) Client

type CoinListData

type CoinListData struct {
	Count   int            `json:"count"`
	List    []CoinListItem `json:"list"`
	MaxPage int            `json:"max_page"`
	Page    int            `json:"page"`
}

type CoinListItem

type CoinListItem struct {
	Chain                string `json:"chain"`
	Coin                 string `json:"coin"`
	ConfirmCount         string `json:"confirm_count"`
	MinTransferInAmount  string `json:"min_transfer_in_amount"`
	MinTransferOutAmount string `json:"min_transfer_out_amount"`
	OpenAddress          string `json:"open_address"`
	OpenIn               int    `json:"open_in"`
	OpenOut              int    `json:"open_out"`
	Status               string `json:"status"`
}

type CoinListRequest

type CoinListRequest struct {
	// coin name (eg: eth)
	Coin string `json:"coin,omitempty"`
	// Main chain name (query main chain and its tokens, such as: eth)
	Chain string `json:"chain,omitempty"`
	// 1<= N <=Max, N>Max ? N=Max ; N<1 ? N=1
	Page int `json:"page,omitempty"`
	// number of pages per page (20 ~ 500), default 20
	PageSize int `json:"page_size,omitempty"`
}

type CoinListResponse

type CoinListResponse struct {
	Response
	Data *CoinListData `json:"data"`
}

func (*CoinListResponse) UnmarshalJSON

func (rcv *CoinListResponse) UnmarshalJSON(bytes []byte) error

type Config

type Config struct {
	// required, provided by platform
	AppId string `json:"app_id" yaml:"app_id"`
	// required, default: 1.0
	Version string `json:"version" yaml:"version"`
	// required, default: admin
	KeyVersion string `json:"key_version" yaml:"key_version"`
	// required, RSA private key value for generate request crypto. Create RSA key pair options,length=2048,format=PKCS#8
	PrivateKey string `json:"private_key" yaml:"private_key"`
	// required, RSA public key value for verify API response,provided by platform
	PlatformPublicKey string `json:"platform_public_key" yaml:"platform_public_key"`
	// required, provided by platform
	BaseUrl string `json:"base_url" yaml:"base_url"`
}

type Response

type Response struct {
	Status    int             `json:"status"`
	Msg       string          `json:"msg"`
	Data      json.RawMessage `json:"data"`
	DateTime  string          `json:"date_time"`
	TimeStamp int64           `json:"time_stamp"`
	Sign      string          `json:"sign"`
}

func (*Response) ApiError

func (rcv *Response) ApiError() error

type TransferRequest

type TransferRequest struct {
	// user ID, out of range error
	UserId string `json:"user_id,omitempty"`
	// currency abbreviation - platform agreement shall prevail
	Coin string `json:"coin,omitempty"`
	// withdrawal amount, an error will occur if it exceeds the range
	Amount string `json:"amount,omitempty"`
	// payment address, an error will occur if it exceeds the range
	Address string `json:"address,omitempty"`
	// memo/tag needs to be filled in when the current currency is eos and its tokens
	Memo string `json:"memo,omitempty"`
	// The unique ID of the merchant's transaction (recommended format: year, month, day, hour, minute, second + 6-digit random number case: 20200311202903000001)
	TradeId string `json:"trade_id,omitempty"`
}

type TransferResponse

type TransferResponse struct {
	Response
	Data *TransferResponseData
}

func (*TransferResponse) UnmarshalJSON

func (rcv *TransferResponse) UnmarshalJSON(bytes []byte) error

type TransferResponseData

type TransferResponseData struct {
	TradeId string `json:"trade_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL