Module: X::Objects::Actions::Engagement

Included in:
X::Objects::API
Defined in:
x-objects/lib/x/objects/actions/engagement.rb

Overview

Like, repost, and bookmark posts as the authenticated user

Internal to x-objects: X::Objects::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

Instance Method Details

#bookmark(post) ⇒ Boolean

Bookmark a post as the authenticated user

The bookmark endpoints take only OAuth 2.0 user context, which the object layer cannot route around, so a client that signs with OAuth 1.0a is refused.

Examples:

Bookmark a post

client.bookmark("1234567890")

Parameters:

  • post (Post, String, Integer) —

    the post or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user has bookmarked the post



70
71
72
# File 'x-objects/lib/x/objects/actions/engagement.rb', line 70

def bookmark(post)
  User.from_id(current_user_id, client: self).bookmark(post)
end

#like(post) ⇒ Boolean

Like a post as the authenticated user

Examples:

Like a post

client.like("1234567890")

Parameters:

  • post (Post, String, Integer) —

    the post or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user now likes the post



23
24
25
# File 'x-objects/lib/x/objects/actions/engagement.rb', line 23

def like(post)
  User.from_id(current_user_id, client: self).like(post)
end

#repost(post) ⇒ Boolean Also known as: retweet

Repost a post as the authenticated user

Examples:

Repost a post

client.repost("1234567890")

Parameters:

  • post (Post, String, Integer) —

    the post or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user has reposted the post



45
46
47
# File 'x-objects/lib/x/objects/actions/engagement.rb', line 45

def repost(post)
  User.from_id(current_user_id, client: self).repost(post)
end

#unbookmark(post) ⇒ Boolean

Remove a bookmark as the authenticated user

The bookmark endpoints take only OAuth 2.0 user context, which the object layer cannot route around, so a client that signs with OAuth 1.0a is refused.

Examples:

Remove a bookmark

client.unbookmark("1234567890")

Parameters:

  • post (Post, String, Integer) —

    the post or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer has the post bookmarked



84
85
86
# File 'x-objects/lib/x/objects/actions/engagement.rb', line 84

def unbookmark(post)
  User.from_id(current_user_id, client: self).unbookmark(post)
end

#unlike(post) ⇒ Boolean

Unlike a post as the authenticated user

Examples:

Unlike a post

client.unlike("1234567890")

Parameters:

  • post (Post, String, Integer) —

    the post or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer likes the post



34
35
36
# File 'x-objects/lib/x/objects/actions/engagement.rb', line 34

def unlike(post)
  User.from_id(current_user_id, client: self).unlike(post)
end

#unrepost(post) ⇒ Boolean Also known as: unretweet

Undo a repost as the authenticated user

Examples:

Undo a repost

client.unrepost("1234567890")

Parameters:

  • post (Post, String, Integer) —

    the post or its identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer reposts the post



56
57
58
# File 'x-objects/lib/x/objects/actions/engagement.rb', line 56

def unrepost(post)
  User.from_id(current_user_id, client: self).unrepost(post)
end