Documentation ¶
Index ¶
- type AccessToken
- type ApiSettings
- func (a *ApiSettings) WithBaseUrl(BaseUrl string) *ApiSettings
- func (a *ApiSettings) WithClientId(ClientId string) *ApiSettings
- func (a *ApiSettings) WithClientSecret(ClientSecret string) *ApiSettings
- func (a *ApiSettings) WithTimeout(Timeout int32) *ApiSettings
- func (a *ApiSettings) WithVerifySsl(VerifySsl bool) *ApiSettings
- type AuthSession
- type DelimInt64
- type DelimString
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int32 `json:"expires_in"` ExpireTime time.Time }
func NewAccessToken ¶
func NewAccessToken(js []byte) (AccessToken, error)
func (AccessToken) IsExpired ¶
func (t AccessToken) IsExpired() bool
type ApiSettings ¶
type ApiSettings struct { BaseUrl string `ini:"base_url"` VerifySsl bool `ini:"verify_ssl"` Timeout int32 `ini:"timeout"` AgentTag string `ini:"agent_tag"` FileName string `ini:"file_name"` ClientId string `ini:"client_id"` ClientSecret string `ini:"client_secret"` ApiVersion string `ini:"api_version"` }
func NewSettings ¶
func NewSettings() *ApiSettings
func NewSettingsFromEnv ¶ added in v0.0.6
func NewSettingsFromEnv() (ApiSettings, error)
func NewSettingsFromFile ¶
func NewSettingsFromFile(file string, section *string) (ApiSettings, error)
func (*ApiSettings) WithBaseUrl ¶
func (a *ApiSettings) WithBaseUrl(BaseUrl string) *ApiSettings
func (*ApiSettings) WithClientId ¶
func (a *ApiSettings) WithClientId(ClientId string) *ApiSettings
func (*ApiSettings) WithClientSecret ¶
func (a *ApiSettings) WithClientSecret(ClientSecret string) *ApiSettings
func (*ApiSettings) WithTimeout ¶
func (a *ApiSettings) WithTimeout(Timeout int32) *ApiSettings
func (*ApiSettings) WithVerifySsl ¶
func (a *ApiSettings) WithVerifySsl(VerifySsl bool) *ApiSettings
type AuthSession ¶
type AuthSession struct { Config ApiSettings Transport http.RoundTripper // contains filtered or unexported fields }
func NewAuthSession ¶
func NewAuthSession(config ApiSettings) *AuthSession
func NewAuthSessionWithTransport ¶ added in v0.0.4
func NewAuthSessionWithTransport(config ApiSettings, transport http.RoundTripper) *AuthSession
The transport parameter may override your VerifySSL setting
func (*AuthSession) Authenticate ¶
func (s *AuthSession) Authenticate(req *http.Request) error
Authenticate checks if the token is expired (do the token refresh if so), and updates the request header with Authorization
func (*AuthSession) Do ¶
func (s *AuthSession) Do(result interface{}, method, ver, path string, reqPars map[string]interface{}, body interface{}, options *ApiSettings) error
type DelimInt64 ¶
type DelimInt64 []int64
type alias to in64 slice, this is needed for custom serialization
func (DelimInt64) MarshalJSON ¶
func (i DelimInt64) MarshalJSON() ([]byte, error)
MarshalJSON is custom json marshaling for DelimInt64 type It marshals the DelimInt64 (slice of int64) to comma separated json string value example:
DelimInt64{1,2,3} -> "1,2,3"
func (*DelimInt64) UnmarshalJSON ¶
func (i *DelimInt64) UnmarshalJSON(b []byte) error
UnmarshalJSON is custom json unmarshaling for DelimInt64 type It expects string as input, split the string by comma and convert it to DelimInt64 (slice of int64) example:
"1,2,3" -> DelimInt64{1,2,3}
type DelimString ¶
type DelimString []string
type alias to string slice, this is needed for custom serialization
func (DelimString) MarshalJSON ¶
func (s DelimString) MarshalJSON() ([]byte, error)
MarshalJSON is custome json marshaling for DelimString type It marshals the DelimString (slice of strings) to comma separated json string value example: DelimString{"one","two","three"} -> "one,two,three"
func (*DelimString) UnmarshalJSON ¶
func (s *DelimString) UnmarshalJSON(b []byte) error
UnmarshalJSON is custom json unmarshaling for DelimString type It expects json string as input, and split it by comma to multiple strings. example:
"one,two,three" -> DelimString{"one","two","three"}