module Mastodon::REST::Statuses

Public Instance Methods

create_status(text, *args) click to toggle source

@overload create_status(text, in_reply_to_id, media_ids, visibility)

Create new status

@param text [String] @param in_reply_to_id [Integer] @param media_ids [Array<Integer>] @param visibility [String] @return [Mastodon::Status] @overload create_status(text, args)

Create new status

@param text [String] @param options [Hash] @option options :in_reply_to_id [Integer] @option options :media_ids [Array<Integer>] @option options :visibility [String] @return <Mastodon::Status>

# File lib/mastodon/rest/statuses.rb, line 26
def create_status(text, *args)
  params = normalize_status_params(*args)
  params[:status] = text
  params['media_ids[]'] ||= params.delete(:media_ids)

  perform_request_with_object(:post, '/api/v1/statuses',
                              params, Mastodon::Status)
end
destroy_status(id) click to toggle source

Destroy status @param id [Integer] @return [Boolean]

# File lib/mastodon/rest/statuses.rb, line 46
def destroy_status(id)
  !perform_request(:delete, "/api/v1/statuses/#{id}").nil?
end
favourite(id) click to toggle source

Favourite a status @param id [Integer] @return [Mastodon::Status]

# File lib/mastodon/rest/statuses.rb, line 69
def favourite(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/favourite",
                              {}, Mastodon::Status)
end
favourited_by(id, options = {}) click to toggle source

Get a list of accounts that favourited a toot @param id [Integer] @param options [Hash] @return [Mastodon::Collection<Mastodon::Account>]

# File lib/mastodon/rest/statuses.rb, line 97
def favourited_by(id, options = {})
  perform_request_with_collection(:get,
                                  "/api/v1/statuses/#{id}/favourited_by",
                                  options, Mastodon::Account)
end
mute_thread(id) click to toggle source

Mute thread @param id [Integer] @return [Mastodon::Status]

# File lib/mastodon/rest/statuses.rb, line 118
def mute_thread(id)
  perform_request_with_object(:post,
                              "/api/v1/statuses/#{id}/mute",
                              {},
                              Mastodon::Status)
end
reblog(id) click to toggle source

Reblog a status @param id [Integer] @return [Mastodon::Status]

# File lib/mastodon/rest/statuses.rb, line 53
def reblog(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/reblog",
                              {}, Mastodon::Status)
end
reblogged_by(id, options = {}) click to toggle source

Get a list of accounts that reblogged a toot @param id [Integer] @param options [Hash] @return [Mastodon::Collection<Mastodon::Account>]

# File lib/mastodon/rest/statuses.rb, line 87
def reblogged_by(id, options = {})
  perform_request_with_collection(:get,
                                  "/api/v1/statuses/#{id}/reblogged_by",
                                  options, Mastodon::Account)
end
status(id) click to toggle source

Retrieve status @param id [Integer] @return [Mastodon::Status]

# File lib/mastodon/rest/statuses.rb, line 38
def status(id)
  perform_request_with_object(:get, "/api/v1/statuses/#{id}",
                              {}, Mastodon::Status)
end
statuses(account_id, options = {}) click to toggle source

Get a list of statuses by a user @param account_id [Integer] @param options [Hash] @option options :max_id [Integer] @option options :since_id [Integer] @option options :limit [Integer] @return [Mastodon::Collection<Mastodon::Status>]

# File lib/mastodon/rest/statuses.rb, line 110
def statuses(account_id, options = {})
  url = "/api/v1/accounts/#{account_id}/statuses"
  perform_request_with_collection(:get, url, options, Mastodon::Status)
end
unfavourite(id) click to toggle source

Undo a favourite of a status @param id [Integer] @return [Mastodon::Status]

# File lib/mastodon/rest/statuses.rb, line 77
def unfavourite(id)
  perform_request_with_object(:post,
                              "/api/v1/statuses/#{id}/unfavourite",
                              {}, Mastodon::Status)
end
unmute_thread(id) click to toggle source

Unmute thread @param id [Integer] @return [Mastodon::Status]

# File lib/mastodon/rest/statuses.rb, line 128
def unmute_thread(id)
  perform_request_with_object(:post,
                              "/api/v1/statuses/#{id}/unmute",
                              {},
                              Mastodon::Status)
end
unreblog(id) click to toggle source

Undo a reblog of a status @param id [Integer] @return [Mastodon::Status]

# File lib/mastodon/rest/statuses.rb, line 61
def unreblog(id)
  perform_request_with_object(:post, "/api/v1/statuses/#{id}/unreblog",
                              {}, Mastodon::Status)
end

Private Instance Methods

normalize_status_params(*args) click to toggle source
# File lib/mastodon/rest/statuses.rb, line 137
def normalize_status_params(*args)
  if args.length == 1 && args.first.is_a?(Hash)
    args.shift
  else
    {
      in_reply_to_id: args.shift,
      'media_ids[]' => args.shift,
      visibility: args.shift
    }
  end
end