Include PartnerTag and PartnerType

This commit is contained in:
Dan Milne
2023-06-05 12:48:32 +10:00
parent 2db1d64720
commit b4ffb58592
4 changed files with 11 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ require 'paapi/response'
module Paapi
class Error < StandardError; end
class NotImplemented < StandardError; end
SEARCH_PARAMS = %i[keywords actor, artist, author, brand title].freeze
SEARCH_PARAMS = %i[Keywords Actor Artist Author Brand Title].freeze
DEFAULT_PARTNER_TYPE = 'Associates'
DEFAULT_MARKET = :us
DEFAULT_CONDITION = 'Any'

View File

@@ -37,7 +37,7 @@ module Paapi
end
def get_items(item_ids:, **options)
payload = { ItemIds: Array(item_ids), Resources: @resources }.merge(options)
payload = { PartnerTag: partner_tag, PartnerType: 'Associates', ItemIds: Array(item_ids), Resources: @resources }.merge(options)
request(op: :get_items, payload: payload)
end
@@ -47,12 +47,12 @@ module Paapi
end
# TODO: Currently we assume Keywords, but we need one of the following: [Keywords Actor Artist Author Brand Title ]
def search_items(keywords: nil, **options )
raise ArgumentError("Missing keywords") unless (options.keys | SEARCH_PARAMS).length.positive?
def search_items(**options )
raise ArgumentError.new("Missing keywords") unless (options.keys & SEARCH_PARAMS).length.positive?
search_index = options.dig(:SearchIndex) ||'All'
payload = { Keywords: keywords, Resources: @resources, ItemCount: 10, ItemPage: 1, SearchIndex: search_index }.merge(options)
payload = { PartnerTag: partner_tag, PartnerType: 'Associates', Resources: @resources, ItemCount: 10, ItemPage: 1, SearchIndex: search_index }.merge(options)
request(op: :search_items, payload: payload)
end

View File

@@ -1,3 +1,3 @@
module Paapi
VERSION = '0.1.8'
VERSION = '0.1.9'
end