vonage 7.25.0 → 7.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -13
  3. data/lib/vonage/basic.rb +1 -1
  4. data/lib/vonage/bearer_token.rb +1 -1
  5. data/lib/vonage/client.rb +14 -0
  6. data/lib/vonage/key_secret_params.rb +3 -2
  7. data/lib/vonage/keys.rb +4 -1
  8. data/lib/vonage/meetings/applications.rb +3 -0
  9. data/lib/vonage/meetings/dial_in_numbers.rb +3 -0
  10. data/lib/vonage/meetings/recordings.rb +6 -0
  11. data/lib/vonage/meetings/rooms.rb +12 -0
  12. data/lib/vonage/meetings/sessions.rb +3 -0
  13. data/lib/vonage/meetings/themes.rb +21 -0
  14. data/lib/vonage/meetings.rb +12 -0
  15. data/lib/vonage/messaging/channels/rcs.rb +42 -0
  16. data/lib/vonage/messaging/message.rb +1 -0
  17. data/lib/vonage/messaging.rb +15 -1
  18. data/lib/vonage/namespace.rb +9 -12
  19. data/lib/vonage/network_authentication/client_authentication.rb +39 -0
  20. data/lib/vonage/network_authentication/server_authentication.rb +47 -0
  21. data/lib/vonage/network_authentication.rb +22 -0
  22. data/lib/vonage/network_number_verification.rb +92 -0
  23. data/lib/vonage/network_sim_swap.rb +84 -0
  24. data/lib/vonage/numbers.rb +11 -11
  25. data/lib/vonage/proactive_connect/events.rb +3 -0
  26. data/lib/vonage/proactive_connect/item.rb +12 -0
  27. data/lib/vonage/proactive_connect/items.rb +9 -0
  28. data/lib/vonage/proactive_connect/list.rb +18 -0
  29. data/lib/vonage/proactive_connect/lists.rb +3 -0
  30. data/lib/vonage/proactive_connect.rb +10 -0
  31. data/lib/vonage/verify2/start_verification_options.rb +2 -1
  32. data/lib/vonage/version.rb +1 -1
  33. data/lib/vonage/voice/actions/connect.rb +7 -2
  34. data/lib/vonage/voice/actions/conversation.rb +8 -2
  35. data/lib/vonage/voice/actions/input.rb +19 -3
  36. data/lib/vonage/voice/actions/notify.rb +8 -3
  37. data/lib/vonage/voice/actions/record.rb +52 -4
  38. data/lib/vonage/voice/actions/stream.rb +48 -4
  39. data/lib/vonage/voice/actions/talk.rb +45 -4
  40. data/lib/vonage/voice.rb +2 -0
  41. data/lib/vonage.rb +2 -0
  42. metadata +8 -2
@@ -49,9 +49,15 @@ module Vonage
49
49
  end
50
50
 
51
51
  def verify_music_on_hold_url
52
- uri = URI.parse(self.musicOnHoldUrl)
52
+ music_on_hold_url = self.musicOnHoldUrl
53
53
 
54
- raise ClientError.new("Invalid 'musicOnHoldUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
54
+ unless music_on_hold_url.is_a?(Array) && music_on_hold_url.length == 1 && music_on_hold_url[0].is_a?(String)
55
+ raise ClientError.new("Expected 'musicOnHoldUrl' parameter to be an Array containing a single string item")
56
+ end
57
+
58
+ uri = URI.parse(music_on_hold_url[0])
59
+
60
+ raise ClientError.new("Invalid 'musicOnHoldUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
55
61
 
56
62
  self.musicOnHoldUrl
57
63
  end
@@ -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, :mode
7
7
 
8
8
  def initialize(attributes = {})
9
9
  @type = attributes.fetch(:type)
@@ -11,6 +11,7 @@ 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)
14
15
 
15
16
  after_initialize!
16
17
  end
@@ -33,6 +34,10 @@ module Vonage
33
34
  if self.eventMethod
34
35
  validate_event_method
35
36
  end
37
+
38
+ if self.mode
39
+ validate_mode
40
+ end
36
41
  end
37
42
 
38
43
  def validate_type
@@ -83,9 +88,13 @@ module Vonage
83
88
  end
84
89
 
85
90
  def validate_event_url
86
- uri = URI.parse(self.eventUrl)
91
+ unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
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])
87
96
 
