Class: ActionTexter::TwilioDelivery
- Inherits:
-
Object
- Object
- ActionTexter::TwilioDelivery
- Defined in:
- lib/action_texter/twilio_delivery.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #deliver(message) ⇒ Object
-
#initialize(config = {}) ⇒ TwilioDelivery
constructor
A new instance of TwilioDelivery.
Constructor Details
#initialize(config = {}) ⇒ TwilioDelivery
Returns a new instance of TwilioDelivery.
5 6 7 8 9 10 11 12 13 |
# File 'lib/action_texter/twilio_delivery.rb', line 5 def initialize(config = {}) @sid = config[:sid] @token = config[:token] @subaccount = config[:subaccount] raise ArgumentError, "you must specify config.action_texter.twilio_settings to contain a :sid" unless @sid raise ArgumentError, "you must specify config.action_texter.twilio_settings to contain a :token" unless @token @client = Twilio::REST::Client.new(@sid, @token) @client = client.accounts.find(@subaccount) if @subaccount end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/action_texter/twilio_delivery.rb', line 3 def client @client end |
Instance Method Details
#deliver(message) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/action_texter/twilio_delivery.rb', line 15 def deliver() client.sms..create( :from => .from, :to => .to, :body => .body.strip ) end |