From b4ffb585929fe73d4802f46476da5006f8a7c264 Mon Sep 17 00:00:00 2001 From: Dan Milne Date: Mon, 5 Jun 2023 12:48:32 +1000 Subject: [PATCH] Include PartnerTag and PartnerType --- CHANGELOG.md | 6 +++++- lib/paapi.rb | 2 +- lib/paapi/client.rb | 8 ++++---- lib/paapi/version.rb | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46573ed..df7a176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -## 0.1.7 ( Unreleased ) +## 0.1.9 (Unreleased) +- Fix bug allowing non-title case Request Parameters +- Add the required PartnerTag and PartnerType key values to the search body request + +## 0.1.7 - Add gem 'net-http-persistent' for connection persistance - Remove the code which would use other http clients if available ## 0.1.3 diff --git a/lib/paapi.rb b/lib/paapi.rb index 3bbd0e6..3228194 100644 --- a/lib/paapi.rb +++ b/lib/paapi.rb @@ -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' diff --git a/lib/paapi/client.rb b/lib/paapi/client.rb index ebeb8f6..783b175 100644 --- a/lib/paapi/client.rb +++ b/lib/paapi/client.rb @@ -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 diff --git a/lib/paapi/version.rb b/lib/paapi/version.rb index 6eb9671..e542b3c 100644 --- a/lib/paapi/version.rb +++ b/lib/paapi/version.rb @@ -1,3 +1,3 @@ module Paapi - VERSION = '0.1.8' + VERSION = '0.1.9' end