Sha256: 4cd9dd55d84835c2f04ed50d3e8f34cc7943725b473c98701b292071183375e4
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require 'uri' require 'net/http' require 'cgi' require 'json' require 'rakuten_web_service/response' require 'rakuten_web_service/error' module RakutenWebService class Client USER_AGENT = "RakutenWebService SDK for Ruby v#{RWS::VERSION}(ruby-#{RUBY_VERSION} [#{RUBY_PLATFORM}])".freeze attr_reader :url def initialize(resource_class) @resource_class = resource_class @url = URI.parse(@resource_class.endpoint) end 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 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rakuten_web_service-1.13.2 | lib/rakuten_web_service/client.rb |
rakuten_web_service-1.13.1 | lib/rakuten_web_service/client.rb |
rakuten_web_service-1.13.0 | lib/rakuten_web_service/client.rb |