module Mastodon::REST::Accounts

Public Instance Methods

account(id) click to toggle source

Retrieve account @param id [Integer] @return [Mastodon::Account]

# 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 = {}) click to toggle source

Sign up (requires authentication with client credentials) @param params [Hash] @option params :username [String] @option params :email [String] @option params :password [String] @option params :agreement [Boolean] @option params :locale [String] @return [Mastodon::AccessToken]

# 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 = {}) click to toggle source

Get a list of followers @param id [Integer] @param options [Hash] @option options :max_id [Integer] @option options :since_id [Integer] @option options :min_id [Integer] @option options :limit [Integer] @return [Mastodon::Collection<Mastodon::Account>]

# File lib/mastodon/rest/accounts.rb, line 47
def followers(id, options = {})
  perform_request_with_collection(:get, "/api/v1/accounts/#{id}/followers", options, Mastodon::Account)
end
following(id, options = {}) click to toggle source

Get a list of followed accounts @param id [Integer] @param options [Hash] @option options :max_id [Integer] @option options :since_id [Integer] @option options :min_id [Integer] @option options :limit [Integer] @return [Mastodon::Collection<Mastodon::Account>]

# File lib/mastodon/rest/accounts.rb, line 59
def following(id, options = {})
  perform_request_with_collection(:get, "/api/v1/accounts/#{id}/following", options, Mastodon::Account)
end
search_accounts(query, params = {}) click to toggle source

Search accounts @param query [String] @param params [Hash] @option params :limit [Integer] @option params :resolve [Boolean] Whether to attempt resolving unknown remote accounts @option params :following [Boolean] Only return matches the authenticated user follows @return [Mastodon::Collection<Mastodon::Account>]

# 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 = {}) click to toggle source

Update authenticated account attributes @param params [Hash] @option params :display_name [String] The name to display in the user's profile @option params :note [String] A new biography for the user @option params :avatar [File, StringIO, HTTP::FormData::File] @option params :header [File, StringIO, HTTP::FormData::File] @return [Mastodon::Account]

# 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() click to toggle source

Retrieve account of authenticated user @return [Mastodon::Account]

# File lib/mastodon/rest/accounts.rb, line 12
def verify_credentials
  perform_request_with_object(:get, '/api/v1/accounts/verify_credentials', {}, Mastodon::Account)
end