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

#authorize_follow_request(id) ⇒ Object

Authorize a follow request

Parameters:

  • id (Integer)


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

def authorize_follow_request(id)
  perform_request(:post, "/api/v1/follow_requests/#{id}/authorize")
end

#block(id) ⇒ Mastodon::Relationship

Block a user

Parameters:

  • id (Integer)

Returns:



75
76
77
# File 'lib/mastodon/rest/relationships.rb', line 75

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

#blocks(options = {}) ⇒ Mastodon::Collection<Mastodon::Account>

Get a list of blocked accounts

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :max_id (Integer)
  • :since_id (Integer)
  • :min_id (Integer)
  • :limit (Integer)

Returns:



68
69
70
# File 'lib/mastodon/rest/relationships.rb', line 68

def blocks(options = {})
  perform_request_with_collection(:get, '/api/v1/blocks', options, Mastodon::Account)
end

#follow(id) ⇒ Mastodon::Relationship

Follow a user

Parameters:

  • id (Integer)

Returns:



43
44
45
# File 'lib/mastodon/rest/relationships.rb', line 43

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

#follow_requests(options = {}) ⇒ Mastodon::Collection<Mastodon::Account>

Get a list of pending follow requests

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :max_id (Integer)
  • :since_id (Integer)
  • :min_id (Integer)
  • :limit (Integer)

Returns:



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

def follow_requests(options = {})
  perform_request_with_collection(:get, '/api/v1/follow_requests', options, Mastodon::Account)
end

#mute(id) ⇒ Mastodon::Relationship

Mute a user

Parameters:

  • id (Integer)

Returns:



100
101
102
# File 'lib/mastodon/rest/relationships.rb', line 100

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

#mute_status(id) ⇒ Mastodon::Status

Mute notifications for a status

Parameters:

  • id (Integer)

Returns:



114
115
116
# File 'lib/mastodon/rest/relationships.rb', line 114

def mute_status(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/mute", {}, Mastodon::Status)
end

#mutes(options = {}) ⇒ Mastodon::Collection<Mastodon::Account>

Get a list of muted accounts

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :max_id (Integer)
  • :since_id (Integer)
  • :min_id (Integer)
  • :limit (Integer)

Returns:



93
94
95
# File 'lib/mastodon/rest/relationships.rb', line 93

def mutes(options = {})
  perform_request_with_collection(:get, '/api/v1/mutes', options, Mastodon::Account)
end

#reject_follow_request(id) ⇒ Object

Reject a follow request

Parameters:

  • id (Integer)


36
37
38
# File 'lib/mastodon/rest/relationships.rb', line 36

def reject_follow_request(id)
  perform_request(:post, "/api/v1/follow_requests/#{id}/reject")
end

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

Get the relationships of authenticated user towards given other users

Parameters:

  • ids (Integer)

Returns:



13
14
15
# File 'lib/mastodon/rest/relationships.rb', line 13

def relationships(*ids)
  perform_request_with_collection(:get, '/api/v1/accounts/relationships', { '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:



50
51
52
# File 'lib/mastodon/rest/relationships.rb', line 50

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:



82
83
84
# File 'lib/mastodon/rest/relationships.rb', line 82

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:



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

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:



107
108
109
# File 'lib/mastodon/rest/relationships.rb', line 107

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

#unmute_status(id) ⇒ Mastodon::Status

Unmute notifications for a status

Parameters:

  • id (Integer)

Returns:



121
122
123
# File 'lib/mastodon/rest/relationships.rb', line 121

def unmute_status(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/unmute", {}, Mastodon::Status)
end