module PixivApi::Request::Util

Public Instance Methods

action_from_response(http_method, path, *opts) click to toggle source
# File lib/pixiv_api/request/util.rb, line 20
def action_from_response(http_method, path, *opts)
  response = request(http_method, path, *opts)
  Response::Action.from_response(response)
end
object_from_response(klass, http_method, path, *opts) click to toggle source
# File lib/pixiv_api/request/util.rb, line 7
def object_from_response(klass, http_method, path, *opts)
  response = request(http_method, path, *opts)
  parsed = response.parsed['response']
  parsed = parsed[0] if parsed.is_a?(Array)

  klass.from_response(response, parsed)
end
objects_from_response(klass, http_method, path, *opts) click to toggle source
# File lib/pixiv_api/request/util.rb, line 15
def objects_from_response(klass, http_method, path, *opts)
  response = request(http_method, path, *opts)
  objects_from_array(response, klass, response.parsed['response'] || [])
end

Private Instance Methods

objects_from_array(response, klass, array) click to toggle source
# File lib/pixiv_api/request/util.rb, line 27
def objects_from_array(response, klass, array)
  ArrayResponse.from_response(response, klass, array)
end
request(http_method, path, *opts) click to toggle source
# File lib/pixiv_api/request/util.rb, line 31
def request(http_method, path, *opts)
  options = opts.extract_options!

  public_send(http_method, path, options.slice(:params, :body))
end