Class: TwilioThinqlcrRuby::TwilioWrapper

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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(, , thinQ_id, thinQ_token)
   = 
   = 
  @thinQ_id = thinQ_id
  @thinQ_token = thinQ_token

  @client = Twilio::REST::Client.new , 
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



10
11
12
# File 'lib/twilio_thinqlcr_ruby.rb', line 10

def client
  @client
end

#thinQ_idObject

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_tokenObject

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_sidObject

Returns the value of attribute twilio_account_sid.



10
11
12
# File 'lib/twilio_thinqlcr_ruby.rb', line 10

def 
  
end

#twilio_account_tokenObject

Returns the value of attribute twilio_account_token.



10
11
12
# File 'lib/twilio_thinqlcr_ruby.rb', line 10

def 
  
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..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.message
    end
end

#isClientValid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/twilio_thinqlcr_ruby.rb', line 21

def isClientValid?
    !@client.nil? and !@client..nil?
end