16
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
|
# File 'lib/tallyable/acts_as_tallyable.rb', line 16
def employee_request
result = tally_request("#{ File.dirname(__FILE__) }/employee_request.xml")
employees = []
unless result.is_a? String
xml = Nokogiri.XML(result.body)
xml.xpath("ENVELOPE").each do |nodes|
params = {}
nodes.children.each do |node|
params[:name] = node.text if node.name == "EMPPROFILENAME"
%w[EMPPROFILEEMAILID
EMPPROFILEGENDER
EMPPROFILEDATEOFBIRTH
EMPPROFILECONTACTNUMBER
EMPPROFILEEMPLOYEEADDRESS].each do |tag|
if node.at(tag)
case node.at(tag).name
when "EMPPROFILEEMAILID"
params[:email] = node.at(tag).text
when "EMPPROFILEGENDER"
params[:gender] = node.at(tag).text
when "EMPPROFILEDATEOFBIRTH"
params[:date_of_birth] = node.at(tag).text
when "EMPPROFILECONTACTNUMBER"
params[:phone] = node.at(tag).text
when "EMPPROFILEEMPLOYEEADDRESS"
params[:address] = node.at(tag).text
end
end
end
if node.name == "EMPPROFILESNO" and !params.empty?
employees << params
params = {}
end
end
employees << params
end
end
employees
end
|