Class: Rakuten::Request
- Inherits:
-
Object
- Object
- Rakuten::Request
- Defined in:
- lib/rakuten/request.rb
Constant Summary collapse
- URL =
"http://webservice.rakuten.de/merchants"
- FORMAT =
"json"
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(*args) ⇒ Request
constructor
A new instance of Request.
- #params ⇒ Object
- #post ⇒ Object
- #resource ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(*args) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 |
# File 'lib/rakuten/request.rb', line 11 def initialize *args @params = args. @group, @method, @version = args.map(&:to_s) @method = @method.camelize(:lower) end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
9 10 11 |
# File 'lib/rakuten/request.rb', line 9 def group @group end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/rakuten/request.rb', line 9 def method @method end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
9 10 11 |
# File 'lib/rakuten/request.rb', line 9 def version @version end |
Instance Method Details
#get ⇒ Object
22 23 24 |
# File 'lib/rakuten/request.rb', line 22 def get resource.get params: params end |
#params ⇒ Object
34 35 36 |
# File 'lib/rakuten/request.rb', line 34 def params @params.merge format: FORMAT end |
#post ⇒ Object
26 27 28 |
# File 'lib/rakuten/request.rb', line 26 def post resource.post params end |
#resource ⇒ Object
30 31 32 |
# File 'lib/rakuten/request.rb', line 30 def resource @resource ||= RestClient::Resource.new(url, timeout: -1, open_timeout: 120) end |
#url ⇒ Object
18 19 20 |
# File 'lib/rakuten/request.rb', line 18 def url @url ||= [URL, group, method, version].compact * '/' end |