class ConnectionLog < ApplicationRecord
  enum service: { tep: 0, stripe: 1, credit_report: 2 }
  enum http_method: { get: 0, post: 1, put: 2, delete: 3 }, _prefix: true

  belongs_to :school
  belongs_to :associated, polymorphic: true

  validates :service, :http_method, :status_code, presence: true
  validates :area, presence: true, length: { maximum: 64 }
  validates :endpoint, presence: true, length: { maximum: 100 }

  scope :by_date_range, ->(range) { where(created_at: range) if range.present? }
end
