Sha256: 0662d197483053f39f17434c0731211e4157ff0cd5825a22411a09cdc925a6cb
Contents?: true
Size: 1.84 KB
Versions: 34
Compression:
Stored size: 1.84 KB
Contents
# # SmsNotification is a concrete class of Notification, sending sms to both members # and users, or in the case of eCommerce, customers. # # This object allows you to create an SmsNotification object, set it's property and # tell it send_notification. It'll handle everything from there including # 1. Running in the background thread # 2. Error recovery # 3. Retry on failure # # The SMS object also uses the templating engine to allow the specification of a template # and a set of local variables for dynamic content. # # Usage: # # sms = SmsNotification.new # sms.to = '5713326267' # sms.message = 'Day is today!' # sms.send_notification # # You are done! Go about your business of creating awesome software! # class SmsNotification < Notification # # Fields # field :sid, type: String validates :to, presence: true, format: { with: /\A\+[1-9]{1}[0-9]{3,14}\z/ } def deliver_message! return unless SystemConfiguration.twilio_configured? config = SystemConfiguration.configuration account_sid = config.twilio_account_id auth_token = config.twilio_auth_token client = Twilio::REST::Client.new account_sid, auth_token twilio_message = if client.respond_to?(:account) client.account.messages.create(body: message, to: to, from: config.twilio_phone_number) else client.messages.create(body: message, to: to, from: config.twilio_phone_number) end # We are saved in the calling class, no reason to save again set sid: twilio_message.sid end # # set the delivery channel for the templates # def delivery_channel DELIVERY_SMS end end
Version data entries
34 entries across 34 versions & 1 rubygems