Module: X::Resources::Actions::Relationships

Included in:
X::Resources::API
Defined in:
x-resources/lib/x/resources/actions/relationships.rb

Overview

Follow, block, and mute users 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

Instance Method Details

#block(user) ⇒ Boolean

Block a user as the authenticated user

Examples:

Block a user

client.block("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user now blocks the user



52
53
54
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 52

def block(user)
  RelationWrites.relate(self, current_user_id, "blocking", {"target_user_id" => Utils.id_of(user, User)}, "blocking")
end

#follow(user) ⇒ Boolean

Follow a user as the authenticated user

A protected user must accept a request to follow them first, so for a protected user true means the follow was requested, not that the authenticated user follows them: until they accept it, the follows? of the authenticated user, as in client.current_user!.follows?(user), answers false.

Examples:

Follow a user

client.follow("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user now follows the user, or, for a protected user, has requested to follow them



30
31
32
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 30

def follow(user)
  RelationWrites.relate(self, current_user_id, "following", {"target_user_id" => Utils.id_of(user, User)}, "following", "pending_follow")
end

#mute(user) ⇒ Boolean

Mute a user as the authenticated user

Examples:

Mute a user

client.mute("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user now mutes the user



74
75
76
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 74

def mute(user)
  RelationWrites.relate(self, current_user_id, "muting", {"target_user_id" => Utils.id_of(user, User)}, "muting")
end

#unblock(user) ⇒ Boolean

Unblock a user as the authenticated user

Examples:

Unblock a user

client.unblock("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer blocks the user



63
64
65
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 63

def unblock(user)
  RelationWrites.unrelate(self, current_user_id, "blocking", Utils.id_of(user, User), "blocking")
end

#unfollow(user) ⇒ Boolean

Unfollow a user as the authenticated user

Examples:

Unfollow a user

client.unfollow("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer follows the user



41
42
43
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 41

def unfollow(user)
  RelationWrites.unrelate(self, current_user_id, "following", Utils.id_of(user, User), "following")
end

#unmute(user) ⇒ Boolean

Unmute a user as the authenticated user

Examples:

Unmute a user

client.unmute("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer mutes the user



85
86
87
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 85

def unmute(user)
  RelationWrites.unrelate(self, current_user_id, "muting", Utils.id_of(user, User), "muting")
end