Documentation
¶
Index ¶
- Constants
- func GetErrorName(code int) string
- func NewError(etype string, message string, data interface{}) error
- type Client
- func (c *Client) CheckEnctokenValid(enctoken string) (bool, error)
- func (c *Client) GenerateSession(password, totpSecret string) (UserSession, error)
- func (c *Client) GetUserProfile() (UserProfile, error)
- func (c *Client) SetBaseURI(baseURI string)
- func (c *Client) SetDebug(debug bool)
- func (c *Client) SetEnctoken(enctoken string)
- func (c *Client) SetHTTPClient(h *http.Client)
- func (c *Client) SetTimeout(timeout time.Duration)
- type Error
- type HTTPClient
- type HTTPResponse
- type LoginResonse
- type PlainResponse
- type Time
- type UserProfile
- type UserSession
Constants ¶
const ( URILogin string = "/api/login" URITwofa string = "/api/twofa" URIUserProfile string = "/oms/user/profile" )
API endpoints
const ( GeneralError = "GeneralException" TokenError = "TokenException" PermissionError = "PermissionError" UserError = "UserException" TwoFAError = "TwoFAException" OrderError = "OrderException" InputError = "InputException" DataError = "DataException" NetworkError = "NetworkException" )
API errors.
Variables ¶
This section is empty.
Functions ¶
func GetErrorName ¶
GetErrorName returns an error name given an HTTP code.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents interface for Kiteauth client.
func (*Client) CheckEnctokenValid ¶ added in v1.0.2
Check if enctoken is valid
func (*Client) GenerateSession ¶
func (c *Client) GenerateSession(password, totpSecret string) (UserSession, error)
GenerateSession gets a user session Step 1: First a login request is made and request_id is obtained. Step 2: Then a twofa request is made to generate the user session.
func (*Client) GetUserProfile ¶
func (c *Client) GetUserProfile() (UserProfile, error)
GetUserProfile gets user profile.
func (*Client) SetBaseURI ¶
SetBaseURI overrides the base Kiteauth API endpoint with custom url.
func (*Client) SetEnctoken ¶
SetEnctoken sets the enctoken to the Kiteauth instance.
func (*Client) SetHTTPClient ¶
SetHTTPClient overrides default http handler with a custom one. This can be used to set custom timeouts and transport.
func (*Client) SetTimeout ¶
SetTimeout sets request timeout for default http client.
type HTTPClient ¶
type HTTPClient interface {
Do(method, rURL string, params url.Values, headers http.Header) (HTTPResponse, error)
DoRaw(method, rURL string, reqBody []byte, headers http.Header) (HTTPResponse, error)
DoEnvelope(method, url string, params url.Values, headers http.Header, obj interface{}) error
DoJSON(method, url string, params url.Values, headers http.Header, obj interface{}) (HTTPResponse, error)
GetClient() *httpClient
}
HTTPClient represents an HTTP client.
func NewHTTPClient ¶
NewHTTPClient returns a self-contained HTTP request object with underlying keep-alive transport.
type HTTPResponse ¶
HTTPResponse encompasses byte body + the response of an HTTP request.
type LoginResonse ¶
type LoginResonse struct {
UserId string `json:"user_id"`
RequestId string `json:"request_id"`
TwofaType string `json:"twofa_type"`
TwofaTypes []string `json:"twofa_types"`
TwofaStatus string `json:"twofa_status"`
Profile struct {
UserName string `json:"user_name"`
UserShortname string `json:"user_shortname"`
AvatarURL any `json:"avatar_url"`
} `json:"profile"`
}
LoginResonse represents a login response
type PlainResponse ¶
PlainResponse is a helper for receiving blank HTTP envelop responses without any payloads.
type UserProfile ¶
type UserProfile struct {
UserId string `json:"user_id"`
UserType string `json:"user_type"`
Email string `json:"email"`
UserName string `json:"user_name"`
UserShortname string `json:"user_shortname"`
Broker string `json:"broker"`
Exchanges []string `json:"exchanges"`
Products []string `json:"products"`
OrderTypes []string `json:"order_types"`
AvatarURL interface{} `json:"avatar_url"`
Meta struct {
DematConsent string `json:"demat_consent"`
} `json:"meta"`
}
UserProfile represents a user profile.
type UserSession ¶
type UserSession struct {
UserId string `json:"user_id"`
Enctoken string `json:"enctoken"`
LoginTime string `json:"login_time"`
}
UserSession represents a user session