Add bookmark support
This commit is contained in:
parent
86627ec7d6
commit
d39c10ba5e
2 changed files with 119 additions and 0 deletions
31
status.go
31
status.go
|
@ -30,6 +30,7 @@ type Status struct {
|
|||
FavouritesCount int64 `json:"favourites_count"`
|
||||
Reblogged interface{} `json:"reblogged"`
|
||||
Favourited interface{} `json:"favourited"`
|
||||
Bookmarked interface{} `json:"bookmarked"`
|
||||
Muted interface{} `json:"muted"`
|
||||
Sensitive bool `json:"sensitive"`
|
||||
SpoilerText string `json:"spoiler_text"`
|
||||
|
@ -149,6 +150,16 @@ func (c *Client) GetFavourites(ctx context.Context, pg *Pagination) ([]*Status,
|
|||
return statuses, nil
|
||||
}
|
||||
|
||||
// GetBookmarks return the bookmark list of the current user.
|
||||
func (c *Client) GetBookmarks(ctx context.Context, pg *Pagination) ([]*Status, error) {
|
||||
var statuses []*Status
|
||||
err := c.doAPI(ctx, http.MethodGet, "/api/v1/bookmarks", nil, &statuses, pg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return statuses, nil
|
||||
}
|
||||
|
||||
// GetStatus return status specified by id.
|
||||
func (c *Client) GetStatus(ctx context.Context, id ID) (*Status, error) {
|
||||
var status Status
|
||||
|
@ -239,6 +250,26 @@ func (c *Client) Unfavourite(ctx context.Context, id ID) (*Status, error) {
|
|||
return &status, nil
|
||||
}
|
||||
|
||||
// Bookmark is bookmark the toot of id and return status of the bookmark toot.
|
||||
func (c *Client) Bookmark(ctx context.Context, id ID) (*Status, error) {
|
||||
var status Status
|
||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/bookmark", id), nil, &status, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
// Unbookmark is unbookmark the toot of id and return status of the unbookmark toot.
|
||||
func (c *Client) Unbookmark(ctx context.Context, id ID) (*Status, error) {
|
||||
var status Status
|
||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unbookmark", id), nil, &status, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
// GetTimelineHome return statuses from home timeline.
|
||||
func (c *Client) GetTimelineHome(ctx context.Context, pg *Pagination) ([]*Status, error) {
|
||||
var statuses []*Status
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue