Skip to content

Commit

Permalink
Merge pull request #78 from patterninc/more-fba-inbound
Browse files Browse the repository at this point in the history
Never trust AI to write all the endpoints you need
  • Loading branch information
gavinritchie authored Oct 25, 2024
2 parents 7c48b9d + 17e5362 commit 9658193
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.4.4 [#73](https://github.com/patterninc/muffin_man/pull/73)

- Support for more Fulfillment Inbound API v2024-03-30 endpoints
# 2.4.1 [#73](https://github.com/patterninc/muffin_man/pull/73)

- Support for Listings Restrictions API v2021-08-01
Expand Down
12 changes: 12 additions & 0 deletions lib/muffin_man/fulfillment_inbound/v20240320.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ def list_placement_options(inbound_plan_id, page_size: nil, pagination_token: ni
call_api
end

def confirm_placement_option(inbound_plan_id, placement_option_id)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/placementOptions/#{placement_option_id}/confirmation" # rubocop:disable Layout/LineLength
@request_type = "POST"
call_api
end

def cancel_inbound_plan(inbound_plan_id)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/cancellation"
@request_type = "POST"
call_api
end

def get_inbound_operation_status(operation_id)
@local_var_path = "#{INBOUND_PATH}/operations/#{operation_id}"
@request_type = "GET"
Expand Down
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.3"
VERSION = "2.4.4"
end
30 changes: 30 additions & 0 deletions spec/muffin_man/fulfillment_inbound/v20240320_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,34 @@
expect(JSON.parse(response.body)["contentUpdatePreviews"]).to be_an(Array)
end
end

describe "confirm_placement_option" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:placement_option_id) { "placementOption123" }

before do
stub_confirm_placement_option
end

it "confirms placement option" do
response = fba_inbound_client.confirm_placement_option(inbound_plan_id, placement_option_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "cancel_inbound_plan" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:placement_option_id) { "placementOption123" }

before do
stub_confirm_placement_option
end

it "cancels the inbound plan" do
response = fba_inbound_client.confirm_placement_option(inbound_plan_id, placement_option_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end
end
18 changes: 18 additions & 0 deletions spec/support/fulfillment_inbound/fulfillment_inbound_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,24 @@ def stub_list_shipment_content_update_previews
headers: {}
)
end

def stub_confirm_placement_option
stub_request(:post, "https://#{hostname}/inbound/fba/2024-03-20/inboundPlans/#{inbound_plan_id}/placementOptions/#{placement_option_id}/confirmation")
.to_return(
status: 202,
body: File.read("./spec/support/fulfillment_inbound/operation_response.json"),
headers: {}
)
end

def stub_cancel_inbound_plan
stub_request(:put, "https://#{hostname}/inbound/fba/2024-03-20/inboundPlans/#{inbound_plan_id}/cancellation")
.to_return(
status: 202,
body: File.read("./spec/support/fulfillment_inbound/operation_response.json"),
headers: {}
)
end
end
end
end

0 comments on commit 9658193

Please sign in to comment.