Documentation
¶
Overview ¶
Package raindrop implements Raindrop.io API client.
API Reference: https://developer.raindrop.io/
Index ¶
- Constants
- func GetHtmlTitle(r io.Reader) (string, bool)
- type AccessTokenResponse
- type AttachFileInfo
- type CacheStatus
- type Client
- func (c *Client) CreateCollection(accessToken string, isRoot bool, view string, title string, sort int, ...) (*CreateCollectionResponse, error)
- func (c *Client) CreateRaindrop(accessToken string, obj *RaindropUserInfo, ctx context.Context) (*SingleRaindropResponse, error)
- func (c *Client) CreateSimpleRaindrop(accessToken string, link string, ctx context.Context) (*SingleRaindropResponse, error)
- func (c *Client) GetAccessToken(userCode string, ctx context.Context) (*AccessTokenResponse, error)
- func (c *Client) GetAuthorizationCode(r *http.Request) (string, error)
- func (c *Client) GetAuthorizationCodeHandler(w http.ResponseWriter, r *http.Request)
- func (c *Client) GetAuthorizationURL() (url.URL, error)
- func (c *Client) GetChildCollections(accessToken string, ctx context.Context) (*GetCollectionsResponse, error)
- func (c Client) GetCollection(accessToken string, id uint32, ctx context.Context) (*GetCollectionResponse, error)
- func (c *Client) GetRaindrop(accessToken string, rId uint32, ctx context.Context) (*SingleRaindropResponse, error)
- func (c *Client) GetRaindrops(accessToken string, searchParam *SearchRdParams, ctx context.Context) (*MultiRaindropsResponse, error)
- func (c *Client) GetRootCollections(accessToken string, ctx context.Context) (*GetCollectionsResponse, error)
- func (c *Client) GetTaggedRaindrops(accessToken string, tag string, ctx context.Context) (*MultiRaindropsResponse, error)
- func (c *Client) GetTags(accessToken string, ctx context.Context) (*Tags, error)
- func (c *Client) RefreshAccessToken(refreshToken string, ctx context.Context) (*AccessTokenResponse, error)
- type Collection
- type CollectionRef
- type CreateCollectionResponse
- type CreatorRef
- type GetCollectionResponse
- type GetCollectionsResponse
- type Highlight
- type MultiRaindropsResponse
- type Raindrop
- type RaindropAttach
- type RaindropCache
- type RaindropUserInfo
- type Reminder
- type SearchRdParams
- type SingleRaindropResponse
- type Tag
- type Tags
- type UserRef
Constants ¶
const ( ALL_COLLECTION_ID = 0 //描述返回所有的集合,除了trash UNSORT_COLLECTION_ID = -1 // unsort collectionid, 中文含义为:没有归类的collection TRASH_COLLECTION_ID = -99 // trash collection )
Variables ¶
This section is empty.
Functions ¶
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"` }
AccessTokenResponse represents the token exchange api response item
type AttachFileInfo ¶
type CacheStatus ¶
type CacheStatus string
const ( READY CacheStatus = "ready" RETRY CacheStatus = "retry" FAILED CacheStatus = "failed" INVALID_O CacheStatus = "invalid-origin" INVALID_TO CacheStatus = "invalid-timeout" INVALID_SIZE CacheStatus = "invalid-size" )
type Client ¶
type Client struct { ClientCode string // contains filtered or unexported fields }
Client is a raindrop 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) CreateRaindrop ¶
func (c *Client) CreateRaindrop(accessToken string, obj *RaindropUserInfo, ctx context.Context) (*SingleRaindropResponse, error)
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) GetAccessToken ¶
GetAccessToken exchanges UserRef's authorization code to access token Reference: https://developer.raindrop.io/v1/authentication/token#step-3-the-token-exchange
func (*Client) GetAuthorizationCode ¶
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 ¶
GetAuthorizationURL returns URL for UserRef 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) GetRaindrop ¶
func (*Client) GetRaindrops ¶
func (c *Client) GetRaindrops(accessToken string, searchParam *SearchRdParams, 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 ¶
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 UserRef `json:"user"` View string `json:"view"` }
Collection represents Raindrop.io collection type
type CollectionRef ¶
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 CreatorRef ¶
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 ¶
MultiRaindropsResponse represents get multiple raindrops api response
type Raindrop ¶
type Raindrop struct { RaindropUserInfo RaindropAttach }
Raindrop represents get raindrops api response item
type RaindropAttach ¶
type RaindropAttach struct { Broken bool `json:"broken"` Cache RaindropCache `json:"cache"` CRef CreatorRef `json:"creatorRef,omitempty"` }
type RaindropCache ¶
type RaindropCache struct { Status CacheStatus `json:"status"` Size uint32 `json:"size"` Created string `json:"created"` }
type RaindropUserInfo ¶
type RaindropUserInfo struct { ID uint32 `json:"_id"` // id Created string `json:"created,omitempty"` LastUpdate string `json:"lastUpdate,omitempty"` Sort int `json:"sort,omitempty"` Tags []string `json:"tags,omitempty"` Media []media `json:"media,omitempty"` Cover string `json:"cover,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"` Domain string `json:"domain"` Note string `json:"note,omitempty"` // note limit 0 - 10000 User UserRef `json:"user"` Removed bool `json:"removed"` Collection CollectionRef `json:"collection,omitempty"` // 貌似无效的字段; CollectionId uint32 `json:"collectionId"` // 和collection类似,估计是新老字段吧; FileInfo AttachFileInfo `json:"file,omitempty"` Important bool `json:"important"` //表示是否重要,红心 Highlights []Highlight `json:"highlights,omitempty"` Reminder Reminder `json:"reminder,omitempty"` }
type SearchRdParams ¶ added in v0.0.2
type SearchRdParams struct { CollectionId int Search string //这种有用户来控制 Sort string //按照某一个字段进行排序 Page int //第几页 PageSize int //每页多少条 }
func (*SearchRdParams) AddToQuery ¶ added in v0.0.2
func (s *SearchRdParams) AddToQuery(query *url.Values)
type SingleRaindropResponse ¶
SingleRaindropResponse represent single raindrop api response