Documentation
¶
Index ¶
- Constants
- func BuildRequest(a any) (io.Reader, string, error)
- func Call(client *http.Client, req *http.Request, log log.Logger) (res *http.Response, err error)
- func CopyResponse(res *http.Response) ([]byte, 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 RetryForRateLimited(api func() error, maxRetry int, log log.Logger) (err error)
- func SaveResponse(res *http.Response, path string) error
- func SleepForRateLimited(err error, log log.Logger) bool
- func ToString(o any) string
- type Attachment
- type Attachments
- type Date
- type Error
- type ErrorResult
- type FDK
- func (fdk *FDK) DoDelete(url string) error
- func (fdk *FDK) DoDownload(url string) (buf []byte, err error)
- func (fdk *FDK) DoDownloadNoAuth(url string) (buf []byte, err error)
- func (fdk *FDK) DoGet(url string, result any) error
- func (fdk *FDK) DoList(url string, lo ListOption, ap any) (next bool, err error)
- func (fdk *FDK) DoPost(url string, source, result any) error
- func (fdk *FDK) DoPut(url string, source, result any) error
- func (fdk *FDK) DoSaveFile(url string, path string) error
- func (fdk *FDK) DoSaveFileNoAuth(url string, path string) error
- func (fdk *FDK) Endpoint(format string, a ...any) string
- func (fdk *FDK) RetryForRateLimited(api func() error) (err error)
- func (fdk *FDK) SleepForRateLimited(err error) bool
- type File
- type Files
- type ListOption
- type PageOption
- 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) SetDate(name string, value Date)
- func (vs Values) SetDatePtr(name string, value *Date)
- 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 ( DateFormat = "2006-01-02" TimeFormat = "2006-01-02T15:04:05Z" )
Variables ¶
This section is empty.
Functions ¶
func BuildRequest ¶
BuildRequest build a fdk request, returns buffer, contentType, error
func RetryForRateLimited ¶ added in v1.0.9
func SleepForRateLimited ¶ added in v1.0.9
SleepForRateLimited 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 Attachments ¶ added in v1.0.9
type Attachments []*Attachment
func (Attachments) Files ¶ added in v1.0.9
func (as Attachments) Files() Files
type Date ¶ added in v1.0.9
func (*Date) MarshalJSON ¶ added in v1.0.9
func (*Date) UnmarshalJSON ¶ added in v1.0.9
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) DoDownloadNoAuth ¶ added in v1.0.9
func (*FDK) DoSaveFileNoAuth ¶ added in v1.0.9
func (*FDK) RetryForRateLimited ¶ added in v1.0.9
func (*FDK) SleepForRateLimited ¶ added in v1.0.9
SleepForRateLimited if err is RateLimitedError, sleep Retry-After and return true
type ListOption ¶
type PageOption ¶ added in v1.0.9
func (*PageOption) IsNil ¶ added in v1.0.9
func (po *PageOption) IsNil() bool
func (*PageOption) Values ¶ added in v1.0.9
func (po *PageOption) 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
type Values ¶
func (Values) SetDatePtr ¶ added in v1.0.9
func (Values) SetStrings ¶
func (Values) SetTimePtr ¶
Click to show internal directories.
Click to hide internal directories.