Class: Notifun::Notifier::TwilioNotifier
- Inherits:
-
ParentNotifier
- Object
- ParentNotifier
- Notifun::Notifier::TwilioNotifier
- Defined in:
- lib/notifun/notifiers/twilio_notifier.rb
Instance Attribute Summary
Attributes inherited from ParentNotifier
Instance Method Summary collapse
Methods inherited from ParentNotifier
Constructor Details
This class inherits a constructor from Notifun::Notifier::ParentNotifier
Instance Method Details
#notify!(text, phone, options) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/notifun/notifiers/twilio_notifier.rb', line 2 def notify!(text, phone, ) if !defined?(Twilio) @success = false @error_message = "Twilio is not defined." return end account_sid = Notifun.configuration.text_config[:account_sid] auth_token = Notifun.configuration.text_config[:auth_token] from = Notifun.configuration.text_config[:from] return false unless account_sid.present? && auth_token.present? && from.present? begin client = Twilio::REST::Client.new account_sid, auth_token client..create( from: from, to: phone, body: text ) rescue Twilio::REST::RequestError => e @success = false @error_message = e. end @success = true end |