pocket

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentType

type ContentType string
const (
	ContentTypeArticle ContentType = "article"
	ContentTypeVideo   ContentType = "video"
	ContentTypeImage   ContentType = "image"
)

type DetailType

type DetailType string
const (
	DetailTypeSimple   DetailType = "simple"
	DetailTypeComplete DetailType = "complete"
)

type FavoriteFilter

type FavoriteFilter string
const (
	FavoriteFilterUnspecified FavoriteFilter = ""
	FavoriteFilterUnfavorited FavoriteFilter = "0"
	FavoriteFilterFavorited   FavoriteFilter = "1"
)

type Item

type Item struct {
	ItemID        int        `json:"item_id,string"`
	ResolvedId    int        `json:"resolved_id,string"`
	GivenURL      string     `json:"given_url"`
	ResolvedURL   string     `json:"resolved_url"`
	GivenTitle    string     `json:"given_title"`
	ResolvedTitle string     `json:"resolved_title"`
	Favorite      int        `json:",string"`
	Status        ItemStatus `json:",string"`
	Excerpt       string
	IsArticle     int                 `json:"is_article,string"`
	HasImage      ItemMediaAttachment `json:"has_image,string"`
	HasVideo      ItemMediaAttachment `json:"has_video,string"`
	WordCount     int                 `json:"word_count,string"`

	// Fields for detailed response
	Tags    map[string]map[string]interface{}
	Authors map[string]map[string]interface{}
	Images  map[string]map[string]interface{}
	Videos  map[string]map[string]interface{}

	// Fields that are not documented but exist
	SortId        int  `json:"sort_id"`
	TimeAdded     Time `json:"time_added"`
	TimeUpdated   Time `json:"time_updated"`
	TimeRead      Time `json:"time_read"`
	TimeFavorited Time `json:"time_favorited"`
}

func (Item) Title

func (item Item) Title() string

Title returns ResolvedTitle or GivenTitle

func (Item) URL

func (item Item) URL() string

URL returns ResolvedURL or GivenURL

type ItemMediaAttachment

type ItemMediaAttachment int
const (
	ItemMediaAttachmentNoMedia  ItemMediaAttachment = 0
	ItemMediaAttachmentHasMedia ItemMediaAttachment = 1
	ItemMediaAttachmentIsMedia  ItemMediaAttachment = 2
)

type ItemStatus

type ItemStatus int
const (
	ItemStatusUnread   ItemStatus = 0
	ItemStatusArchived ItemStatus = 1
	ItemStatusDeleted  ItemStatus = 2
)

type Pocket

type Pocket struct {
	UpdateFrequency time.Duration `envconfig:"UPDATE_FREQUENCY" default:"1h" required:"true" desc:"How often to query getPocket"`
	HealthCheck     time.Duration `envconfig:"HEALTH_CHECK" default:"30s" required:"true"`
	URL             string        `envconfig:"POCKET_URL" default:"https://getpocket.com/v3/get" required:"true"`
	ConsumerKey     string        `envconfig:"CONSUMER_KEY" required:"true" desc:"See https://getpocket.com/developer/apps/ to get a consumer key"`
	Username        string        `envconfig:"USERNAME" desc:"The pocket username (will try to fetch it if not found)"`
	Token           string        `envconfig:"TOKEN" desc:"The access token, will try to fetch it if not found or invalid"`

	ItemsC chan Item `ignored:"true"`
	// contains filtered or unexported fields
}

func NewPocket

func NewPocket(downloader *http.Downloader) (*Pocket, error)

func (*Pocket) Doc

func (p *Pocket) Doc(w io.Writer)

func (*Pocket) Get

func (p *Pocket) Get(ctx context.Context) error

func (*Pocket) RunPoller

func (p *Pocket) RunPoller(ctx context.Context) error

func (*Pocket) Usage

func (p *Pocket) Usage()

type RetrieveOption

type RetrieveOption struct {
	ConsumerKey string         `json:"consumer_key"`
	AccessToken string         `json:"access_token"`
	State       State          `json:"state,omitempty"`
	Favorite    FavoriteFilter `json:"favorite,omitempty"`
	Tag         string         `json:"tag,omitempty"`
	ContentType ContentType    `json:"contentType,omitempty"`
	Sort        Sort           `json:"sort,omitempty"`
	DetailType  DetailType     `json:"detailType,omitempty"`
	Search      string         `json:"search,omitempty"`
	Domain      string         `json:"domain,omitempty"`
	Since       int            `json:"since,omitempty"`
	Count       int            `json:"count,omitempty"`
	Offset      int            `json:"offset,omitempty"`
}

RetrieveOption is the options for retrieve API.

type RetrieveResult

type RetrieveResult struct {
	List     map[string]Item
	Status   int
	Complete int
	Since    int
}

type Sort

type Sort string
const (
	SortNewest Sort = "newest"
	SortOldest Sort = "oldest"
	SortTitle  Sort = "title"
	SortSite   Sort = "site"
)

type State

type State string
const (
	StateUnread  State = "unread"
	StateArchive State = "archive"
	StateAll     State = "all"
)

type Time

type Time time.Time

func (Time) MarshalBinary

func (t Time) MarshalBinary() (data []byte, err error)

func (*Time) UnmarshalBinary

func (t *Time) UnmarshalBinary(data []byte) error

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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