-
Notifications
You must be signed in to change notification settings - Fork 21
/
api.go
48 lines (39 loc) · 1.68 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package bookmark
import (
"context"
"github.com/michimani/gotwi"
"github.com/michimani/gotwi/tweet/bookmark/types"
)
const (
listEndpoint = "https://api.twitter.com/2/users/:id/bookmarks"
createEndpoint = "https://api.twitter.com/2/users/:id/bookmarks"
deleteEndpoint = "https://api.twitter.com/2/users/:id/bookmarks/:tweet_id"
)
// Allows you to get information about a authenticated user’s 800 most recent bookmarked Tweets
// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/get-users-id-bookmarks
func List(ctx context.Context, c *gotwi.Client, p *types.ListInput) (*types.ListOutput, error) {
res := &types.ListOutput{}
if err := c.CallAPI(ctx, listEndpoint, "GET", p, res); err != nil {
return nil, err
}
return res, nil
}
// Causes the user ID of an authenticated user identified in the path parameter
// to Bookmark the target Tweet provided in the request body.
// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/post-users-id-bookmarks
func Create(ctx context.Context, c *gotwi.Client, p *types.CreateInput) (*types.CreateOutput, error) {
res := &types.CreateOutput{}
if err := c.CallAPI(ctx, createEndpoint, "POST", p, res); err != nil {
return nil, err
}
return res, nil
}
// Allows a user or authenticated user ID to remove a Bookmark of a Tweet.
// https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/delete-users-id-bookmarks-tweet_id
func Delete(ctx context.Context, c *gotwi.Client, p *types.DeleteInput) (*types.DeleteOutput, error) {
res := &types.DeleteOutput{}
if err := c.CallAPI(ctx, deleteEndpoint, "DELETE", p, res); err != nil {
return nil, err
}
return res, nil
}