Class: Dscf::Core::NotificationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/dscf/core/notification_service.rb

Defined Under Namespace

Modules: Adapters

Class Method Summary collapse

Class Method Details

.deliver(notification) ⇒ Object



7
8
9
10
11
# File 'app/services/dscf/core/notification_service.rb', line 7

def deliver(notification)
  adapter = resolve_adapter
  adapter.send_sms(notification.recipient.phone, notification.body)
  notification.update!(status: :delivered, delivered_at: Time.current)
end

.resolve_adapterObject



13
14
15
16
17
18
19
20
# File 'app/services/dscf/core/notification_service.rb', line 13

def resolve_adapter
  adapter_name = Rails.application.config.x.sms_adapter || :stub

  case adapter_name.to_sym
  when :stub then Adapters::SmsStub
  else raise ArgumentError, "Unknown SMS adapter: #{adapter_name}"
  end
end