Module: Mastodon::REST::Utils
- Included in:
- Accounts, Apps, Conversations, CustomEmojis, DomainBlocks, Endorsements, Filters, Instances, Lists, Media, Notifications, Relationships, Reports, ScheduledStatuses, Search, Statuses, Suggestions, Timelines
- Defined in:
- lib/mastodon/rest/utils.rb
Instance Method Summary collapse
-
#array_param(key, values) ⇒ Array
Format an array of values into a query param.
- #perform_request(request_method, path, options = {}) ⇒ Object
- #perform_request_with_collection(request_method, path, options, klass) ⇒ Object
- #perform_request_with_object(request_method, path, options, klass) ⇒ Object
Instance Method Details
#array_param(key, values) ⇒ Array
Format an array of values into a query param
35 36 37 |
# File 'lib/mastodon/rest/utils.rb', line 35 def array_param(key, values) values.map.with_index { |value, i| ["#{key}[]", value] } end |
#perform_request(request_method, path, options = {}) ⇒ Object
9 10 11 |
# File 'lib/mastodon/rest/utils.rb', line 9 def perform_request(request_method, path, = {}) Mastodon::REST::Request.new(self, request_method, path, ).perform end |
#perform_request_with_collection(request_method, path, options, klass) ⇒ Object
26 27 28 29 |
# File 'lib/mastodon/rest/utils.rb', line 26 def perform_request_with_collection(request_method, path, , klass) response = perform_request(request_method, path, ) Mastodon::Collection.new(response, klass) end |
#perform_request_with_object(request_method, path, options, klass) ⇒ Object
17 18 19 20 |
# File 'lib/mastodon/rest/utils.rb', line 17 def perform_request_with_object(request_method, path, , klass) response = perform_request(request_method, path, ) klass.new(response) end |