vonage 7.26.0 → 7.27.1

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.
@@ -13,6 +13,8 @@ module Vonage
13
13
 
14
14
  # Create a list item
15
15
  #
16
+ # @deprecated
17
+ #
16
18
  # @example
17
19
  # response = proactive_connect.item.create(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', data: {name: 'Joe Bloggs', email: 'joe@email.com'})
18
20
  #
@@ -25,6 +27,7 @@ module Vonage
25
27
  # @see https://developer.vonage.com/en/api/proactive-connect#itemsCreate
26
28
  #
27
29
  def create(list_id:, data:)
30
+ logger.info('This method is deprecated and will be removed in a future release.')
28
31
  raise ArgumentError.new(":data must be a Hash") unless data.is_a? Hash
29
32
  request(
30
33
  "/v0.1/bulk/lists/#{list_id}/items",
@@ -35,6 +38,8 @@ module Vonage
35
38
 
36
39
  # Get list item by id
37
40
  #
41
+ # @deprecated
42
+ #
38
43
  # @example
39
44
  # response = proactive_connect.item.find(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', item_id: 'd97ebf20-e4de-4e50-921a-7bb4dceb373a')
40
45
  #
@@ -47,11 +52,14 @@ module Vonage
47
52
  # @see https://developer.vonage.com/en/api/proactive-connect#itemsGet
48
53
  #
49
54
  def find(list_id:, item_id:)
55
+ logger.info('This method is deprecated and will be removed in a future release.')
50
56
  request("/v0.1/bulk/lists/#{list_id}/items/#{item_id}")
51
57
  end
52
58
 
53
59
  # Update list item
54
60
  #
61
+ # @deprecated
62
+ #
55
63
  # @example
56
64
  # response = proactive_connect.item.create(
57
65
  # list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865',
@@ -73,6 +81,7 @@ module Vonage
73
81
  # @see https://developer.vonage.com/en/api/proactive-connect#itemsUpdate
74
82
  #
75
83
  def update(list_id:, item_id:, data:)
84
+ logger.info('This method is deprecated and will be removed in a future release.')
76
85
  raise ArgumentError.new(":data must be a Hash") unless data.is_a? Hash
77
86
  request(
78
87
  "/v0.1/bulk/lists/#{list_id}/items/#{item_id}",
@@ -83,6 +92,8 @@ module Vonage
83
92
 
84
93
  # Delete list item
85
94
  #
95
+ # @deprecated
96
+ #
86
97
  # @example
87
98
  # response = proactive_connect.item.delete(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', item_id: 'd97ebf20-e4de-4e50-921a-7bb4dceb373a')
88
99
  #
@@ -95,6 +106,7 @@ module Vonage
95
106
  # @see https://developer.vonage.com/en/api/proactive-connect#itemsDelete
96
107
  #
97
108
  def delete(list_id:, item_id:)
109
+ logger.info('This method is deprecated and will be removed in a future release.')
98
110
  request(
99
111
  "/v0.1/bulk/lists/#{list_id}/items/#{item_id}",
100
112
  type: Delete
@@ -11,6 +11,8 @@ module Vonage
11
11
 
12
12
  # Find all list items
13
13
  #
14
+ # @deprecated
15
+ #
14
16
  # @example
15
17
  # response = proactive_connect.items.list(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
16
18
  #
@@ -29,6 +31,7 @@ module Vonage
29
31
  # @see https://developer.vonage.com/en/api/proactive-connect#itemsFindAll
30
32
  #
31
33
  def list(list_id:, **params)
34
+ logger.info('This method is deprecated and will be removed in a future release.')
32
35
  path = "/v0.1/bulk/lists/#{list_id}/items"
33
36
  path += "?#{Params.encode(params)}" unless params.empty?
34
37
 
@@ -37,6 +40,8 @@ module Vonage
37
40
 
38
41
  # Download list items as a CSV file format
39
42
  #
43
+ # @deprecated
44
+ #
40
45
  # @example
41
46
  # response = proactive_connect.items.download_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
42
47
  #
@@ -64,6 +69,7 @@ module Vonage
64
69
  # @see https://developer.vonage.com/en/api/proactive-connect#itemsDownload
65
70
  #
66
71
  def download_csv(list_id:, order: 'asc', **params)
72
+ logger.info('This method is deprecated and will be removed in a future release.')
67
73
  response = request("/v0.1/bulk/lists/#{list_id}/items/download?order=#{order}", response_class: FileResponse)
68
74
 
69
75
  response.filename = params[:filename] if params[:filename]
@@ -74,6 +80,8 @@ module Vonage
74
80
 
75
81
  # Import list items from a CSV file
76
82
  #
83
+ # @deprecated
84
+ #
77
85
  # @example
78
86
  # response = proactive_connect.items.upload_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', filepath: '/files/import.csv')
79
87
  #
@@ -96,6 +104,7 @@ module Vonage
96
104
  # @see https://developer.vonage.com/en/api/proactive-connect#itemsImport
97
105
  #
98
106
  def upload_csv(list_id:, filepath:)
107
+ logger.info('This method is deprecated and will be removed in a future release.')
99
108
  pn = Pathname.new(filepath)
100
109
  raise ArgumentError, ':filepath not for a file' unless pn.file?
101
110
  raise ArgumentError, 'file at :filepath not readable' unless pn.readable?
@@ -13,6 +13,8 @@ module Vonage
13
13
 
14
14
  # Create list
15
15
  #
16
+ # @deprecated
17
+ #
16
18
  # @example
17
19
  # response = proactive_connect.list.create(name: 'List Number 1')
18
20
  #
@@ -47,6 +49,7 @@ module Vonage
47
49
  # @see https://developer.vonage.com/en/api/proactive-connect#listsCreate
48
50
  #
49
51
  def create(name:, **params)
52
+ logger.info('This method is deprecated and will be removed in a future release.')
50
53
  request(
51
54
  "/v0.1/bulk/lists",
52
55
  params: params.merge({ name: name }),
@@ -56,6 +59,8 @@ module Vonage
56
59
 
57
60
  # Get list by id
58
61
  #
62
+ # @deprecated
63
+ #
59
64
  # @example
60
65
  # response = proactive_connect.list.find(id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
61
66
  #
@@ -65,11 +70,14 @@ module Vonage
65
70
  # @see https://developer.vonage.com/en/api/proactive-connect#listsGet
66
71
  #
67
72
  def find(id:)
73
+ logger.info('This method is deprecated and will be removed in a future release.')
68
74
  request("/v0.1/bulk/lists/#{id}")
69
75
  end
70
76
 
71
77
  # Update list
72
78
  #
79
+ # @deprecated
80
+ #
73
81
  # @example
74
82
  # response = proactive_connect.list.update(name: 'List Number 1')
75
83
  #
@@ -107,6 +115,7 @@ module Vonage
107
115
  # @see https://developer.vonage.com/en/api/proactive-connect#listsUpdate
108
116
  #
109
117
  def update(id:, name:, **params)
118
+ logger.info('This method is deprecated and will be removed in a future release.')
110
119
  request(
111
120
  "/v0.1/bulk/lists/#{id}",
112
121
  params: params.merge({ name: name }),
@@ -116,6 +125,8 @@ module Vonage
116
125
 
117
126
  # Delete a list by id
118
127
  #
128
+ # @deprecated
129
+ #
119
130
  # @example
120
131
  # response = proactive_connect.list.delete(id: '74ea1ecf-06c9-4072-a285-61677bd353e8')
121
132
  #
@@ -125,6 +136,7 @@ module Vonage
125
136
  # @see https://developer.vonage.com/en/api/proactive-connect#listsDelete
126
137
  #
127
138
  def delete(id:)
139
+ logger.info('This method is deprecated and will be removed in a future release.')
128
140
  request(
129
141
  "/v0.1/bulk/lists/#{id}",
130
142
  type: Delete
@@ -133,6 +145,8 @@ module Vonage
133
145
 
134
146
  # Clear list by deleting all items
135
147
  #
148
+ # @deprecated
149
+ #
136
150
  # @example
137
151
  # response = proactive_connect.list.clear_items(id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
138
152
  #
@@ -142,6 +156,7 @@ module Vonage
142
156
  # @see https://developer.vonage.com/en/api/proactive-connect#listsClear
143
157
  #
144
158
  def clear_items(id:)
159
+ logger.info('This method is deprecated and will be removed in a future release.')
145
160
  request(
146
161
  "/v0.1/bulk/lists/#{id}/clear",
147
162
  type: Post
@@ -150,6 +165,8 @@ module Vonage
150
165
 
151
166
  # Fetch and replace all items from datasource
152
167
  #
168
+ # @deprecated
169
+ #
153
170
  # @example
154
171
  # response = proactive_connect.list.fetch_and_replace_items(id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
155
172
  #
@@ -159,6 +176,7 @@ module Vonage
159
176
  # @see https://developer.vonage.com/en/api/proactive-connect#listsFetch
160
177
  #
161
178
  def fetch_and_replace_items(id:)
179
+ logger.info('This method is deprecated and will be removed in a future release.')
162
180
  request(
163
181
  "/v0.1/bulk/lists/#{id}/fetch",
164
182
  type: Post
@@ -11,6 +11,8 @@ module Vonage
11
11
 
12
12
  # Find all lists
13
13
  #
14
+ # @deprecated
15
+ #
14
16
  # @example
15
17
  # response = proactive_connect.lists.list
16
18
  #
@@ -26,6 +28,7 @@ module Vonage
26
28
  # @see https://developer.vonage.com/en/api/proactive-connect#listsFindAll
27
29
  #
28
30
  def list(**params)
31
+ logger.info('This method is deprecated and will be removed in a future release.')
29
32
  path = "/v0.1/bulk/lists"
30
33
  path += "?#{Params.encode(params)}" unless params.empty?
31
34
 
@@ -5,28 +5,38 @@ module Vonage
5
5
  class ProactiveConnect < Namespace
6
6
  extend T::Sig
7
7
 
8
+ # @deprecated
8
9
  sig { returns(T.nilable(Vonage::ProactiveConnect::Lists)) }
9
10
  def lists
11
+ logger.info('This method is deprecated and will be removed in a future release.')
10
12
  @lists ||= Lists.new(@config)
11
13
  end
12
14
 
15
+ # @deprecated
13
16
  sig { returns(T.nilable(Vonage::ProactiveConnect::List)) }
14
17
  def list
18
+ logger.info('This method is deprecated and will be removed in a future release.')
15
19
  @list ||= List.new(@config)
16
20
  end
17
21
 
22
+ # @deprecated
18
23
  sig { returns(T.nilable(Vonage::ProactiveConnect::Items)) }
19
24
  def items
25
+ logger.info('This method is deprecated and will be removed in a future release.')
20
26
  @items ||= Items.new(@config)
21
27
  end
22
28
 
29
+ # @deprecated
23
30
  sig { returns(T.nilable(Vonage::ProactiveConnect::Item)) }
24
31
  def item
32
+ logger.info('This method is deprecated and will be removed in a future release.')
25
33
  @item ||= Item.new(@config)
26
34
  end
27
35
 
36
+ # @deprecated
28
37
  sig { returns(T.nilable(Vonage::ProactiveConnect::Events)) }
29
38
  def events
39
+ logger.info('This method is deprecated and will be removed in a future release.')
30
40
  @events ||= Events.new(@config)
31
41
  end
32
42
  end
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- VERSION = '7.26.0'
4
+ VERSION = '7.27.1'
5
5
  end
@@ -107,9 +107,13 @@ module Vonage
107
107
  end
108
108
 
109
109
  def verify_event_url
110
- uri = URI.parse(self.eventUrl)
110
+ unless self.eventUrl.is_a?(Array) && self.eventUrl.length == 1 && self.eventUrl[0].is_a?(String)
111
+ raise ClientError.new("Expected 'eventUrl' parameter to be an Array containing a single string item")
112
+ end
113
+
114
+ uri = URI.parse(self.eventUrl[0])
111
115
 
112
- raise ClientError.new("Invalid 'eventUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
116
+ raise ClientError.new("Invalid 'eventUrl' value, array must contain a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
113
117
 
114
118
  self.eventUrl
115
119
  end
@@ -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