raindrop

package
v0.0.0-...-d4c1e95 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package raindrop implements Raindrop.io API client.

API Reference: https://developer.raindrop.io/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHtmlTitle

func GetHtmlTitle(r io.Reader) (string, bool)

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Expires      int    `json:"expires,omitempty"`
	ExpiresIn    int    `json:"expires_in,omitempty"`
	TokenType    string `json:"token_type,omitempty"`
	Error        string `json:"error,omitempty"`
	ErrorMessage string `json:"errorMessage,omitempty"`
	Result       bool   `json:"result"`
	Status       int    `json:"status"`
}

AccessTokenResponse represents the token exchange api response item

type Client

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

Client is a raindrop client

func NewClient

func NewClient(clientId string, clientSecret string, redirectUri string) (*Client, error)

NewClient creates Raindrop.io client

func (*Client) CreateCollection

func (c *Client) CreateCollection(accessToken string, isRoot bool, view string, title string, sort int,
	public bool, parentId uint32, cover []string, ctx context.Context) (*CreateCollectionResponse, error)

CreateCollection creates new Collection Reference: https://developer.raindrop.io/v1/collections/methods#create-collection

func (*Client) CreateSimpleRaindrop

func (c *Client) CreateSimpleRaindrop(accessToken string, link string, ctx context.Context) (*SingleRaindropResponse, error)

CreateSimpleRaindrop creates new simple unsorted Raindrop Reference: https://developer.raindrop.io/v1/raindrops/single#create-raindrop

func (*Client) DeleteTags

func (c *Client) DeleteTags(accessToken string, ctx context.Context, tagIDs []string) error

DeleteTags calls Delete tags API. Reference: https://developer.raindrop.io/v1/tags#remove-tag-s

func (*Client) GetAccessToken

func (c *Client) GetAccessToken(userCode string, ctx context.Context) (*AccessTokenResponse, error)

GetAccessToken exchanges user's authorization code to access token Reference: https://developer.raindrop.io/v1/authentication/token#step-3-the-token-exchange

func (*Client) GetAuthorizationCode

func (c *Client) GetAuthorizationCode(r *http.Request) (string, error)

GetAuthorizationCode returns authorization code or an error from raindrop's redirect request Reference: https://developer.raindrop.io/v1/authentication/token#step-2-the-redirection-to-your-application-site

func (*Client) GetAuthorizationCodeHandler

func (c *Client) GetAuthorizationCodeHandler(w http.ResponseWriter, r *http.Request)

GetAuthorizationCodeHandler handles redirect request from raindrop's authorization page

func (*Client) GetAuthorizationURL

func (c *Client) GetAuthorizationURL() (url.URL, error)

GetAuthorizationURL returns URL for user to authorize app

func (*Client) GetChildCollections

func (c *Client) GetChildCollections(accessToken string, ctx context.Context) (*GetCollectionsResponse, error)

GetChildCollections call Get child collections API. Reference: https://developer.raindrop.io/v1/collections/methods#get-child-collections

func (Client) GetCollection

func (c Client) GetCollection(accessToken string, id uint32, ctx context.Context) (*GetCollectionResponse, error)

GetCollection call Get collection API. Reference: https://developer.raindrop.io/v1/collections/methods#get-collection

func (*Client) GetRaindrops

func (c *Client) GetRaindrops(accessToken string, collectionID string, perpage int, ctx context.Context) (*MultiRaindropsResponse, error)

GetRaindrops call get raindrops API. Reference: https://developer.raindrop.io/v1/raindrops/multiple#get-raindrops

func (*Client) GetRootCollections

func (c *Client) GetRootCollections(accessToken string, ctx context.Context) (*GetCollectionsResponse, error)

GetRootCollections call Get root collections API. Reference: https://developer.raindrop.io/v1/collections/methods#get-root-collections

func (*Client) GetTaggedRaindrops

func (c *Client) GetTaggedRaindrops(accessToken string, tag string, ctx context.Context) (*MultiRaindropsResponse, error)

GetTaggedRaindrops finds raindrops with exact tags. This function calls Get raindrops API with collectionID=0 and specify given tag as a search parameter.

Reference: https://developer.raindrop.io/v1/raindrops/multiple#search-parameter

func (*Client) GetTags

func (c *Client) GetTags(accessToken string, ctx context.Context) (*Tags, error)

GetTags calls Get tags API. Reference: https://developer.raindrop.io/v1/tags#get-tags

func (*Client) RefreshAccessToken

func (c *Client) RefreshAccessToken(refreshToken string, ctx context.Context) (*AccessTokenResponse, error)

RefreshAccessToken refreshes expired token Reference: https://developer.raindrop.io/v1/authentication/token#the-access-token-refresh

type Collection

type Collection struct {
	ID         uint32   `json:"_id"`
	Access     access   `json:"access"`
	Color      string   `json:"color"`
	Count      uint32   `json:"count"`
	Cover      []string `json:"cover"`
	Created    string   `json:"created"`
	LastUpdate string   `json:"lastUpdate"`
	ParentId   int      `json:"parent_id,omitempty"`
	Expanded   bool     `json:"expanded"`
	Public     bool     `json:"public"`
	Title      string   `json:"title"`
	User       user     `json:"user"`
	View       string   `json:"view"`
}

Collection represents Raindrop.io collection type

type CreateCollectionResponse

type CreateCollectionResponse struct {
	Result       bool                    `json:"result"`
	Item         createCollectionRequest `json:"item,omitempty"`
	Error        string                  `json:"error,omitempty"`
	ErrorMessage string                  `json:"errorMessage,omitempty"`
}

CreateCollectionResponse represents create collection api response item

type DeleteTagsResponse

type DeleteTagsResponse struct {
	Result bool `json:"result"`
}

type GetCollectionResponse

type GetCollectionResponse struct {
	Result bool       `json:"result"`
	Item   Collection `json:"item"`
}

GetCollectionResponse represents get collection by id api response

type GetCollectionsResponse

type GetCollectionsResponse struct {
	Result bool         `json:"result"`
	Items  []Collection `json:"items"`
}

GetCollectionsResponse represents get root and child collections api response

type MultiRaindropsResponse

type MultiRaindropsResponse struct {
	Result bool       `json:"result"`
	Items  []Raindrop `json:"items"`
}

MultiRaindropsResponse represents get multiple raindrops api response

type Raindrop

type Raindrop struct {
	PleaseParse pleaseParse `json:"pleaseParse"`
	Created     string      `json:"created,omitempty"`
	LastUpdate  string      `json:"lastUpdate,omitempty"`
	Order       int         `json:"order,omitempty"`
	Tags        []string    `json:"tags,omitempty"`
	Media       []media     `json:"media,omitempty"`
	Cover       string      `json:"cover,omitempty"`
	Collection  Collection  `json:"collection,omitempty"`
	Type        string      `json:"type,omitempty"`
	HTML        string      `json:"html,omitempty"`
	Excerpt     string      `json:"excerpt,omitempty"`
	Title       string      `json:"title,omitempty"`
	Link        string      `json:"link"`
}

Raindrop represents get raindrops api response item

type SingleRaindropResponse

type SingleRaindropResponse struct {
	Result bool     `json:"result"`
	Items  Raindrop `json:"item"`
}

SingleRaindropResponse represent single raindrop api response

type Tag

type Tag struct {
	ID    string `json:"_id"`
	Count int    `json:"count"`
}

Tag represents get tags api response item

type Tags

type Tags struct {
	Result bool  `json:"result"`
	Items  []Tag `json:"items"`
}

Tags represents get tags api response

Jump to

Keyboard shortcuts

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