client

package
v0.0.0-...-a65879d Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	AnnotatorSchemaVersion string  `json:"annotator_schema_version"`
	CreatedAt              Time    `json:"created_at"`
	ID                     int     `json:"id"`
	Quote                  string  `json:"quote"`
	Ranges                 []Range `json:"ranges"`
	Text                   string  `json:"text"`
	UpdatedAt              Time    `json:"updated_at"`
}

type Annotations

type Annotations struct {
	Rows  []Annotation `json:"rows"`
	Total int          `json:"total"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(log logr.Logger, httpClient HttpClient, baseURL, clientId, clientSecret string, credentials CredentialStore) *Client

func (*Client) AuthHeader

func (c *Client) AuthHeader() (string, error)

func (*Client) ExportEntry

func (c *Client) ExportEntry(id int, format string, w io.Writer) error

func (*Client) Get

func (c *Client) Get(url string, data interface{}) error

func (*Client) GetEntries

func (c *Client) GetEntries(param url.Values) ([]Item, error)

func (*Client) GetEntry

func (c *Client) GetEntry(id int) (Item, error)

func (*Client) GetToken

func (c *Client) GetToken() error

func (*Client) Patch

func (c *Client) Patch(url string, data map[string]interface{}) error

func (*Client) PatchEntry

func (c *Client) PatchEntry(id int, data map[string]interface{}) error

func (*Client) RefreshToken

func (c *Client) RefreshToken() error

func (*Client) Request

func (c *Client) Request(method, url string, body io.Reader) (*http.Response, error)

type CredentialStore

type CredentialStore interface {
	Username() string
	Password() string
}

type Embedded

type Embedded struct {
	Items []Item `json:"items"`
}

type Entries

type Entries struct {
	Page      int
	Limit     int
	Pages     int
	Total     int
	NaviLinks Links    `json:"_links"`
	Embedded  Embedded `json:"_embedded"`
}

type HttpClient

type HttpClient interface {
	PostForm(url string, data url.Values) (resp *http.Response, err error)
	Do(req *http.Request) (*http.Response, error)
}

type Item

type Item struct {
	Links          Links        `json:"_links"`
	Annotations    []Annotation `json:"annotations"`
	CreatedAt      Time         `json:"created_at"`
	Content        string       `json:"content"`
	DomainName     string       `json:"domain_name"`
	ID             int          `json:"id"`
	IsArchived     int          `json:"is_archived"`
	IsStarred      int          `json:"is_starred"`
	Language       string       `json:"language"`
	Mimetype       string       `json:"mimetype"`
	PreviewPicture string       `json:"preview_picture"`
	ReadingTime    int          `json:"reading_time"`
	Tags           []Tag        `json:"tags"`
	Title          string       `json:"title"`
	UpdatedAt      Time         `json:"updated_at"`
	URL            string       `json:"url"`
	UserEmail      string       `json:"user_email"`
	UserID         int          `json:"user_id"`
	UserName       string       `json:"user_name"`
}
type Link struct {
	Href string
}
type Links struct {
	Self  *Link
	First *Link
	Last  *Link
	Next  *Link
}

type Range

type Range struct {
	End         string      `json:"end"`
	EndOffset   interface{} `json:"endOffset"`
	Start       string      `json:"start"`
	StartOffset interface{} `json:"startOffset"`
}

type Tag

type Tag struct {
	ID    int    `json:"id"`
	Label string `json:"label"`
	Slug  string `json:"slug"`
}

type Time

type Time struct {
	time.Time
}

func (*Time) UnmarshalJSON

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

Jump to

Keyboard shortcuts

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