module ADIWG::Mdtranslator::Readers::MdJson::OrderProcess

Public Class Methods

unpack(hOrder, responseObj, inContext = nil) click to toggle source
# File lib/adiwg/mdtranslator/readers/mdJson/modules/module_orderProcess.rb, line 17
def self.unpack(hOrder, responseObj, inContext = nil)

   @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson

   # return nil object if input is empty
   if hOrder.empty?
      @MessagePath.issueWarning(610, responseObj, inContext)
      return nil
   end

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intOrder = intMetadataClass.newOrderProcess

   # order process - fees
   if hOrder.has_key?('fees')
      unless hOrder['fees'] == ''
         intOrder[:fees] = hOrder['fees']
      end
   end

   # order process - planned availability
   if hOrder.has_key?('plannedAvailability')
      unless hOrder['plannedAvailability'].empty?
         hDate = DateTime.unpack(hOrder['plannedAvailability'], responseObj)
         unless hDate.nil?
            intOrder[:plannedAvailability] = hDate
         end
      end
   end

   # order process - ordering instructions
   if hOrder.has_key?('orderingInstructions')
      unless hOrder['orderingInstructions'] == ''
         intOrder[:orderingInstructions] = hOrder['orderingInstructions']
      end
   end

   # order process - turnaround
   if hOrder.has_key?('turnaround')
      unless hOrder['turnaround'] == ''
         intOrder[:turnaround] = hOrder['turnaround']
      end
   end

   return intOrder
end