Wrap requests in responses. Update response to make the original request available

This commit is contained in:
Dan Milne
2019-09-09 11:29:44 +10:00
parent 9d14bd8567
commit 5d5a135e54
2 changed files with 10 additions and 10 deletions

View File

@@ -14,20 +14,20 @@ module Paapi
@partner_type = partner_type @partner_type = partner_type
end end
def get_items(item_ids: )[] def get_items(item_ids:, **options)
Request.new(client: self).get_items(item_ids: item_ids) Response.new(Request.new(client: self).get_items(item_ids: item_ids, **options))
end end
def get_variations(asin: ) def get_variations(asin:, **options )
Request.new(client: self).get_variations(asin: asin) Response.new(Request.new(client: self).get_variations(asin: asin, **options))
end end
def search_items(keywords: ) def search_items(keywords:, **options )
Request.new(client: self).search_items(keywords: keywords) Response.new(Request.new(client: self).search_items(keywords: keywords, **options))
end end
def get_browse_nodes def get_browse_nodes(keywords:, **options)
Request.new(client: self).get_browse_nodes(keywords: keywords) Response.new(Request.new(client: self).get_browse_nodes(keywords: keywords, **options))
end end
end end
end end

View File

@@ -2,9 +2,9 @@ require 'json'
module Paapi module Paapi
class Response class Response
attr_reader :status, :data attr_reader :http_response, :data
def initialize(response) def initialize(response)
@status = response.status.to_s @http_response = response
@data = JSON.parse( response.body.to_s ) @data = JSON.parse( response.body.to_s )
end end
end end