Module: Mastodon::REST::Lists

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

Instance Method Summary collapse

Methods included from Utils

#array_param, #perform_request, #perform_request_with_collection, #perform_request_with_object

Instance Method Details

#add_accounts_to_list(id, account_ids = []) ⇒ Object

Add accounts to a list

Parameters:

  • id (Integer)
  • account_ids (Array<Integer>) (defaults to: [])


65
66
67
# File 'lib/mastodon/rest/lists.rb', line 65

def add_accounts_to_list(id,  = [])
  perform_request(:post, "/api/v1/lists/#{id}/accounts", { 'account_ids[]':  })
end

#create_list(params = {}) ⇒ Mastodon::List

Create a list

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :title (Object)

Returns:



31
32
33
# File 'lib/mastodon/rest/lists.rb', line 31

def create_list(params = {})
  perform_request_with_object(:post, '/api/v1/lists/', params, Mastodon::List)
end

#delete_list(id) ⇒ Object

Delete a list

Parameters:

  • id (Integer)


46
47
48
# File 'lib/mastodon/rest/lists.rb', line 46

def delete_list(id)
  perform_request(:delete, "/api/v1/lists/#{id}")
end

#list(id) ⇒ Mastodon::List

Retrieve a list

Parameters:

  • id (Integer)

Returns:



23
24
25
# File 'lib/mastodon/rest/lists.rb', line 23

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

#list_accounts(id, options = {}) ⇒ Mastodon::Collection<Mastodon::Account>

Get a list of accounts on the list

Parameters:

  • id (Integer)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :max_id (Integer)
  • :since_id (Integer)
  • :min_id (Integer)
  • :limit (Integer)

Returns:



58
59
60
# File 'lib/mastodon/rest/lists.rb', line 58

def list_accounts(id, options = {})
  perform_request_with_collection(:get, "/api/v1/lists/#{id}/accounts", options, Mastodon::Account)
end

#lists(options = {}) ⇒ Mastodon::Collection<Mastodon::List>

Get a list of your lists

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :max_id (Integer)
  • :since_id (Integer)
  • :limit (Integer)

Returns:



16
17
18
# File 'lib/mastodon/rest/lists.rb', line 16

def lists(options = {})
  perform_request_with_collection(:get, '/api/v1/lists', options, Mastodon::List)
end

#remove_accounts_from_list(id, account_ids = []) ⇒ Object

Remove accounts from list

Parameters:

  • id (Integer)
  • account_ids (Array<Integer>) (defaults to: [])


72
73
74
# File 'lib/mastodon/rest/lists.rb', line 72

def remove_accounts_from_list(id,  = [])
  perform_request(:delete, "/api/v1/lists/#{id}/accounts", { 'account_ids[]':  })
end

#update_list(id, params = {}) ⇒ Mastodon::List

Update a list

Parameters:

  • id (Integer)
  • params (Hash) (defaults to: {})

Options Hash (params):

  • :title (Object)

Returns:



40
41
42
# File 'lib/mastodon/rest/lists.rb', line 40

def update_list(id, params = {})
  perform_request_with_object(:put, "/api/v1/lists/#{id}", params, Mastodon::List)
end