http_log.rb 949 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Common::Model::HttpLog < Sequencer::Unit::Base
  3. uses :dry_run, :action, :remote_id, :mapped, :exception
  4. def process
  5. return if dry_run
  6. ::HttpLog.create(
  7. direction: 'out',
  8. facility: facility,
  9. method: 'tcp',
  10. url: url,
  11. status: status,
  12. ip: nil,
  13. request: {
  14. content: mapped,
  15. },
  16. response: {
  17. message: response
  18. },
  19. created_by_id: 1,
  20. updated_by_id: 1,
  21. )
  22. end
  23. private
  24. def url
  25. "#{action} -> #{remote_id}"
  26. end
  27. def status
  28. @status ||= begin
  29. action == :failed ? :failed : :success
  30. end
  31. end
  32. def response
  33. exception ? exception.message : status
  34. end
  35. def facility
  36. raise "Missing implementation of '#{__method__}' method for '#{self.class.name}'"
  37. end
  38. end