module Instapaper::HTTP::Utils
Private Instance Methods
coerce_hash(response)
click to toggle source
# File lib/instapaper/http/utils.rb, line 59 def coerce_hash(response) if response.key?('hash') response['instapaper_hash'] = response.delete('hash') end if response.key?('bookmarks') response['bookmarks'] = response['bookmarks'].collect do |bookmark| coerce_hash(bookmark) end end response end
perform_get_with_objects(path, options, klass)
click to toggle source
@param path [String] @param options [Hash] @param klass [Class]
# File lib/instapaper/http/utils.rb, line 18 def perform_get_with_objects(path, options, klass) perform_request_with_objects(:get, path, options, klass) end
perform_post_with_object(path, options, klass)
click to toggle source
@param path [String] @param options [Hash] @param klass [Class]
# File lib/instapaper/http/utils.rb, line 35 def perform_post_with_object(path, options, klass) perform_request_with_object(:post, path, options, klass) end
perform_post_with_objects(path, options, klass)
click to toggle source
@param path [String] @param options [Hash] @param klass [Class]
# File lib/instapaper/http/utils.rb, line 11 def perform_post_with_objects(path, options, klass) perform_request_with_objects(:post, path, options, klass) end
perform_post_with_unparsed_response(path, options)
click to toggle source
@param path [String] @param options [Hash]
# File lib/instapaper/http/utils.rb, line 51 def perform_post_with_unparsed_response(path, options) perform_request(:post, path, options.merge(raw: true)) end
perform_request(method, path, options)
click to toggle source
# File lib/instapaper/http/utils.rb, line 55 def perform_request(method, path, options) Instapaper::HTTP::Request.new(self, method, path, options).perform end
perform_request_with_object(request_method, path, options, klass)
click to toggle source
@param request_method [Symbol] @param path [String] @param options [Hash] @param klass [Class]
# File lib/instapaper/http/utils.rb, line 43 def perform_request_with_object(request_method, path, options, klass) response = perform_request(request_method, path, options) response = response.is_a?(Array) ? response.first : response klass.new(coerce_hash(response)) end
perform_request_with_objects(request_method, path, options, klass)
click to toggle source
@param request_method [Symbol] @param path [String] @param options [Hash] @param klass [Class]
# File lib/instapaper/http/utils.rb, line 26 def perform_request_with_objects(request_method, path, options, klass) perform_request(request_method, path, options).collect do |element| klass.new(coerce_hash(element)) end end