class Noticed::DeliveryMethods::Twilio

Public Instance Methods

deliver() click to toggle source
# File lib/noticed/delivery_methods/twilio.rb, line 4
def deliver
  post(url, basic_auth: {user: account_sid, pass: auth_token}, form: format)
end

Private Instance Methods

account_sid() click to toggle source
# File lib/noticed/delivery_methods/twilio.rb, line 30
def account_sid
  credentials.fetch(:account_sid)
end
auth_token() click to toggle source
# File lib/noticed/delivery_methods/twilio.rb, line 34
def auth_token
  credentials.fetch(:auth_token)
end
credentials() click to toggle source
# File lib/noticed/delivery_methods/twilio.rb, line 42
def credentials
  if (method = options[:credentials])
    notification.send(method)
  else
    Rails.application.credentials.twilio
  end
end
format() click to toggle source
# File lib/noticed/delivery_methods/twilio.rb, line 10
def format
  if (method = options[:format])
    notification.send(method)
  else
    {
      From: phone_number,
      To: recipient.phone_number,
      Body: notification.params[:message]
    }
  end
end
phone_number() click to toggle source
# File lib/noticed/delivery_methods/twilio.rb, line 38
def phone_number
  credentials.fetch(:phone_number)
end
url() click to toggle source
# File lib/noticed/delivery_methods/twilio.rb, line 22
def url
  if (method = options[:url])
    notification.send(method)
  else
    "https://api.twilio.com/2010-04-01/Accounts/#{account_sid}/Messages.json"
  end
end