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, in_reply_to_id, media_ids, visibility) ⇒ Mastodon::Status #create_status(text, args) ⇒ Mastodon::Status

Overloads:

  • #create_status(text, in_reply_to_id, media_ids, visibility) ⇒ Mastodon::Status

    Create new status

  • #create_status(text, args) ⇒ Mastodon::Status

    Create new status

Parameters:

  • text (String)
  • in_reply_to_id (Integer)
  • media_ids (Array<Integer>)
  • visibility (String)
  • text (String)
  • options (Hash)

Returns:



26
27
28
29
30
31
32
33
# 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) ⇒ Boolean

Destroy status

Parameters:

  • id (Integer)

Returns:

  • (Boolean)


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

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

#favourite(id) ⇒ Mastodon::Status

Favourite a status

Parameters:

  • id (Integer)

Returns:



69
70
71
72
# 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 = {}) ⇒ Mastodon::Collection<Mastodon::Account>

Get a list of accounts that favourited a toot

Parameters:

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

Returns:



97
98
99
100
101
# 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) ⇒ Mastodon::Status

Mute thread

Parameters:

  • id (Integer)

Returns:



118
119
120
121
122
123
# 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) ⇒ Mastodon::Status

Reblog a status

Parameters:

  • id (Integer)

Returns:



53
54
55
56
# 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 = {}) ⇒ Mastodon::Collection<Mastodon::Account>

Get a list of accounts that reblogged a toot

Parameters:

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

Returns:



87
88
89
90
91
# 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) ⇒ Mastodon::Status

Retrieve status

Parameters:

  • id (Integer)

Returns:



38
39
40
41
# 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 = {}) ⇒ 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)
  • :limit (Integer)

Returns:



110
111
112
113
# File 'lib/mastodon/rest/statuses.rb', line 110

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

#unfavourite(id) ⇒ Mastodon::Status

Undo a favourite of a status

Parameters:

  • id (Integer)

Returns:



77
78
79
80
81
# 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) ⇒ Mastodon::Status

Unmute thread

Parameters:

  • id (Integer)

Returns:



128
129
130
131
132
133
# 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) ⇒ Mastodon::Status

Undo a reblog of a status

Parameters:

  • id (Integer)

Returns:



61
62
63
64
# File 'lib/mastodon/rest/statuses.rb', line 61

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