Documentation
¶
Index ¶
- Variables
- type Client
- type Logger
- type Response
- func (r *Response) ValueFromKey(key string) (any, error)
- func (r *Response) ValueFromKeyMap(key string) (map[string]any, error)
- func (r *Response) ValueFromKeyN(key string, index int) (any, error)
- func (r *Response) ValueFromKeyNMap(key string, index int) (map[string]any, error)
- func (r *Response) ValueFromKeyNString(key string, index int) (string, error)
- func (r *Response) ValueFromKeyString(key string) (string, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Current oauth token
Token string
// URL to be used when refreshing the token
TokenRefreshURL string
// Client ID of the service user account in IFS
ID string
// Client secret of the service user account in IFS
Secret string
// The root url of the IFS api. This allows calling specific endpoints
// without needing to provide the whole URL each time.
RootURL string
// Fully customizable logger enabled by default with sane defaults.
// Disable with Client.DisableLogging().
Log Logger
}
Client used to make requests and store the latest response
func NewClient ¶
Creates a client Expects the IFS user clientID and clientSecret. As well as the url to issue refresh requests. Also takes the rootURL of the api for ex: "https://ifs.com/main/ifsapplications/projection/v1" This makes it less noisy when calling endpoints later as you just have to provide the endpoint not the whole url each time.
type Logger ¶
Wrapper around log.Logger to allow the user to disable logging.
func (*Logger) Disable ¶
func (l *Logger) Disable()
Disables the logger. Can also set Logger.Enabled manually
func (*Logger) Enable ¶
func (l *Logger) Enable()
Enables the logger. Can also set Logger.Enabled manually
type Response ¶
type Response struct {
// Raw response from IFS
DataRaw []byte
// Response from IFS already mapped
DataMap map[string]any
// @odata.count if exists in the response if not found it will be -1
Count int
// IFS returned value array. Typically it will be an array of objects.
Value []any
// HTTP status code
StatusCode int
}
The response from the IFS API
func (*Response) ValueFromKey ¶
Returns the first value indexed by key in Response.ValueMap if it exists
func (*Response) ValueFromKeyMap ¶ added in v0.3.0
Returns the first value indexed by key in Response.ValueMap as a map[string]any if it exists. Useful for converting value into a struct.
func (*Response) ValueFromKeyN ¶
Returns the value indexed by key in Response.ValueMap[index] if it exists.
func (*Response) ValueFromKeyNMap ¶ added in v0.3.0
Returns the value indexed by key in Response.ValueMap[index] as a map[string]any if it exists. Useful for converting value into a struct.
func (*Response) ValueFromKeyNString ¶ added in v0.2.0
Returns the value indexed by key in Response.ValueMap[index] as a string if it exists.