class TwilioThinqlcr::TwilioWrapper

The main twilio wrapper class that integrates thinQ.

Constants

THINQ_DOMAIN
TWIML_RESOURCE_URL_DEFAULT

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.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

Public Instance Methods

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