internal

package
v0.0.0-...-c2f68b4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const PageCount = 100

PageCount is the default response page count

Variables

This section is empty.

Functions

func PutAuth

func PutAuth(auth *Creds)

PutAuth saves the pocket credentials into a file

Types

type App

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

func NewApp

func NewApp(list Items) *App

func (*App) Run

func (app *App) Run()

type Client

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

func NewClient

func NewClient(auth *Creds) *Client

func (*Client) Authenticate

func (c *Client) Authenticate(consumerKey string) *Creds

Authenticate a consumer key

func (*Client) Retrieve

func (c *Client) Retrieve(after string, offset int) ([]Item, error)

func (*Client) RetrieveAll

func (c *Client) RetrieveAll(after string) ([]Item, error)

type Creds

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

Creds is a pair of keys

func GetAuth

func GetAuth() *Creds

GetAuth returns the saved pocket credentials

type DB

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

DB is a wrapper around bolt database connection

func NewDB

func NewDB() *DB

NewDB returns a new database connnection

func (*DB) Close

func (b *DB) Close()

Close closed the database connection

func (*DB) Delete

func (b *DB) Delete(item Item) error

Delete deletes a pocket item

func (*DB) Get

func (b *DB) Get() (Items, error)

Get gets all stored pocket items

func (*DB) Put

func (b *DB) Put(items []Item) error

Put saves a list of pocket items

type Item

type Item struct {
	ID            string         `json:"item_id"`
	GivenURL      string         `json:"given_url"`
	GivenTitle    string         `json:"given_title"`
	ResolvedTitle string         `json:"resolved_title"`
	AddedAt       string         `json:"time_added"`
	TagsMap       map[string]Tag `json:"tags"`
}

Item is the poeckt item

func (Item) Host

func (item Item) Host() string

Host returns the item's given URL host

func (Item) Tags

func (item Item) Tags() Tags

Tags returns the list of the item's tag

func (Item) Title

func (item Item) Title() string

Title gets the item's title

func (Item) URL

func (item Item) URL() string

URL returns the item's given URL

type Items

type Items []Item

Items is a list of items

func (Items) GetTagged

func (items Items) GetTagged(tags Tags) Items

GetTagged filter items by tags

func (Items) Tags

func (items Items) Tags() Tags

Tags return a list of tags from a list of items

type Tag

type Tag struct {
	ID    string `json:"item_id"`
	Label string `json:"tag"`
}

Tag is a packet tag

func (Tag) String

func (t Tag) String() string

type Tags

type Tags []Tag

Tags is a set of Tags

func (Tags) Len

func (t Tags) Len() int

Len return the length of a list of tags

func (Tags) Less

func (t Tags) Less(i, j int) bool

Less compares two tags by label

func (Tags) String

func (t Tags) String() string

func (Tags) Swap

func (t Tags) Swap(i, j int)

Swap swaps two tags

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