mirror of
https://github.com/dkam/paapi.git
synced 2025-12-28 07:04:53 +00:00
Wrap requests in responses. Update response to make the original request available
This commit is contained in:
@@ -14,20 +14,20 @@ module Paapi
|
||||
@partner_type = partner_type
|
||||
end
|
||||
|
||||
def get_items(item_ids: )[]
|
||||
Request.new(client: self).get_items(item_ids: item_ids)
|
||||
def get_items(item_ids:, **options)
|
||||
Response.new(Request.new(client: self).get_items(item_ids: item_ids, **options))
|
||||
end
|
||||
|
||||
def get_variations(asin: )
|
||||
Request.new(client: self).get_variations(asin: asin)
|
||||
def get_variations(asin:, **options )
|
||||
Response.new(Request.new(client: self).get_variations(asin: asin, **options))
|
||||
end
|
||||
|
||||
def search_items(keywords: )
|
||||
Request.new(client: self).search_items(keywords: keywords)
|
||||
def search_items(keywords:, **options )
|
||||
Response.new(Request.new(client: self).search_items(keywords: keywords, **options))
|
||||
end
|
||||
|
||||
def get_browse_nodes
|
||||
Request.new(client: self).get_browse_nodes(keywords: keywords)
|
||||
def get_browse_nodes(keywords:, **options)
|
||||
Response.new(Request.new(client: self).get_browse_nodes(keywords: keywords, **options))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,9 @@ require 'json'
|
||||
|
||||
module Paapi
|
||||
class Response
|
||||
attr_reader :status, :data
|
||||
attr_reader :http_response, :data
|
||||
def initialize(response)
|
||||
@status = response.status.to_s
|
||||
@http_response = response
|
||||
@data = JSON.parse( response.body.to_s )
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user