Documentation
¶
Index ¶
- Constants
- func BuildJSONRequest(a any) (io.Reader, string, error)
- func BuildMultipartRequest(vs Values, fs Files) (io.Reader, string, error)
- func IsResultError(err error) bool
- type Attachment
- type Attachments
- type Client
- func (c *Client) DoCall(req *http.Request, result any) error
- func (c *Client) DoCopyFile(ctx context.Context, url string, w io.Writer) error
- func (c *Client) DoCopyFileNoAuth(ctx context.Context, url string, w io.Writer) error
- func (c *Client) DoDelete(ctx context.Context, url string) error
- func (c *Client) DoGet(ctx context.Context, url string, result any) error
- func (c *Client) DoList(ctx context.Context, url string, lo ListOption, ap any) (next bool, err error)
- func (c *Client) DoPost(ctx context.Context, url string, source, result any) error
- func (c *Client) DoPut(ctx context.Context, url string, source, result any) error
- func (c *Client) DoReadFile(ctx context.Context, url string) (buf []byte, err error)
- func (c *Client) DoReadFileNoAuth(ctx context.Context, url string) (buf []byte, err error)
- func (c *Client) DoSaveFile(ctx context.Context, url string, path string) error
- func (c *Client) DoSaveFileNoAuth(ctx context.Context, url string, path string) error
- func (c *Client) Endpoint(format string, a ...any) string
- func (c *Client) RetryForError(ctx context.Context, api func() error) (err error)
- type CustomRequest
- type Date
- type FieldError
- type File
- type Files
- type ListOption
- type PageOption
- type ResultError
- type Time
- type TimeSpent
- type Values
- func (vs Values) Add(key, value string)
- func (vs Values) Del(key string)
- func (vs Values) Encode() string
- func (vs Values) Get(key string) string
- func (vs Values) Has(key string) bool
- func (vs Values) Map() map[string][]string
- func (vs Values) Set(key, value 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) SetStringMap(name string, value map[string]string)
- func (vs Values) SetStrings(name string, value []string)
- func (vs Values) SetStringsPtr(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 = time.DateOnly // "2006-01-02" TimeFormat = time.RFC3339 // "2006-01-02T15:04:05Z07:00" )
Variables ¶
This section is empty.
Functions ¶
func BuildMultipartRequest ¶
func IsResultError ¶ added in v1.1.4
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 ¶
type Attachments []*Attachment
func (Attachments) Files ¶
func (as Attachments) Files() Files
type Client ¶ added in v1.1.6
type Client struct {
Domain string
Apikey string
Username string
Password string
Transport http.RoundTripper
Timeout time.Duration
Logger log.Logger
MaxRetries int
RetryAfter time.Duration
ShouldRetry func(error) bool // default retry on not canceled error or (status = 429 || (status >= 500 && status <= 599))
}
func (*Client) DoCopyFile ¶ added in v1.1.6
func (*Client) DoCopyFileNoAuth ¶ added in v1.1.6
func (*Client) DoReadFile ¶ added in v1.1.6
func (*Client) DoReadFileNoAuth ¶ added in v1.1.6
func (*Client) DoSaveFile ¶ added in v1.1.6
func (*Client) DoSaveFileNoAuth ¶ added in v1.1.6
type FieldError ¶
type FieldError struct {
Code string `json:"code,omitempty"`
Field string `json:"field,omitempty"`
Message string `json:"message,omitempty"`
}
func (*FieldError) Error ¶
func (fe *FieldError) Error() string
type ListOption ¶
type PageOption ¶
func (*PageOption) IsNil ¶
func (po *PageOption) IsNil() bool
func (*PageOption) Values ¶
func (po *PageOption) Values() Values
type ResultError ¶
type ResultError struct {
Method string `json:"-"` // http request method
URL *url.URL `json:"-"` // http request URL
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 []*FieldError `json:"errors,omitempty"`
RetryAfter time.Duration `json:"-"`
}
func AsResultError ¶ added in v1.1.4
func AsResultError(err error) (re *ResultError, ok bool)
func (*ResultError) Detail ¶
func (re *ResultError) Detail() string
func (*ResultError) Error ¶
func (re *ResultError) Error() string
func (*ResultError) GetRetryAfter ¶
func (re *ResultError) GetRetryAfter() time.Duration
type TimeSpent ¶
func ParseTimeSpent ¶
type Values ¶
func (Values) Add ¶
Add adds the value to key. It appends to any existing values associated with key.
func (Values) Encode ¶
Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") sorted by key.
func (Values) Get ¶
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.
func (Values) SetDatePtr ¶
func (Values) SetStrings ¶
func (Values) SetStringsPtr ¶
func (Values) SetTimePtr ¶
Click to show internal directories.
Click to hide internal directories.