Module: ADIWG::Mdtranslator::Readers::MdJson::OrderProcess

Defined in:
lib/adiwg/mdtranslator/readers/mdJson/modules/module_orderProcess.rb

Class Method Summary collapse

Class Method Details

.unpack(hOrder, responseObj, inContext = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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