Class: TwilioThinqlcr::TwilioWrapper
- Inherits:
-
Object
- Object
- TwilioThinqlcr::TwilioWrapper
- Defined in:
- lib/twilio_thinqlcr.rb
Overview
The main twilio wrapper class that integrates thinQ.
Constant Summary collapse
- THINQ_DOMAIN =
"wap.thinq.com"- TWIML_RESOURCE_URL_DEFAULT =
"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, twiml_resource_url = nil) ⇒ 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.
10 11 12 13 14 15 16 17 |
# File 'lib/twilio_thinqlcr.rb', line 10 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.
8 9 10 |
# File 'lib/twilio_thinqlcr.rb', line 8 def client @client end |
#thinQ_id ⇒ Object
Returns the value of attribute thinQ_id.
8 9 10 |
# File 'lib/twilio_thinqlcr.rb', line 8 def thinQ_id @thinQ_id end |
#thinQ_token ⇒ Object
Returns the value of attribute thinQ_token.
8 9 10 |
# File 'lib/twilio_thinqlcr.rb', line 8 def thinQ_token @thinQ_token end |
#twilio_account_sid ⇒ Object
Returns the value of attribute twilio_account_sid.
8 9 10 |
# File 'lib/twilio_thinqlcr.rb', line 8 def twilio_account_sid @twilio_account_sid end |
#twilio_account_token ⇒ Object
Returns the value of attribute twilio_account_token.
8 9 10 |
# File 'lib/twilio_thinqlcr.rb', line 8 def twilio_account_token @twilio_account_token end |
Instance Method Details
#call(from, to, twiml_resource_url = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/twilio_thinqlcr.rb', line 23 def call(from, to, twiml_resource_url = nil) @twiml_resource_url = twiml_resource_url ||= TWIML_RESOURCE_URL_DEFAULT if !self.isClientValid? return "Invalid Twilio Account details." end begin # :url => @twiml_resource_url, @call = @client.calls.create({:to => "sip:#{to}@#{THINQ_DOMAIN}?thinQid=#{@thinQ_id}&thinQtoken=#{@thinQ_token}", :from => from, :url => @twiml_resource_url}) return @call rescue Exception => e return e. end end |
#isClientValid? ⇒ Boolean
19 20 21 |
# File 'lib/twilio_thinqlcr.rb', line 19 def isClientValid? !@client.nil? and !@client.accounts.nil? end |