lib/mws/fulfillment_outbound_shipment.rb in peddler-0.7.7 vs lib/mws/fulfillment_outbound_shipment.rb in peddler-0.7.8

- old
+ new

@@ -1,6 +1,7 @@ require 'peddler/client' +require 'excon' module MWS # The Fulfillment Outbound Shipment API enables you to fulfill orders placed # through channels other than Amazon's retail web site, using your inventory # in the Amazon Fulfillment Network. You can request previews of potential @@ -19,12 +20,49 @@ raise NotImplementedError end # Requests that Amazon ship items from the seller's Amazon Fulfillment # Network inventory to a destination address - def create_fulfillment_order - raise NotImplementedError + # + # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_CreateFulfillmentOrder.html + # @param seller_fulfillment_order_id [String] + # @param displayable_order_id [String] + # @param displayable_order_date_time [String, #iso8601] + # @param displayable_order_comment [String] + # @param shipping_speed_category [String] + # @param destination_address [Struct, Hash] + # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_Datatypes.html#Address + # @params items [Array<Struct, Hash>] + # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_Datatypes.html#CreateFulfillmentOrderItem + # @param opts [Hash] + # @option opts [String] :fulfillment_action + # @option opts [String] :fulfillment_policy + # @option opts [Array<String>] :notification_email_list + # @option opts [Struct, Hash] :cod_settings + # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_Datatypes.html#CODSettings + # @return [Peddler::XMLParser] + def create_fulfillment_order(seller_fulfillment_order_id, displayable_order_id, displayable_order_date_time, displayable_order_comment, shipping_speed_category, destination_address, items, opts = {}) + if opts.has_key?(:cod_settings) + opts['CODSettings'] = opts.delete(:cod_settings) + end + + operation('CreateFulfillmentOrder') + .add(opts + .merge( + 'SellerFulfillmentOrderId' => seller_fulfillment_order_id, + 'DisplayableOrderId' => displayable_order_id, + 'DisplayableOrderDateTime' => displayable_order_date_time, + 'DisplayableOrderComment' => displayable_order_comment, + 'ShippingSpeedCategory' => shipping_speed_category, + 'DestinationAddress' => destination_address, + 'Items' => items + ) + ) + .structure!('Items', 'member') + .structure!('NotificationEmailList', 'member') + + run end # Updates and/or requests shipment for a fulfillment order with an order # hold on it def update_fulfillment_order @@ -52,11 +90,18 @@ raise NotImplementedError end # Requests that Amazon stop attempting to fulfill an existing fulfillment # order - def cancel_fulfillment_order - raise NotImplementedError + # + # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_CancelFulfillmentOrder.html + # @param seller_fulfillment_order_id [String] + # @return [Peddler::XMLParser] + def cancel_fulfillment_order(seller_fulfillment_order_id) + operation('CancelFulfillmentOrder') + .add('SellerFulfillmentOrderId' => seller_fulfillment_order_id) + + run end # Gets the operational status of the API # # @see http://docs.developer.amazonservices.com/en_US/fba_outbound/MWS_GetServiceStatus.html