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



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

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

#amd!(**args) ⇒ Object



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

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

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



4
5
6
7
8
9
# 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::MACHINE, Relay::CallDetectState::HUMAN,
    Relay::CallDetectState::UNKNOWN, Relay::CallDetectState::CED, Relay::CallDetectState::CNG)
  DetectResult.new(component: component)
end

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



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

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

#detect_answering_machine(**args) ⇒ Object



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

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

#detect_answering_machine!(**args) ⇒ Object



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

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

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



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

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



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

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



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

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



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

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.



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

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.



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

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.



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

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.



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

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