mirror of
https://github.com/dkam/paapi.git
synced 2025-12-28 15:14:52 +00:00
61 lines
1.7 KiB
Ruby
61 lines
1.7 KiB
Ruby
require 'byebug'
|
|
|
|
module Paapi
|
|
class Request
|
|
include AwsRequest
|
|
attr_accessor :client, :marketplace, :resources, :payload, :service, :partner_type
|
|
attr_reader :partner_tag
|
|
|
|
def initialize(client:, resources: nil)
|
|
@client = client
|
|
@marketplace = client.marketplace
|
|
@partner_tag = client.partner_tag
|
|
@partner_type = 'Associates'
|
|
|
|
@resources = resources || [
|
|
"Images.Primary.Large",
|
|
"ItemInfo.ContentInfo",
|
|
"ItemInfo.ProductInfo",
|
|
"ItemInfo.Title",
|
|
"ItemInfo.ExternalIds",
|
|
"Offers.Listings.Availability.Message",
|
|
"Offers.Listings.Condition",
|
|
"Offers.Listings.Condition.SubCondition",
|
|
"Offers.Listings.DeliveryInfo.IsAmazonFulfilled",
|
|
"Offers.Listings.DeliveryInfo.IsFreeShippingEligible",
|
|
"Offers.Listings.DeliveryInfo.IsPrimeEligible",
|
|
"Offers.Listings.MerchantInfo",
|
|
"Offers.Listings.Price",
|
|
"Offers.Listings.SavingBasis"
|
|
]
|
|
end
|
|
|
|
def get_items(item_ids:, **options)
|
|
item_ids = Array(item_ids)
|
|
|
|
payload = { ItemIds: item_ids, Resources: @resources }
|
|
|
|
do_request(op: :get_items, payload: payload)
|
|
end
|
|
|
|
def get_variations(asin:)
|
|
payload = { ASIN: asin, Resources: @resources }
|
|
|
|
do_request(op: :get_variations, payload: payload)
|
|
end
|
|
|
|
def search_items(keywords:, **options )
|
|
search_index = 'All'
|
|
|
|
# %i[Keywords Actor Artist Author Brand Title ]
|
|
|
|
payload = { Keywords: keywords, Resources: @resources, ItemCount: 10, ItemPage: 1, SearchIndex: search_index }.merge(options)
|
|
|
|
do_request(op: :search_items, payload: payload)
|
|
end
|
|
|
|
def get_browse_nodes
|
|
raise NotImplemented
|
|
end
|
|
end
|
|
end |