Skip to content

Commit

Permalink
Merge pull request #77 from patterninc/update-shipment-endpoints
Browse files Browse the repository at this point in the history
Write update endpoints
  • Loading branch information
gavinritchie authored Oct 24, 2024
2 parents 4da2f30 + c1e9b2b commit 7c48b9d
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 1 deletion.
28 changes: 28 additions & 0 deletions lib/muffin_man/fulfillment_inbound/v20240320.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,34 @@ def set_prep_details(body) # rubocop:disable Naming/AccessorMethodName
@request_type = "POST"
call_api
end

def generate_shipment_content_update_previews(inbound_plan_id, shipment_id, body)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/contentUpdatePreviews" # rubocop:disable Layout/LineLength
@request_body = body
@request_type = "POST"
call_api
end

def get_shipment_content_update_preview(inbound_plan_id, shipment_id, content_update_preview_id)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/contentUpdatePreviews/#{content_update_preview_id}" # rubocop:disable Layout/LineLength
@request_type = "GET"
call_api
end

def confirm_shipment_content_update_preview(inbound_plan_id, shipment_id, content_update_preview_id)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/contentUpdatePreviews/#{content_update_preview_id}/confirmation" # rubocop:disable Layout/LineLength
@request_type = "POST"
call_api
end

def list_shipment_content_update_previews(inbound_plan_id, shipment_id, page_size: nil, pagination_token: nil)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/contentUpdatePreviews" # rubocop:disable Layout/LineLength
@query_params = {}
@query_params["pageSize"] = page_size if page_size
@query_params["paginationToken"] = pagination_token if pagination_token
@request_type = "GET"
call_api
end
end
end
end
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.2"
VERSION = "2.4.3"
end
79 changes: 79 additions & 0 deletions spec/muffin_man/fulfillment_inbound/v20240320_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,83 @@
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "generate_shipment_content_update_previews" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:shipment_id) { "sh150f31d2-f3c0-4364-bf0a-63ee9c7ce99f" }
let(:body) do
{
boxes: [
{
boxId: "box1",
items: [
{
msku: "Sunglasses",
quantity: 5
}
]
}
]
}
end

before do
stub_generate_shipment_content_update_previews
end

it "generates shipment content update previews" do
response = fba_inbound_client.generate_shipment_content_update_previews(inbound_plan_id, shipment_id, body)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "get_shipment_content_update_preview" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:shipment_id) { "sh150f31d2-f3c0-4364-bf0a-63ee9c7ce99f" }
let(:content_update_preview_id) { "preview123" }

before do
stub_get_shipment_content_update_preview
end

it "gets shipment content update preview" do
response = fba_inbound_client.get_shipment_content_update_preview(inbound_plan_id, shipment_id,
content_update_preview_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["contentUpdatePreviewId"]).to eq(content_update_preview_id)
end
end

describe "confirm_shipment_content_update_preview" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:shipment_id) { "sh150f31d2-f3c0-4364-bf0a-63ee9c7ce99f" }
let(:content_update_preview_id) { "preview123" }

before do
stub_confirm_shipment_content_update_preview
end

it "confirms shipment content update preview" do
response = fba_inbound_client.confirm_shipment_content_update_preview(inbound_plan_id, shipment_id,
content_update_preview_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "list_shipment_content_update_previews" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:shipment_id) { "sh150f31d2-f3c0-4364-bf0a-63ee9c7ce99f" }

before do
stub_list_shipment_content_update_previews
end

it "lists shipment content update previews" do
response = fba_inbound_client.list_shipment_content_update_previews(inbound_plan_id, shipment_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["contentUpdatePreviews"]).to be_an(Array)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"operationId": "op0987654321"
}
36 changes: 36 additions & 0 deletions spec/support/fulfillment_inbound/fulfillment_inbound_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,42 @@ def stub_set_prep_details(prep_details)
headers: {}
)
end

def stub_generate_shipment_content_update_previews
stub_request(:post, "https://#{hostname}/inbound/fba/2024-03-20/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/contentUpdatePreviews")
.to_return(
status: 200,
body: File.read("./spec/support/fulfillment_inbound/generate_shipment_content_update_previews.json"),
headers: {}
)
end

