Module: X::Resources::Actions::Engagement
- Included in:
- X::Resources::API
- Defined in:
- x-resources/lib/x/resources/actions/engagement.rb
Overview
Like, repost, and bookmark posts as the authenticated user
Internal to x-resources: X::Resources::API includes it, and its methods are public API of the client that includes API, but the module is only how they are grouped, and some of them need the methods of another, so include API rather than this module alone.
Instance Method Summary collapse
-
#bookmark(post) ⇒ Boolean
Bookmark a post as the authenticated user.
-
#like(post) ⇒ Boolean
Like a post as the authenticated user.
-
#repost(post) ⇒ Boolean
(also: #retweet)
Repost a post as the authenticated user.
-
#unbookmark(post) ⇒ Boolean
Remove a bookmark as the authenticated user.
-
#unlike(post) ⇒ Boolean
Unlike a post as the authenticated user.
-
#unrepost(post) ⇒ Boolean
(also: #unretweet)
Undo a repost as the authenticated user.
Instance Method Details
#bookmark(post) ⇒ Boolean
Bookmark a post as the authenticated user
Bookmarking a post takes only OAuth 2.0 user context, which the object layer cannot route around, so a client that signs with OAuth 1.0a is refused.
72 73 74 |
# File 'x-resources/lib/x/resources/actions/engagement.rb', line 72 def bookmark(post) RelationWrites.relate(self, current_user_id, "bookmarks", {"tweet_id" => Utils.id_of(post, Post)}, "bookmarked") end |
#like(post) ⇒ Boolean
Like a post as the authenticated user
25 26 27 |
# File 'x-resources/lib/x/resources/actions/engagement.rb', line 25 def like(post) RelationWrites.relate(self, current_user_id, "likes", {"tweet_id" => Utils.id_of(post, Post)}, "liked") end |
#repost(post) ⇒ Boolean Also known as: retweet
Repost a post as the authenticated user
47 48 49 |
# File 'x-resources/lib/x/resources/actions/engagement.rb', line 47 def repost(post) RelationWrites.relate(self, current_user_id, "retweets", {"tweet_id" => Utils.id_of(post, Post)}, "retweeted") end |
#unbookmark(post) ⇒ Boolean
Remove a bookmark as the authenticated user
Removing a bookmark takes only OAuth 2.0 user context, which the object layer cannot route around, so a client that signs with OAuth 1.0a is refused.
86 87 88 |
# File 'x-resources/lib/x/resources/actions/engagement.rb', line 86 def unbookmark(post) RelationWrites.unrelate(self, current_user_id, "bookmarks", Utils.id_of(post, Post), "bookmarked") end |
#unlike(post) ⇒ Boolean
Unlike a post as the authenticated user
36 37 38 |
# File 'x-resources/lib/x/resources/actions/engagement.rb', line 36 def unlike(post) RelationWrites.unrelate(self, current_user_id, "likes", Utils.id_of(post, Post), "liked") end |
#unrepost(post) ⇒ Boolean Also known as: unretweet
Undo a repost as the authenticated user
58 59 60 |
# File 'x-resources/lib/x/resources/actions/engagement.rb', line 58 def unrepost(post) RelationWrites.unrelate(self, current_user_id, "retweets", Utils.id_of(post, Post), "retweeted") end |