2023-02-13 17:31:57 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Provides methods for SupportingDocumentRefusal
|
|
|
|
class SupportingDocumentRefusalService
|
|
|
|
def self.list(filters = {})
|
|
|
|
refusals = []
|
2023-05-24 19:56:48 +02:00
|
|
|
if filters[:supportable_id].present?
|
|
|
|
refusals = SupportingDocumentRefusal.where(supportable_id: filters[:supportable_id],
|
|
|
|
supportable_type: filters[:supportable_type])
|
|
|
|
end
|
2023-02-13 17:31:57 +01:00
|
|
|
refusals
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.create(supporting_document_refusal)
|
|
|
|
saved = supporting_document_refusal.save
|
|
|
|
|
2023-05-24 19:56:48 +02:00
|
|
|
if saved && supporting_document_refusal.supportable_type == 'User'
|
2023-02-13 17:31:57 +01:00
|
|
|
NotificationCenter.call type: 'notify_admin_user_supporting_document_refusal',
|
|
|
|
receiver: User.admins_and_managers,
|
|
|
|
attached_object: supporting_document_refusal
|
|
|
|
NotificationCenter.call type: 'notify_user_supporting_document_refusal',
|
2023-05-24 19:56:48 +02:00
|
|
|
receiver: supporting_document_refusal.supportable,
|
2023-02-13 17:31:57 +01:00
|
|
|
attached_object: supporting_document_refusal
|
|
|
|
end
|
|
|
|
saved
|
|
|
|
end
|
|
|
|
end
|