Skip to content

Commit 3813fa7

Browse files
authored
Merge pull request #104 from patterninc/get_shipment_items
get_shipment_items
2 parents fe6571f + d21f822 commit 3813fa7

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

lib/muffin_man/fulfillment_inbound/v0.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ def void_transport(shipment_id)
137137
@request_type = "POST"
138138
call_api
139139
end
140+
141+
def get_shipment_items(query_type, marketplace_id, last_updated_after: nil, last_updated_before: nil, next_token: nil)
142+
@local_var_path = "/fba/inbound/v0/shipmentItems"
143+
@query_params = {
144+
"MarketplaceId" => marketplace_id,
145+
"QueryType" => query_type,
146+
}
147+
@query_params["LastUpdatedAfter"] = last_updated_after unless last_updated_after.nil?
148+
@query_params["LastUpdatedBefore"] = last_updated_before unless last_updated_before.nil?
149+
@query_params["NextToken"] = next_token unless next_token.nil?
150+
151+
@request_type = "GET"
152+
call_api
153+
end
140154
end
141155
end
142156
end

spec/muffin_man/fulfillment_inbound/v0_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,21 @@
213213
expect(JSON.parse(response.body).dig("payload", "TransportResult", "TransportStatus")).not_to be_empty
214214
end
215215
end
216+
217+
describe "get_shipment_items" do
218+
before { stub_get_shipment_items }
219+
let(:query_type) { "DATE_RANGE" }
220+
let(:marketplace_id) { "ATVPDKIKX0DER" }
221+
let(:last_updated_after) { "2022-09-30T00:00:00Z" }
222+
let(:last_updated_before) { "2022-10-01T00:00:00Z" }
223+
224+
it "makes a request to get shipment items with all parameters" do
225+
response = fba_inbound_client.get_shipment_items(query_type, marketplace_id,
226+
last_updated_after: last_updated_after,
227+
last_updated_before: last_updated_before)
228+
expect(response.response_code).to eq(200)
229+
expect(JSON.parse(response.body).dig("payload", "ItemData")).not_to be_empty
230+
expect(JSON.parse(response.body).dig("payload", "NextToken")).not_to be_nil
231+
end
232+
end
216233
end

spec/support/sp_api_helpers.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ def stub_get_shipment_items_by_shipment_id
332332
.to_return(status: 200, body: File.read("./spec/support/get_shipment_items_by_shipment_id_v0.json"), headers: {})
333333
end
334334

335+
def stub_get_shipment_items
336+
stub_request(:get, "https://#{hostname}/fba/inbound/v0/shipmentItems?MarketplaceId=#{marketplace_id}&QueryType=#{query_type}&LastUpdatedAfter=#{last_updated_after}&LastUpdatedBefore=#{last_updated_before}")
337+
.to_return(status: 200, body: File.read("./spec/support/get_shipment_items_by_shipment_id_v0.json"), headers: {})
338+
end
339+
335340
def stub_get_item_eligibility_preview
336341
stub_request(:get, "https://#{hostname}/fba/inbound/v1/eligibility/itemPreview?asin=#{asin}&program=#{program}")
337342
.to_return(status: 200, body: {"payload"=>{"asin"=>asin, "program"=>program, "isEligibleForProgram"=>true}}.to_json, headers: {})

0 commit comments

Comments
 (0)