twilio-ruby 5.23.1 → 5.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +30 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +2 -2
  5. data/lib/twilio-ruby/rest/autopilot/v1/assistant.rb +26 -0
  6. data/lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb +437 -0
  7. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +7 -0
  8. data/lib/twilio-ruby/rest/insights/v1/summary.rb +7 -0
  9. data/lib/twilio-ruby/rest/preview/trusted_comms/current_call.rb +61 -5
  10. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +3 -19
  11. data/lib/twilio-ruby/rest/sync.rb +1 -1
  12. data/lib/twilio-ruby/rest/sync/v1.rb +1 -1
  13. data/lib/twilio-ruby/rest/sync/v1/service.rb +62 -6
  14. data/lib/twilio-ruby/rest/verify/v2/service.rb +26 -0
  15. data/lib/twilio-ruby/rest/verify/v2/service/rate_limit.rb +416 -0
  16. data/lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb +424 -0
  17. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +6 -1
  18. data/lib/twilio-ruby/twiml/voice_response.rb +3 -3
  19. data/lib/twilio-ruby/version.rb +1 -1
  20. data/spec/integration/api/v2010/account/conference/participant_spec.rb +142 -15
  21. data/spec/integration/api/v2010/account/conference_spec.rb +190 -20
  22. data/spec/integration/api/v2010/account/message_spec.rb +125 -51
  23. data/spec/integration/autopilot/v1/assistant/webhook_spec.rb +246 -0
  24. data/spec/integration/autopilot/v1/assistant_spec.rb +8 -4
  25. data/spec/integration/flex_api/v1/configuration_spec.rb +48 -0
  26. data/spec/integration/insights/v1/summary_spec.rb +1 -0
  27. data/spec/integration/preview/trusted_comms/current_call_spec.rb +9 -1
  28. data/spec/integration/sync/v1/service_spec.rb +12 -4
  29. data/spec/integration/verify/v2/service/rate_limit/bucket_spec.rb +249 -0
  30. data/spec/integration/verify/v2/service/rate_limit_spec.rb +221 -0
  31. data/spec/integration/verify/v2/service/verification_spec.rb +36 -0
  32. data/spec/integration/verify/v2/service_spec.rb +8 -4
  33. metadata +11 -2
