2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Import
|
|
|
|
module Common
|
|
|
|
module Model
|
|
|
|
class HttpLog < Sequencer::Unit::Base
|
|
|
|
|
2017-12-21 11:19:30 +00:00
|
|
|
uses :dry_run, :action, :remote_id, :mapped, :exception
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
def process
|
|
|
|
return if dry_run
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
::HttpLog.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
direction: 'out',
|
|
|
|
facility: facility,
|
|
|
|
method: 'tcp',
|
|
|
|
url: "#{action} -> #{remote_id}",
|
|
|
|
status: status,
|
|
|
|
ip: nil,
|
|
|
|
request: {
|
2017-08-14 11:56:23 +00:00
|
|
|
content: mapped,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
response: {
|
2017-08-14 11:56:23 +00:00
|
|
|
message: response
|
|
|
|
},
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def status
|
|
|
|
@status ||= begin
|
2017-12-21 11:19:30 +00:00
|
|
|
action == :failed ? :failed : :success
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def response
|
|
|
|
exception ? exception.message : status
|
|
|
|
end
|
|
|
|
|
|
|
|
def facility
|
|
|
|
raise "Missing implementation of '#{__method__}' method for '#{self.class.name}'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|