Module: Mastodon::REST::Accounts
Instance Method Summary collapse
-
#account(id) ⇒ Mastodon::Account
Retrieve account.
-
#create_account(params = {}) ⇒ Mastodon::AccessToken
Sign up (requires authentication with client credentials).
-
#followers(id, options = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Get a list of followers.
-
#following(id, options = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Get a list of followed accounts.
-
#search_accounts(query, params = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Search accounts.
-
#update_credentials(params = {}) ⇒ Mastodon::Account
Update authenticated account attributes.
-
#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
#account(id) ⇒ Mastodon::Account
Retrieve account
35 36 37 |
# File 'lib/mastodon/rest/accounts.rb', line 35 def account(id) perform_request_with_object(:get, "/api/v1/accounts/#{id}", {}, Mastodon::Account) end |
#create_account(params = {}) ⇒ Mastodon::AccessToken
Sign up (requires authentication with client credentials)
71 72 73 |
# File 'lib/mastodon/rest/accounts.rb', line 71 def create_account(params = {}) perform_request_with_object(:post, '/api/v1/accounts', params, Mastodon::AccessToken) end |
#followers(id, options = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Get a list of followers
47 48 49 |
# File 'lib/mastodon/rest/accounts.rb', line 47 def followers(id, = {}) perform_request_with_collection(:get, "/api/v1/accounts/#{id}/followers", , Mastodon::Account) end |
#following(id, options = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Get a list of followed accounts
59 60 61 |
# File 'lib/mastodon/rest/accounts.rb', line 59 def following(id, = {}) perform_request_with_collection(:get, "/api/v1/accounts/#{id}/following", , Mastodon::Account) end |
#search_accounts(query, params = {}) ⇒ Mastodon::Collection<Mastodon::Account>
Search accounts
82 83 84 |
# File 'lib/mastodon/rest/accounts.rb', line 82 def search_accounts(query, params = {}) perform_request_with_collection(:get, '/api/v1/accounts/search', { q: query }.merge(params), Mastodon::Account) end |
#update_credentials(params = {}) ⇒ Mastodon::Account
Update authenticated account attributes
23 24 25 26 27 28 29 30 |
# File 'lib/mastodon/rest/accounts.rb', line 23 def update_credentials(params = {}) %i(avatar header).each do |key| next unless params.key?(key) params[key] = params[key].is_a?(HTTP::FormData::File) ? params[key] : HTTP::FormData::File.new(params[key]) end perform_request_with_object(:patch, '/api/v1/accounts/update_credentials', params, Mastodon::Account) end |
#verify_credentials ⇒ Mastodon::Account
Retrieve account of authenticated user
12 13 14 |
# File 'lib/mastodon/rest/accounts.rb', line 12 def verify_credentials perform_request_with_object(:get, '/api/v1/accounts/verify_credentials', {}, Mastodon::Account) end |