88
- raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
97
+ raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
89
98
 
90
99
  self.eventUrl
91
100
  end
@@ -96,6 +105,12 @@ module Vonage
96
105
  raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
97
106
  end
98
107
 
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
+
99
114
  def action
100
115
  create_input!(self)
101
116
  end
@@ -112,6 +127,7 @@ module Vonage
112
127
  ncco[0].merge!(speech: builder.speech) if builder.speech
113
128
  ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
114
129
  ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
130
+ ncco[0].merge!(mode: builder.mode) if builder.mode
115
131
 
116
132
  ncco
117
133
  end
@@ -22,10 +22,15 @@ module Vonage
22
22
  end
23
23
 
24
24
  def validate_event_url
25
- uri = URI.parse(self.eventUrl[0])
25
+ event_url = self.eventUrl
26
26
 
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)
27
+ unless event_url.is_a?(Array) && event_url.length == 1 && event_url[0].is_a?(String)
28
+ raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
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)
29
34
 
30
35
  self.eventUrl
31
36
  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, :transcription
7
7
 
8
8
  def initialize(attributes = {})
9
9
  @format = attributes.fetch(:format, nil)
@@ -15,6 +15,7 @@ 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)
18
19
 
19
20
  after_initialize!
20
21
  end
@@ -55,6 +56,10 @@ module Vonage
55
56
  if self.eventMethod
56
57
  validate_event_method
57
58
  end
59
+
60
+ if self.transcription
61
+ validate_transcription
62
+ end
58
63
  end
59
64
 
60
65
  def validate_format
@@ -90,9 +95,13 @@ module Vonage
90
95
  end
91
96
 
92
97
  def validate_event_url
93
- uri = URI.parse(self.eventUrl)
98
+ unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
99
+ raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
100
+ end
94
101
 
95
- raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
102
+ uri = URI.parse(self.eventUrl[0])
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)
96
105
 
97
106
  self.eventUrl
98
107
  end
@@ -100,7 +109,45 @@ module Vonage
100
109
  def validate_event_method
101
110
  valid_methods = ['GET', 'POST']
102
111
 
103
- raise ClientError.new("Invalid 'eventMethod' value. must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
112
+ raise ClientError.new("Invalid 'eventMethod' value. Must be either: 'GET' or 'POST'") unless valid_methods.include?(self.eventMethod.upcase)
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
104
151
  end
105
152
 
106
153
  def action
@@ -123,6 +170,7 @@ module Vonage
123
170
  ncco[0].merge!(beepStart: builder.beepStart) if builder.beepStart
124
171
  ncco[0].merge!(eventUrl: builder.eventUrl) if builder.eventUrl
125
172
  ncco[0].merge!(eventMethod: builder.eventMethod) if builder.eventMethod
173
+ ncco[0].merge!(transcription: builder.transcription) if builder.transcription
126
174
 
127
175
  ncco
128
176
  end
@@ -3,13 +3,16 @@
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, :eventOnCompletion, :eventUrl, :eventMethod
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)
13
16
 
14
17
  after_initialize!
15
18
  end
@@ -28,12 +31,28 @@ module Vonage
28
31
  if self.loop
29
32
  verify_loop
30
33
  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
31
46
  end
32
47
 
33
48
  def verify_stream_url
34
- raise ClientError.new("Expected 'streamUrl' parameter to be an Array containing a single string item") unless self.streamUrl.is_a?(Array)
49
+ stream_url = self.streamUrl
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
35
54
 
36
- uri = URI.parse(self.streamUrl[0])
55
+ uri = URI.parse(stream_url[0])
37
56
 
38
57
  raise ClientError.new("Invalid 'streamUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
39
58
  end
@@ -47,7 +66,29 @@ module Vonage
47
66
  end
48
67
 
49
68
  def verify_loop
50
- raise ClientError.new("Expected 'loop' value to be either 1 or 0") unless self.loop == 1 || self.loop == 0
69
+ raise ClientError.new("Expected 'loop' value to be either 0 or a positive integer") unless self.loop >= 0
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)
51
92
  end
52
93
 
53
94
  def action
@@ -65,6 +106,9 @@ module Vonage
65
106
  ncco[0].merge!(level: builder.level) if builder.level
66
107
  ncco[0].merge!(bargeIn: builder.bargeIn) if (builder.bargeIn || builder.bargeIn == false)
