Class: TwilioThinqlcrRuby::TwilioWrapper
- Inherits:
-
Object
- Object
- TwilioThinqlcrRuby::TwilioWrapper
- Defined in:
- lib/twilio_thinqlcr_ruby.rb
Overview
The main twilio wrapper class that inegrates thinQ.
Constant Summary collapse
- THINQ_DOMAIN =
"wap.thinq.com"- TWIML_RESOURCE_URL =
"http://demo.twilio.com/docs/voice.xml"
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#thinQ_id ⇒ Object
Returns the value of attribute thinQ_id.
-
#thinQ_token ⇒ Object
Returns the value of attribute thinQ_token.
-
#twilio_account_sid ⇒ Object
Returns the value of attribute twilio_account_sid.
-
#twilio_account_token ⇒ Object
Returns the value of attribute twilio_account_token.
Instance Method Summary collapse
- #call(from, to) ⇒ Object
-
#initialize(twilio_account_sid, twilio_account_token, thinQ_id, thinQ_token) ⇒ TwilioWrapper
constructor
A new instance of TwilioWrapper.
- #isClientValid? ⇒ Boolean
Constructor Details
#initialize(twilio_account_sid, twilio_account_token, thinQ_id, thinQ_token) ⇒ TwilioWrapper
Returns a new instance of TwilioWrapper.
12 13 14 15 16 17 18 19 |
# File 'lib/twilio_thinqlcr_ruby.rb', line 12 def initialize(twilio_account_sid, twilio_account_token, thinQ_id, thinQ_token) @twilio_account_sid = twilio_account_sid @twilio_account_token = twilio_account_token @thinQ_id = thinQ_id @thinQ_token = thinQ_token @client = Twilio::REST::Client.new twilio_account_sid, twilio_account_token end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/twilio_thinqlcr_ruby.rb', line 10 def client @client end |
#thinQ_id ⇒ Object
Returns the value of attribute thinQ_id.
10 11 12 |
# File 'lib/twilio_thinqlcr_ruby.rb', line 10 def thinQ_id @thinQ_id end |
#thinQ_token ⇒ Object
Returns the value of attribute thinQ_token.
10 11 12 |
# File 'lib/twilio_thinqlcr_ruby.rb', line 10 def thinQ_token @thinQ_token end |
#twilio_account_sid ⇒ Object
Returns the value of attribute twilio_account_sid.
10 11 12 |
# File 'lib/twilio_thinqlcr_ruby.rb', line 10 def twilio_account_sid @twilio_account_sid end |
#twilio_account_token ⇒ Object
Returns the value of attribute twilio_account_token.
10 11 12 |
# File 'lib/twilio_thinqlcr_ruby.rb', line 10 def twilio_account_token @twilio_account_token end |
Instance Method Details
#call(from, to) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/twilio_thinqlcr_ruby.rb', line 25 def call(from, to) if !self.isClientValid? return "Invalid Twilio Account details." end begin @call = @client.account.calls.create({:to => "sip:#{to}@#{THINQ_DOMAIN}", :from => from, :url => TWIML_RESOURCE_URL, :thinQid => @thinQ_id, :thinQtoken => @thinQ_token}) return @call.sid rescue Exception => e return e. end end |
#isClientValid? ⇒ Boolean
21 22 23 |
# File 'lib/twilio_thinqlcr_ruby.rb', line 21 def isClientValid? !@client.nil? and !@client.account.nil? end |