platform

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeArticle = "article"
	ContentTypeVideo   = "video"
	ContentTypeImage   = "image"

	SortNewest = "newest"
	SortOldest = "oldest"
	SortTitle  = "title"
	SortSite   = "site"

	StateUnread  = "unread"
	StateArchive = "archive"
	StateAll     = "all"

	DetailTypeSimple   = "simple"
	DetailTypeComplete = "complete"

	FavoriteFilterUnspecified = ""
	FavoriteFilterUnfavorited = "0"
	FavoriteFilterFavorited   = "1"

	ItemStatusUnread   = 0
	ItemStatusArchived = 1
	ItemStatusDeleted  = 2

	ItemMediaAttachmentNoMedia  = 0
	ItemMediaAttachmentHasMedia = 1
	ItemMediaAttachmentIsMedia  = 2
)
View Source
const (
	EventDelete  = "delete"
	EventArchive = "archive"
)
View Source
const URL = "https://getpocket.com"

Variables

This section is empty.

Functions

func GenerateAuthorizationURL

func GenerateAuthorizationURL(requestToken *RequestToken, redirectURL string) string

func ObtainAccessToken

func ObtainAccessToken(consumerKey string, requestToken *RequestToken) (string, error)

func Post

func Post(action string, data, res interface{}) error

Types

type AddOption

type AddOption struct {
	URL   string `json:"url,omitempty"`
	Title string `json:"title,omitempty"`
	Tags  string `json:"tags,omitempty"`
}

type Authorization

type Authorization struct {
	AccessToken string `json:"access_token"`
	Username    string `json:"username"`
}

func Auth

func Auth(consumerKey string) (Authorization, error)

OAuth2 1. Send the consumer key. 2. User needs to confirm on a webpage. 3. Get a token back - save it to a file. 4. Can retrieve pocket list thanks to token.

type Client

type Client struct {
	ConsumerKey string `json:"consumer_key"`
	AccessToken string `json:"access_token"`
}

Client represents a Pocket client that grants OAuth access to your application

func NewClient

func NewClient(consumerKey, accessToken string) *Client

NewClient creates a new Pocket client.

func (*Client) Add

func (c *Client) Add(URL string) error

func (*Client) Archive

func (c *Client) Archive(IDs []int) (*ModifyResult, error)

func (*Client) Delete

func (c *Client) Delete(IDs []int) (*ModifyResult, error)

func (*Client) Retrieve

func (c *Client) Retrieve(count int, sort string, search string, filter string) (*RetrieveResult, error)

func (*Client) RetrieveArchive

func (c *Client) RetrieveArchive(count int, sort string, search string, filter string) (*RetrieveResult, error)

func (*Client) Unarchive

func (c *Client) Unarchive(IDs []int) (*ModifyResult, error)

type Entry

type Entry struct {
	URL   string
	Title string
	ID    int
}

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        int    `json:",string"`
	Excerpt       string
	IsArticle     int `json:"is_article,string"`
	HasImage      int `json:"has_image,string"`
	HasVideo      int `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 Modify

type Modify struct {
	Action string `json:"action"`
	ID     int    `json:"item_id,string"`
}

Action represents one action in a bulk modify requests.

type ModifyResult

type ModifyResult struct {
	// The results for each of the requested actions.
	ActionResults []string
	Status        int
}

type RequestToken

type RequestToken struct {
	Code string `json:"code"`
}

func ObtainRequestToken

func ObtainRequestToken(consumerKey, redirectURL string) (*RequestToken, error)

type RetrieveOption

type RetrieveOption struct {
	State       string `json:"state,omitempty"`
	Favorite    string `json:"favorite,omitempty"`
	Tag         string `json:"tag,omitempty"`
	ContentType string `json:"contentType,omitempty"`
	Sort        string `json:"sort,omitempty"`
	DetailType  string `json:"detailType,omitempty"`
	Search      string `json:"search,omitempty"`
	Domain      string `json:"domain,omitempty"`
	Since       int64  `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     []Item
	Status   int
	Complete int
	Since    int
}

func (RetrieveResult) FlattenList

func (r RetrieveResult) FlattenList() []Item

func (*RetrieveResult) UnmarshalJSON

func (r *RetrieveResult) UnmarshalJSON(data []byte) error

type Time

type Time time.Time

func (*Time) UnmarshalJSON

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

type Tview

type Tview struct {
	Entries []Entry
}

func (*Tview) List

func (t *Tview) List(
	archiver func(IDs []int),
	deleter func(IDs []int),
	adder func(IDs []int),
	noconfirm bool,
)

Jump to

Keyboard shortcuts

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