67
108
  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
68
112
 
69
113
  ncco
70
114
  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, :premium
5
+ attr_accessor :text, :bargeIn, :loop, :level, :language, :style, :premium, :eventOnCompletion, :eventUrl, :eventMethod
6
6
 
7
7
  def initialize(attributes= {})
8
8
  @text = attributes.fetch(:text)
@@ -12,12 +12,15 @@ module Vonage
12
12
  @language = attributes.fetch(:language, nil)
13
13
  @style = attributes.fetch(:style, nil)
14
14
  @premium = attributes.fetch(:premium, nil)
15
+ @eventOnCompletion = attributes.fetch(:eventOnCompletion, nil)
16
+ @eventUrl = attributes.fetch(:eventUrl, nil)
17
+ @eventMethod = attributes.fetch(:eventMethod, nil)
15
18
 
16
19
  after_initialize!
17
20
  end
18
21
 
19
22
  def after_initialize!
20
- if self.bargeIn
23
+ if self.bargeIn || self.bargeIn == false
21
24
  verify_barge_in
22
25
  end
23
26
 
@@ -33,9 +36,21 @@ module Vonage
33
36
  verify_style
34
37
  end
35
38
 
36
- if self.premium
39
+ if self.premium || self.premium == false
37
40
  verify_premium
38
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
39
54
  end
40
55
 
41
56
  def verify_barge_in
@@ -43,7 +58,7 @@ module Vonage
43
58
  end
44
59
 
45
60
  def verify_loop
46
- raise ClientError.new("Expected 'loop' value to be either 1 or 0") unless self.loop == 1 || self.loop == 0
61
+ raise ClientError.new("Expected 'loop' value to be either 0 or a positive integer") unless self.loop >= 0
47
62
  end
48
63
 
49
64
  def verify_level
@@ -58,6 +73,28 @@ module Vonage
58
73
  raise ClientError.new("Expected 'premium' value to be a Boolean") unless self.premium == true || self.premium == false
59
74
  end
60
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
+
61
98
  def action
62
99
  create_talk!(self)
63
100
  end
@@ -75,6 +112,10 @@ module Vonage
75
112
  ncco[0].merge!(level: builder.level) if builder.level
76
113
  ncco[0].merge!(language: builder.language) if builder.language
77
114
  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
78
119
 
79
120
  ncco
80
121
  end
data/lib/vonage/voice.rb CHANGED
@@ -18,6 +18,8 @@ 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.
21
23
  #
22
24
  # @option params [Hash] :from
23
25
  # Connect to a Phone (PSTN) number. Should not be set if **:random_from_number** is **true**
data/lib/vonage.rb CHANGED
@@ -13,8 +13,10 @@ module Vonage
13
13
  'http' => 'HTTP',
14
14
  'json' => 'JSON',
15
15
  'jwt' => 'JWT',
16
+ 'rcs' => 'RCS',
16
17
  'sip' => 'SIP',
17
18
  'sms' => 'SMS',
19
+ 'network_sim_swap' => 'NetworkSIMSwap',
18
20
  'mms' => 'MMS',
19
21
  'tfa' => 'TFA',
20
22
  'version' => 'VERSION',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vonage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.25.0
4
+ version: 7.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-19 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vonage-jwt
@@ -184,11 +184,17 @@ files:
184
184
  - lib/vonage/messaging.rb
185
185
  - lib/vonage/messaging/channels/messenger.rb
186
186
  - lib/vonage/messaging/channels/mms.rb
187
+ - lib/vonage/messaging/channels/rcs.rb
187
188
  - lib/vonage/messaging/channels/sms.rb
188
189
  - lib/vonage/messaging/channels/viber.rb
189
190
  - lib/vonage/messaging/channels/whats_app.rb
190
191
  - lib/vonage/messaging/message.rb
191
192
  - lib/vonage/namespace.rb
193
+ - lib/vonage/network_authentication.rb
194
+ - lib/vonage/network_authentication/client_authentication.rb
195
+ - lib/vonage/network_authentication/server_authentication.rb
196
+ - lib/vonage/network_number_verification.rb
197
+ - lib/vonage/network_sim_swap.rb
192
198
  - lib/vonage/number_insight.rb
193
199
  - lib/vonage/number_insight_2.rb
194
200
  - lib/vonage/numbers.rb