Class: LastResort::ExceptionSession
- Inherits:
-
Object
- Object
- LastResort::ExceptionSession
- Defined in:
- lib/last-resort/twilio.rb
Overview
Represents the email notification (exception) from ContextIO. Created when our webhook is called from ContextIO.
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
Call the next Contact in the queue.
-
#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.
27 28 29 30 31 32 33 |
# File 'lib/last-resort/twilio.rb', line 27 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
25 26 27 |
# File 'lib/last-resort/twilio.rb', line 25 def call @call end |
#client ⇒ Object
Array of strings representing numbers
25 26 27 |
# File 'lib/last-resort/twilio.rb', line 25 def client @client end |
#contacts ⇒ Object
Array of strings representing numbers
25 26 27 |
# File 'lib/last-resort/twilio.rb', line 25 def contacts @contacts end |
#description ⇒ Object
Array of strings representing numbers
25 26 27 |
# File 'lib/last-resort/twilio.rb', line 25 def description @description end |
#handled ⇒ Object
Array of strings representing numbers
25 26 27 |
# File 'lib/last-resort/twilio.rb', line 25 def handled @handled end |
#index ⇒ Object
Array of strings representing numbers
25 26 27 |
# File 'lib/last-resort/twilio.rb', line 25 def index @index end |
Instance Method Details
#call_next ⇒ Object
Call the next Contact in the queue. Returns false if call was not made
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/last-resort/twilio.rb', line 36 def call_next @index += 1 return false if @handled || @index >= @contacts.size # 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)
63 64 65 |
# File 'lib/last-resort/twilio.rb', line 63 def callee_name @contacts[@index].name end |
#callee_number ⇒ Object
Number of latest callee (latest call)
68 69 70 |
# File 'lib/last-resort/twilio.rb', line 68 def callee_number @contacts[@index].number end |
#end ⇒ Object
Called when someone in the queue has handled this
53 54 55 |
# File 'lib/last-resort/twilio.rb', line 53 def end @handled = true end |
#notify ⇒ Object
Begin the notification cycle
58 59 60 |
# File 'lib/last-resort/twilio.rb', line 58 def notify self.call_next end |