Class: Telephony::Call

Inherits:
Base
  • Object
show all
Includes:
CallStateMachine, NumberHelper
Defined in:
app/models/telephony/call.rb

Instance Method Summary collapse

Methods included from NumberHelper

#extract_area_code, #normalize_number

Instance Method Details

#agent?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'app/models/telephony/call.rb', line 79

def agent?
  agent.present?
end

#caller_idObject



43
44
45
# File 'app/models/telephony/call.rb', line 43

def caller_id
  conversation.caller_id
end

#dial_into_conference!Object



38
39
40
41
# File 'app/models/telephony/call.rb', line 38

def dial_into_conference!
  provider_call = Telephony.provider.dial_into_conference id, number(true), caller_id
  update_attribute :sid, provider_call.sid
end

#make!Object



33
34
35
36
# File 'app/models/telephony/call.rb', line 33

def make!
  provider_call = Telephony.provider.call id, number(true), caller_id
  update_attribute :sid, provider_call.sid
end

#number(with_protocol = false) ⇒ Object



21
22
23
24
25
26
27
# File 'app/models/telephony/call.rb', line 21

def number with_protocol = false
  if agent
    agent.number with_protocol
  else
    customer_number
  end
end

#record!(options) ⇒ Object



51
52
53
54
55
56
57
# File 'app/models/telephony/call.rb', line 51

def record!(options)
  if options.include?(:RecordingUrl) && options.include?(:RecordingDuration)
    recordings.create url: options[:RecordingUrl],
                      duration: options[:RecordingDuration],
                      start_time: options[:RecordingDuration].to_i.seconds.ago
  end
end

#recorded?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/models/telephony/call.rb', line 59

def recorded?
  agent.nil?
end

#redirect_to_conferenceObject



71
72
73
# File 'app/models/telephony/call.rb', line 71

def redirect_to_conference
  Telephony.provider.redirect_to_conference id, sid
end

#redirect_to_dialObject



63
64
65
# File 'app/models/telephony/call.rb', line 63

def redirect_to_dial
  Telephony.provider.redirect_to_dial id, sid
end

#redirect_to_holdObject



75
76
77
# File 'app/models/telephony/call.rb', line 75

def redirect_to_hold
  Telephony.provider.redirect_to_hold id, sid
end

#redirect_to_inbound_connect(csr_id) ⇒ Object



67
68
69
# File 'app/models/telephony/call.rb', line 67

def redirect_to_inbound_connect csr_id
  Telephony.provider.redirect_to_inbound_connect csr_id, sid
end

#sanitized_numberObject



29
30
31
# File 'app/models/telephony/call.rb', line 29

def sanitized_number
  normalize_number(number)
end

#whitelisted_number?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/telephony/call.rb', line 47

def whitelisted_number?
  agent || number != Telephony.provider.uncallable_number
end