Skip to content

Commit fe6571f

Browse files
rdt-for-vdf (#102)
* rdt-for-vdf * rdt-for-vdf * rdt-for-vdf * rdt-for-vdf * rdt-for-vdf * rdt-for-vdf * rdt-for-vdf
1 parent 8b5753f commit fe6571f

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.5.0 [#102](https://github.com/patterninc/muffin_man/pull/102)
2+
3+
- Restrictive data token for Vendor Direct Fulfillment Shipping v2021-12-28 createShippingLabels
4+
15
# 2.4.14
26

37
- Fixed query params of Amazon Finances API v2024-06-19 [#98](https://github.com/patterninc/muffin_man/pull/98)

lib/muffin_man/sp_api_client.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SpApiClient
99
attr_reader :refresh_token, :client_id, :client_secret, :sandbox, :config,
1010
:region, :request_type, :local_var_path, :query_params,
1111
:request_body, :scope, :access_token_cache_key, :credentials,
12-
:pii_data_elements
12+
:pii_data_elements, :requires_rdt
1313

1414
ACCESS_TOKEN_URL = "https://api.amazon.com/auth/o2/token".freeze
1515
SERVICE_NAME = "execute-api".freeze
@@ -31,6 +31,7 @@ def initialize(credentials, sandbox = false)
3131
@sandbox = sandbox
3232
@credentials = credentials
3333
@pii_data_elements = []
34+
@requires_rdt = false
3435
Typhoeus::Config.user_agent = ""
3536
@config = MuffinMan.configuration
3637
end
@@ -132,7 +133,7 @@ def request_grantless_access_token
132133
end
133134

134135
def headers
135-
if requires_rdt_token_for_pii?
136+
if requires_rdt_token_for_pii? || requires_rdt
136137
access_token = retrieve_rdt_access_token || retrieve_lwa_access_token
137138
else
138139
access_token = scope ? retrieve_grantless_access_token : retrieve_lwa_access_token

lib/muffin_man/vendor_direct_fulfillment_shipping/v20211228.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ def get_shipping_label(purchase_order_number)
3434
call_api
3535
end
3636

37-
def create_shipping_labels(purchase_order_number, selling_party, ship_from_party, containers: nil)
37+
def create_shipping_labels(purchase_order_number, selling_party, ship_from_party, containers)
3838
@local_var_path = "/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/#{purchase_order_number}"
3939
@request_body = {
4040
"sellingParty" => selling_party,
41-
"shipFromParty" => ship_from_party
41+
"shipFromParty" => ship_from_party,
42+
"containers" => containers
4243
}
43-
@request_body["containers"] = containers if containers
4444
@request_type = "POST"
45+
@requires_rdt = true
4546
call_api
4647
end
4748

lib/muffin_man/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module MuffinMan
4-
VERSION = "2.4.14"
4+
VERSION = "2.5.0"
55
end

spec/muffin_man/vendor_direct_fulfillment_shipping/v20211228_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@
9494
let(:ship_from_party) { { "partyId" => "ABCD" } }
9595

9696
it "executes create_shipping_labels request" do
97+
stub_request_rdt_token
9798
stub_vendor_direct_fulfillment_shipping_v20211228_create_shipping_labels
9899
response = vendor_direct_fulfillment_shipping_client.create_shipping_labels(
99100
purchase_order_number,
100101
selling_party,
101-
ship_from_party
102+
ship_from_party,
103+
[]
102104
)
103105
expect(response.response_code).to eq(200)
104106
expect(JSON.parse(response.body)).to include(

0 commit comments

Comments
 (0)