Documentation ¶
Index ¶
- Variables
- func AddToQueryIfSet(q url.Values, key string, value string)
- func FirstNElementsOfSlice[Element any](slice []Element, n int) []Element
- func MapToCommaString[t any](slice []t) string
- type Call
- func (a *Call[responseType]) Execute(httpClient HTTPClient) (*CallResponse[responseType], error)
- func (a *Call[responseType]) WithBody(body []byte) *Call[responseType]
- func (a *Call[responseType]) WithParseErrorListOnError() *Call[responseType]
- func (a *Call[responseType]) WithQueryParams(queryParams url.Values) *Call[responseType]
- func (a *Call[responseType]) WithRateLimit(callsPer float32, duration time.Duration) *Call[responseType]
- func (a *Call[responseType]) WithRestrictedDataToken(token *string) *Call[responseType]
- type CallResponse
- type Error
- type ErrorList
- type HTTPClient
- type JsonTimeISO8601
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrMaxRetryCountReached = fmt.Errorf("max retry count of %d reached", constants.MaxRetryCountOnTooManyRequestsError)
)
Functions ¶
func FirstNElementsOfSlice ¶ added in v0.5.0
func MapToCommaString ¶ added in v0.5.0
Types ¶
type Call ¶
type Call[responseType any] struct { Method string URL string QueryParams url.Values Body []byte RestrictedDataToken *string ParseErrorListOnError bool WaitDurationOnRateLimit time.Duration }
func (*Call[responseType]) Execute ¶
func (a *Call[responseType]) Execute(httpClient HTTPClient) (*CallResponse[responseType], error)
Execute will return response object on success
func (*Call[responseType]) WithParseErrorListOnError ¶ added in v0.3.0
func (*Call[responseType]) WithQueryParams ¶
func (*Call[responseType]) WithRateLimit ¶ added in v0.5.1
func (*Call[responseType]) WithRestrictedDataToken ¶
WithRestrictedDataToken is optional and can be passed to replace the existing accessToken
type CallResponse ¶ added in v0.3.0
type CallResponse[responseBodyType any] struct { Status int ResponseBody *responseBodyType ErrorList *ErrorList }
func (*CallResponse[any]) ErrorsAsString ¶ added in v0.4.4
func (r *CallResponse[any]) ErrorsAsString() string
ErrorsAsString returns all errors as string or an empty string.
func (*CallResponse[any]) IsError ¶ added in v0.3.0
func (r *CallResponse[any]) IsError() bool
IsError checks if the status is in range 4xx - 5xx
func (*CallResponse[any]) IsSuccess ¶ added in v0.3.0
func (r *CallResponse[any]) IsSuccess() bool
IsSuccess checks if the status is in range 2xx
type Error ¶
type Error struct { // An error code that identifies the type of error that occurred. Code string `json:"code"` // A message that describes the error condition in a human-readable form. Message string `json:"message"` // Additional details that can help the caller understand or fix the issue. Details *string `json:"details,omitempty"` }
Error response returned when the request is unsuccessful.
type ErrorList ¶
type ErrorList struct {
Errors []Error `json:"errors"`
}
ErrorList A list of error responses returned when a request is unsuccessful.
type HTTPClient ¶ added in v0.6.0
type JsonTimeISO8601 ¶
JsonTimeISO8601 marshals time.Time to ISO 8601 format
func (JsonTimeISO8601) MarshalJSON ¶
func (t JsonTimeISO8601) MarshalJSON() ([]byte, error)
func (JsonTimeISO8601) String ¶
func (t JsonTimeISO8601) String() string
Click to show internal directories.
Click to hide internal directories.