Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fba inbound remainder #76

Merged
merged 3 commits into from
Oct 23, 2024
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
99 changes: 99 additions & 0 deletions lib/muffin_man/fulfillment_inbound/v20240320.rb
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to update the Muffin Man version?

Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,105 @@ def get_inbound_operation_status(operation_id)
@request_type = "GET"
call_api
end

def list_shipment_pallets(inbound_plan_id, shipment_id, page_size: nil, pagination_token: nil)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/pallets"
@query_params = {}
@query_params["pageSize"] = page_size if page_size
@query_params["paginationToken"] = pagination_token if pagination_token
@request_type = "GET"
call_api
end

def get_self_ship_appointment_slots(inbound_plan_id, shipment_id, page_size: nil, pagination_token: nil)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/shipments/#{shipment_id}/selfShipAppointmentSlots" # 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

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

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

def list_transportation_options(inbound_plan_id, page_size: nil, pagination_token: nil, placement_option_id: nil,
shipment_id: nil)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/transportationOptions"
@query_params = {}
@query_params["pageSize"] = page_size if page_size
@query_params["paginationToken"] = pagination_token if pagination_token
@query_params["placementOptionId"] = placement_option_id if placement_option_id
@query_params["shipmentId"] = shipment_id if shipment_id
@request_type = "GET"
call_api
end

def generate_transportation_options(inbound_plan_id, body)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/transportationOptions"
@request_body = body
@request_type = "POST"
call_api
end

def confirm_transportation_options(inbound_plan_id, body)
@local_var_path = "#{INBOUND_PATH}/inboundPlans/#{inbound_plan_id}/transportationOptions/confirmation"
@request_body = body
@request_type = "POST"
call_api
end

def list_item_compliance_details(mskus, marketplace_id)
@local_var_path = "#{INBOUND_PATH}/items/compliance"
@query_params = {}
@query_params["mskus"] = mskus
@query_params["marketplaceId"] = marketplace_id
@request_type = "GET"
call_api
end

def update_item_compliance_details(marketplace_id, body)
@local_var_path = "#{INBOUND_PATH}/items/compliance"
@query_params = {}
@query_params["marketplaceId"] = marketplace_id
@request_body = body
@request_type = "PUT"
call_api
end

def create_marketplace_item_labels(body)
@local_var_path = "#{INBOUND_PATH}/items/labels"
@request_body = body
@request_type = "POST"
call_api
end

def list_prep_details(marketplace_id, mskus)
@local_var_path = "#{INBOUND_PATH}/items/prepDetails"
@query_params = {}
@query_params["marketplaceId"] = marketplace_id
@query_params["mskus"] = mskus
@request_type = "GET"
call_api
end

def set_prep_details(body) # rubocop:disable Naming/AccessorMethodName
@local_var_path = "#{INBOUND_PATH}/items/prepDetails"
@request_body = body
@request_type = "POST"
call_api
end
end
end
end
2 changes: 2 additions & 0 deletions lib/muffin_man/listings_restrictions/v20210801.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module MuffinMan
module ListingsRestrictions
class V20210801 < SpApiClient
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.1"
VERSION = "2.4.2"
end
209 changes: 209 additions & 0 deletions spec/muffin_man/fulfillment_inbound/v20240320_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
RSpec.describe MuffinMan::FulfillmentInbound::V20240320 do
subject(:fba_inbound_client) { described_class.new(credentials) }

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

before do
stub_request_access_token
end
Expand Down Expand Up @@ -273,4 +276,210 @@
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "list_shipment_pallets" do
before do
stub_list_shipment_pallets
end

it "lists shipment pallets" do
response = fba_inbound_client.list_shipment_pallets(inbound_plan_id, shipment_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["pallets"]).to be_an(Array)
end
end

describe "get_self_ship_appointment_slots" do
before do
stub_get_self_ship_appointment_slots
end

it "gets self-ship appointment slots" do
response = fba_inbound_client.get_self_ship_appointment_slots(inbound_plan_id, shipment_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["slots"]).to be_an(Array)
end
end

describe "generate_self_ship_appointment_slots" do
let(:body) do
{
desiredStartDate: "2024-01-01T10:00:00Z",
desiredEndDate: "2024-01-01T12:00:00Z"
}
end

before do
stub_generate_self_ship_appointment_slots
end

it "generates self-ship appointment slots" do
response = fba_inbound_client.generate_self_ship_appointment_slots(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 "schedule_self_ship_appointment" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:shipment_id) { "sh150f31d2-f3c0-4364-bf0a-63ee9c7ce99f" }
let(:slot_id) { "slot123" }
let(:body) do
{
desiredStartDate: "2024-01-01T10:00:00Z",
desiredEndDate: "2024-01-01T12:00:00Z"
}
end

