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(
|
|
|
|
direction: 'out',
|
|
|
|
facility: facility,
|
|
|
|
method: 'tcp',
|
2017-12-21 11:19:30 +00:00
|
|
|
url: "#{action} -> #{remote_id}",
|
2017-08-14 11:56:23 +00:00
|
|
|
status: status,
|
|
|
|
ip: nil,
|
|
|
|
request: {
|
|
|
|
content: mapped,
|
|
|
|
},
|
|
|
|
response: {
|
|
|
|
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
|