module Mastodon::REST::Accounts

Public Instance Methods

accept_follow_request(id) click to toggle source

Accept a follow request @param id [Integer] @return [Boolean]

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

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

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

Add an endorsement @param id [Integer] @return [Mastodon::Relationship]

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

Get user blocks @param options [Hash] @option options :limit [Integer] @return [Mastodon::Collection<Mastodon::Account>]

# File lib/mastodon/rest/accounts.rb, line 112
def blocks(options = {})
  perform_request_with_collection(:get, '/api/v1/blocks',
                                  options, Mastodon::Account)
end
endorsements() click to toggle source

Get account endorsements @return [Mastodon::Collection<Mastodon::Account>]

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

Follow a remote user @param uri [String] The URI of the remote user, in the format of

username@domain

@return [Mastodon::Account]

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

Gets follow requests @param options [Hash] @option options :limit [Integer] @return [Mastodon::Collection<Mastodon::Account>]

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

Get a list of followers @param id [Integer] @return [Mastodon::Collection<Mastodon::Account>]

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

Get a list of followed accounts @param id [Integer] @return [Mastodon::Collection<Mastodon::Account>]

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

Get user mutes @return [Mastodon::Collection<Mastodon::Account>]

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

Reject follow request @param id [Integer] @return [Boolean]

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

Remove an endorsement @param id [Integer] @return [Mastodon::Relationship]

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

Report an account @param id [Integer] @param options [Hash] @option options :status_ids [Array<Integer>] @option options :comment [String]

# File lib/mastodon/rest/accounts.rb, line 121
def report(id, options = {})
  options[:account_id] = id
  !perform_request(:post, '/api/v1/reports', options).nil?
end
update_credentials(opts = {}) click to toggle source

@return [Mastodon::Account]

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

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

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