Class: LastResort::ExceptionSession
- Inherits:
-
Object
- Object
- LastResort::ExceptionSession
- Defined in:
- lib/last-resort/twilio.rb
Instance Attribute Summary collapse
-
#call ⇒ Object
Array of strings representing numbers.
-
#client ⇒ Object
Array of strings representing numbers.
-
#contacts ⇒ Object
Array of strings representing numbers.
-
#description ⇒ Object
Array of strings representing numbers.
-
#handled ⇒ Object
Array of strings representing numbers.
-
#index ⇒ Object
Array of strings representing numbers.
Instance Method Summary collapse
-
#call_next ⇒ Object
Return false if call was not made.
-
#callee_name ⇒ Object
Name of the latest callee (latest call).
-
#callee_number ⇒ Object
Number of latest callee (latest call).
-
#end ⇒ Object
Called when someone in the queue has handled this.
-
#initialize(contacts = [], description = "a general exception has occurred") ⇒ ExceptionSession
constructor
A new instance of ExceptionSession.
-
#notify ⇒ Object
Begin the notification cycle.
Constructor Details
#initialize(contacts = [], description = "a general exception has occurred") ⇒ ExceptionSession
Returns a new instance of ExceptionSession.
25 26 27 28 29 30 31 |
# File 'lib/last-resort/twilio.rb', line 25 def initialize(contacts = [], description = "a general exception has occurred") @contacts = contacts @description = description @client = Twilio::REST::Client.new ACCOUNT_SID, AUTH_TOKEN @index = -1 @handled = false end |
Instance Attribute Details
#call ⇒ Object
Array of strings representing numbers
23 24 25 |
# File 'lib/last-resort/twilio.rb', line 23 def call @call end |
#client ⇒ Object
Array of strings representing numbers
23 24 25 |
# File 'lib/last-resort/twilio.rb', line 23 def client @client end |
#contacts ⇒ Object
Array of strings representing numbers
23 24 25 |
# File 'lib/last-resort/twilio.rb', line 23 def contacts @contacts end |
#description ⇒ Object
Array of strings representing numbers
23 24 25 |
# File 'lib/last-resort/twilio.rb', line 23 def description @description end |
#handled ⇒ Object
Array of strings representing numbers
23 24 25 |
# File 'lib/last-resort/twilio.rb', line 23 def handled @handled end |
#index ⇒ Object
Array of strings representing numbers
23 24 25 |
# File 'lib/last-resort/twilio.rb', line 23 def index @index end |
Instance Method Details
#call_next ⇒ Object
Return false if call was not made
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/last-resort/twilio.rb', line 34 def call_next @index += 1 return false if @contacts.empty? || @index >= @contacts.size || @handled # Make the call @call = @client.account.calls.create( :from => FROM_NUMBER, :to => @contacts[@index].number, :url => "http://#{HOST}/twilio/call", :status_callback => "http://#{HOST}/twilio/status_callback" ) return true end |
#callee_name ⇒ Object
Name of the latest callee (latest call)
61 62 63 |
# File 'lib/last-resort/twilio.rb', line 61 def callee_name @contacts[@index].name end |
#callee_number ⇒ Object
Number of latest callee (latest call)
66 67 68 |
# File 'lib/last-resort/twilio.rb', line 66 def callee_number @contacts[@index].number end |
#end ⇒ Object
Called when someone in the queue has handled this
51 52 53 |
# File 'lib/last-resort/twilio.rb', line 51 def end @handled = true end |
#notify ⇒ Object
Begin the notification cycle
56 57 58 |
# File 'lib/last-resort/twilio.rb', line 56 def notify self.call_next end |