checkpoint: get bookmarks
This commit is contained in:
parent
674f277eba
commit
4d30e643af
3 changed files with 34 additions and 0 deletions
|
@ -62,3 +62,20 @@ func (g *Client) CreateStatus(form CreateStatusForm) (model.Status, error) {
|
|||
|
||||
return status, nil
|
||||
}
|
||||
|
||||
func (g *Client) GetBookmarks(limit int) (model.StatusList, error) {
|
||||
path := fmt.Sprintf("/api/v1/bookmarks?limit=%d", limit)
|
||||
url := g.Authentication.Instance + path
|
||||
|
||||
bookmarks := model.StatusList{
|
||||
Type: model.StatusListBookMarks,
|
||||
Name: "BOOKMARKS",
|
||||
Statuses: nil,
|
||||
}
|
||||
|
||||
if err := g.sendRequest(http.MethodGet, url, nil, &bookmarks.Statuses); err != nil {
|
||||
return bookmarks, fmt.Errorf("received an error after sending the request to get the bookmarks: %w", err)
|
||||
}
|
||||
|
||||
return bookmarks, nil
|
||||
}
|
||||
|
|
|
@ -44,4 +44,5 @@ const (
|
|||
resourceNote = "note"
|
||||
resourceStatus = "status"
|
||||
resourceTimeline = "timeline"
|
||||
resourceBookmarks = "bookmarks"
|
||||
)
|
||||
|
|
|
@ -66,6 +66,7 @@ func (c *ShowExecutor) Execute() error {
|
|||
resourceFollowers: c.showFollowers,
|
||||
resourceFollowing: c.showFollowing,
|
||||
resourceBlocked: c.showBlocked,
|
||||
resourceBookmarks: c.showBookmarks,
|
||||
}
|
||||
|
||||
doFunc, ok := funcMap[c.resourceType]
|
||||
|
@ -313,3 +314,18 @@ func (c *ShowExecutor) showBlocked(gtsClient *client.Client) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ShowExecutor) showBookmarks(gtsClient *client.Client) error {
|
||||
bookmarks, err := gtsClient.GetBookmarks(c.limit)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the list of bookmarks: %w", err)
|
||||
}
|
||||
|
||||
if len(bookmarks.Statuses) > 0 {
|
||||
utilities.Display(bookmarks, *c.topLevelFlags.NoColor)
|
||||
} else {
|
||||
fmt.Println("You have no bookmarks.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue