Module: Signalwire::Relay::Calling::CallConvenienceMethods

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

Instance Method Summary collapse

Instance Method Details

#play_audio(url_p = nil, volume_p = nil, **args) ⇒ Object



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

def play_audio(url_p = nil, volume_p = nil, **args)
  url = args.delete(:url)
  volume = args.delete(:volume)
  set_parameters(binding, %i{url volume}, %i{url})

  play(play: audio_payload(url), volume: volume)
end

#play_audio!(url_p = nil, volume_p = nil, **args) ⇒ Object



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

def play_audio!(url_p = nil, volume_p = nil, **args)
  url = args.delete(:url)
  volume = args.delete(:volume)
  set_parameters(binding, %i{url volume}, %i{url})

  play!(play: audio_payload(url), volume: volume)
end

#play_ringtone(name:, duration: nil) ⇒ Object



38
39
40
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 38

def play_ringtone(name:, duration: nil)
  play ringtone_payload(name, duration)
end

#play_ringtone!(name:, duration: nil) ⇒ Object



42
43
44
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 42

def play_ringtone!(name:, duration: nil)
  play ringtone_payload(name, duration)
end

#play_silence(duration) ⇒ Object



19
20
21
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 19

def play_silence(duration)
  play silence_payload(duration)
end

#play_silence!(duration) ⇒ Object



23
24
25
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 23

def play_silence!(duration)
  play! silence_payload(duration)
end

#play_tts(text_p = nil, language_p = Relay::DEFAULT_LANGUAGE, gender_p = Relay::DEFAULT_GENDER, volume_p = nil, text: nil, language: Relay::DEFAULT_LANGUAGE, gender: Relay::DEFAULT_GENDER, volume: nil) ⇒ Object



27
28
29
30
31
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 27

def play_tts(text_p=nil, language_p=Relay::DEFAULT_LANGUAGE, gender_p=Relay::DEFAULT_GENDER, volume_p=nil, text: nil, language: Relay::DEFAULT_LANGUAGE, gender: Relay::DEFAULT_GENDER, volume: nil)
  set_parameters(binding, %i{text language gender volume}, %i{text})

  play play: tts_payload(text, language, gender), volume: volume
end

#play_tts!(text_p = nil, language_p = Relay::DEFAULT_LANGUAGE, gender_p = Relay::DEFAULT_GENDER, text: nil, language: Relay::DEFAULT_LANGUAGE, gender: Relay::DEFAULT_GENDER, volume: nil) ⇒ Object



33
34
35
36
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 33

def play_tts!(text_p=nil, language_p=Relay::DEFAULT_LANGUAGE, gender_p=Relay::DEFAULT_GENDER, text: nil, language: Relay::DEFAULT_LANGUAGE, gender: Relay::DEFAULT_GENDER, volume: nil)
  set_parameters(binding, %i{text language gender volume}, %i{text})
  play! tts_payload(text, language, gender), volume: volume
end

#prompt_audio(collect_p = nil, url_p = nil, volume_p = nil, **args) ⇒ Object



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

def prompt_audio(collect_p = nil, url_p = nil, volume_p=nil, **args)
  collect = args.delete(:collect)
  url = args.delete(:url)
  volume = args.delete(:volume)
  collect = compile_collect_arguments(args) if collect.nil? && collect_p.nil?
  set_parameters(binding, %i{collect url volume}, %i{collect url})

  prompt(collect: collect, play: audio_payload(url), volume: volume)
end

#prompt_audio!(collect_p = nil, url_p = nil, volume_p = nil, **args) ⇒ Object



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

def prompt_audio!(collect_p = nil, url_p = nil, volume_p=nil, **args)
  collect = args.delete(:collect)
  url = args.delete(:url)
  volume = args.delete(:volume)
  collect = compile_collect_arguments(args) if collect.nil? && collect_p.nil?
  set_parameters(binding, %i{collect url volume}, %i{collect url})

  prompt!(collect: collect, play: audio_payload(url), volume: volume)
