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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_contact.rb', line 21
def self.unpack(hContact, responseObj)
@MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
if hContact.empty?
@MessagePath.issueWarning(100, responseObj)
return nil
end
intMetadataClass = InternalMetadata.new
intContact = intMetadataClass.newContact
outContext = nil
if hContact.has_key?('contactId')
intContact[:contactId] = hContact['contactId']
outContext = 'contact ID ' + hContact['contactId']
end
if intContact[:contactId].nil? || intContact[:contactId] == ''
@MessagePath.issueError(101, responseObj)
end
if hContact.has_key?('externalIdentifier')
aItems = hContact['externalIdentifier']
aItems.each do |item|
hReturn = Identifier.unpack(item, responseObj, outContext)
unless hReturn.nil?
intContact[:externalIdentifier] << hReturn
end
end
end
if hContact.has_key?('isOrganization')
if hContact['isOrganization'] === true
intContact[:isOrganization] = true
end
end
if hContact.has_key?('positionName')
unless hContact['positionName'] == ''
intContact[:positionName] = hContact['positionName']
end
end
if hContact.has_key?('name')
unless hContact['name'] == ''
intContact[:name] = hContact['name']
end
end
if intContact[:name].nil? || intContact[:name] == ''
if intContact[:isOrganization] === true
@MessagePath.issueError(102, responseObj, outContext)
else
if intContact[:positionName].nil? || intContact[:positionName] == ''
@MessagePath.issueError(103, responseObj, outContext)
end
end
end
if hContact.has_key?('memberOfOrganization')
hContact['memberOfOrganization'].each do |item|
unless item == ''
intContact[:memberOfOrgs] << item
end
end
end
if hContact.has_key?('logoGraphic')
aItems = hContact['logoGraphic']
aItems.each do |item|
hReturn = Graphic.unpack(item, responseObj, outContext)
unless hReturn.nil?
intContact[:logos] << hReturn
end
end
end
if hContact.has_key?('phone')
aItems = hContact['phone']
aItems.each do |item|
hReturn = Phone.unpack(item, responseObj, outContext)
unless hReturn.nil?
intContact[:phones] << hReturn
end
end
end
if hContact.has_key?('address')
aItems = hContact['address']
aItems.each do |item|
hReturn = Address.unpack(item, responseObj, outContext)
unless hReturn.nil?
intContact[:addresses] << hReturn
end
end
end
if hContact.has_key?('electronicMailAddress')
hContact['electronicMailAddress'].each do |item|
unless item == ''
intContact[:eMailList] << item
end
end
end
if hContact.has_key?('onlineResource')
aItems = hContact['onlineResource']
aItems.each do |item|
hReturn = OnlineResource.unpack(item, responseObj, outContext)
unless hReturn.nil?
intContact[:onlineResources] << hReturn
end
end
end
if hContact.has_key?('hoursOfService')
hContact['hoursOfService'].each do |item|
unless item == ''
intContact[:hoursOfService] << item
end
end
end
if hContact.has_key?('contactInstructions')
unless hContact['contactInstructions'] == ''
intContact[:contactInstructions] = hContact['contactInstructions']
end
end
if hContact.has_key?('contactType')
unless hContact['contactType'] == ''
intContact[:contactType] = hContact['contactType']
end
end
return intContact
end
|