Module: Mastodon::REST::Accounts

Includes:
Utils
Included in:
API
Defined in:
lib/mastodon/rest/accounts.rb

Instance Method Summary collapse

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

Parameters:

  • id (Integer)

Returns:



37
38
39
40
# File 'lib/mastodon/rest/accounts.rb', line 37

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

#follow_by_uri(uri) ⇒ Mastodon::Account

Follow a remote user

Parameters:

  • uri (String)

    The URI of the remote user, in the format of username@domain

Returns:



64
65
66
67
68
# File 'lib/mastodon/rest/accounts.rb', line 64

def follow_by_uri(uri)
  perform_request_with_object(:post,
                              '/api/v1/follows', { uri: uri },
                              Mastodon::)
end

#followers(id) ⇒ Mastodon::Collection<Mastodon::Account>

Get a list of followers

Parameters:

  • id (Integer)

Returns:



45
46
47
48
49
# File 'lib/mastodon/rest/accounts.rb', line 45

def followers(id)
  perform_request_with_collection(:get,
                                  "/api/v1/accounts/#{id}/followers",
                                  {}, Mastodon::)
end

#following(id) ⇒ Mastodon::Collection<Mastodon::Account>

Get a list of followed accounts

Parameters:

  • id (Integer)

Returns:



54
55
56
57
58
# File 'lib/mastodon/rest/accounts.rb', line 54

def following(id)
  perform_request_with_collection(:get,
                                  "/api/v1/accounts/#{id}/following",
                                  {}, Mastodon::)
end

#update_credentials(opts = {}) ⇒ Mastodon::Account

Update authenticated account attributes

Parameters:

  • options (Hash)

Returns:



28
29
30
31
32
# File 'lib/mastodon/rest/accounts.rb', line 28

def update_credentials(opts = {})
  perform_request_with_object(:patch,
                              '/api/v1/accounts/update_credentials',
                              opts, Mastodon::)
end

#verify_credentialsMastodon::Account

Retrieve account of authenticated user

Returns:



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

def verify_credentials
  perform_request_with_object(:get, '/api/v1/accounts/verify_credentials',
                              {}, Mastodon::)
end