Documentation
¶
Index ¶
- Constants
- func BuildRequest(a any) (io.Reader, string, error)
- func Call(client *http.Client, req *http.Request, retryOnRateLimited int, log log.Logger) (res *http.Response, err error)
- func DecodeResponse(res *http.Response, obj any) error
- func LogRequest(log log.Logger, req *http.Request) (rid uint64)
- func LogResponse(log log.Logger, res *http.Response, rid uint64)
- func SleepAndRetry(api func() error, maxRetry int, log log.Logger) (err error)
- func SleepForRetry(err error, log log.Logger) bool
- func ToString(o any) string
- type Attachment
- type Error
- type ErrorResult
- type FDK
- func (fdk *FDK) DoDelete(url string) error
- func (fdk *FDK) DoDownload(url string) ([]byte, error)
- func (fdk *FDK) DoGet(url string, result any) error
- func (fdk *FDK) DoList(url string, lo ListOption, ap any) (bool, error)
- func (fdk *FDK) DoPost(url string, source, result any) error
- func (fdk *FDK) DoPut(url string, source, result any) error
- func (fdk *FDK) DoSave(url string, filename string) error
- func (fdk *FDK) SleepAndRetry(api func() error, maxRetry int) (err error)
- func (fdk *FDK) SleepForRetry(err error) bool
- type File
- type Files
- type ListOption
- type RateLimitedError
- type Time
- type Values
- func (vs Values) Encode() string
- func (vs Values) Map() map[string][]string
- func (vs Values) SetBool(name string, value bool)
- func (vs Values) SetInt(name string, value int)
- func (vs Values) SetInt64(name string, value int64)
- func (vs Values) SetInt64s(name string, value []int64)
- func (vs Values) SetInts(name string, value []int)
- func (vs Values) SetMap(name string, value map[string]any)
- func (vs Values) SetString(name string, value string)
- func (vs Values) SetStrings(name string, value []string)
- func (vs Values) SetTime(name string, value Time)
- func (vs Values) SetTimePtr(name string, value *Time)
- type WithFiles
Constants ¶
View Source
const TimeFormat = "2006-01-02T15:04:05Z"
Variables ¶
This section is empty.
Functions ¶
func BuildRequest ¶
BuildRequest build a fdk request, returns buffer, contentType, error
func SleepForRetry ¶
SleepForRetry if err is RateLimitedError, sleep Retry-After and return true
Types ¶
type Attachment ¶
type Attachment struct {
ID int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Size int `json:"size,omitempty"`
ContentType string `json:"content_type,omitempty"`
AttachmentURL string `json:"attachment_url,omitempty"`
CanonicalURL string `json:"canonical_url,omitempty"`
CreatedAt *Time `json:"created_at,omitempty"`
UpdatedAt *Time `json:"updated_at,omitempty"`
// contains filtered or unexported fields
}
func NewAttachment ¶
func NewAttachment(file string, data ...[]byte) *Attachment
func (*Attachment) Data ¶
func (a *Attachment) Data() []byte
func (*Attachment) Field ¶
func (a *Attachment) Field() string
func (*Attachment) File ¶
func (a *Attachment) File() string
func (*Attachment) String ¶
func (a *Attachment) String() string
type Error ¶
type ErrorResult ¶
type ErrorResult struct {
StatusCode int `json:"-"` // http status code
Status string `json:"-"` // http status
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Description string `json:"description,omitempty"`
Errors []*Error `json:"errors,omitempty"`
}
func (*ErrorResult) Error ¶
func (er *ErrorResult) Error() string
type FDK ¶
type FDK struct {
Domain string
Apikey string
Username string
Password string
Transport http.RoundTripper
Timeout time.Duration
Logger log.Logger
RetryOnRateLimited int
}
func (*FDK) SleepAndRetry ¶
func (*FDK) SleepForRetry ¶
SleepForRetry if err is RateLimitedError, sleep Retry-After and return true
type ListOption ¶
type ListOption interface {
Values() Values
}
type RateLimitedError ¶
type RateLimitedError struct {
StatusCode int // http status code
RetryAfter int // retry after seconds
}
func (*RateLimitedError) Error ¶
func (e *RateLimitedError) Error() string
Click to show internal directories.
Click to hide internal directories.