Module: Mastodon::REST::Relationships

Includes:
Utils
Included in:
API
Defined in:
lib/mastodon/rest/relationships.rb

Instance Method Summary collapse

Methods included from Utils

#array_param, #perform_request, #perform_request_with_collection, #perform_request_with_object

Instance Method Details

#block(id) ⇒ Mastodon::Relationship

Block a user

Parameters:

  • id (Integer)

Returns:



47
48
49
50
# File 'lib/mastodon/rest/relationships.rb', line 47

def block(id)
  perform_request_with_object(:post, "/api/v1/accounts/#{id}/block",
                              {}, Mastodon::Relationship)
end

#follow(id) ⇒ Mastodon::Relationship

Follow a user

Parameters:

  • id (Integer)

Returns:



23
24
25
26
# File 'lib/mastodon/rest/relationships.rb', line 23

def follow(id)
  perform_request_with_object(:post, "/api/v1/accounts/#{id}/follow",
                              {}, Mastodon::Relationship)
end

#mute(id) ⇒ Mastodon::Relationship

Mute a user

Parameters:

  • id (Integer)

Returns:



63
64
65
66
# File 'lib/mastodon/rest/relationships.rb', line 63

def mute(id)
  perform_request_with_object(:post, "/api/v1/accounts/#{id}/mute",
                              {}, Mastodon::Relationship)
end

#relationships(*ids) ⇒ Mastodon::Collection<Mastodon::Relationship>

Get the relationships of authenticated user towards given other users

Parameters:

  • ids (Integer)

Returns:



14
15
16
17
18
# File 'lib/mastodon/rest/relationships.rb', line 14

def relationships(*ids)
  perform_request_with_collection(:get, '/api/v1/accounts/relationships',
                                  array_param(:id, ids),
                                  Mastodon::Relationship)
end

#remote_follow(uri) ⇒ Mastodon::Account

Follow a remote user

Parameters:

  • uri (String)

    username@domain of the person you want to follow

Returns:



31
32
33
34
# File 'lib/mastodon/rest/relationships.rb', line 31

def remote_follow(uri)
  perform_request_with_object(:post, '/api/v1/follows', { uri: uri },
                              Mastodon::Account)
end

#unblock(id) ⇒ Mastodon::Relationship

Unblock a user

Parameters:

  • id (Integer)

Returns:



55
56
57
58
# File 'lib/mastodon/rest/relationships.rb', line 55

def unblock(id)
  perform_request_with_object(:post, "/api/v1/accounts/#{id}/unblock",
                              {}, Mastodon::Relationship)
end

#unfollow(id) ⇒ Mastodon::Relationship

Unfollow a user

Parameters:

  • id (Integer)

Returns:



39
40
41
42
# File 'lib/mastodon/rest/relationships.rb', line 39

def unfollow(id)
  perform_request_with_object(:post, "/api/v1/accounts/#{id}/unfollow",
                              {}, Mastodon::Relationship)
end

#unmute(id) ⇒ Mastodon::Relationship

Unmute a user

Parameters:

  • id (Integer)

Returns:



71
72
73
74
# File 'lib/mastodon/rest/relationships.rb', line 71

def unmute(id)
  perform_request_with_object(:post, "/api/v1/accounts/#{id}/unmute",
                              {}, Mastodon::Relationship)
end