From 6e364c68627baad672d0729bcced89d61eede464 Mon Sep 17 00:00:00 2001 From: Nitin Bhakar Date: Wed, 24 Sep 2025 11:28:32 +0530 Subject: [PATCH 1/4] get_shipment_items --- lib/muffin_man/fulfillment_inbound/v0.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/muffin_man/fulfillment_inbound/v0.rb b/lib/muffin_man/fulfillment_inbound/v0.rb index 930c62a..4e2c3e3 100644 --- a/lib/muffin_man/fulfillment_inbound/v0.rb +++ b/lib/muffin_man/fulfillment_inbound/v0.rb @@ -137,6 +137,20 @@ def void_transport(shipment_id) @request_type = "POST" call_api end + + def get_shipment_items(query_type, marketplace_id, last_updated_after: nil, last_updated_before: nil, next_token: nil) + @local_var_path = "/fba/inbound/v0/shipmentItems" + @query_params = { + "MarketplaceId" => marketplace_id, + "QueryType" => query_type, + } + @query_params["LastUpdatedAfter"] = last_updated_after unless last_updated_after.nil? + @query_params["LastUpdatedBefore"] = last_updated_before unless last_updated_before.nil? + @query_params["NextToken"] = next_token unless next_token.nil? + + @request_type = "GET" + call_api + end end end end From c8c85c4fd513027c526f45c85071db8ff8c85459 Mon Sep 17 00:00:00 2001 From: Nitin Bhakar Date: Wed, 24 Sep 2025 23:05:52 +0530 Subject: [PATCH 2/4] adding spec --- spec/muffin_man/fulfillment_inbound/v0_spec.rb | 17 +++++++++++++++++ spec/support/sp_api_helpers.rb | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/spec/muffin_man/fulfillment_inbound/v0_spec.rb b/spec/muffin_man/fulfillment_inbound/v0_spec.rb index af5b05c..b9f68bd 100644 --- a/spec/muffin_man/fulfillment_inbound/v0_spec.rb +++ b/spec/muffin_man/fulfillment_inbound/v0_spec.rb @@ -213,4 +213,21 @@ expect(JSON.parse(response.body).dig("payload", "TransportResult", "TransportStatus")).not_to be_empty end end + + describe "get_shipment_items" do + before { stub_get_shipment_items } + let(:query_type) { "DATE_RANGE" } + let(:marketplace_id) { "ATVPDKIKX0DER" } + let(:last_updated_after) { "2022-09-30T00:00:00Z" } + let(:last_updated_before) { "2022-10-01T00:00:00Z" } + + it "makes a request to get shipment items with all parameters" do + response = fba_inbound_client.get_shipment_items(query_type, marketplace_id, + last_updated_after: last_updated_after, + last_updated_before: last_updated_before) + expect(response.response_code).to eq(200) + expect(JSON.parse(response.body).dig("payload", "ItemData")).not_to be_empty + expect(JSON.parse(response.body).dig("payload", "NextToken")).not_to be_nil + end + end end diff --git a/spec/support/sp_api_helpers.rb b/spec/support/sp_api_helpers.rb index 3371f8e..c49dc8b 100644 --- a/spec/support/sp_api_helpers.rb +++ b/spec/support/sp_api_helpers.rb @@ -332,6 +332,11 @@ def stub_get_shipment_items_by_shipment_id .to_return(status: 200, body: File.read("./spec/support/get_shipment_items_by_shipment_id_v0.json"), headers: {}) end + def stub_get_shipment_items + stub_request(:get, "https://#{hostname}/fba/inbound/v0/shipmentItems?MarketplaceId=#{marketplace_id}&QueryType=#{query_type}") + .to_return(status: 200, body: File.read("./spec/support/get_shipment_items_by_shipment_id_v0.json"), headers: {}) + end + def stub_get_item_eligibility_preview stub_request(:get, "https://#{hostname}/fba/inbound/v1/eligibility/itemPreview?asin=#{asin}&program=#{program}") .to_return(status: 200, body: {"payload"=>{"asin"=>asin, "program"=>program, "isEligibleForProgram"=>true}}.to_json, headers: {}) From ad11d3e11b4d3f7f59516c5f41cf1f1074f85982 Mon Sep 17 00:00:00 2001 From: Nitin Bhakar Date: Wed, 24 Sep 2025 23:08:30 +0530 Subject: [PATCH 3/4] rspec fix --- spec/support/sp_api_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/sp_api_helpers.rb b/spec/support/sp_api_helpers.rb index c49dc8b..a939217 100644 --- a/spec/support/sp_api_helpers.rb +++ b/spec/support/sp_api_helpers.rb @@ -333,7 +333,7 @@ def stub_get_shipment_items_by_shipment_id end def stub_get_shipment_items - stub_request(:get, "https://#{hostname}/fba/inbound/v0/shipmentItems?MarketplaceId=#{marketplace_id}&QueryType=#{query_type}") + stub_request(:get, "https://#{hostname}/fba/inbound/v0/shipmentItems?MarketplaceId=#{marketplace_id}&QueryType=#{query_type}&LastUpdatedAfter=#{last_updated_after}&LastUpdatedBefore=#{last_updated_before}") .to_return(status: 200, body: File.read("./spec/support/get_shipment_items_by_shipment_id_v0.json"), headers: {}) end From d21f822fd8548e50567b12507980ff9a272b1f40 Mon Sep 17 00:00:00 2001 From: Nitin Bhakar Date: Wed, 24 Sep 2025 23:10:27 +0530 Subject: [PATCH 4/4] rubocop fix --- spec/muffin_man/fulfillment_inbound/v0_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/muffin_man/fulfillment_inbound/v0_spec.rb b/spec/muffin_man/fulfillment_inbound/v0_spec.rb index b9f68bd..ea8aa27 100644 --- a/spec/muffin_man/fulfillment_inbound/v0_spec.rb +++ b/spec/muffin_man/fulfillment_inbound/v0_spec.rb @@ -222,7 +222,7 @@ let(:last_updated_before) { "2022-10-01T00:00:00Z" } it "makes a request to get shipment items with all parameters" do - response = fba_inbound_client.get_shipment_items(query_type, marketplace_id, + response = fba_inbound_client.get_shipment_items(query_type, marketplace_id, last_updated_after: last_updated_after, last_updated_before: last_updated_before) expect(response.response_code).to eq(200)