Documentation ¶
Index ¶
- Constants
- func EncryptPassword(raw, timestamp string) (encrypted string, err error)
- func NewError(httpStatus int, resp *apiResponse) error
- type ApiError
- type Client
- func (c *Client) Call(ctx context.Context, method, path string, queryParams interface{}, ...) (err error)
- func (c *Client) Delete(ctx context.Context, path string, queryParams interface{}, resp interface{}, ...) error
- func (c *Client) Get(ctx context.Context, path string, queryParams url.Values, resp interface{}, ...) error
- func (c *Client) GetOTP(ctx context.Context, ropts ...RequestOption) (string, error)
- func (c *Client) GetOTPV2(ctx context.Context, ropts ...RequestOption) (string, error)
- func (c *Client) Post(ctx context.Context, path string, body interface{}, resp interface{}, ...) error
- func (c *Client) Put(ctx context.Context, path string, body interface{}, resp interface{}, ...) error
- type Option
- type Options
- type RequestOption
- type RequestOptions
Constants ¶
const DefaultHttpUrl = "https://openapi.longportapp.com"
DefaultHttpUrl
const DefaultTimeout = 15 * time.Second
DefaultTimeout
Variables ¶
This section is empty.
Functions ¶
func EncryptPassword ¶
EncryptPassword use to encrypt password Use aes with cbc mode to encrypt password 1. use md5(timestamp) as secret key for md5 have fixed length 2. use key[:16] is cbc iv 3. md5(raw_password) as plain content 4. padding plain content 5. encrypt
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a http client to access Longbridge REST OpenAPI
func NewFromCfg ¶
NewFromCfg init longbridge http client from *config.Config
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, method, path string, queryParams interface{}, body interface{}, resp interface{}, ropts ...RequestOption) (err error)
Call will send request with signature to http server
func (*Client) Delete ¶
func (c *Client) Delete(ctx context.Context, path string, queryParams interface{}, resp interface{}, ropts ...RequestOption) error
Delete sends Delete request with queryParams
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, path string, queryParams url.Values, resp interface{}, ropts ...RequestOption) error
Get sends Get request with queryParams
func (*Client) GetOTP ¶
GetOTP to get one time password Reference: https://open.longportapp.com/en/docs/socket-token-api
type Option ¶
type Option func(*Options)
Option for http client
func WithAccessToken ¶
WithAccessToken to set access token
func WithTimeout ¶
WithTimeout to set http client timeout. Worked when Options.Client is not set
type Options ¶
type Options struct { URL string AppKey string AppSecret string AccessToken string Timeout time.Duration Client *http.Client }
Options for http client
type RequestOption ¶
type RequestOption func(*RequestOptions)
RequestOption use to set addition info to request
type RequestOptions ¶
RequestOptions use to set additional information for the request