Class: EBayEnterpriseAffiliateNetwork::APIResponse
- Inherits:
-
Object
- Object
- EBayEnterpriseAffiliateNetwork::APIResponse
- Defined in:
- lib/ebay_enterprise_affiliate_network/api_response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(response) ⇒ APIResponse
constructor
A new instance of APIResponse.
Constructor Details
#initialize(response) ⇒ APIResponse
Returns a new instance of APIResponse.
5 6 7 8 9 10 |
# File 'lib/ebay_enterprise_affiliate_network/api_response.rb', line 5 def initialize(response) @request = response.request body = JSON.parse(response.body) @meta = RecursiveOpenStruct.new(body["meta"]) @data = parse(body["data"]) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/ebay_enterprise_affiliate_network/api_response.rb', line 3 def data @data end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
3 4 5 |
# File 'lib/ebay_enterprise_affiliate_network/api_response.rb', line 3 def @meta end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
3 4 5 |
# File 'lib/ebay_enterprise_affiliate_network/api_response.rb', line 3 def request @request end |
Instance Method Details
#all ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/ebay_enterprise_affiliate_network/api_response.rb', line 12 def all while .pagination.next uri = Addressable::URI.parse(.pagination.next.href) next_page_response = EBayEnterpriseAffiliateNetwork::Publisher.new.request(uri.origin + uri.path, uri.query_values) @meta = next_page_response. @data += next_page_response.data end @data end |