@@ -0,0 +1,424 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Verify < Domain
12
+ class V2 < Version
13
+ class ServiceContext < InstanceContext
14
+ class RateLimitContext < InstanceContext
15
+ ##
16
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
17
+ class BucketList < ListResource
18
+ ##
19
+ # Initialize the BucketList
20
+ # @param [Version] version Version that contains the resource
21
+ # @param [String] service_sid The SID of the
22
+ # [Service](https://www.twilio.com/docs/verify/api-beta/service-beta) the resource
23
+ # is associated with.
24
+ # @param [String] rate_limit_sid The Twilio-provided string that uniquely
25
+ # identifies the Rate Limit resource.
26
+ # @return [BucketList] BucketList
27
+ def initialize(version, service_sid: nil, rate_limit_sid: nil)
28
+ super(version)
29
+
30
+ # Path Solution
31
+ @solution = {service_sid: service_sid, rate_limit_sid: rate_limit_sid}
32
+ @uri = "/Services/#{@solution[:service_sid]}/RateLimits/#{@solution[:rate_limit_sid]}/Buckets"
33
+ end
34
+
35
+ ##
36
+ # Retrieve a single page of BucketInstance records from the API.
37
+ # Request is executed immediately.
38
+ # @param [String] max Maximum number of requests permitted in during the interval.
39
+ # @param [String] interval Number of seconds that the rate limit will be enforced
40
+ # over.
41
+ # @return [BucketInstance] Newly created BucketInstance
42
+ def create(max: nil, interval: nil)
43
+ data = Twilio::Values.of({'Max' => max, 'Interval' => interval, })
44
+
45
+ payload = @version.create(
46
+ 'POST',
47
+ @uri,
48
+ data: data
49
+ )
50
+
51
+ BucketInstance.new(
52
+ @version,
53
+ payload,
54
+ service_sid: @solution[:service_sid],
55
+ rate_limit_sid: @solution[:rate_limit_sid],
56
+ )
57
+ end
58
+
59
+ ##
60
+ # Lists BucketInstance records from the API as a list.
61
+ # Unlike stream(), this operation is eager and will load `limit` records into
62
+ # memory before returning.
63
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
64
+ # guarantees to never return more than limit. Default is no limit
65
+ # @param [Integer] page_size Number of records to fetch per request, when
66
+ # not set will use the default value of 50 records. If no page_size is defined
67
+ # but a limit is defined, stream() will attempt to read the limit with the most
68
+ # efficient page size, i.e. min(limit, 1000)
69
+ # @return [Array] Array of up to limit results
70
+ def list(limit: nil, page_size: nil)
71
+ self.stream(limit: limit, page_size: page_size).entries
72
+ end
73
+
74
+ ##
75
+ # Streams BucketInstance records from the API as an Enumerable.
76
+ # This operation lazily loads records as efficiently as possible until the limit
77
+ # is reached.
78
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
79
+ # guarantees to never return more than limit. Default is no limit.
80
+ # @param [Integer] page_size Number of records to fetch per request, when
81
+ # not set will use the default value of 50 records. If no page_size is defined
82
+ # but a limit is defined, stream() will attempt to read the limit with the most
83
+ # efficient page size, i.e. min(limit, 1000)
84
+ # @return [Enumerable] Enumerable that will yield up to limit results
85
+ def stream(limit: nil, page_size: nil)
86
+ limits = @version.read_limits(limit, page_size)
87
+
88
+ page = self.page(page_size: limits[:page_size], )
89
+
90
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
91
+ end
92
+
93
+ ##
94
+ # When passed a block, yields BucketInstance records from the API.
95
+ # This operation lazily loads records as efficiently as possible until the limit
96
+ # is reached.
97
+ def each
98
+ limits = @version.read_limits
99
+
100
+ page = self.page(page_size: limits[:page_size], )
101
+
102
+ @version.stream(page,
103
+ limit: limits[:limit],
104
+ page_limit: limits[:page_limit]).each {|x| yield x}
105
+ end
106
+
107
+ ##
108
+ # Retrieve a single page of BucketInstance records from the API.
109
+ # Request is executed immediately.
110
+ # @param [String] page_token PageToken provided by the API
111
+ # @param [Integer] page_number Page Number, this value is simply for client state
112
+ # @param [Integer] page_size Number of records to return, defaults to 50
113
+ # @return [Page] Page of BucketInstance
114
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
115
+ params = Twilio::Values.of({
116
+ 'PageToken' => page_token,
117
+ 'Page' => page_number,
118
+ 'PageSize' => page_size,
119
+ })
120
+ response = @version.page(
121
+ 'GET',
122
+ @uri,
123
+ params
124
+ )
125
+ BucketPage.new(@version, response, @solution)
126
+ end
127
+
128
+ ##
129
+ # Retrieve a single page of BucketInstance records from the API.
130
+ # Request is executed immediately.
131
+ # @param [String] target_url API-generated URL for the requested results page
132
+ # @return [Page] Page of BucketInstance
133
+ def get_page(target_url)
134
+ response = @version.domain.request(
135
+ 'GET',
136
+ target_url
137
+ )
138
+ BucketPage.new(@version, response, @solution)
139
+ end
140
+
141
+ ##
142
+ # Provide a user friendly representation
143
+ def to_s
144
+ '#<Twilio.Verify.V2.BucketList>'
145
+ end
146
+ end
147
+
148
+ ##
149
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
150
+ class BucketPage < Page
151
+ ##
152
+ # Initialize the BucketPage
153
+ # @param [Version] version Version that contains the resource
154
+ # @param [Response] response Response from the API
155
+ # @param [Hash] solution Path solution for the resource
156
+ # @return [BucketPage] BucketPage
157
+ def initialize(version, response, solution)
158
+ super(version, response)
159
+
160
+ # Path Solution
161
+ @solution = solution
162
+ end
163
+
164
+ ##
165
+ # Build an instance of BucketInstance
166
+ # @param [Hash] payload Payload response from the API
167
+ # @return [BucketInstance] BucketInstance
168
+ def get_instance(payload)
169
+ BucketInstance.new(
170
+ @version,
171
+ payload,
172
+ service_sid: @solution[:service_sid],
173
+ rate_limit_sid: @solution[:rate_limit_sid],
174
+ )
175
+ end
176
+
177
+ ##
178
+ # Provide a user friendly representation
179
+ def to_s
180
+ '<Twilio.Verify.V2.BucketPage>'
181
+ end
182
+ end
183
+
184
+ ##
185
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
186
+ class BucketContext < InstanceContext
187
+ ##
188
+ # Initialize the BucketContext
189
+ # @param [Version] version Version that contains the resource
190
+ # @param [String] service_sid The SID of the
191
+ # [Service](https://www.twilio.com/docs/verify/api-beta/service-beta) the resource
192
+ # is associated with.
193
+ # @param [String] rate_limit_sid The Twilio-provided string that uniquely
194
+ # identifies the Rate Limit resource.
195
+ # @param [String] sid A 34 character string that uniquely identifies this Bucket.
196
+ # @return [BucketContext] BucketContext
197
+ def initialize(version, service_sid, rate_limit_sid, sid)
198
+ super(version)
199
+
200
+ # Path Solution
201
+ @solution = {service_sid: service_sid, rate_limit_sid: rate_limit_sid, sid: sid, }
202
+ @uri = "/Services/#{@solution[:service_sid]}/RateLimits/#{@solution[:rate_limit_sid]}/Buckets/#{@solution[:sid]}"
203
+ end
204
+
205
+ ##
206
+ # Update the BucketInstance
207
+ # @param [String] max Maximum number of requests permitted in during the interval.
208
+ # @param [String] interval Number of seconds that the rate limit will be enforced
209
+ # over.
210
+ # @return [BucketInstance] Updated BucketInstance
211
+ def update(max: :unset, interval: :unset)
212
+ data = Twilio::Values.of({'Max' => max, 'Interval' => interval, })
213
+
214
+ payload = @version.update(
215
+ 'POST',
216
+ @uri,
217
+ data: data,
218
+ )
219
+
220
+ BucketInstance.new(
221
+ @version,
222
+ payload,
223
+ service_sid: @solution[:service_sid],
224
+ rate_limit_sid: @solution[:rate_limit_sid],
225
+ sid: @solution[:sid],
226
+ )
227
+ end
228
+
229
+ ##
230
+ # Fetch a BucketInstance
231
+ # @return [BucketInstance] Fetched BucketInstance
232
+ def fetch
233
+ params = Twilio::Values.of({})
234
+
235
+ payload = @version.fetch(
236
+ 'GET',
237
+ @uri,
238
+ params,
239
+ )
240
+
241
+ BucketInstance.new(
242
+ @version,
243
+ payload,
244
+ service_sid: @solution[:service_sid],
245
+ rate_limit_sid: @solution[:rate_limit_sid],
246
+ sid: @solution[:sid],
247
+ )
248
+ end
249
+
250
+ ##
251
+ # Deletes the BucketInstance
252
+ # @return [Boolean] true if delete succeeds, true otherwise
253
+ def delete
254
+ @version.delete('delete', @uri)
255
+ end
256
+
257
+ ##
258
+ # Provide a user friendly representation
259
+ def to_s
260
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
261
+ "#<Twilio.Verify.V2.BucketContext #{context}>"
262
+ end
263
+
264
+ ##
265
+ # Provide a detailed, user friendly representation
266
+ def inspect
267
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
268
+ "#<Twilio.Verify.V2.BucketContext #{context}>"
269
+ end
270
+ end
271
+
272
+ ##
273
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
274
+ class BucketInstance < InstanceResource
275
+ ##
276
+ # Initialize the BucketInstance
277
+ # @param [Version] version Version that contains the resource
278
+ # @param [Hash] payload payload that contains response from Twilio
279
+ # @param [String] service_sid The SID of the
280
+ # [Service](https://www.twilio.com/docs/verify/api-beta/service-beta) the resource
281
+ # is associated with.
282
+ # @param [String] rate_limit_sid The Twilio-provided string that uniquely
283
+ # identifies the Rate Limit resource.
284
+ # @param [String] sid A 34 character string that uniquely identifies this Bucket.
285
+ # @return [BucketInstance] BucketInstance
286
+ def initialize(version, payload, service_sid: nil, rate_limit_sid: nil, sid: nil)
287
+ super(version)
288
+
289
+ # Marshaled Properties
290
+ @properties = {
291
+ 'sid' => payload['sid'],
292
+ 'rate_limit_sid' => payload['rate_limit_sid'],
293
+ 'service_sid' => payload['service_sid'],
294
+ 'account_sid' => payload['account_sid'],
295
+ 'max' => payload['max'].to_i,
296
+ 'interval' => payload['interval'].to_i,
297
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
298
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
299
+ 'url' => payload['url'],
300
+ }
301
+
302
+ # Context
303
+ @instance_context = nil
304
+ @params = {
305
+ 'service_sid' => service_sid,
306
+ 'rate_limit_sid' => rate_limit_sid,
307
+ 'sid' => sid || @properties['sid'],
308
+ }
309
+ end
310
+
311
+ ##
312
+ # Generate an instance context for the instance, the context is capable of
313
+ # performing various actions. All instance actions are proxied to the context
314
+ # @return [BucketContext] BucketContext for this BucketInstance
315
+ def context
316
+ unless @instance_context
317
+ @instance_context = BucketContext.new(
318
+ @version,
319
+ @params['service_sid'],
320
+ @params['rate_limit_sid'],
321
+ @params['sid'],
322
+ )
323
+ end
324
+ @instance_context
325
+ end
326
+
327
+ ##
328
+ # @return [String] A string that uniquely identifies this Bucket.
329
+ def sid
330
+ @properties['sid']
331
+ end
332
+
333
+ ##
334
+ # @return [String] Rate Limit Sid.
335
+ def rate_limit_sid
336
+ @properties['rate_limit_sid']
337
+ end
338
+
339
+ ##
340
+ # @return [String] The SID of the Service that the resource is associated with
341
+ def service_sid
342
+ @properties['service_sid']
343
+ end
344
+
345
+ ##
346
+ # @return [String] The SID of the Account that created the resource
347
+ def account_sid
348
+ @properties['account_sid']
349
+ end
350
+
351
+ ##
352
+ # @return [String] Max number of requests.
353
+ def max
354
+ @properties['max']
355
+ end
356
+
357
+ ##
358
+ # @return [String] Number of seconds that the rate limit will be enforced over.
359
+ def interval
360
+ @properties['interval']
361
+ end
362
+
363
+ ##
364
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was created
365
+ def date_created
366
+ @properties['date_created']
367
+ end
368
+
369
+ ##
370
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was last updated
371
+ def date_updated
372
+ @properties['date_updated']
373
+ end
374
+
375
+ ##
376
+ # @return [String] The URL of this resource.
377
+ def url
378
+ @properties['url']
379
+ end
380
+
381
+ ##
382
+ # Update the BucketInstance
383
+ # @param [String] max Maximum number of requests permitted in during the interval.
384
+ # @param [String] interval Number of seconds that the rate limit will be enforced
385
+ # over.
386
+ # @return [BucketInstance] Updated BucketInstance
387
+ def update(max: :unset, interval: :unset)
388
+ context.update(max: max, interval: interval, )
389
+ end
390
+
391
+ ##
392
+ # Fetch a BucketInstance
393
+ # @return [BucketInstance] Fetched BucketInstance
394
+ def fetch
395
+ context.fetch
396
+ end
397
+
398
+ ##
399
+ # Deletes the BucketInstance
400
+ # @return [Boolean] true if delete succeeds, true otherwise
401
+ def delete
402
+ context.delete
403
+ end
404
+
405
+ ##
406
+ # Provide a user friendly representation
407
+ def to_s
408
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
409
+ "<Twilio.Verify.V2.BucketInstance #{values}>"
410
+ end
411
+
412
+ ##
413
+ # Provide a detailed, user friendly representation
414
+ def inspect
415
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
416
+ "<Twilio.Verify.V2.BucketInstance #{values}>"
417
+ end
418
+ end
419
+ end
420
+ end
421
+ end
422
+ end
423
+ end
424
+ end
@@ -50,8 +50,12 @@ module Twilio
50
50
  # Requires the PSD2 Service flag enabled.
