class ShipCompliant::CommitSalesOrderResult

ShipCompliant::CommitSalesOrderResult

Wraps the response of CommitSalesOrder and provides methods to quickly access shipments, and the committed shipment keys.

Public Instance Methods

committed_shipments() click to toggle source

Gets the keys for committed shipments.

puts result.committed_shipments #=> ['SHIPMENT-1', 'SHIPMENT-2', ...]
# File lib/ship_compliant/commit_sales_order_result.rb, line 24
def committed_shipments
  shipments
    .select { |s| s[:is_committed] == true }
    .map { |s| s[:key] }
end
shipments() click to toggle source

Returns an array of shipment objects.

puts result.shipments #=> [
  {
    key: 'SHIPMENT-KEY',
    is_committed: true/false
  }
]
# File lib/ship_compliant/commit_sales_order_result.rb, line 17
def shipments
  Array.wrap(response[:shipments][:shipment_commit_response])
end