Module: Signalwire::Relay::Calling::CallDetectMethods

Included in:
Call
Defined in:
lib/signalwire/relay/calling/call_detect_methods.rb

Instance Method Summary collapse

Instance Method Details

#amd(**args) ⇒ Object



24
25
26
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 24

def amd(**args)
  detect(type: :machine, **args)
end

#amd!(**args) ⇒ Object



28
29
30
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 28

def amd!(**args)
  detect!(type: :machine, **args)
end

#detect(type:, **args) ⇒ Object



4
5
6
7
8
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 4

def detect(type:, **args)
  component = build_detect_component(type, args)
  component.wait_for(Relay::CallDetectState::CED, Relay::CallDetectState::CNG)
  DetectResult.new(component: component)
end

#detect!(type:, **args) ⇒ Object



10
11
12
13
14
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 10

def detect!(type:, **args)
  component = build_detect_component(type, args)
  component.execute
  DetectAction.new(component: component)
end

#detect_answering_machine(**args) ⇒ Object



16
17
18
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 16

def detect_answering_machine(**args)
  detect(type: :machine, **args)
end

#detect_answering_machine!(**args) ⇒ Object



20
21
22
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 20

def detect_answering_machine!(**args)
  detect!(type: :machine, **args)
end

#detect_digit(digits: nil, timeout: Relay::DEFAULT_CALL_TIMEOUT) ⇒ Object



86
87
88
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 86

def detect_digit(digits: nil, timeout: Relay::DEFAULT_CALL_TIMEOUT)
  detect(type: :digit, digits: digits, timeout: timeout)
end

#detect_digit!(digits: nil, timeout: Relay::DEFAULT_CALL_TIMEOUT) ⇒ Object



90
91
92
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 90

def detect_digit!(digits: nil, timeout: Relay::DEFAULT_CALL_TIMEOUT)
  detect!(type: :digit, digits: digits, timeout: timeout)
end

#detect_fax(tone: nil, timeout: Relay::DEFAULT_CALL_TIMEOUT) ⇒ Object



78
79
80
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 78

def detect_fax(tone: nil, timeout: Relay::DEFAULT_CALL_TIMEOUT)
  detect(type: :fax, tone: tone, timeout: timeout)
end

#detect_fax!(tone: nil, timeout: Relay::DEFAULT_CALL_TIMEOUT) ⇒ Object



82
83
84
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 82

def detect_fax!(tone: nil, timeout: Relay::DEFAULT_CALL_TIMEOUT)
  detect!(type: :fax, tone: tone, timeout: timeout)    
end

#detect_human(params: {}, timeout: Relay::DEFAULT_CALL_TIMEOUT) ⇒ Object

deprecated since version 2.2. Will be deleted in version 3.0.



33
34
35
36
37
38
39
40
41
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 33

def detect_human(params: {}, timeout: Relay::DEFAULT_CALL_TIMEOUT)
  detect = {
    type: Relay::CallDetectType::MACHINE,
    params: params
  }
  component = Signalwire::Relay::Calling::Detect.new(call: self, detect: detect, timeout: timeout)
  component.wait_for(Relay::CallDetectState::MACHINE, Relay::CallDetectState::UNKNOWN, Relay::CallDetectState::HUMAN)
  DetectResult.new(component: component)
end

#detect_human!(params: {}, timeout: Relay::DEFAULT_CALL_TIMEOUT) ⇒ Object

deprecated since version 2.2. Will be deleted in version 3.0.



44
45
46
47
48
49
50
51
52
53
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 44

def detect_human!(params: {}, timeout: Relay::DEFAULT_CALL_TIMEOUT)
  detect = {
    type: Relay::CallDetectType::MACHINE,
    params: params
  }
  component = Signalwire::Relay::Calling::Detect.new(call: self, detect: detect, timeout: timeout)
  component.setup_waiting_events([Relay::CallDetectState::MACHINE, Relay::CallDetectState::UNKNOWN, Relay::CallDetectState::HUMAN])
  component.execute
  DetectAction.new(component: component)
end

#detect_machine(params: {}, timeout: Relay::DEFAULT_CALL_TIMEOUT) ⇒ Object

deprecated since version 2.2. Will be deleted in version 3.0.



56
57
58
59
60
61
62
63
64
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 56

def detect_machine(params: {}, timeout: Relay::DEFAULT_CALL_TIMEOUT)
  detect = {
    type: Relay::CallDetectType::MACHINE,
    params: params
  }
  component = Signalwire::Relay::Calling::Detect.new(call: self, detect: detect, timeout: timeout)
  component.wait_for(Relay::CallDetectState::MACHINE, Relay::CallDetectState::UNKNOWN, Relay::CallDetectState::HUMAN)
  DetectResult.new(component: component)
end

#detect_machine!(params: {}, timeout: Relay::DEFAULT_CALL_TIMEOUT) ⇒ Object

deprecated since version 2.2. Will be deleted in version 3.0.



67
68
69
70
71
72
73
74
75
76
# File 'lib/signalwire/relay/calling/call_detect_methods.rb', line 67

def detect_machine!(params: {}, timeout: Relay::DEFAULT_CALL_TIMEOUT)
  detect = {
    type: Relay::CallDetectType::MACHINE,
    params: params
  }
  component = Signalwire::Relay::Calling::Detect.new(call: self, detect: detect, timeout: timeout)
  component.setup_waiting_events([Relay::CallDetectState::MACHINE, Relay::CallDetectState::UNKNOWN, Relay::CallDetectState::HUMAN])
  component.execute
  DetectAction.new(component: component)                                
end