Class: Signalwire::Relay::Calling::Prompt
- Inherits:
-
ControlComponent
- Object
- Component
- ControlComponent
- Signalwire::Relay::Calling::Prompt
- Defined in:
- lib/signalwire/relay/calling/component/prompt.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#terminator ⇒ Object
readonly
Returns the value of attribute terminator.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Component
#blocker, #call, #completed, #event, #execute_result, #state, #successful
Instance Method Summary collapse
- #event_type ⇒ Object
-
#initialize(call:, collect:, play:, volume: nil) ⇒ Prompt
constructor
A new instance of Prompt.
- #inner_params ⇒ Object
- #method ⇒ Object
- #notification_handler(event) ⇒ Object
- #volume(setting) ⇒ Object
Methods inherited from ControlComponent
#control_id, #execute_subcommand, #setup_handlers, #stop
Methods inherited from Component
#after_execute, #check_for_waiting_events, #create_blocker, #execute, #execute_params, #handle_execute_result, #has_blocker?, #payload, #setup_handlers, #setup_waiting_events, #terminate, #unblock, #wait_for, #wait_on_blocker
Methods included from Logger
Constructor Details
#initialize(call:, collect:, play:, volume: nil) ⇒ Prompt
Returns a new instance of Prompt.
6 7 8 9 10 11 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 6 def initialize(call:, collect:, play:, volume: nil) super(call: call) @play = play @collect = collect @volume = volume end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
5 6 7 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 5 def input @input end |
#terminator ⇒ Object (readonly)
Returns the value of attribute terminator.
5 6 7 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 5 def terminator @terminator end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 5 def type @type end |
Instance Method Details
#event_type ⇒ Object
17 18 19 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 17 def event_type Relay::CallNotification::COLLECT end |
#inner_params ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 21 def inner_params prm = { node_id: @call.node_id, call_id: @call.id, control_id: control_id, play: @play, collect: @collect } prm[:volume] = @volume unless @volume.nil? prm end |
#method ⇒ Object
13 14 15 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 13 def method Relay::ComponentMethod::PROMPT end |
#notification_handler(event) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 33 def notification_handler(event) @completed = true result = event.call_params[:result] @type = result[:type] @state = @type if @type == Relay::CallPromptState::DIGIT digit_event(result) elsif type == Relay::CallPromptState::SPEECH speech_event(result) else @state = @type @successful = false end check_for_waiting_events end |
#volume(setting) ⇒ Object
51 52 53 |
# File 'lib/signalwire/relay/calling/component/prompt.rb', line 51 def volume(setting) execute_subcommand '.volume', Signalwire::Relay::Calling::PromptVolumeResult, { volume: setting } end |