2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
class WebHookLog < ActiveRecord::Base
|
|
|
|
belongs_to :web_hook
|
|
|
|
|
|
|
|
serialize :request_headers, Hash # rubocop:disable Cop/ActiveRecordSerialize
|
|
|
|
serialize :request_data, Hash # rubocop:disable Cop/ActiveRecordSerialize
|
|
|
|
serialize :response_headers, Hash # rubocop:disable Cop/ActiveRecordSerialize
|
|
|
|
|
|
|
|
validates :web_hook, presence: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
def self.recent
|
|
|
|
where('created_at >= ?', 2.days.ago.beginning_of_day)
|
|
|
|
.order(created_at: :desc)
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
def success?
|
|
|
|
response_status =~ /^2/
|
|
|
|
end
|
|
|
|
end
|