Module: TwilioWrapper
Constant Summary collapse
- API_VERSION =
'2010-04-01'
Instance Attribute Summary collapse
-
#account_sid ⇒ Object
Returns the value of attribute account_sid.
-
#account_token ⇒ Object
Returns the value of attribute account_token.
-
#caller_id ⇒ Object
Returns the value of attribute caller_id.
-
#caller_pin ⇒ Object
Returns the value of attribute caller_pin.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#twilio_response ⇒ Object
Returns the value of attribute twilio_response.
Instance Method Summary collapse
Instance Attribute Details
#account_sid ⇒ Object
Returns the value of attribute account_sid.
8 9 10 |
# File 'lib/twilio-wrapper.rb', line 8 def account_sid @account_sid end |
#account_token ⇒ Object
Returns the value of attribute account_token.
8 9 10 |
# File 'lib/twilio-wrapper.rb', line 8 def account_token @account_token end |
#caller_id ⇒ Object
Returns the value of attribute caller_id.
8 9 10 |
# File 'lib/twilio-wrapper.rb', line 8 def caller_id @caller_id end |
#caller_pin ⇒ Object
Returns the value of attribute caller_pin.
8 9 10 |
# File 'lib/twilio-wrapper.rb', line 8 def caller_pin @caller_pin end |
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/twilio-wrapper.rb', line 8 def logger @logger end |
#twilio_response ⇒ Object
Returns the value of attribute twilio_response.
8 9 10 |
# File 'lib/twilio-wrapper.rb', line 8 def twilio_response @twilio_response end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
10 11 12 13 14 |
# File 'lib/twilio-wrapper.rb', line 10 def configure yield self @account = Twilio::RestAccount.new(@account_sid, @account_token) end |
#sms(recipient_number, message) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/twilio-wrapper.rb', line 16 def sms(recipient_number, ) payload = { 'From' => caller_id, 'To' => recipient_number, 'Body' => } resp = @account.request("/#{API_VERSION}/Accounts/#{@account_sid}/SMS/Messages", 'POST', payload) send_success = resp.is_a?(Net::HTTPSuccess) if(logger) if(send_success) logger.debug("Twilio SMS Sent") else logger.warn("Twilio SMS Failed: #{resp.inspect}") end end return send_success end |