Sha256: 93f1ccc13d768417df2b05f63fcff01b19ec262e2b2f42d5164991127a20c3c5
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'typhoeus' module Youku module V2 class Request attr_reader :url, :params, :response # Public: Constructor. # # url - The String url. # params - The Hash query params. def initialize(url, params) @url = url @params = params @response = Typhoeus::Request.new(url, params: params, connecttimeout: 5, timeout: 10).run end # Public: Get next page. # # Returns the instance of Youku::V2::Request. def next_page Request.new url, params.merge(page: params[:page] + 1) end # Returns true at successful request , false otherwise. def ok? response.code == 200 end # Public: Get response code. # # Returns Integer code of response. def code response.code end # Public: Get return code. # # Returns Integer return code. def return_code response.return_code end # Public: Get body. # # Returns the instance of Hashie::Mash. def body @body ||= Hashie::Mash.new(MultiJson.load response.body || '') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
youku_client-0.0.1 | lib/youku/v2/request.rb |