class ActionTexter::TwilioClient
Implementation of client for Twilio: twilio.com
Attributes
account_sid[RW]
auth_token[RW]
Public Class Methods
new(account_sid, auth_token)
click to toggle source
Create a new Twilio client with account sid and auth token
@param [String] account_sid
as specified by Twilio for authenticating. @param [String] auth_token
as specified by Twilio for authenticating.
Calls superclass method
# 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
Public Instance Methods
deliver(message)
click to toggle source
# File lib/action_texter/twilio.rb, line 57 def deliver(message) 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" => message.from, "To" => message.to, "Body" => message.text}) response = http.request(request) return ActionTexter::TwilioResponse.new(response.body) end
to_s()
click to toggle source
@private
# File lib/action_texter/twilio.rb, line 69 def to_s "#<#{self.class.name}:#{key}>" end