end

#prompt_ringtone(collect: nil, name:, duration: nil, **args) ⇒ Object



109
110
111
112
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 109

def prompt_ringtone(collect: nil, name:, duration: nil, **args)
  collect = compile_collect_arguments(args) if collect.nil?
  prompt(collect: collect, play: ringtone_payload(name, duration))
end

#prompt_ringtone!(collect: nil, name:, duration: nil, **args) ⇒ Object



114
115
116
117
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 114

def prompt_ringtone!(collect: nil, name:, duration: nil, **args)
  collect = compile_collect_arguments(args) if collect.nil?
  prompt!(collect: collect, play: ringtone_payload(name, duration))
end

#prompt_silence(collect_p = nil, duration_p = nil, **args) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 66

def prompt_silence(collect_p = nil, duration_p = nil, **args)
  collect = args.delete(:collect)
  duration = args.delete(:duration)
  collect = compile_collect_arguments(args) if collect.nil? && collect_p.nil?
  set_parameters(binding, %i{collect duration}, %i{collect duration})

  prompt(collect: collect, play: silence_payload(duration))
end

#prompt_silence!(collect_p = nil, duration_p = nil, **args) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 75

def prompt_silence!(collect_p = nil, duration_p = nil, **args)
  collect = args.delete(:collect)
  duration = args.delete(:duration)
  collect = compile_collect_arguments(args) if collect.nil? && collect_p.nil?
  set_parameters(binding, %i{collect duration}, %i{collect duration})

  prompt!(collect: collect, play: silence_payload(duration))
end

#prompt_tts(collect_p = nil, text_p = nil, volume_p = nil, language_p = Relay::DEFAULT_LANGUAGE, gender_p = Relay::DEFAULT_GENDER, **args) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 84

def prompt_tts(collect_p = nil, text_p = nil, volume_p=nil, language_p=Relay::DEFAULT_LANGUAGE, gender_p=Relay::DEFAULT_GENDER, **args)
  collect = args.delete(:collect)
  text = args.delete(:text)
  volume = args.delete(:volume)
  language = args.delete(:language) || Relay::DEFAULT_LANGUAGE
  gender = args.delete(:gender) || Relay::DEFAULT_GENDER
  collect = compile_collect_arguments(args) if collect.nil? && collect_p.nil?

  set_parameters(binding, %i{collect text language gender volume}, %i{collect text})
  prompt(collect: collect, play: tts_payload(text, language, gender), volume: volume)
end

#prompt_tts!(collect_p = nil, text_p = nil, volume_p = nil, language_p = Relay::DEFAULT_LANGUAGE, gender_p = Relay::DEFAULT_GENDER, **args) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 96

def prompt_tts!(collect_p = nil, text_p = nil, volume_p=nil, language_p=Relay::DEFAULT_LANGUAGE, gender_p=Relay::DEFAULT_GENDER, **args)
  collect = args.delete(:collect)
  text = args.delete(:text)
  volume = args.delete(:volume)
  language = args.delete(:language) || Relay::DEFAULT_LANGUAGE
  gender = args.delete(:gender) || Relay::DEFAULT_GENDER
  collect = compile_collect_arguments(args) if collect.nil? && collect_p.nil?

  set_parameters(binding, %i{collect text language gender volume}, %i{collect text})

  prompt!(collect: collect, play: tts_payload(text, language, gender), volume: volume)
end

#wait_for_answeredObject



123
124
125
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 123

def wait_for_answered
  wait_for(Relay::CallState::ANSWERED)
end

#wait_for_endedObject



131
132
133
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 131

def wait_for_ended
  wait_for(Relay::CallState::ENDED)
end

#wait_for_endingObject



127
128
129
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 127

def wait_for_ending
  wait_for(Relay::CallState::ENDING)
end

#wait_for_ringingObject



119
120
121
# File 'lib/signalwire/relay/calling/call_convenience_methods.rb', line 119

def wait_for_ringing
  wait_for(Relay::CallState::RINGING)
end