Class: Hertz::Twilio::NotificationDeliveryJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/hertz/twilio/notification_delivery_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(notification) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/jobs/hertz/twilio/notification_delivery_job.rb', line 8

def perform(notification)
  return unless notification.receiver.hertz_phone_number.present?
  return if notification.delivered_with?(:twilio)

  twilio_client.messages.create(
    to: notification.receiver.hertz_phone_number,
    from: Hertz::Twilio.sender_id || Hertz::Twilio.phone_number,
    body: notification.sms_body
  )

  notification.mark_delivered_with(:twilio)
end