Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Configure Twilio by setting class instance variables, if you so choose

  • Loading branch information...
commit ddc882d1722d53005d0d9a7b518f6fb389a44571 1 parent d83e9b3
@evanfarrar evanfarrar authored
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/sms.rb
View
17 lib/sms.rb
@@ -2,13 +2,22 @@
require File.join(File.dirname(__FILE__), 'sms', 'twiliolib')
module SMS
- TWILIO_SEND = "/2008-08-01/Accounts/#{ENV['TWILIO_ID']}/SMS/Messages"
+
+ class << self
+ attr_accessor :twilio_id
+ attr_accessor :twilio_phone
+ attr_accessor :twilio_secret
+ def twilio_send
+ "/2008-08-01/Accounts/#{self.twilio_id||ENV['TWILIO_ID']}/SMS/Messages"
+ end
+ end
+
def self.text(message, options={})
- twilio = Twilio::RestAccount.new ENV['TWILIO_ID'], ENV['TWILIO_SECRET']
- res = twilio.request TWILIO_SEND, 'POST',
+ twilio = Twilio::RestAccount.new self.twilio_id||ENV['TWILIO_ID'], self.twilio_secret||ENV['TWILIO_SECRET']
+ res = twilio.request self.twilio_send, 'POST',
'To' => options[:to],
- 'From' => options[:from] || ENV['TWILIO_PHONE'],
+ 'From' => options[:from] || (self.twilio_phone||ENV['TWILIO_PHONE']),
'Body' => message
if res.code.to_i == 201
true
Please sign in to comment.
Something went wrong with that request. Please try again.