Module: Mastodon::REST::Utils

Included in:
Accounts, Apps, Instances, Media, Notifications, Relationships, Search, Statuses, Suggestions, Timelines
Defined in:
lib/mastodon/rest/utils.rb

Instance Method Summary collapse

Instance Method Details

#array_param(key, values) ⇒ Array

Format an array of values into a query param



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

def array_param(key, values)
  values.map.with_index { |value, _i| ["#{key}[]", value] }
end

#perform_request(request_method, path, options = {}) ⇒ Object



11
12
13
# File 'lib/mastodon/rest/utils.rb', line 11

def perform_request(request_method, path, options = {})
  Mastodon::REST::Request.new(self, request_method, path, options).perform
end

#perform_request_with_collection(request_method, path, options, klass) ⇒ Object



28
29
30
31
# File 'lib/mastodon/rest/utils.rb', line 28

def perform_request_with_collection(request_method, path, options, klass)
  response = perform_request(request_method, path, options)
  Mastodon::Collection.new(response, klass)
end

#perform_request_with_object(request_method, path, options, klass) ⇒ Object



19
20
21
22
# File 'lib/mastodon/rest/utils.rb', line 19

def perform_request_with_object(request_method, path, options, klass)
  response = perform_request(request_method, path, options)
  klass.new(response)
end