Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lib/muffin_man/sp_api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the containers parameter required is a breaking change. Consider adding a deprecation warning or making it optional with a default empty array to maintain backward compatibility.

Suggested change
def create_shipping_labels(purchase_order_number, selling_party, ship_from_party, containers)
def create_shipping_labels(purchase_order_number, selling_party, ship_from_party, containers = [])

Copilot uses AI. Check for mistakes.
@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

Expand Down
2 changes: 1 addition & 1 deletion lib/muffin_man/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module MuffinMan
VERSION = "2.4.14"
VERSION = "2.5.0"
end
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down