Module: Mastodon::REST::Statuses

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

Instance Method Summary collapse

Methods included from Utils

#array_param, #perform_request, #perform_request_with_collection, #perform_request_with_object

Instance Method Details

#create_status(text, params = {}) ⇒ Mastodon::Status

Create new status

Parameters:

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

Options Hash (params):

  • :in_reply_to_id (Integer)
  • :media_ids (Array<Integer>)
  • :visibility (String)
  • :language (String)
  • :sensitive (Boolean)
  • :spoiler_text (String)
  • :scheduled_at (String)

Returns:



20
21
22
23
24
25
# File 'lib/mastodon/rest/statuses.rb', line 20

def create_status(text, params = {})
  params[:status]        = text
  params[:'media_ids[]'] = params.delete(:media_ids) if params.key?(:media_ids)

  perform_request_with_object(:post, '/api/v1/statuses', params, Mastodon::Status)
end

#destroy_status(id) ⇒ Boolean

Destroy status

Parameters:

  • id (Integer)

Returns:

  • (Boolean)


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

def destroy_status(id)
  !perform_request(:delete, "/api/v1/statuses/#{id}").nil?
end

#favourite(id) ⇒ Mastodon::Status

Favourite a status

Parameters:

  • id (Integer)

Returns:



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

def favourite(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/favourite", {}, Mastodon::Status)
end

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

Get a list of accounts that favourited a toot

Parameters:

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

Options Hash (options):

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

Returns:



89
90
91
# File 'lib/mastodon/rest/statuses.rb', line 89

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

#pin(id) ⇒ Mastodon::Status

Pin status on own profile

Parameters:

  • id (Integer)

Returns:



96
97
98
# File 'lib/mastodon/rest/statuses.rb', line 96

def pin(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/pin", {}, Mastodon::Status)
end

#reblog(id) ⇒ Mastodon::Status

Reblog a status

Parameters:

  • id (Integer)

Returns:



44
45
46
# File 'lib/mastodon/rest/statuses.rb', line 44

def reblog(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/reblog", {}, Mastodon::Status)
end

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

Get a list of accounts that reblogged a toot

Parameters:

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

Options Hash (options):

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

Returns:



77
78
79
# File 'lib/mastodon/rest/statuses.rb', line 77

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

#status(id) ⇒ Mastodon::Status

Retrieve status

Parameters:

  • id (Integer)

Returns:



30
31
32
# File 'lib/mastodon/rest/statuses.rb', line 30

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

#statuses(account_id, options = {}) ⇒ Mastodon::Collection<Mastodon::Status>

Get a list of statuses by a user

Parameters:

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

Options Hash (options):

  • :max_id (Integer)
  • :since_id (Integer)
  • :min_id (Integer)
  • :limit (Integer)
  • :only_media (Boolean)
  • :pinned (Boolean)
  • :exclude_replies (Boolean)
  • :exclude_reblogs (Boolean)

Returns:



119
120
121
# File 'lib/mastodon/rest/statuses.rb', line 119

def statuses(, options = {})
  perform_request_with_collection(:get, "/api/v1/accounts/#{}/statuses", options, Mastodon::Status)
end

#unfavourite(id) ⇒ Mastodon::Status

Undo a favourite of a status

Parameters:

  • id (Integer)

Returns:



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

def unfavourite(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/unfavourite", {}, Mastodon::Status)
end

#unpin(id) ⇒ Mastodon::Status

Unpin status from own profile

Parameters:

  • id (Integer)

Returns:



103
104
105
# File 'lib/mastodon/rest/statuses.rb', line 103

def unpin(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/unpin", {}, Mastodon::Status)
end

#unreblog(id) ⇒ Mastodon::Status

Undo a reblog of a status

Parameters:

  • id (Integer)

Returns:



51
52
53
# File 'lib/mastodon/rest/statuses.rb', line 51

def unreblog(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/unreblog", {}, Mastodon::Status)
end