2016-11-25 16:10:37 +00:00
|
|
|
module Import
|
|
|
|
module OTRS
|
|
|
|
module Helper
|
|
|
|
extend self
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def from_mapping(record)
|
|
|
|
result = {}
|
|
|
|
# use the mapping of the class in which
|
|
|
|
# this module gets extended
|
2017-10-01 12:25:52 +00:00
|
|
|
self.class::MAPPING.each do |key_sym, value|
|
2016-11-25 16:10:37 +00:00
|
|
|
key = key_sym.to_s
|
|
|
|
next if !record.key?(key)
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
result[value] = record[key]
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-11-25 16:10:37 +00:00
|
|
|
result
|
|
|
|
end
|
|
|
|
|
|
|
|
def active?(record)
|
|
|
|
case record['ValidID'].to_s
|
|
|
|
when '3'
|
|
|
|
false
|
|
|
|
when '2'
|
|
|
|
false
|
|
|
|
when '1'
|
|
|
|
true
|
|
|
|
when '0'
|
|
|
|
false
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|