Class: Phone::BroadcastCallStatus
- Inherits:
-
BaseService
- Object
- BaseService
- Phone::BroadcastCallStatus
- Defined in:
- app/services/phone/broadcast_call_status.rb
Overview
Class responsible for sending current calls
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #call_status_broadcast_hash ⇒ Object
- #current_calls_grouped_by_employee_id ⇒ Object
- #perform(options = {}) ⇒ Object
Instance Method Details
#call_status_broadcast_hash ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/phone/broadcast_call_status.rb', line 15 def call_status_broadcast_hash current_calls = current_calls_grouped_by_employee_id broadcast = {} EmployeePhoneStatus.extension_to_employee_id_hash.each do |extension, employee_id| current_call = current_calls[employee_id] || {} broadcast[employee_id] = { current_call_status: current_call[:state] || "", current_call: current_call, timestamp: Time.current.to_i } end broadcast end |
#current_calls_grouped_by_employee_id ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/services/phone/broadcast_call_status.rb', line 30 def current_calls_grouped_by_employee_id hsh = {} extension_map = EmployeePhoneStatus.extension_to_employee_id_hash current_calls = Phone::Pbx.instance.current_calls current_calls.each do |call| from_number = call[:from_caller_id_number] to_number = call[:to_caller_id_number] if employee_id = extension_map[from_number] hsh[employee_id] = call.merge(direction: :out) elsif employee_id = extension_map[to_number] hsh[employee_id] = call.merge(direction: :in) end end hsh end |