diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cda0e8..e550ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.5.0 [#102](https://github.com/patterninc/muffin_man/pull/102) + +- Restrictive data token for Vendor Direct Fulfillment Shipping v2021-12-28 createShippingLabels + # 2.4.14 - Fixed query params of Amazon Finances API v2024-06-19 [#98](https://github.com/patterninc/muffin_man/pull/98) diff --git a/lib/muffin_man/sp_api_client.rb b/lib/muffin_man/sp_api_client.rb index 61dbc37..4372ea7 100644 --- a/lib/muffin_man/sp_api_client.rb +++ b/lib/muffin_man/sp_api_client.rb @@ -9,7 +9,7 @@ class SpApiClient attr_reader :refresh_token, :client_id, :client_secret, :sandbox, :config, :region, :request_type, :local_var_path, :query_params, :request_body, :scope, :access_token_cache_key, :credentials, - :pii_data_elements + :pii_data_elements, :requires_rdt ACCESS_TOKEN_URL = "https://api.amazon.com/auth/o2/token".freeze SERVICE_NAME = "execute-api".freeze @@ -31,6 +31,7 @@ def initialize(credentials, sandbox = false) @sandbox = sandbox @credentials = credentials @pii_data_elements = [] + @requires_rdt = false Typhoeus::Config.user_agent = "" @config = MuffinMan.configuration end @@ -132,7 +133,7 @@ def request_grantless_access_token end def headers - if requires_rdt_token_for_pii? + if requires_rdt_token_for_pii? || requires_rdt access_token = retrieve_rdt_access_token || retrieve_lwa_access_token else access_token = scope ? retrieve_grantless_access_token : retrieve_lwa_access_token diff --git a/lib/muffin_man/vendor_direct_fulfillment_shipping/v20211228.rb b/lib/muffin_man/vendor_direct_fulfillment_shipping/v20211228.rb index 58ca38b..5ee80d8 100644 --- a/lib/muffin_man/vendor_direct_fulfillment_shipping/v20211228.rb +++ b/lib/muffin_man/vendor_direct_fulfillment_shipping/v20211228.rb @@ -34,14 +34,15 @@ def get_shipping_label(purchase_order_number) call_api end - def create_shipping_labels(purchase_order_number, selling_party, ship_from_party, containers: nil) + def create_shipping_labels(purchase_order_number, selling_party, ship_from_party, containers) @local_var_path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/#{purchase_order_number}" @request_body = { "sellingParty" => selling_party, - "shipFromParty" => ship_from_party + "shipFromParty" => ship_from_party, + "containers" => containers } - @request_body["containers"] = containers if containers @request_type = "POST" + @requires_rdt = true call_api end diff --git a/lib/muffin_man/version.rb b/lib/muffin_man/version.rb index 3aa95d2..2df6eb4 100644 --- a/lib/muffin_man/version.rb +++ b/lib/muffin_man/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module MuffinMan - VERSION = "2.4.14" + VERSION = "2.5.0" end diff --git a/spec/muffin_man/vendor_direct_fulfillment_shipping/v20211228_spec.rb b/spec/muffin_man/vendor_direct_fulfillment_shipping/v20211228_spec.rb index bc2fc9a..6e7316a 100644 --- a/spec/muffin_man/vendor_direct_fulfillment_shipping/v20211228_spec.rb +++ b/spec/muffin_man/vendor_direct_fulfillment_shipping/v20211228_spec.rb @@ -94,11 +94,13 @@ let(:ship_from_party) { { "partyId" => "ABCD" } } it "executes create_shipping_labels request" do + stub_request_rdt_token stub_vendor_direct_fulfillment_shipping_v20211228_create_shipping_labels response = vendor_direct_fulfillment_shipping_client.create_shipping_labels( purchase_order_number, selling_party, - ship_from_party + ship_from_party, + [] ) expect(response.response_code).to eq(200) expect(JSON.parse(response.body)).to include(