vonage 7.27.0 → 8.0.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +89 -388
- data/lib/vonage/applications.rb +4 -12
- data/lib/vonage/basic.rb +1 -1
- data/lib/vonage/bearer_token.rb +1 -1
- data/lib/vonage/client.rb +0 -65
- data/lib/vonage/client_error.rb +1 -1
- data/lib/vonage/config.rb +1 -9
- data/lib/vonage/conversations/events.rb +0 -12
- data/lib/vonage/conversations/legs.rb +0 -6
- data/lib/vonage/conversations/members.rb +0 -15
- data/lib/vonage/conversations/users.rb +0 -15
- data/lib/vonage/conversations.rb +0 -30
- data/lib/vonage/errors.rb +20 -37
- data/lib/vonage/gsm7.rb +1 -1
- data/lib/vonage/jwt.rb +0 -17
- data/lib/vonage/key_secret_params.rb +2 -3
- data/lib/vonage/keys.rb +1 -11
- data/lib/vonage/logger.rb +3 -5
- data/lib/vonage/messaging/channels/viber.rb +1 -8
- data/lib/vonage/messaging/channels/whats_app.rb +1 -3
- data/lib/vonage/messaging/message.rb +0 -1
- data/lib/vonage/messaging.rb +4 -34
- data/lib/vonage/namespace.rb +68 -137
- data/lib/vonage/numbers.rb +17 -40
- data/lib/vonage/server_error.rb +1 -1
- data/lib/vonage/signature.rb +5 -5
- data/lib/vonage/sms.rb +20 -20
- data/lib/vonage/version.rb +1 -1
- data/lib/vonage/video/archives.rb +53 -18
- data/lib/vonage/video/list_response.rb +11 -0
- data/lib/vonage/video/moderation.rb +22 -7
- data/lib/vonage/video/signals.rb +9 -4
- data/lib/vonage/video/streams.rb +12 -6
- data/lib/vonage/video.rb +13 -50
- data/lib/vonage/voice/actions/connect.rb +5 -34
- data/lib/vonage/voice/actions/conversation.rb +4 -10
- data/lib/vonage/voice/actions/input.rb +3 -19
- data/lib/vonage/voice/actions/notify.rb +3 -8
- data/lib/vonage/voice/actions/pay.rb +107 -0
- data/lib/vonage/voice/actions/record.rb +4 -52
- data/lib/vonage/voice/actions/stream.rb +4 -48
- data/lib/vonage/voice/actions/talk.rb +4 -54
- data/lib/vonage/voice/talk.rb +1 -11
- data/lib/vonage/voice.rb +0 -24
- data/lib/vonage.rb +0 -4
- data/vonage.gemspec +1 -3
- metadata +9 -104
- data/lib/vonage/api_error.rb +0 -33
- data/lib/vonage/conversation/event/list_response.rb +0 -11
- data/lib/vonage/conversation/event.rb +0 -108
- data/lib/vonage/conversation/list_response.rb +0 -11
- data/lib/vonage/conversation/member/list_response.rb +0 -11
- data/lib/vonage/conversation/member.rb +0 -134
- data/lib/vonage/conversation/user/conversations_list_response.rb +0 -11
- data/lib/vonage/conversation/user/sessions_list_response.rb +0 -11
- data/lib/vonage/conversation/user.rb +0 -67
- data/lib/vonage/conversation.rb +0 -164
- data/lib/vonage/meetings/applications.rb +0 -28
- data/lib/vonage/meetings/dial_in_numbers/list_response.rb +0 -11
- data/lib/vonage/meetings/dial_in_numbers.rb +0 -26
- data/lib/vonage/meetings/recordings.rb +0 -42
- data/lib/vonage/meetings/rooms/list_response.rb +0 -11
- data/lib/vonage/meetings/rooms.rb +0 -167
- data/lib/vonage/meetings/sessions/list_response.rb +0 -11
- data/lib/vonage/meetings/sessions.rb +0 -31
- data/lib/vonage/meetings/themes/list_response.rb +0 -11
- data/lib/vonage/meetings/themes.rb +0 -239
- data/lib/vonage/meetings.rb +0 -50
- data/lib/vonage/messaging/channels/rcs.rb +0 -42
- data/lib/vonage/network_authentication/client_authentication.rb +0 -39
- data/lib/vonage/network_authentication/server_authentication.rb +0 -47
- data/lib/vonage/network_authentication.rb +0 -22
- data/lib/vonage/network_number_verification.rb +0 -92
- data/lib/vonage/network_sim_swap.rb +0 -84
- data/lib/vonage/number_insight_2.rb +0 -36
- data/lib/vonage/proactive_connect/events/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/events.rb +0 -71
- data/lib/vonage/proactive_connect/item.rb +0 -116
- data/lib/vonage/proactive_connect/items/file_response.rb +0 -32
- data/lib/vonage/proactive_connect/items/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/items.rb +0 -116
- data/lib/vonage/proactive_connect/list.rb +0 -186
- data/lib/vonage/proactive_connect/lists/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/lists.rb +0 -38
- data/lib/vonage/proactive_connect.rb +0 -43
- data/lib/vonage/subaccounts/balance_transfers/list_response.rb +0 -11
- data/lib/vonage/subaccounts/credit_transfers/list_response.rb +0 -11
- data/lib/vonage/subaccounts/list_response.rb +0 -15
- data/lib/vonage/subaccounts.rb +0 -203
- data/lib/vonage/users/list_response.rb +0 -11
- data/lib/vonage/users.rb +0 -156
- data/lib/vonage/verify2/channels/email.rb +0 -36
- data/lib/vonage/verify2/channels/silent_auth.rb +0 -45
- data/lib/vonage/verify2/channels/sms.rb +0 -63
- data/lib/vonage/verify2/channels/voice.rb +0 -32
- data/lib/vonage/verify2/channels/whats_app.rb +0 -39
- data/lib/vonage/verify2/channels/whats_app_interactive.rb +0 -32
- data/lib/vonage/verify2/start_verification_options.rb +0 -63
- data/lib/vonage/verify2/workflow.rb +0 -39
- data/lib/vonage/verify2/workflow_builder.rb +0 -25
- data/lib/vonage/verify2.rb +0 -100
- data/lib/vonage/video/archives/list_response.rb +0 -11
- data/lib/vonage/video/broadcasts/list_response.rb +0 -11
- data/lib/vonage/video/broadcasts.rb +0 -75
- data/lib/vonage/video/captions.rb +0 -67
- data/lib/vonage/video/renders/list_response.rb +0 -11
- data/lib/vonage/video/renders.rb +0 -107
- data/lib/vonage/video/sip.rb +0 -48
- data/lib/vonage/video/streams/list_response.rb +0 -11
- data/lib/vonage/video/web_socket.rb +0 -61
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
module Vonage
|
5
5
|
class Voice::Actions::Input
|
6
|
-
attr_accessor :type, :dtmf, :speech, :eventUrl, :eventMethod
|
6
|
+
attr_accessor :type, :dtmf, :speech, :eventUrl, :eventMethod
|
7
7
|
|
8
8
|
def initialize(attributes = {})
|
9
9
|
@type = attributes.fetch(:type)
|
@@ -11,7 +11,6 @@ module Vonage
|
|
11
11
|
@speech = attributes.fetch(:speech, nil)
|
12
12
|
@eventUrl = attributes.fetch(:eventUrl, nil)
|
13
13
|
@eventMethod = attributes.fetch(:eventMethod, nil)
|
14
|
-
@mode = attributes.fetch(:mode, nil)
|
15
14
|
|
16
15
|
after_initialize!
|
17
16
|
end
|
@@ -34,10 +33,6 @@ module Vonage
|
|
34
33
|
if self.eventMethod
|
35
34
|
validate_event_method
|
36
35
|
end
|
37
|
-
|
38
|
-
if self.mode
|
39
|
-
validate_mode
|
40
|
-
end
|
41
36
|
end
|
42
37
|
|
43
38
|
def validate_type
|
@@ -88,13 +83,9 @@ module Vonage
|
|
88
83
|
end
|
89
84
|
|
90
85
|
def validate_event_url
|
91
|
-
|
92
|
-
raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
|
93
|
-
end
|
94
|
-
|
95
|
-
uri = URI.parse(self.eventUrl[0])
|
86
|
+
uri = URI.parse(self.eventUrl)
|
96
87
|
|
97
|
-
raise ClientError.new("Invalid 'eventUrl' value,
|
88
|
+
raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
98
89
|
|
99
90
|
self.eventUrl
|
100
91
|
end
|
@@ -105,12 +96,6 @@ module Vonage
|
|
105
96
|
raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
|
106
97
|
end
|
107
98
|
|
108
|
-
def validate_mode
|
109
|
-
valid_modes = ['asyncronous']
|
110
|
-
|
111
|
-
raise ClientError.new("Invalid 'mode' value, must be asyncronous'") unless valid_modes.include?(self.mode)
|
112
|
-
end
|
113
|
-
|
114
99
|
def action
|
115
100
|
create_input!(self)
|
116
101
|
end
|
@@ -127,7 +112,6 @@ module Vonage
|
|
127
112
|
ncco[0].merge!(speech: builder.speech) if builder.speech
|
128
113
|
ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
|
129
114
|
ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
|
130
|
-
ncco[0].merge!(mode: builder.mode) if builder.mode
|
131
115
|
|
132
116
|
ncco
|
133
117
|
end
|
@@ -22,15 +22,10 @@ module Vonage
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def validate_event_url
|
25
|
-
|
25
|
+
uri = URI.parse(self.eventUrl[0])
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
uri = URI.parse(event_url[0])
|
32
|
-
|
33
|
-
raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
27
|
+
raise ClientError.new("Expected 'eventUrl' value to be an Array with a single string") unless self.eventUrl.is_a?(Array)
|
28
|
+
raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
34
29
|
|
35
30
|
self.eventUrl
|
36
31
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
module Vonage
|
4
|
+
class Voice::Actions::Pay
|
5
|
+
attr_accessor :amount, :currency, :eventUrl, :prompts, :voice
|
6
|
+
|
7
|
+
def initialize(attributes= {})
|
8
|
+
@amount = attributes.fetch(:amount)
|
9
|
+
@currency = attributes.fetch(:currency, nil)
|
10
|
+
@eventUrl = attributes.fetch(:eventUrl, nil)
|
11
|
+
@prompts = attributes.fetch(:prompts, nil)
|
12
|
+
@voice = attributes.fetch(:voice, nil)
|
13
|
+
|
14
|
+
after_initialize!
|
15
|
+
end
|
16
|
+
|
17
|
+
def action
|
18
|
+
create_pay!(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_pay!(builder)
|
22
|
+
ncco = [
|
23
|
+
{
|
24
|
+
action: 'pay',
|
25
|
+
amount: builder.amount
|
26
|
+
}
|
27
|
+
]
|
28
|
+
|
29
|
+
ncco[0].merge!(currency: builder.currency) if builder.currency
|
30
|
+
ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
|
31
|
+
ncco[0].merge!(prompts: builder.prompts) if builder.prompts
|
32
|
+
ncco[0].merge!(voice: builder.voice) if builder.voice
|
33
|
+
|
34
|
+
ncco
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def after_initialize!
|
40
|
+
verify_amount
|
41
|
+
|
42
|
+
if self.eventUrl
|
43
|
+
verify_event_url
|
44
|
+
end
|
45
|
+
|
46
|
+
if self.prompts
|
47
|
+
verify_prompts
|
48
|
+
end
|
49
|
+
|
50
|
+
if self.voice
|
51
|
+
verify_voice
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def verify_amount
|
56
|
+
verify_amount_class
|
57
|
+
verify_amount_value
|
58
|
+
end
|
59
|
+
|
60
|
+
def verify_event_url
|
61
|
+
raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item") unless self.eventUrl.is_a?(Array)
|
62
|
+
|
63
|
+
uri = URI.parse(self.eventUrl[0])
|
64
|
+
|
65
|
+
raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
66
|
+
end
|
67
|
+
|
68
|
+
def verify_prompts
|
69
|
+
verify_prompts_structure
|
70
|
+
verify_prompts_values
|
71
|
+
end
|
72
|
+
|
73
|
+
def verify_voice
|
74
|
+
verify_voice_structure
|
75
|
+
verify_voice_style if self.voice[:style]
|
76
|
+
end
|
77
|
+
|
78
|
+
def verify_amount_class
|
79
|
+
raise ClientError.new("Invalid 'amount' value, must be a float") unless self.amount.is_a?(Float)
|
80
|
+
end
|
81
|
+
|
82
|
+
def verify_amount_value
|
83
|
+
raise ClientError.new("Invalid 'amount' value, must be greater than 0") unless self.amount > 0
|
84
|
+
end
|
85
|
+
|
86
|
+
def verify_prompts_structure
|
87
|
+
raise ClientError.new("Invalid 'prompt', must be an array of at least one hash") unless self.prompts.is_a?(Array) && !self.prompts.empty? && self.prompts.all?(Hash)
|
88
|
+
end
|
89
|
+
|
90
|
+
def verify_prompts_values
|
91
|
+
self.prompts.each do |prompt|
|
92
|
+
prompt_keys = prompt.keys
|
93
|
+
[:type, :text, :errors].each do |key|
|
94
|
+
raise ClientError.new("Invalid 'prompt', '#{key}' is required") unless prompt_keys.include?(key)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def verify_voice_structure
|
100
|
+
raise ClientError.new("Expected 'voice' value to be a Hash") unless self.voice.is_a?(Hash)
|
101
|
+
end
|
102
|
+
|
103
|
+
def verify_voice_style
|
104
|
+
raise ClientError.new("Expected 'style' value to be an Integer") unless self.voice[:style].is_a?(Integer)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
module Vonage
|
5
5
|
class Voice::Actions::Record
|
6
|
-
attr_accessor :format, :split, :channels, :endOnSilence, :endOnKey, :timeOut, :beepStart, :eventUrl, :eventMethod
|
6
|
+
attr_accessor :format, :split, :channels, :endOnSilence, :endOnKey, :timeOut, :beepStart, :eventUrl, :eventMethod
|
7
7
|
|
8
8
|
def initialize(attributes = {})
|
9
9
|
@format = attributes.fetch(:format, nil)
|
@@ -15,7 +15,6 @@ module Vonage
|
|
15
15
|
@beepStart = attributes.fetch(:beepStart, nil)
|
16
16
|
@eventUrl = attributes.fetch(:eventUrl, nil)
|
17
17
|
@eventMethod = attributes.fetch(:eventMethod, nil)
|
18
|
-
@transcription = attributes.fetch(:transcription, nil)
|
19
18
|
|
20
19
|
after_initialize!
|
21
20
|
end
|
@@ -56,10 +55,6 @@ module Vonage
|
|
56
55
|
if self.eventMethod
|
57
56
|
validate_event_method
|
58
57
|
end
|
59
|
-
|
60
|
-
if self.transcription
|
61
|
-
validate_transcription
|
62
|
-
end
|
63
58
|
end
|
64
59
|
|
65
60
|
def validate_format
|
@@ -95,13 +90,9 @@ module Vonage
|
|
95
90
|
end
|
96
91
|
|
97
92
|
def validate_event_url
|
98
|
-
|
99
|
-
raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
|
100
|
-
end
|
93
|
+
uri = URI.parse(self.eventUrl)
|
101
94
|
|
102
|
-
uri
|
103
|
-
|
104
|
-
raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
95
|
+
raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
105
96
|
|
106
97
|
self.eventUrl
|
107
98
|
end
|
@@ -109,45 +100,7 @@ module Vonage
|
|
109
100
|
def validate_event_method
|
110
101
|
valid_methods = ['GET', 'POST']
|
111
102
|
|
112
|
-
raise ClientError.new("Invalid 'eventMethod' value.
|
113
|
-
end
|
114
|
-
|
115
|
-
def validate_transcription
|
116
|
-
raise ClientError.new("Expected 'transcription' parameter to be a Hash") unless self.transcription.is_a?(Hash)
|
117
|
-
|
118
|
-
if self.transcription[:language]
|
119
|
-
raise ClientError.new("Invalid 'language' value, must be a String") unless self.transcription[:language].is_a?(String)
|
120
|
-
end
|
121
|
-
|
122
|
-
if self.transcription[:eventUrl]
|
123
|
-
event_url = self.transcription[:eventUrl]
|
124
|
-
|
125
|
-
unless event_url.is_a?(Array) && event_url.length == 1 && event_url[0].is_a?(String)
|
126
|
-
raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
|
127
|
-
end
|
128
|
-
|
129
|
-
uri = URI.parse(event_url[0])
|
130
|
-
|
131
|
-
raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
132
|
-
end
|
133
|
-
|
134
|
-
if self.transcription[:eventMethod]
|
135
|
-
event_method = self.transcription[:eventMethod]
|
136
|
-
raise ClientError.new("Invalid 'eventMethod' value, must be either: 'GET' or 'POST'") unless ['GET', 'POST'].include?(event_method.upcase)
|
137
|
-
end
|
138
|
-
|
139
|
-
if self.transcription[:sentimentAnalysis]
|
140
|
-
sentiment_analysis = self.transcription[:sentimentAnalysis]
|
141
|
-
raise ClientError.new("Invalid 'sentimentAnalysis' value, must be a Boolean") unless sentiment_analysis == true || sentiment_analysis == false
|
142
|
-
end
|
143
|
-
|
144
|
-
# if self.dtmf[:maxDigits]
|
145
|
-
# raise ClientError.new("Expected 'maxDigits' to not be more than 22") if self.dtmf[:maxDigits] > 22
|
146
|
-
# end
|
147
|
-
|
148
|
-
# if self.dtmf[:submitOnHash]
|
149
|
-
# raise ClientError.new("Invalid 'submitOnHash' value, must be a Boolean") unless self.dtmf[:submitOnHash] == true || self.dtmf[:submitOnHash] == false
|
150
|
-
# end
|
103
|
+
raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
|
151
104
|
end
|
152
105
|
|
153
106
|
def action
|
@@ -170,7 +123,6 @@ module Vonage
|
|
170
123
|
ncco[0].merge!(beepStart: builder.beepStart) if builder.beepStart
|
171
124
|
ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
|
172
125
|
ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
|
173
|
-
ncco[0].merge!(transcription: builder.transcription) if builder.transcription
|
174
126
|
|
175
127
|
ncco
|
176
128
|
end
|
@@ -3,16 +3,13 @@
|
|
3
3
|
|
4
4
|
module Vonage
|
5
5
|
class Voice::Actions::Stream
|
6
|
-
attr_accessor :streamUrl, :level, :bargeIn, :loop
|
6
|
+
attr_accessor :streamUrl, :level, :bargeIn, :loop
|
7
7
|
|
8
8
|
def initialize(attributes = {})
|
9
9
|
@streamUrl = attributes.fetch(:streamUrl)
|
10
10
|
@level = attributes.fetch(:level, nil)
|
11
11
|
@bargeIn = attributes.fetch(:bargeIn, nil)
|
12
12
|
@loop = attributes.fetch(:loop, nil)
|
13
|
-
@eventOnCompletion = attributes.fetch(:eventOnCompletion, nil)
|
14
|
-
@eventUrl = attributes.fetch(:eventUrl, nil)
|
15
|
-
@eventMethod = attributes.fetch(:eventMethod, nil)
|
16
13
|
|
17
14
|
after_initialize!
|
18
15
|
end
|
@@ -31,28 +28,12 @@ module Vonage
|
|
31
28
|
if self.loop
|
32
29
|
verify_loop
|
33
30
|
end
|
34
|
-
|
35
|
-
if self.eventOnCompletion || self.eventOnCompletion == false
|
36
|
-
verify_event_on_completion
|
37
|
-
end
|
38
|
-
|
39
|
-
if self.eventUrl
|
40
|
-
verify_event_url
|
41
|
-
end
|
42
|
-
|
43
|
-
if self.eventMethod
|
44
|
-
verify_event_method
|
45
|
-
end
|
46
31
|
end
|
47
32
|
|
48
33
|
def verify_stream_url
|
49
|
-
|
50
|
-
|
51
|
-
unless stream_url.is_a?(Array) && stream_url.length == 1 && stream_url[0].is_a?(String)
|
52
|
-
raise ClientError.new("Expected 'streamUrl' parameter to be an Array containing a single string item")
|
53
|
-
end
|
34
|
+
raise ClientError.new("Expected 'streamUrl' parameter to be an Array containing a single string item") unless self.streamUrl.is_a?(Array)
|
54
35
|
|
55
|
-
uri = URI.parse(
|
36
|
+
uri = URI.parse(self.streamUrl[0])
|
56
37
|
|
57
38
|
raise ClientError.new("Invalid 'streamUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
58
39
|
end
|
@@ -66,29 +47,7 @@ module Vonage
|
|
66
47
|
end
|
67
48
|
|
68
49
|
def verify_loop
|
69
|
-
raise ClientError.new("Expected 'loop' value to be either
|
70
|
-
end
|
71
|
-
|
72
|
-
def verify_event_on_completion
|
73
|
-
raise ClientError.new("Expected 'eventOnCompletion' value to be a Boolean") unless self.eventOnCompletion == true || self.eventOnCompletion == false
|
74
|
-
end
|
75
|
-
|
76
|
-
def verify_event_url
|
77
|
-
unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
|
78
|
-
raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
|
79
|
-
end
|
80
|
-
|
81
|
-
uri = URI.parse(self.eventUrl[0])
|
82
|
-
|
83
|
-
raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
84
|
-
|
85
|
-
self.eventUrl
|
86
|
-
end
|
87
|
-
|
88
|
-
def verify_event_method
|
89
|
-
valid_methods = ['GET', 'POST']
|
90
|
-
|
91
|
-
raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
|
50
|
+
raise ClientError.new("Expected 'loop' value to be either 1 or 0") unless self.loop == 1 || self.loop == 0
|
92
51
|
end
|
93
52
|
|
94
53
|
def action
|
@@ -106,9 +65,6 @@ module Vonage
|
|
106
65
|
ncco[0].merge!(level: builder.level) if builder.level
|
107
66
|
ncco[0].merge!(bargeIn: builder.bargeIn) if (builder.bargeIn || builder.bargeIn == false)
|
108
67
|
ncco[0].merge!(loop: builder.loop) if builder.loop
|
109
|
-
ncco[0].merge!(eventOnCompletion: builder.eventOnCompletion) if (builder.eventOnCompletion || builder.eventOnCompletion == false)
|
110
|
-
ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
|
111
|
-
ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
|
112
68
|
|
113
69
|
ncco
|
114
70
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
module Vonage
|
4
4
|
class Voice::Actions::Talk
|
5
|
-
attr_accessor :text, :bargeIn, :loop, :level, :language, :style
|
5
|
+
attr_accessor :text, :bargeIn, :loop, :level, :language, :style
|
6
6
|
|
7
7
|
def initialize(attributes= {})
|
8
8
|
@text = attributes.fetch(:text)
|
@@ -11,16 +11,12 @@ module Vonage
|
|
11
11
|
@level = attributes.fetch(:level, nil)
|
12
12
|
@language = attributes.fetch(:language, nil)
|
13
13
|
@style = attributes.fetch(:style, nil)
|
14
|
-
@premium = attributes.fetch(:premium, nil)
|
15
|
-
@eventOnCompletion = attributes.fetch(:eventOnCompletion, nil)
|
16
|
-
@eventUrl = attributes.fetch(:eventUrl, nil)
|
17
|
-
@eventMethod = attributes.fetch(:eventMethod, nil)
|
18
14
|
|
19
15
|
after_initialize!
|
20
16
|
end
|
21
17
|
|
22
18
|
def after_initialize!
|
23
|
-
if self.bargeIn
|
19
|
+
if self.bargeIn
|
24
20
|
verify_barge_in
|
25
21
|
end
|
26
22
|
|
@@ -35,22 +31,6 @@ module Vonage
|
|
35
31
|
if self.style
|
36
32
|
verify_style
|
37
33
|
end
|
38
|
-
|
39
|
-
if self.premium || self.premium == false
|
40
|
-
verify_premium
|
41
|
-
end
|
42
|
-
|
43
|
-
if self.eventOnCompletion || self.eventOnCompletion == false
|
44
|
-
verify_event_on_completion
|
45
|
-
end
|
46
|
-
|
47
|
-
if self.eventUrl
|
48
|
-
verify_event_url
|
49
|
-
end
|
50
|
-
|
51
|
-
if self.eventMethod
|
52
|
-
verify_event_method
|
53
|
-
end
|
54
34
|
end
|
55
35
|
|
56
36
|
def verify_barge_in
|
@@ -58,7 +38,7 @@ module Vonage
|
|
58
38
|
end
|
59
39
|
|
60
40
|
def verify_loop
|
61
|
-
raise ClientError.new("Expected 'loop' value to be either
|
41
|
+
raise ClientError.new("Expected 'loop' value to be either 1 or 0") unless self.loop == 1 || self.loop == 0
|
62
42
|
end
|
63
43
|
|
64
44
|
def verify_level
|
@@ -69,32 +49,6 @@ module Vonage
|
|
69
49
|
raise ClientError.new("Expected 'style' value to be an Integer") unless self.style.is_a?(Integer)
|
70
50
|
end
|
71
51
|
|
72
|
-
def verify_premium
|
73
|
-
raise ClientError.new("Expected 'premium' value to be a Boolean") unless self.premium == true || self.premium == false
|
74
|
-
end
|
75
|
-
|
76
|
-
def verify_event_on_completion
|
77
|
-
raise ClientError.new("Expected 'eventOnCompletion' value to be a Boolean") unless self.eventOnCompletion == true || self.eventOnCompletion == false
|
78
|
-
end
|
79
|
-
|
80
|
-
def verify_event_url
|
81
|
-
unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
|
82
|
-
raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
|
83
|
-
end
|
84
|
-
|
85
|
-
uri = URI.parse(self.eventUrl[0])
|
86
|
-
|
87
|
-
raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
88
|
-
|
89
|
-
self.eventUrl
|
90
|
-
end
|
91
|
-
|
92
|
-
def verify_event_method
|
93
|
-
valid_methods = ['GET', 'POST']
|
94
|
-
|
95
|
-
raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
|
96
|
-
end
|
97
|
-
|
98
52
|
def action
|
99
53
|
create_talk!(self)
|
100
54
|
end
|
@@ -112,12 +66,8 @@ module Vonage
|
|
112
66
|
ncco[0].merge!(level: builder.level) if builder.level
|
113
67
|
ncco[0].merge!(language: builder.language) if builder.language
|
114
68
|
ncco[0].merge!(style: builder.style) if builder.style
|
115
|
-
ncco[0].merge!(premium: builder.premium) if (builder.bargeIn || builder.bargeIn == false)
|
116
|
-
ncco[0].merge!(eventOnCompletion: builder.eventOnCompletion) if (builder.eventOnCompletion || builder.eventOnCompletion == false)
|
117
|
-
ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
|
118
|
-
ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
|
119
69
|
|
120
70
|
ncco
|
121
71
|
end
|
122
72
|
end
|
123
|
-
end
|
73
|
+
end
|
data/lib/vonage/voice/talk.rb
CHANGED
@@ -12,18 +12,8 @@ module Vonage
|
|
12
12
|
# @option params [required, String] :text
|
13
13
|
# The text to read.
|
14
14
|
#
|
15
|
-
# @option params [String] :language
|
16
|
-
# The language to use. See {https://developer.vonage.com/en/api/voice#startTalk-req-body} for a list of valid language codes.
|
17
|
-
#
|
18
|
-
# @option params [Integer] :style
|
19
|
-
# The vocal style, as identified by an assigned integer.
|
20
|
-
# See {https://developer.vonage.com/en/voice/voice-api/concepts/text-to-speech#supported-languages} for a list of available styles.
|
21
|
-
#
|
22
|
-
# @option params [Boolean] :premium
|
23
|
-
# Set to `true` to use the premium version of the specified style if available, otherwise the standard version will be used.
|
24
|
-
#
|
25
15
|
# @option params [String] :voice_name
|
26
|
-
# The voice & language to use.
|
16
|
+
# The voice & language to use.
|
27
17
|
#
|
28
18
|
# @option params [Integer] :loop
|
29
19
|
# The number of times to repeat the text the file, 0 for infinite.
|
data/lib/vonage/voice.rb
CHANGED
@@ -18,8 +18,6 @@ module Vonage
|
|
18
18
|
#
|
19
19
|
# @option params [required, Array<Hash>] :to
|
20
20
|
# Connect to a Phone (PSTN) number, SIP Endpoint, Websocket, or VBC extension.
|
21
|
-
# The `to` Hash can contain a number of different properties depending on the `type`.
|
22
|
-
# See the API reference for specific details.
|
23
21
|
#
|
24
22
|
# @option params [Hash] :from
|
25
23
|
# Connect to a Phone (PSTN) number. Should not be set if **:random_from_number** is **true**
|
@@ -50,17 +48,6 @@ module Vonage
|
|
50
48
|
# @option params [String] :machine_detection
|
51
49
|
# Configure the behavior when Vonage detects that the call is answered by voicemail.
|
52
50
|
#
|
53
|
-
# @option params [Hash] :advanced_machine_detection
|
54
|
-
# Configure the behavior of Vonage's advanced machine detection. Overrides machine_detection if both are set.
|
55
|
-
# Hash with three possible properties:
|
56
|
-
# - :behavior [String]: Must be one of `continue` or `hangup`. When hangup is used, the call will be terminated if a
|
57
|
-
# machine is detected. When continue is used, the call will continue even if a machine is detected.
|
58
|
-
# - :mode [String]: Must be one of `detect` or `detect_beep`. Detect if machine answered and sends a human or
|
59
|
-
# machine status in the webhook payload. When set to `detect_beep`, the system also attempts to detect
|
60
|
-
# voice mail beep and sends an additional parameter `sub_state` in the webhook with the value `beep_start`.
|
61
|
-
# - :beep_timeout [Integer]: Min: 45, Max: 120. Maximum time in seconds Vonage should wait for a machine beep
|
62
|
-
# to be detected. A machine event with `sub_state` set to `beep_timeout` will be sent if the timeout is exceeded.
|
63
|
-
#
|
64
51
|
# @option params [Integer] :length_timer
|
65
52
|
# Set the number of seconds that elapse before Vonage hangs up after the call state changes to in_progress.
|
66
53
|
#
|
@@ -281,16 +268,5 @@ module Vonage
|
|
281
268
|
def dtmf
|
282
269
|
@dtmf ||= DTMF.new(@config)
|
283
270
|
end
|
284
|
-
|
285
|
-
# Validate a JSON Web Token from a Voice API Webhook.
|
286
|
-
#
|
287
|
-
# @param [String, required] :token The JWT from the Webhook's Authorization header
|
288
|
-
# @param [String, optional] :signature_secret The account signature secret. Required, unless `signature_secret`
|
289
|
-
# is set in `Config`
|
290
|
-
#
|
291
|
-
# @return [Boolean] true, if the JWT is verified, false otherwise
|
292
|
-
def verify_webhook_token(token:, signature_secret: @config.signature_secret)
|
293
|
-
JWT.verify_hs256_signature(token: token, signature_secret: signature_secret)
|
294
|
-
end
|
295
271
|
end
|
296
272
|
end
|
data/lib/vonage.rb
CHANGED
@@ -7,16 +7,12 @@ module Vonage
|
|
7
7
|
loader = Zeitwerk::Loader.new
|
8
8
|
loader.tag = File.basename(__FILE__, '.rb')
|
9
9
|
loader.inflector.inflect({
|
10
|
-
'api_error' => 'APIError',
|
11
10
|
'dtmf' => 'DTMF',
|
12
11
|
'gsm7' => 'GSM7',
|
13
12
|
'http' => 'HTTP',
|
14
13
|
'json' => 'JSON',
|
15
14
|
'jwt' => 'JWT',
|
16
|
-
'rcs' => 'RCS',
|
17
|
-
'sip' => 'SIP',
|
18
15
|
'sms' => 'SMS',
|
19
|
-
'network_sim_swap' => 'NetworkSIMSwap',
|
20
16
|
'mms' => 'MMS',
|
21
17
|
'tfa' => 'TFA',
|
22
18
|
'version' => 'VERSION',
|
data/vonage.gemspec
CHANGED
@@ -12,11 +12,9 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = 'This is the Ruby Server SDK for Vonage APIs. To use it you\'ll need a Vonage account. Sign up for free at https://www.vonage.com'
|
13
13
|
s.files = Dir.glob('lib/**/*.rb') + %w(LICENSE.txt README.md vonage.gemspec)
|
14
14
|
s.required_ruby_version = '>= 2.5.0'
|
15
|
-
s.add_dependency('vonage-jwt', '~> 0.
|
15
|
+
s.add_dependency('vonage-jwt', '~> 0.1.0')
|
16
16
|
s.add_dependency('zeitwerk', '~> 2', '>= 2.2')
|
17
17
|
s.add_dependency('sorbet-runtime', '~> 0.5')
|
18
|
-
s.add_dependency('multipart-post', '~> 2.0')
|
19
|
-
s.add_dependency('net-http-persistent', '~> 4.0', '>= 4.0.2')
|
20
18
|
s.add_runtime_dependency('rexml')
|
21
19
|
s.add_runtime_dependency('phonelib')
|
22
20
|
s.require_path = 'lib'
|