before do
stub_schedule_self_ship_appointment
end

it "schedules a self-ship appointment" do
response = fba_inbound_client.schedule_self_ship_appointment(inbound_plan_id, shipment_id, slot_id, body)
expect(response.success?).to be true
expect(JSON.parse(response.body)["appointmentId"]).not_to be_nil
end
end

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

before do
stub_list_transportation_options(inbound_plan_id)
end

it "lists transportation options" do
response = fba_inbound_client.list_transportation_options(inbound_plan_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["transportationOptions"]).to be_an(Array)
end
end

describe "generate_transportation_options" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:body) do
{
placementOptionId: "placementOption123"
}
end

before do
stub_generate_transportation_options
end

it "generates transportation options" do
response = fba_inbound_client.generate_transportation_options(inbound_plan_id, body)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "confirm_transportation_options" do
let(:inbound_plan_id) { "wf03769cea-f374-4853-ab93-1a4cf8a62e35" }
let(:body) do
{
transportationOptionId: "transportationOption123"
}
end

before do
stub_confirm_transportation_options
end

it "confirms transportation options" do
response = fba_inbound_client.confirm_transportation_options(inbound_plan_id, body)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "list_item_compliance_details" do
let(:mskus) { ["Sunglasses", "Hat"] }
let(:marketplace_id) { "ATVPDKIKX0DER" }

before do
stub_list_item_compliance_details
end

it "lists item compliance details" do
response = fba_inbound_client.list_item_compliance_details(mskus, marketplace_id)
expect(response.success?).to be true
expect(JSON.parse(response.body)["complianceDetails"]).to be_an(Array)
end
end

describe "update_item_compliance_details" do
let(:marketplace_id) { "ATVPDKIKX0DER" }
let(:body) do
{
msku: "Sunglasses",
complianceStatus: "COMPLIANT"
}
end

before do
stub_update_item_compliance_details
end

it "updates item compliance details" do
response = fba_inbound_client.update_item_compliance_details(marketplace_id, body)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "create_marketplace_item_labels" do
let(:body) do
{
msku: "Sunglasses",
quantity: 10
}
end

before do
stub_create_marketplace_item_labels
end

it "creates marketplace item labels" do
response = fba_inbound_client.create_marketplace_item_labels(body)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end

describe "list_prep_details" do
let(:marketplace_id) { "ATVPDKIKX0DER" }
let(:mskus) { ["Sunglasses", "Hat"] }

before do
stub_list_prep_details
end

it "lists prep details" do
response = fba_inbound_client.list_prep_details(marketplace_id, mskus)
expect(response.success?).to be true
expect(JSON.parse(response.body)["prepDetails"]).to be_an(Array)
end
end

describe "set_prep_details" do
let(:body) do
{
msku: "Sunglasses",
prepOwner: "AMAZON",
prepInstructions: "Handle with care"
}
end

before do
stub_set_prep_details(body)
end

it "sets prep details" do
response = fba_inbound_client.set_prep_details(body)
expect(response.success?).to be true
expect(JSON.parse(response.body)["operationId"]).not_to be_nil
end
end
end
6 changes: 3 additions & 3 deletions spec/muffin_man/listings_restrictions/v20210801_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
it "get listing restrictions for restricted asin" do
stub_get_listings_restricted
listings_restrictions = listings_redictions_client.get_listings_restrictions(asin, seller_id,
amazon_marketplace_id, condition_type)
amazon_marketplace_id, condition_type) # rubocop:disable Layout/LineLength
expect(listings_restrictions.response_code).to eq(200)
expect(JSON.parse(listings_restrictions.body)["restrictions"][0]["reasons"][0]["reasonCode"]).to eq("APPROVAL_REQUIRED")
expect(JSON.parse(listings_restrictions.body)["restrictions"][0]["reasons"][0]["reasonCode"]).to eq("APPROVAL_REQUIRED") # rubocop:disable Layout/LineLength
end

it "get listing restrictions for unrestricted asin" do
stub_get_listings_unrestricted
listings_restrictions = listings_redictions_client.get_listings_restrictions(asin, seller_id,
amazon_marketplace_id, condition_type)
amazon_marketplace_id, condition_type) # rubocop:disable Layout/LineLength
expect(listings_restrictions.response_code).to eq(200)
expect(JSON.parse(listings_restrictions.body)["restrictions"]).to eq([{}])
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"operationId": "op1122334455"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"operationId": "op9988776655"
}
Loading
Loading