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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_address.rb', line 22
def self.unpack(hAddress, responseObj, inContext = nil)
@MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
if hAddress.empty?
@MessagePath.issueWarning(10, responseObj, inContext)
return nil
end
intMetadataClass = InternalMetadata.new
intAdd = intMetadataClass.newAddress
if hAddress.has_key?('addressType')
hAddress['addressType'].each do |item|
unless item == ''
intAdd[:addressTypes] << item
end
end
end
if intAdd[:addressTypes].empty?
@MessagePath.issueError(11, responseObj, inContext)
end
if hAddress.has_key?('description')
unless hAddress['description'] == ''
intAdd[:description] = hAddress['description']
end
end
if hAddress.has_key?('deliveryPoint')
hAddress['deliveryPoint'].each do |item|
unless item == ''
intAdd[:deliveryPoints] << item
end
end
end
if hAddress.has_key?('city')
unless hAddress['city'] == ''
intAdd[:city] = hAddress['city']
end
end
if hAddress.has_key?('administrativeArea')
unless hAddress['administrativeArea'] == ''
intAdd[:adminArea] = hAddress['administrativeArea']
end
end
if hAddress.has_key?('postalCode')
unless hAddress['postalCode'] == ''
intAdd[:postalCode] = hAddress['postalCode']
end
end
if hAddress.has_key?('country')
unless hAddress['country'] == ''
intAdd[:country] = hAddress['country']
end
end
return intAdd
end
|