Class: RakutenWebService::Client
- Inherits:
-
Object
- Object
- RakutenWebService::Client
- Defined in:
- lib/rakuten_web_service/client.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #get(params) ⇒ Object
-
#initialize(resource_class) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(resource_class) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/rakuten_web_service/client.rb', line 10 def initialize(resource_class) @resource_class = resource_class @url = URI.parse(@resource_class.endpoint) end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/rakuten_web_service/client.rb', line 8 def url @url end |
Instance Method Details
#get(params) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rakuten_web_service/client.rb', line 15 def get(params) params = RakutenWebService.configuration.generate_parameters(params) response = request(url.path, params) body = JSON.parse(response.body) if Net::HTTPSuccess === response return RakutenWebService::Response.new(@resource_class, body) else raise RakutenWebService::Error.repository[response.code.to_i], body['error_description'] end end |