51
51
  # @param [String] payee The payee of the associated PSD2 compliant transaction.
52
52
  # Requires the PSD2 Service flag enabled.
53
+ # @param [Hash] rate_limits The custom key-value pairs of Programmable Rate
54
+ # Limits. Keys should be the unique_name configured while creating you Rate Limit
55
+ # along with the associated values for each particular request. You may include
56
+ # multiple Rate Limit values in each request.
53
57
  # @return [VerificationInstance] Newly created VerificationInstance
54
- def create(to: nil, channel: nil, custom_message: :unset, send_digits: :unset, locale: :unset, custom_code: :unset, amount: :unset, payee: :unset)
58
+ def create(to: nil, channel: nil, custom_message: :unset, send_digits: :unset, locale: :unset, custom_code: :unset, amount: :unset, payee: :unset, rate_limits: :unset)
55
59
  data = Twilio::Values.of({
56
60
  'To' => to,
57
61
  'Channel' => channel,
@@ -61,6 +65,7 @@ module Twilio
61
65
  'CustomCode' => custom_code,
62
66
  'Amount' => amount,
63
67
  'Payee' => payee,
68
+ 'RateLimits' => Twilio.serialize_object(rate_limits),
64
69
  })
65
70
 
66
71
  payload = @version.create(
@@ -925,10 +925,10 @@ module Twilio
925
925
  ##
926
926
  # Create a new <Room> element
927
927
  # name:: Room name
928
- # participantIdentity:: Participant identity when connecting to the Room
928
+ # participant_identity:: Participant identity when connecting to the Room
929
929
  # keyword_args:: additional attributes
930
- def room(name, participantIdentity: nil, **keyword_args)
931
- append(Room.new(name, participantIdentity: participantIdentity, **keyword_args))
930
+ def room(name, participant_identity: nil, **keyword_args)
931
+ append(Room.new(name, participant_identity: participant_identity, **keyword_args))
932
932
  end
933
933
 
934
934
  ##