class RakutenWebService::Client
Constants
- USER_AGENT
Attributes
url[R]
Public Class Methods
new(resource_class)
click to toggle source
# File lib/rakuten_web_service/client.rb, line 16 def initialize(resource_class) @resource_class = resource_class @url = URI.parse(@resource_class.endpoint) end
Public Instance Methods
get(params)
click to toggle source
# File lib/rakuten_web_service/client.rb, line 21 def get(params) params = RakutenWebService.configuration.generate_parameters(params) response = request(url.path, params) body = JSON.parse(response.body) unless response.is_a?(Net::HTTPSuccess) raise RakutenWebService::Error.for(response) end RakutenWebService::Response.new(@resource_class, body) end
Private Instance Methods
request(path, params)
click to toggle source
# File lib/rakuten_web_service/client.rb, line 34 def request(path, params) http = Net::HTTP.new(url.host, url.port) http.use_ssl = true if RakutenWebService.configuration.debug_mode? http.set_debug_output($stderr) end path = "#{path}?#{URI.encode_www_form(params)}" header = { 'User-Agent' => USER_AGENT } http.get(path, header) end