2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-01-08 15:29:34 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Import
|
|
|
|
module Zendesk
|
|
|
|
module Common
|
|
|
|
class CustomFields < Sequencer::Unit::Base
|
|
|
|
include ::Sequencer::Unit::Import::Common::Mapping::Mixin::ProvideMapped
|
|
|
|
|
|
|
|
uses :resource
|
|
|
|
|
|
|
|
def process
|
|
|
|
provide_mapped do
|
|
|
|
attributes_hash
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def remote_fields
|
|
|
|
raise 'Missing implementation of remote_fields method'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
@fields ||= remote_fields
|
|
|
|
end
|
|
|
|
|
|
|
|
def attributes_hash
|
|
|
|
return {} if fields.blank?
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2018-01-08 15:29:34 +00:00
|
|
|
fields.each_with_object({}) do |(key, value), result|
|
|
|
|
next if value.nil?
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2018-01-08 15:29:34 +00:00
|
|
|
result[key] = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|