Sha256: aa94ed81e77e842f948f03aff512b4350f4a9ae0ac805ab96c6d7ae72f636cb0
Contents?: true
Size: 1.35 KB
Versions: 7
Compression:
Stored size: 1.35 KB
Contents
module SocialNetworking # Sends sms or emails to participants. class Notification include Sms attr_reader :current_participant, :mailer, :recipient, :message_body, :subject def initialize( current_participant:, mailer:, recipient:, message_body:, subject:) @current_participant = current_participant @mailer = mailer @message_body = message_body @recipient = recipient @subject = subject end def notify return if current_participant == recipient if recipient.contact_preference == "email" send_email else begin send_sms(recipient, message_body) rescue Twilio::REST::RequestError => exception Raven .capture_message "TWILLIO: failed to notify recipient via SMS", extra: { message: exception.message, phone_number: recipient.try(:phone_number), participant: recipient.try(:id) } if defined?(Raven) end end end def send_email mailer .notify( recipient: recipient, body: message_body, subject: subject) .deliver_now end end end
Version data entries
7 entries across 7 versions & 1 rubygems