Class: Ebay::Finding::Api::Response
- Inherits:
-
Object
- Object
- Ebay::Finding::Api::Response
- Defined in:
- lib/ebay/finding/api/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(key_name, response) ⇒ Response
constructor
A new instance of Response.
- #items ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(key_name, response) ⇒ Response
Returns a new instance of Response.
5 6 7 8 |
# File 'lib/ebay/finding/api/response.rb', line 5 def initialize(key_name, response) @key_name = key_name @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/ebay/finding/api/response.rb', line 3 def response @response end |
Instance Method Details
#items ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/ebay/finding/api/response.rb', line 10 def items return [] unless success? result = JSON.parse(@response.body)["#{@key_name}Response"].first["searchResult"].first return [] if result["@count"] === "0" @items ||= result["item"] end |
#success? ⇒ Boolean
20 21 22 |
# File 'lib/ebay/finding/api/response.rb', line 20 def success? @response.success? end |