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

Options Hash (params):

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

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


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


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

Options Hash (options):

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

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::)
end

#pin(id) ⇒ Mastodon::Status

Pin status on own profile


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


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

Options Hash (options):

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

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::)
end

#status(id) ⇒ Mastodon::Status

Retrieve status


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

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)

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

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

#unfavourite(id) ⇒ Mastodon::Status

Undo a favourite of a status


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


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


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