Class: ActionTexter::TwilioClient
- Defined in:
- lib/action_texter/twilio.rb
Overview
Implementation of client for Twilio: twilio.com
Instance Attribute Summary collapse
-
#account_sid ⇒ Object
Returns the value of attribute account_sid.
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
Instance Method Summary collapse
- #deliver(message) ⇒ Object
-
#initialize(account_sid, auth_token) ⇒ TwilioClient
constructor
Create a new Twilio client with account sid and auth token.
- #to_s ⇒ Object
Methods inherited from Client
Constructor Details
#initialize(account_sid, auth_token) ⇒ TwilioClient
Create a new Twilio client with account sid and auth token
51 52 53 54 55 |
# File 'lib/action_texter/twilio.rb', line 51 def initialize(account_sid, auth_token) super() self.account_sid = account_sid self.auth_token = auth_token end |
Instance Attribute Details
#account_sid ⇒ Object
Returns the value of attribute account_sid.
45 46 47 |
# File 'lib/action_texter/twilio.rb', line 45 def account_sid @account_sid end |
#auth_token ⇒ Object
Returns the value of attribute auth_token.
45 46 47 |
# File 'lib/action_texter/twilio.rb', line 45 def auth_token @auth_token end |
Instance Method Details
#deliver(message) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/action_texter/twilio.rb', line 57 def deliver() http = Net::HTTP.new("api.twilio.com", 443) http.use_ssl = true request = Net::HTTP::Post.new("/2010-04-01/Accounts/#{@account_sid}/Messages.json") request.basic_auth(@account_sid, @auth_token) request.set_form_data({"From" => .from, "To" => .to, "Body" => .text}) response = http.request(request) return ActionTexter::TwilioResponse.new(response.body) end |
#to_s ⇒ Object
69 70 71 |
# File 'lib/action_texter/twilio.rb', line 69 def to_s "#<#{self.class.name}:#{key}>" end |