Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type AuthError
- type BulkCreateRequest
- type BulkCreateResponse
- type Client
- func (c *Client) CreateCollection(ctx context.Context, req *CreateCollectionRequest) (*Collection, error)
- func (c *Client) CreateRaindrop(ctx context.Context, req *CreateRaindropRequest) (*Raindrop, error)
- func (c *Client) CreateRaindropsBulk(ctx context.Context, items []CreateRaindropRequest) ([]Raindrop, error)
- func (c *Client) Delete(ctx context.Context, path string) error
- func (c *Client) DeleteCollection(ctx context.Context, id int) error
- func (c *Client) DeleteRaindrop(ctx context.Context, id int, permanent bool) error
- func (c *Client) DeleteTags(ctx context.Context, collectionID int, tags []string) error
- func (c *Client) Get(ctx context.Context, path string, out interface{}) error
- func (c *Client) GetCollection(ctx context.Context, id int) (*Collection, error)
- func (c *Client) GetRaindrop(ctx context.Context, id int) (*Raindrop, error)
- func (c *Client) GetUser(ctx context.Context) (*User, error)
- func (c *Client) ListAllCollections(ctx context.Context) ([]Collection, error)
- func (c *Client) ListChildCollections(ctx context.Context) ([]Collection, error)
- func (c *Client) ListRaindrops(ctx context.Context, collectionID int, opts ListOptions) (*RaindropsResponse, error)
- func (c *Client) ListRootCollections(ctx context.Context) ([]Collection, error)
- func (c *Client) ListTags(ctx context.Context, collectionID int) ([]Tag, error)
- func (c *Client) ParseURL(ctx context.Context, rawURL string) (*ParsedURL, error)
- func (c *Client) Post(ctx context.Context, path string, body interface{}, out interface{}) error
- func (c *Client) Put(ctx context.Context, path string, body interface{}, out interface{}) error
- func (c *Client) RenameTags(ctx context.Context, collectionID int, oldTags []string, newName string) error
- func (c *Client) ResolveCollection(ctx context.Context, nameOrID string) (int, error)
- func (c *Client) Token(ctx context.Context) (*oauth2.Token, error)
- func (c *Client) UpdateCollection(ctx context.Context, id int, req *UpdateCollectionRequest) (*Collection, error)
- func (c *Client) UpdateRaindrop(ctx context.Context, id int, req *UpdateRaindropRequest) (*Raindrop, error)
- type Collection
- type CollectionRef
- type CollectionResponse
- type CollectionsResponse
- type CreateCollectionRequest
- type CreateRaindropRequest
- type DeleteTagsRequest
- type Highlight
- type ListOptions
- type NotFoundError
- type ParsedURL
- type Raindrop
- type RaindropResponse
- type RaindropsResponse
- type RateLimitError
- type RenameTagRequest
- type RetryTransport
- type Tag
- type TagsResponse
- type UpdateCollectionRequest
- type UpdateRaindropRequest
- type User
Constants ¶
const ( BaseURL = "https://api.raindrop.io/rest/v1" UserAgent = "raindrop-cli/0.1.0" ContentType = "application/json" )
const ( ExitSuccess = 0 ExitError = 1 ExitUsage = 2 ExitAuth = 3 ExitNotFound = 4 ExitRateLimit = 5 )
const ( MaxRateLimitRetries = 3 Max5xxRetries = 1 RateLimitBaseDelay = 1 * time.Second ServerErrorRetryDelay = 2 * time.Second )
const SystemCollectionAll = 0
SystemCollectionAll represents all raindrops.
const SystemCollectionTrash = -99
SystemCollectionTrash represents trashed raindrops.
const SystemCollectionUnsorted = -1
SystemCollectionUnsorted represents unsorted raindrops.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BulkCreateRequest ¶
type BulkCreateRequest struct {
Items []CreateRaindropRequest `json:"items"`
}
BulkCreateRequest wraps bulk create payload.
type BulkCreateResponse ¶
BulkCreateResponse wraps bulk create response.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Raindrop.io API client.
func NewClient ¶
func NewClient(ts oauth2.TokenSource) *Client
NewClient creates a new API client with the given token source.
func NewClientFromAuth ¶
NewClientFromAuth creates a client using stored auth credentials.
func NewClientWithBaseURL ¶
func NewClientWithBaseURL(ts oauth2.TokenSource, baseURL string) *Client
NewClientWithBaseURL creates a new API client with a custom base URL.
func (*Client) CreateCollection ¶
func (c *Client) CreateCollection(ctx context.Context, req *CreateCollectionRequest) (*Collection, error)
CreateCollection creates a new collection.
func (*Client) CreateRaindrop ¶
CreateRaindrop creates a new raindrop.
func (*Client) CreateRaindropsBulk ¶
func (c *Client) CreateRaindropsBulk(ctx context.Context, items []CreateRaindropRequest) ([]Raindrop, error)
CreateRaindropsBulk creates multiple raindrops (max 100 per call).
func (*Client) DeleteCollection ¶
DeleteCollection deletes a collection.
func (*Client) DeleteRaindrop ¶
DeleteRaindrop moves a raindrop to trash, or permanently deletes if permanent=true.
func (*Client) DeleteTags ¶
DeleteTags removes tags from a collection.
func (*Client) GetCollection ¶
GetCollection fetches a single collection by ID.
func (*Client) GetRaindrop ¶
GetRaindrop fetches a single raindrop by ID.
func (*Client) ListAllCollections ¶
func (c *Client) ListAllCollections(ctx context.Context) ([]Collection, error)
ListAllCollections fetches both root and child collections.
func (*Client) ListChildCollections ¶
func (c *Client) ListChildCollections(ctx context.Context) ([]Collection, error)
ListChildCollections fetches all child collections.
func (*Client) ListRaindrops ¶
func (c *Client) ListRaindrops(ctx context.Context, collectionID int, opts ListOptions) (*RaindropsResponse, error)
ListRaindrops fetches raindrops from a collection. collectionID: 0 = all, -1 = unsorted, -99 = trash
func (*Client) ListRootCollections ¶
func (c *Client) ListRootCollections(ctx context.Context) ([]Collection, error)
ListRootCollections fetches all root-level collections.
func (*Client) ListTags ¶
ListTags fetches all tags for a collection. collectionID: 0 = all collections
func (*Client) RenameTags ¶
func (c *Client) RenameTags(ctx context.Context, collectionID int, oldTags []string, newName string) error
RenameTags renames tags in a collection.
func (*Client) ResolveCollection ¶
ResolveCollection converts a name or ID string to a collection ID. Supports: numeric ID, "all" (0), "unsorted" (-1), "trash" (-99), or name lookup.
func (*Client) UpdateCollection ¶
func (c *Client) UpdateCollection(ctx context.Context, id int, req *UpdateCollectionRequest) (*Collection, error)
UpdateCollection updates an existing collection.
func (*Client) UpdateRaindrop ¶
func (c *Client) UpdateRaindrop(ctx context.Context, id int, req *UpdateRaindropRequest) (*Raindrop, error)
UpdateRaindrop updates an existing raindrop.
type Collection ¶
type Collection struct {
ID int `json:"_id"`
Title string `json:"title"`
Count int `json:"count"`
Color string `json:"color,omitempty"`
Parent *CollectionRef `json:"parent,omitempty"`
Expanded bool `json:"expanded"`
Created time.Time `json:"created"`
Updated time.Time `json:"lastUpdate"`
}
Collection represents a Raindrop.io collection.
func (*Collection) ParentID ¶
func (c *Collection) ParentID() int
ParentID returns the parent collection ID, or 0 if no parent.
type CollectionRef ¶
type CollectionRef struct {
ID int `json:"$id"`
}
CollectionRef is a reference to a collection (used in API responses).
type CollectionResponse ¶
type CollectionResponse struct {
Item Collection `json:"item"`
Result bool `json:"result"`
}
CollectionResponse wraps a single collection.
type CollectionsResponse ¶
type CollectionsResponse struct {
Items []Collection `json:"items"`
Result bool `json:"result"`
}
CollectionsResponse wraps a list of collections.
type CreateCollectionRequest ¶
type CreateCollectionRequest struct {
Title string `json:"title"`
Parent *struct {
ID int `json:"$id"`
} `json:"parent,omitempty"`
Color string `json:"color,omitempty"`
}
CreateCollectionRequest is the payload for creating a collection.
type CreateRaindropRequest ¶
type CreateRaindropRequest struct {
Link string `json:"link,omitempty"`
Title string `json:"title,omitempty"`
Excerpt string `json:"excerpt,omitempty"`
Note string `json:"note,omitempty"`
Tags []string `json:"tags,omitempty"`
Important bool `json:"important,omitempty"`
Collection struct {
ID int `json:"$id"`
} `json:"collection,omitempty"`
PleaseParse bool `json:"pleaseParse,omitempty"` //nolint:tagliatelle // API uses camelCase
}
CreateRaindropRequest is the payload for creating a raindrop.
type DeleteTagsRequest ¶
type DeleteTagsRequest struct {
Tags []string `json:"tags"`
}
DeleteTagsRequest is the payload for deleting tags.
type Highlight ¶
type Highlight struct {
ID string `json:"_id"`
Text string `json:"text"`
Note string `json:"note,omitempty"`
Color string `json:"color,omitempty"`
Created time.Time `json:"created"`
}
Highlight represents a text highlight in a raindrop.
type ListOptions ¶
ListOptions configures list/search requests.
type NotFoundError ¶
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type ParsedURL ¶
type ParsedURL struct {
Result bool `json:"result"`
Item struct {
Title string `json:"title"`
Excerpt string `json:"excerpt"`
Type string `json:"type"`
Cover string `json:"cover"`
} `json:"item"`
}
ParsedURL represents the response from /import/url/parse.
type Raindrop ¶
type Raindrop struct {
ID int `json:"_id"`
Link string `json:"link"`
Title string `json:"title"`
Excerpt string `json:"excerpt"`
Note string `json:"note"`
Type string `json:"type"`
Tags []string `json:"tags"`
Important bool `json:"important"`
Collection *CollectionRef `json:"collection,omitempty"`
Cover string `json:"cover"`
Domain string `json:"domain"`
Created time.Time `json:"created"`
Updated time.Time `json:"lastUpdate"`
Highlights []Highlight `json:"highlights,omitempty"`
}
Raindrop represents a bookmark in Raindrop.io.
func (*Raindrop) CollectionID ¶
CollectionID returns the collection ID, or 0 if none.
type RaindropResponse ¶
RaindropResponse wraps a single raindrop response.
type RaindropsResponse ¶
RaindropsResponse wraps a list of raindrops.
type RateLimitError ¶
type RateLimitError struct {
RetryAfter int // seconds
}
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type RenameTagRequest ¶
RenameTagRequest is the payload for renaming a tag.
type RetryTransport ¶
type RetryTransport struct {
Base http.RoundTripper
MaxRetries429 int
MaxRetries5xx int
BaseDelay time.Duration
}
RetryTransport wraps an http.RoundTripper with retry logic for rate limits (429) and server errors (5xx).
func NewRetryTransport ¶
func NewRetryTransport(base http.RoundTripper) *RetryTransport
type TagsResponse ¶
type TagsResponse struct {
Items []Tag `json:"items"`
}
TagsResponse wraps a list of tags.
type UpdateCollectionRequest ¶
type UpdateCollectionRequest struct {
Title string `json:"title,omitempty"`
Parent *struct {
ID int `json:"$id"`
} `json:"parent,omitempty"`
Color string `json:"color,omitempty"`
}
UpdateCollectionRequest is the payload for updating a collection.
type UpdateRaindropRequest ¶
type UpdateRaindropRequest struct {
Link string `json:"link,omitempty"`
Title string `json:"title,omitempty"`
Excerpt string `json:"excerpt,omitempty"`
Note string `json:"note,omitempty"`
Tags []string `json:"tags,omitempty"`
Important *bool `json:"important,omitempty"`
Collection *struct {
ID int `json:"$id"`
} `json:"collection,omitempty"`
}
UpdateRaindropRequest is the payload for updating a raindrop.