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
14 changes: 14 additions & 0 deletions lib/muffin_man/fulfillment_inbound/v0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets add some rspecs for this and we are good to merge!

@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
17 changes: 17 additions & 0 deletions spec/muffin_man/fulfillment_inbound/v0_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions spec/support/sp_api_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}&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

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: {})
Expand Down