Sha256: 7e88be5d0d938b21a8b2de5bfc0d5061a89c7da339c5a4872f8908a1d15b7c5d

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

module ShipCompliant
  # == ShipCompliant::VoidSalesOrder
  #
  # This method takes in a sales order key and
  # voids all shipments in an existing sales order.
  # Voided shipments do not count towards volume limits or reporting.
  # 
  # Use this method if an order has been voided. You can also use this method to
  # void an order with committed shipments before entering a new order with the same order key.
  #
  #   result = ShipCompliant::VoidSalesOrder.by_order_key('OrderKey')
  #   
  #   if result.success?
  #     puts "Order Voided"
  #   else
  #     puts "Failed to void order"
  #
  #     result.errors.each do |error|
  #       puts "[%d] %s" % [error.code, error.message]
  #     end
  #   end
  class VoidSalesOrder

    # Takes an sales order key and makes a request to void
    # it in the system.
    #
    # Returns an instance of ShipCompliant::VoidSalesOrderResult
    #
    #   result = ShipCompliant::VoidSalesOrder.by_order_key('OrderKey')
    def self.by_order_key(order_key)
      result = void_order({ 'SalesOrderKey' => order_key })
      VoidSalesOrderResult.new(result)
    end

    private

    def self.void_order(request)
      ShipCompliant.client.call(:void_sales_order, request)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ship_compliant-0.2.1 lib/ship_compliant/void_sales_order.rb
ship_compliant-0.2.0 lib/ship_compliant/void_sales_order.rb
ship_compliant-0.1.2 lib/ship_compliant/void_sales_order.rb
ship_compliant-0.1.1 lib/ship_compliant/void_sales_order.rb
ship_compliant-0.1.0 lib/ship_compliant/void_sales_order.rb