2018-08-03 17:22:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 13:17:42 +00:00
|
|
|
class WebHookLog < ApplicationRecord
|
2017-04-27 10:08:57 +00:00
|
|
|
belongs_to :web_hook
|
|
|
|
|
2017-07-03 14:01:41 +00:00
|
|
|
serialize :request_headers, Hash # rubocop:disable Cop/ActiveRecordSerialize
|
|
|
|
serialize :request_data, Hash # rubocop:disable Cop/ActiveRecordSerialize
|
|
|
|
serialize :response_headers, Hash # rubocop:disable Cop/ActiveRecordSerialize
|
2017-04-27 10:08:57 +00:00
|
|
|
|
|
|
|
validates :web_hook, presence: true
|
|
|
|
|
2018-06-28 13:34:31 +00:00
|
|
|
def self.recent
|
|
|
|
where('created_at >= ?', 2.days.ago.beginning_of_day)
|
|
|
|
.order(created_at: :desc)
|
|
|
|
end
|
|
|
|
|
2017-04-27 10:08:57 +00:00
|
|
|
def success?
|
|
|
|
response_status =~ /^2/
|
|
|
|
end
|
|
|
|
end
|