class Signalwire::Relay::Calling::Prompt
Attributes
input[R]
terminator[R]
type[R]
Public Class Methods
new(call:, collect:, play:, volume: nil)
click to toggle source
Calls superclass method
# 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
Public Instance Methods
event_type()
click to toggle source
# File lib/signalwire/relay/calling/component/prompt.rb, line 17 def event_type Relay::CallNotification::COLLECT end
inner_params()
click to toggle source
# 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()
click to toggle source
# File lib/signalwire/relay/calling/component/prompt.rb, line 13 def method Relay::ComponentMethod::PROMPT end
notification_handler(event)
click to toggle source
# 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)
click to toggle source
# File lib/signalwire/relay/calling/component/prompt.rb, line 51 def volume(setting) execute_subcommand '.volume', Signalwire::Relay::Calling::PromptVolumeResult, { volume: setting } end
Private Instance Methods
digit_event(result)
click to toggle source
# File lib/signalwire/relay/calling/component/prompt.rb, line 57 def digit_event(result) @successful = true @input = result.dig(:params, :digits) @terminator = result.dig(:params, :terminator) end
speech_event(result)
click to toggle source
# File lib/signalwire/relay/calling/component/prompt.rb, line 63 def speech_event(result) @successful = true @input = result.dig(:params, :text) @confidence = result.dig(:params, :confidence) end