Module: Mastodon::REST::Accounts
Instance Method Summary collapse
-
#accept_follow_request(id) ⇒ Boolean
Accept a follow request.
-
#account(id) ⇒ Mastodon::Account
Retrieve account.
-
#add_endorsement(id) ⇒ Mastodon::Relationship
Add an endorsement.
-
#blocks(options = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Get user blocks.
-
#endorsements ⇒ Mastodon::Collection<Mastodon::Account>
Get account endorsements.
-
#follow_by_uri(uri) ⇒ Mastodon::Account
Follow a remote user.
-
#follow_requests(options = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Gets follow requests.
-
#followers(id) ⇒ Mastodon::Collection<Mastodon::Account>
Get a list of followers.
-
#following(id) ⇒ Mastodon::Collection<Mastodon::Account>
Get a list of followed accounts.
-
#mutes ⇒ Mastodon::Collection<Mastodon::Account>
Get user mutes.
-
#reject_follow_request(id) ⇒ Boolean
Reject follow request.
-
#remove_endorsement(id) ⇒ Mastodon::Relationship
Remove an endorsement.
-
#report(id, options = {}) ⇒ Object
Report an account.
- #update_credentials(opts = {}) ⇒ Mastodon::Account
-
#verify_credentials ⇒ Mastodon::Account
Retrieve account of authenticated user.
Methods included from Utils
#array_param, #perform_request, #perform_request_with_collection, #perform_request_with_object
Instance Method Details
#accept_follow_request(id) ⇒ Boolean
Accept a follow request
137 138 139 |
# File 'lib/mastodon/rest/accounts.rb', line 137 def accept_follow_request(id) !perform_request(:post, "/api/v1/follow_requests/#{id}/authorize").nil? end |
#account(id) ⇒ Mastodon::Account
Retrieve account
45 46 47 48 |
# File 'lib/mastodon/rest/accounts.rb', line 45 def account(id) perform_request_with_object(:get, "/api/v1/accounts/#{id}", {}, Mastodon::Account) end |
#add_endorsement(id) ⇒ Mastodon::Relationship
Add an endorsement
89 90 91 92 |
# File 'lib/mastodon/rest/accounts.rb', line 89 def add_endorsement(id) perform_request_with_object(:post, "/api/v1/accounts/#{id}/pin", {}, Mastodon::Relationship) end |
#blocks(options = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Get user blocks
112 113 114 115 |
# File 'lib/mastodon/rest/accounts.rb', line 112 def blocks( = {}) perform_request_with_collection(:get, '/api/v1/blocks', , Mastodon::Account) end |
#endorsements ⇒ Mastodon::Collection<Mastodon::Account>
Get account endorsements
81 82 83 84 |
# File 'lib/mastodon/rest/accounts.rb', line 81 def endorsements perform_request_with_collection(:get, '/api/v1/endorsements', {}, Mastodon::Account) end |
#follow_by_uri(uri) ⇒ Mastodon::Account
Follow a remote user
72 73 74 75 76 |
# File 'lib/mastodon/rest/accounts.rb', line 72 def follow_by_uri(uri) perform_request_with_object(:post, '/api/v1/follows', { uri: uri }, Mastodon::Account) end |
#follow_requests(options = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Gets follow requests
129 130 131 132 |
# File 'lib/mastodon/rest/accounts.rb', line 129 def follow_requests( = {}) perform_request_with_collection(:get, '/api/v1/follow_requests', , Mastodon::Account) end |
#followers(id) ⇒ Mastodon::Collection<Mastodon::Account>
Get a list of followers
53 54 55 56 57 |
# File 'lib/mastodon/rest/accounts.rb', line 53 def followers(id) perform_request_with_collection(:get, "/api/v1/accounts/#{id}/followers", {}, Mastodon::Account) end |
#following(id) ⇒ Mastodon::Collection<Mastodon::Account>
Get a list of followed accounts
62 63 64 65 66 |
# File 'lib/mastodon/rest/accounts.rb', line 62 def following(id) perform_request_with_collection(:get, "/api/v1/accounts/#{id}/following", {}, Mastodon::Account) end |
#mutes ⇒ Mastodon::Collection<Mastodon::Account>
Get user mutes
103 104 105 106 |
# File 'lib/mastodon/rest/accounts.rb', line 103 def mutes perform_request_with_collection(:get, '/api/v1/mutes', {}, Mastodon::Account) end |
#reject_follow_request(id) ⇒ Boolean
Reject follow request
144 145 146 |
# File 'lib/mastodon/rest/accounts.rb', line 144 def reject_follow_request(id) !perform_request(:post, "/api/v1/follow_requests/#{id}/reject").nil? end |
#remove_endorsement(id) ⇒ Mastodon::Relationship
Remove an endorsement
97 98 99 100 |
# File 'lib/mastodon/rest/accounts.rb', line 97 def remove_endorsement(id) perform_request_with_object(:post, "/api/v1/accounts/#{id}/unpin", {}, Mastodon::Relationship) end |
#report(id, options = {}) ⇒ Object
Report an account
121 122 123 124 |
# File 'lib/mastodon/rest/accounts.rb', line 121 def report(id, = {}) [:account_id] = id !perform_request(:post, '/api/v1/reports', ).nil? end |
#update_credentials(opts = {}) ⇒ Mastodon::Account
32 33 34 35 36 37 38 39 40 |
# File 'lib/mastodon/rest/accounts.rb', line 32 def update_credentials(opts = {}) opts[:fields] and opts.delete(:fields).each_with_index { |f, i| opts["fields_attributes[#{i}][name]"] = f[:name] opts["fields_attributes[#{i}][value]"] = f[:value] } perform_request_with_object(:patch, '/api/v1/accounts/update_credentials', opts, Mastodon::Account) end |
#verify_credentials ⇒ Mastodon::Account
Retrieve account of authenticated user
14 15 16 17 |
# File 'lib/mastodon/rest/accounts.rb', line 14 def verify_credentials perform_request_with_object(:get, '/api/v1/accounts/verify_credentials', {}, Mastodon::Account) end |