class TwilioThinqlcrRuby::TwilioWrapper

The main twilio wrapper class that inegrates thinQ.

Constants

THINQ_DOMAIN
TWIML_RESOURCE_URL

Attributes

client[RW]
thinQ_id[RW]
thinQ_token[RW]
twilio_account_sid[RW]
twilio_account_token[RW]

Public Class Methods

new(twilio_account_sid, twilio_account_token, thinQ_id, thinQ_token) click to toggle source
# 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

Public Instance Methods

call(from, to) click to toggle source
# 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.message
    end
end
isClientValid?() click to toggle source
# File lib/twilio_thinqlcr_ruby.rb, line 21
def isClientValid?
    !@client.nil? and !@client.account.nil?
end