class Notifiable::Sms::Twilio

Attributes

account_sid[RW]
auth_token[RW]
sms_originator[RW]

Protected Instance Methods

enqueue(device_token, localized_notification) click to toggle source
# File lib/notifiable/sms/twilio.rb, line 13
              def enqueue(device_token, localized_notification)                                  
        
raise "Account SID missing" if account_sid.nil?
raise "Auth token missing" if auth_token.nil?
raise "Auth token missing" if sms_originator.nil?
        
result = twilio_client.account.messages.create({
      :from => sms_originator, 
      :to => device_token.token, 
      :body => localized_notification.message,  
})

if result.error_code == nil
  processed(device_token, 0)
else
  processed(device_token, result.error_code.to_i)            
end
              end

Private Instance Methods

twilio_client() click to toggle source
# File lib/notifiable/sms/twilio.rb, line 33
def twilio_client
                        @twilio_client ||= ::Twilio::REST::Client.new(account_sid, auth_token)
end