def stub_get_shipment_content_update_preview
stub_request(:get, "https://#{hostname}/inbound/fba/2024-03-20/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/contentUpdatePreviews/#{content_update_preview_id}")
.to_return(
status: 200,
body: File.read("./spec/support/fulfillment_inbound/get_shipment_content_update_preview.json"),
headers: {}
)
end

def stub_confirm_shipment_content_update_preview
stub_request(:post, "https://#{hostname}/inbound/fba/2024-03-20/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/contentUpdatePreviews/#{content_update_preview_id}/confirmation")
.to_return(
status: 200,
body: File.read("./spec/support/fulfillment_inbound/confirm_shipment_content_update_preview.json"),
headers: {}
)
end

def stub_list_shipment_content_update_previews
stub_request(:get, "https://#{hostname}/inbound/fba/2024-03-20/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/contentUpdatePreviews")
.to_return(
status: 200,
body: File.read("./spec/support/fulfillment_inbound/list_shipment_content_update_previews.json"),
headers: {}
)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"operationId": "op1234567890"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"contentUpdatePreviewId": "preview123",
"expiration": "2019-08-24T14:15:22Z",
"transportationOption": {
"shipmentId": "string",
"transportationOptionId": "string",
"shippingSolution": "AMAZON_PARTNERED_CARRIER",
"carrier": {
"name": "string",
"alphaCode": "string"
},
"shippingMode": "GROUND_SMALL_PARCEL",
"quote": {
"cost": {
"code": "str",
"amount": 0
},
"voidableUntil": "2019-08-24T14:15:22Z",
"expiration": "2019-08-24T14:15:22Z"
},
"carrierAppointment": {
"startTime": "2019-08-24T14:15:22Z",
"endTime": "2019-08-24T14:15:22Z"
},
"preconditions": [
"string"
]
},
"requestedUpdates": {
"boxes": [
{
"weight": {
"unit": "LB",
"value": 0
},
"dimensions": {
"unitOfMeasurement": "IN",
"length": 0,
"width": 0,
"height": 0
},
"quantity": 1,
"packageId": "string",
"items": [
{
"msku": "Sunglasses",
"prepOwner": "AMAZON",
"labelOwner": "AMAZON",
"quantity": 1,
"expiration": "2019-08-24T14:15:22Z",
"manufacturingLotCode": "manufacturingLotCode"
}
],
"contentInformationSource": "BOX_CONTENT_PROVIDED"
}
],
"items": [
{
"msku": "Sunglasses",
"prepOwner": "AMAZON",
"labelOwner": "AMAZON",
"quantity": 1,
"expiration": "2019-08-24T14:15:22Z",
"manufacturingLotCode": "manufacturingLotCode"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"pagination": {
"nextToken": "string"
},
"contentUpdatePreviews": [
{
"contentUpdatePreviewId": "string",
"expiration": "2019-08-24T14:15:22Z",
"transportationOption": {
"shipmentId": "string",
"transportationOptionId": "string",
"shippingSolution": "AMAZON_PARTNERED_CARRIER",
"carrier": {
"name": "string",
"alphaCode": "string"
},
"shippingMode": "GROUND_SMALL_PARCEL",
"quote": {
"cost": {
"code": "str",
"amount": 0
},
"voidableUntil": "2019-08-24T14:15:22Z",
"expiration": "2019-08-24T14:15:22Z"
},
"carrierAppointment": {
"startTime": "2019-08-24T14:15:22Z",
"endTime": "2019-08-24T14:15:22Z"
},
"preconditions": [
"string"
]
},
"requestedUpdates": {
"boxes": [
{
"weight": {
"unit": "LB",
"value": 0
},
"dimensions": {
"unitOfMeasurement": "IN",
"length": 0,
"width": 0,
"height": 0
},
"quantity": 1,
"packageId": "string",
"items": [
{
"msku": "Sunglasses",
"prepOwner": "AMAZON",
"labelOwner": "AMAZON",
"quantity": 1,
"expiration": "2019-08-24T14:15:22Z",
"manufacturingLotCode": "manufacturingLotCode"
}
],
"contentInformationSource": "BOX_CONTENT_PROVIDED"
}
],
"items": [
{
"msku": "Sunglasses",
"prepOwner": "AMAZON",
"labelOwner": "AMAZON",
"quantity": 1,
"expiration": "2019-08-24T14:15:22Z",
"manufacturingLotCode": "manufacturingLotCode"
}
]
}
}
]
}

0 comments on commit 7c48b9d

Please sign in to comment.