Class: TwilioWithThinq::TwilioWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/twilio_with_thinq.rb

Overview

The main twilio wrapper class that inegrates thinQ.

Constant Summary collapse

TWIML_RESOURCE_URL =
"http://cris.viralearnings.com/twiml/get_response"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(customer_number, twilio_account_sid, twilio_account_token, twilio_phone_number) ⇒ TwilioWrapper

Returns a new instance of TwilioWrapper.



12
13
14
15
16
17
18
19
# File 'lib/twilio_with_thinq.rb', line 12

def initialize(customer_number, , , twilio_phone_number)
  @customer_number = customer_number
   = 
   = 
  @twilio_phone_number = twilio_phone_number

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

Instance Attribute Details

#callback_detailsObject

Returns the value of attribute callback_details.



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

def callback_details
  @callback_details
end

#callback_typeObject

Returns the value of attribute callback_type.



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

def callback_type
  @callback_type
end

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#customer_numberObject

Returns the value of attribute customer_number.



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

def customer_number
  @customer_number
end

#twilio_account_sidObject

Returns the value of attribute twilio_account_sid.



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

def 
  
end

#twilio_account_tokenObject

Returns the value of attribute twilio_account_token.



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

def 
  
end

#twilio_phone_numberObject

Returns the value of attribute twilio_phone_number.



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

def twilio_phone_number
  @twilio_phone_number
end

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/twilio_with_thinq.rb', line 25

def call
    if !self.isClientValid?
      return "Invalid Twilio Account details."
    end

    begin
      @call = @client..calls.create({:to => @customer_number,
                                            :from => @twilio_phone_number,
                                            :url => TWIML_RESOURCE_URL})
      return  @call.sid
    rescue Exception => e
      return e.message
    end
end

#isClientValid?Boolean

Returns:

  • (Boolean)


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

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