2018-08-03 13:22:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 09:17:42 -04:00
|
|
|
class WebHookLog < ApplicationRecord
|
2017-04-27 06:08:57 -04:00
|
|
|
belongs_to :web_hook
|
|
|
|
|
2017-07-03 10:01:41 -04: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 06:08:57 -04:00
|
|
|
|
|
|
|
validates :web_hook, presence: true
|
|
|
|
|
2018-06-28 09:34:31 -04:00
|
|
|
def self.recent
|
|
|
|
where('created_at >= ?', 2.days.ago.beginning_of_day)
|
|
|
|
.order(created_at: :desc)
|
|
|
|
end
|
|
|
|
|
2017-04-27 06:08:57 -04:00
|
|
|
def success?
|
|
|
|
response_status =~ /^2/
|
|
|
|
end
|
|
|
|
end
|