fdk

package
v1.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateFormat = "2006-01-02"
	TimeFormat = "2006-01-02T15:04:05Z"
)

Variables

This section is empty.

Functions

func ToJSON added in v1.0.10

func ToJSON(o any) string

func ToJSONIndent added in v1.0.10

func ToJSONIndent(o any) string

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

type Date struct {
	time.Time
}

func ParseDate added in v1.0.10

func ParseDate(s string) (*Date, error)

func (*Date) MarshalJSON added in v1.0.9

func (d *Date) MarshalJSON() ([]byte, error)

func (*Date) String added in v1.0.9

func (d *Date) String() string

func (*Date) UnmarshalJSON added in v1.0.9

func (d *Date) UnmarshalJSON(data []byte) (err error)

type Error

type Error struct {
	Code    string `json:"code,omitempty"`
	Field   string `json:"field,omitempty"`
	Message string `json:"message,omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

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"`
	RetryAfter  time.Duration
}

func (*ErrorResult) Detail added in v1.0.10

func (er *ErrorResult) Detail() string

func (*ErrorResult) Error

func (er *ErrorResult) Error() string

func (*ErrorResult) GetRetryAfter added in v1.0.16

func (er *ErrorResult) GetRetryAfter() time.Duration

type FDK

type FDK struct {
	Domain   string
	Apikey   string
	Username string
	Password string

	Transport http.RoundTripper
	Timeout   time.Duration
	Logger    log.Logger

	MaxRetries    int
	RetryAfter    time.Duration
	AbortOnRetry  func() error
	AbortInterval time.Duration
}

func (*FDK) DoDelete

func (fdk *FDK) DoDelete(url string) error

func (*FDK) DoDownload

func (fdk *FDK) DoDownload(url string) (buf []byte, err error)

func (*FDK) DoDownloadNoAuth added in v1.0.9

func (fdk *FDK) DoDownloadNoAuth(url string) (buf []byte, err error)

func (*FDK) DoGet

func (fdk *FDK) DoGet(url string, result any) error

func (*FDK) DoList

func (fdk *FDK) DoList(url string, lo ListOption, ap any) (next bool, err error)

func (*FDK) DoPost

func (fdk *FDK) DoPost(url string, source, result any) error

func (*FDK) DoPut

func (fdk *FDK) DoPut(url string, source, result any) error

func (*FDK) DoSaveFile added in v1.0.9

func (fdk *FDK) DoSaveFile(url string, path string) error

func (*FDK) DoSaveFileNoAuth added in v1.0.9

func (fdk *FDK) DoSaveFileNoAuth(url string, path string) error

func (*FDK) Endpoint added in v1.0.9

func (fdk *FDK) Endpoint(format string, a ...any) string

Endpoint formats endpoint url

func (*FDK) RetryForError added in v1.0.10

func (fdk *FDK) RetryForError(api func() error) (err error)

type File

type File interface {
	Field() string
	File() string
	Data() []byte
}

type Files

type Files []File

type ListOption

type ListOption interface {
	IsNil() bool
	Values() Values
}

type PageOption added in v1.0.9

type PageOption struct {
	Page    int
	PerPage int
}

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 Time

type Time struct {
	time.Time
}

func ParseTime added in v1.0.10

func ParseTime(s string) (*Time, error)

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

func (*Time) String

func (t *Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

type TimeSpent added in v1.0.10

type TimeSpent = tmu.HHMM

func ParseTimeSpent added in v1.0.10

func ParseTimeSpent(s string) (TimeSpent, error)

type Values

type Values url.Values

func (Values) Encode

func (vs Values) Encode() string

func (Values) Map

func (vs Values) Map() map[string][]string

func (Values) SetBool

func (vs Values) SetBool(name string, value bool)

func (Values) SetDate added in v1.0.9

func (vs Values) SetDate(name string, value Date)

func (Values) SetDatePtr added in v1.0.9

func (vs Values) SetDatePtr(name string, value *Date)

func (Values) SetInt

func (vs Values) SetInt(name string, value int)

func (Values) SetInt64

func (vs Values) SetInt64(name string, value int64)

func (Values) SetInt64s

func (vs Values) SetInt64s(name string, value []int64)

func (Values) SetInts

func (vs Values) SetInts(name string, value []int)

func (Values) SetMap

func (vs Values) SetMap(name string, value map[string]any)

func (Values) SetString

func (vs Values) SetString(name string, value string)

func (Values) SetStringMap added in v1.0.10

func (vs Values) SetStringMap(name string, value map[string]string)

func (Values) SetStrings

func (vs Values) SetStrings(name string, value []string)

func (Values) SetTime

func (vs Values) SetTime(name string, value Time)

func (Values) SetTimePtr

func (vs Values) SetTimePtr(name string, value *Time)

type WithFiles

type WithFiles interface {
	Files() Files
	Values() Values
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL