twilio-ruby 5.23.1 → 5.24.0

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.
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
@@ -174,6 +174,7 @@ module Twilio
174
174
  'public_attributes' => payload['public_attributes'],
175
175
  'plugin_service_enabled' => payload['plugin_service_enabled'],
176
176
  'plugin_service_attributes' => payload['plugin_service_attributes'],
177
+ 'integrations' => payload['integrations'],
177
178
  'url' => payload['url'],
178
179
  }
179
180
 
@@ -373,6 +374,12 @@ module Twilio
373
374
  @properties['plugin_service_attributes']
374
375
  end
375
376
 
377
+ ##
378
+ # @return [Hash] Integration parameters
379
+ def integrations
380
+ @properties['integrations']
381
+ end
382
+
376
383
  ##
377
384
  # @return [String] The URL for this resource
378
385
  def url
@@ -142,6 +142,7 @@ module Twilio
142
142
  'sip_edge' => payload['sip_edge'],
143
143
  'tags' => payload['tags'],
144
144
  'url' => payload['url'],
145
+ 'attributes' => payload['attributes'],
145
146
  }
146
147
 
147
148
  # Context
@@ -274,6 +275,12 @@ module Twilio
274
275
  @properties['url']
275
276
  end
276
277
 
278
+ ##
279
+ # @return [Hash] The attributes
280
+ def attributes
281
+ @properties['attributes']
282
+ end
283
+
277
284
  ##
278
285
  # Fetch a CallSummaryInstance
279
286
  # @param [call_summary.ProcessingState] processing_state The processing_state
@@ -128,8 +128,16 @@ module Twilio
128
128
  'sid' => payload['sid'],
129
129
  'from' => payload['from'],
130
130
  'to' => payload['to'],
131
+ 'status' => payload['status'],
131
132
  'reason' => payload['reason'],
132
133
  'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
134
+ 'caller' => payload['caller'],
135
+ 'logo' => payload['logo'],
136
+ 'bg_color' => payload['bg_color'],
137
+ 'font_color' => payload['font_color'],
138
+ 'use_case' => payload['use_case'],
139
+ 'manager' => payload['manager'],
140
+ 'shield_img' => payload['shield_img'],
133
141
  'url' => payload['url'],
134
142
  }
135
143
 
@@ -150,35 +158,83 @@ module Twilio
150
158
  end
151
159
 
152
160
  ##
153
- # @return [String] A string that uniquely identifies this Current Call.
161
+ # @return [String] A string that uniquely identifies this current phone call.
154
162
  def sid
155
163
  @properties['sid']
156
164
  end
157
165
 
158
166
  ##
159
- # @return [String] The originating Phone Number
167
+ # @return [String] The originating phone number
160
168
  def from
161
169
  @properties['from']
162
170
  end
163
171
 
164
172
  ##
165
- # @return [String] The terminating Phone Number
173
+ # @return [String] The terminating phone number
166
174
  def to
167
175
  @properties['to']
168
176
  end
169
177
 
170
178
  ##
171
- # @return [String] The business reason for this phone call
179
+ # @return [String] The status of the current phone call
180
+ def status
181
+ @properties['status']
182
+ end
183
+
184
+ ##
185
+ # @return [String] The business reason for this current phone call
172
186
  def reason
173
187
  @properties['reason']
174
188
  end
175
189
 
176
190
  ##
177
- # @return [Time] The date this Current Call was created
191
+ # @return [Time] The date this current phone call was created
178
192
  def created_at
179
193
  @properties['created_at']
180
194
  end
181
195
 
196
+ ##
197
+ # @return [String] Caller name of the current phone call
198
+ def caller
199
+ @properties['caller']
200
+ end
201
+
202
+ ##
203
+ # @return [String] Logo URL of the caller
204
+ def logo
205
+ @properties['logo']
206
+ end
207
+
208
+ ##
209
+ # @return [String] Background color of the current phone call
210
+ def bg_color
211
+ @properties['bg_color']
212
+ end
213
+
214
+ ##
215
+ # @return [String] Font color of the current phone call
216
+ def font_color
217
+ @properties['font_color']
218
+ end
219
+
220
+ ##
221
+ # @return [String] The use case for the current phone call
222
+ def use_case
223
+ @properties['use_case']
224
+ end
225
+
226
+ ##
227
+ # @return [String] The name of the CPS organization
228
+ def manager
229
+ @properties['manager']
230
+ end
231
+
232
+ ##
233
+ # @return [String] Shield image URL that serves as authenticity proof of the current phone call
234
+ def shield_img
235
+ @properties['shield_img']
236
+ end
237
+
182
238
  ##
183
239
  # @return [String] The URL of this resource.
184
240
  def url
@@ -241,20 +241,14 @@ module Twilio
241
241
  # the `ttl` value.
242
242
  # @param [String] ttl The time, in seconds, when the session will expire. The time
243
243
  # is measured from the last Session create or the Session's last Interaction.
244
- # @param [session.Mode] mode The Mode of the Session. Can be: `message-only`,
245
- # `voice-only`, or `voice-and-message` and the default value is
246
- # `voice-and-message`.
247
244
  # @param [session.Status] status The new status of the resource. Can be:
248
245
  # `in-progress` to re-open a session or `closed` to close a session.
249
- # @param [Hash] participants The Participant objects to include in the session.
250
246
  # @return [SessionInstance] Updated SessionInstance
251
- def update(date_expiry: :unset, ttl: :unset, mode: :unset, status: :unset, participants: :unset)
247
+ def update(date_expiry: :unset, ttl: :unset, status: :unset)
252
248
  data = Twilio::Values.of({
253
249
  'DateExpiry' => Twilio.serialize_iso8601_datetime(date_expiry),
254
250
  'Ttl' => ttl,
255
- 'Mode' => mode,
256
251
  'Status' => status,
257
- 'Participants' => Twilio.serialize_list(participants) { |e| Twilio.serialize_object(e) },
258
252
  })
259
253
 
260
254
  payload = @version.update(
@@ -494,21 +488,11 @@ module Twilio
494
488
  # the `ttl` value.
495
489
  # @param [String] ttl The time, in seconds, when the session will expire. The time
496
490
  # is measured from the last Session create or the Session's last Interaction.
497
- # @param [session.Mode] mode The Mode of the Session. Can be: `message-only`,
498
- # `voice-only`, or `voice-and-message` and the default value is
499
- # `voice-and-message`.
500
491
  # @param [session.Status] status The new status of the resource. Can be:
501
492
  # `in-progress` to re-open a session or `closed` to close a session.
502
- # @param [Hash] participants The Participant objects to include in the session.
503
493
  # @return [SessionInstance] Updated SessionInstance
504
- def update(date_expiry: :unset, ttl: :unset, mode: :unset, status: :unset, participants: :unset)
505
- context.update(
506
- date_expiry: date_expiry,
507
- ttl: ttl,
508
- mode: mode,
509
- status: status,
510
- participants: participants,
511
- )
494
+ def update(date_expiry: :unset, ttl: :unset, status: :unset)
495
+ context.update(date_expiry: date_expiry, ttl: ttl, status: status, )
512
496
  end
513
497
 
514
498
  ##
@@ -29,7 +29,7 @@ module Twilio
29
29
  end
30
30
 
31
31
  ##
32
- # @param [String] sid The sid
32
+ # @param [String] sid A unique identifier for this service instance.
33
33
  # @return [Twilio::REST::Sync::V1::ServiceInstance] if sid was passed.
34
34
  # @return [Twilio::REST::Sync::V1::ServiceList]
35
35
  def services(sid=:unset)
@@ -19,7 +19,7 @@ module Twilio
19
19
  end
20
20
 
21
21
  ##
22
- # @param [String] sid The sid
22
+ # @param [String] sid A unique identifier for this service instance.
23
23
  # @return [Twilio::REST::Sync::V1::ServiceContext] if sid was passed.
24
24
  # @return [Twilio::REST::Sync::V1::ServiceList]
25
25
  def services(sid=:unset)
@@ -38,13 +38,27 @@ module Twilio
38
38
  # identities must be granted access to Sync objects via the [Permissions
39
39
  # API](https://www.twilio.com/docs/api/sync/rest/sync-rest-api-permissions) in
40
40
  # this Service.
41
+ # @param [Boolean] reachability_debouncing_enabled `true` or `false` - If false,
42
+ # every endpoint disconnection immediately yields a reachability webhook (if
43
+ # enabled). If true, then 'disconnection' webhook events will only be fired after
44
+ # a configurable delay. Intervening reconnections would effectively cancel that
45
+ # webhook. Defaults to false.
46
+ # @param [String] reachability_debouncing_window Reachability webhook delay period
47
+ # in milliseconds. Determines the delay after which a Sync identity is declared
48
+ # actually offline, measured from the moment the last running client disconnects.
49
+ # If all endpoints remain offline throughout this delay, then reachability
50
+ # webhooks will be fired (if enabled). A reconnection by any endpoint during this
51
+ # window — from the same identity — means no reachability webhook would be fired.
52
+ # Must be between 1000 and 30000. Defaults to 5000.
41
53
  # @return [ServiceInstance] Newly created ServiceInstance
42
- def create(friendly_name: :unset, webhook_url: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset)
54
+ def create(friendly_name: :unset, webhook_url: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset, reachability_debouncing_enabled: :unset, reachability_debouncing_window: :unset)
43
55
  data = Twilio::Values.of({
44
56
  'FriendlyName' => friendly_name,
45
57
  'WebhookUrl' => webhook_url,
46
58
  'ReachabilityWebhooksEnabled' => reachability_webhooks_enabled,
47
59
  'AclEnabled' => acl_enabled,
60
+ 'ReachabilityDebouncingEnabled' => reachability_debouncing_enabled,
61
+ 'ReachabilityDebouncingWindow' => reachability_debouncing_window,
48
62
  })
49
63
 
50
64
  payload = @version.create(
@@ -182,7 +196,7 @@ module Twilio
182
196
  ##
183
197
  # Initialize the ServiceContext
184
198
  # @param [Version] version Version that contains the resource
185
- # @param [String] sid The sid
199
+ # @param [String] sid A unique identifier for this service instance.
186
200
  # @return [ServiceContext] ServiceContext
187
201
  def initialize(version, sid)
188
202
  super(version)
@@ -232,13 +246,27 @@ module Twilio
232
246
  # identities must be granted access to Sync objects via the [Permissions
233
247
  # API](https://www.twilio.com/docs/api/sync/rest/sync-rest-api-permissions) in
234
248
  # this Service.
249
+ # @param [Boolean] reachability_debouncing_enabled `true` or `false` - If false,
250
+ # every endpoint disconnection immediately yields a reachability webhook (if
251
+ # enabled). If true, then 'disconnection' webhook events will only be fired after
252
+ # a configurable delay. Intervening reconnections would effectively cancel that
253
+ # webhook. Defaults to false.
254
+ # @param [String] reachability_debouncing_window Reachability webhook delay period
255
+ # in milliseconds. Determines the delay after which a Sync identity is declared
256
+ # actually offline, measured from the moment the last running client disconnects.
257
+ # If all endpoints remain offline throughout this delay, then reachability
258
+ # webhooks will be fired (if enabled). A reconnection by any endpoint during this
259
+ # window — from the same identity — means no reachability webhook would be fired.
260
+ # Must be between 1000 and 30000. Defaults to 5000.
235
261
  # @return [ServiceInstance] Updated ServiceInstance
236
- def update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset)
262
+ def update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset, reachability_debouncing_enabled: :unset, reachability_debouncing_window: :unset)
237
263
  data = Twilio::Values.of({
238
264
  'WebhookUrl' => webhook_url,
239
265
  'FriendlyName' => friendly_name,
240
266
  'ReachabilityWebhooksEnabled' => reachability_webhooks_enabled,
241
267
  'AclEnabled' => acl_enabled,
268
+ 'ReachabilityDebouncingEnabled' => reachability_debouncing_enabled,
269
+ 'ReachabilityDebouncingWindow' => reachability_debouncing_window,
242
270
  })
243
271
 
244
272
  payload = @version.update(
@@ -344,7 +372,7 @@ module Twilio
344
372
  # Initialize the ServiceInstance
345
373
  # @param [Version] version Version that contains the resource
346
374
  # @param [Hash] payload payload that contains response from Twilio
347
- # @param [String] sid The sid
375
+ # @param [String] sid A unique identifier for this service instance.
348
376
  # @return [ServiceInstance] ServiceInstance
349
377
  def initialize(version, payload, sid: nil)
350
378
  super(version)
@@ -361,6 +389,8 @@ module Twilio
361
389
  'webhook_url' => payload['webhook_url'],
362
390
  'reachability_webhooks_enabled' => payload['reachability_webhooks_enabled'],
363
391
  'acl_enabled' => payload['acl_enabled'],
392
+ 'reachability_debouncing_enabled' => payload['reachability_debouncing_enabled'],
393
+ 'reachability_debouncing_window' => payload['reachability_debouncing_window'].to_i,
364
394
  'links' => payload['links'],
365
395
  }
366
396
 
@@ -381,7 +411,7 @@ module Twilio
381
411
  end
382
412
 
383
413
  ##
384
- # @return [String] The sid
414
+ # @return [String] A unique identifier for this service instance.
385
415
  def sid
386
416
  @properties['sid']
387
417
  end
@@ -440,6 +470,18 @@ module Twilio
440
470
  @properties['acl_enabled']
441
471
  end
442
472
 
473
+ ##
474
+ # @return [Boolean] true or false - Determines whether transient disconnections (i.e. an immediate reconnect succeeds) cause reachability webhooks.
475
+ def reachability_debouncing_enabled
476
+ @properties['reachability_debouncing_enabled']
477
+ end
478
+
479
+ ##
480
+ # @return [String] Determines how long an identity must be offline before reachability webhooks fire.
481
+ def reachability_debouncing_window
482
+ @properties['reachability_debouncing_window']
483
+ end
484
+
443
485
  ##
444
486
  # @return [String] The links
445
487
  def links
@@ -472,13 +514,27 @@ module Twilio
472
514
  # identities must be granted access to Sync objects via the [Permissions
473
515
  # API](https://www.twilio.com/docs/api/sync/rest/sync-rest-api-permissions) in
474
516
  # this Service.
517
+ # @param [Boolean] reachability_debouncing_enabled `true` or `false` - If false,
518
+ # every endpoint disconnection immediately yields a reachability webhook (if
519
+ # enabled). If true, then 'disconnection' webhook events will only be fired after
520
+ # a configurable delay. Intervening reconnections would effectively cancel that
521
+ # webhook. Defaults to false.
522
+ # @param [String] reachability_debouncing_window Reachability webhook delay period
523
+ # in milliseconds. Determines the delay after which a Sync identity is declared
524
+ # actually offline, measured from the moment the last running client disconnects.
525
+ # If all endpoints remain offline throughout this delay, then reachability
526
+ # webhooks will be fired (if enabled). A reconnection by any endpoint during this
527
+ # window — from the same identity — means no reachability webhook would be fired.
528
+ # Must be between 1000 and 30000. Defaults to 5000.
475
529
  # @return [ServiceInstance] Updated ServiceInstance
476
- def update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset)
530
+ def update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset, reachability_debouncing_enabled: :unset, reachability_debouncing_window: :unset)
477
531
  context.update(
478
532
  webhook_url: webhook_url,
479
533
  friendly_name: friendly_name,
480
534
  reachability_webhooks_enabled: reachability_webhooks_enabled,
481
535
  acl_enabled: acl_enabled,
536
+ reachability_debouncing_enabled: reachability_debouncing_enabled,
537
+ reachability_debouncing_window: reachability_debouncing_window,
482
538
  )
483
539
  end
484
540
 
@@ -202,6 +202,7 @@ module Twilio
202
202
  # Dependents
203
203
  @verifications = nil
204
204
  @verification_checks = nil
205
+ @rate_limits = nil
205
206
  end
206
207
 
207
208
  ##
@@ -293,6 +294,24 @@ module Twilio
293
294
  @verification_checks
294
295
  end
295
296
 
297
+ ##
298
+ # Access the rate_limits
299
+ # @return [RateLimitList]
300
+ # @return [RateLimitContext] if sid was passed.
301
+ def rate_limits(sid=:unset)
302
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
303
+
304
+ if sid != :unset
305
+ return RateLimitContext.new(@version, @solution[:sid], sid, )
306
+ end
307
+
308
+ unless @rate_limits
309
+ @rate_limits = RateLimitList.new(@version, service_sid: @solution[:sid], )
310
+ end
311
+
312
+ @rate_limits
313
+ end
314
+
296
315
  ##
297
316
  # Provide a user friendly representation
298
317
  def to_s
@@ -489,6 +508,13 @@ module Twilio
489
508
  context.verification_checks
490
509
  end
491
510
 
511
+ ##
512
+ # Access the rate_limits
513
+ # @return [rate_limits] rate_limits
514
+ def rate_limits
515
+ context.rate_limits
516
+ end
517
+
492
518
  ##
493
519
  # Provide a user friendly representation
494
520
  def to_s
@@ -0,0 +1,416 @@
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
+ ##
15
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
16
+ class RateLimitList < ListResource
17
+ ##
18
+ # Initialize the RateLimitList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] service_sid The SID of the
21
+ # [Service](https://www.twilio.com/docs/verify/api-beta/service-beta) the resource
22
+ # is associated with.
23
+ # @return [RateLimitList] RateLimitList
24
+ def initialize(version, service_sid: nil)
25
+ super(version)
26
+
27
+ # Path Solution
28
+ @solution = {service_sid: service_sid}
29
+ @uri = "/Services/#{@solution[:service_sid]}/RateLimits"
30
+ end
31
+
32
+ ##
33
+ # Retrieve a single page of RateLimitInstance records from the API.
34
+ # Request is executed immediately.
35
+ # @param [String] unique_name Provides a unique and addressable name to be
36
+ # assigned to this Rate Limit, assigned by the developer, to be optionally used in
37
+ # addition to SID.
38
+ # @param [String] description Description of this Rate Limit
39
+ # @return [RateLimitInstance] Newly created RateLimitInstance
40
+ def create(unique_name: nil, description: :unset)
41
+ data = Twilio::Values.of({'UniqueName' => unique_name, 'Description' => description, })
42
+
43
+ payload = @version.create(
44
+ 'POST',
45
+ @uri,
46
+ data: data
47
+ )
48
+
49
+ RateLimitInstance.new(@version, payload, service_sid: @solution[:service_sid], )
50
+ end
51
+
52
+ ##
53
+ # Lists RateLimitInstance records from the API as a list.
54
+ # Unlike stream(), this operation is eager and will load `limit` records into
55
+ # memory before returning.
56
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
57
+ # guarantees to never return more than limit. Default is no limit
58
+ # @param [Integer] page_size Number of records to fetch per request, when
59
+ # not set will use the default value of 50 records. If no page_size is defined
60
+ # but a limit is defined, stream() will attempt to read the limit with the most
61
+ # efficient page size, i.e. min(limit, 1000)
62
+ # @return [Array] Array of up to limit results
63
+ def list(limit: nil, page_size: nil)
64
+ self.stream(limit: limit, page_size: page_size).entries
65
+ end
66
+
67
+ ##
68
+ # Streams RateLimitInstance records from the API as an Enumerable.
69
+ # This operation lazily loads records as efficiently as possible until the limit
70
+ # is reached.
71
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
72
+ # guarantees to never return more than limit. Default is no limit.
73
+ # @param [Integer] page_size Number of records to fetch per request, when
74
+ # not set will use the default value of 50 records. If no page_size is defined
75
+ # but a limit is defined, stream() will attempt to read the limit with the most
76
+ # efficient page size, i.e. min(limit, 1000)
77
+ # @return [Enumerable] Enumerable that will yield up to limit results
78
+ def stream(limit: nil, page_size: nil)
79
+ limits = @version.read_limits(limit, page_size)
80
+
81
+ page = self.page(page_size: limits[:page_size], )
82
+
83
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
84
+ end
85
+
86
+ ##
87
+ # When passed a block, yields RateLimitInstance records from the API.
88
+ # This operation lazily loads records as efficiently as possible until the limit
89
+ # is reached.
90
+ def each
91
+ limits = @version.read_limits
92
+
93
+ page = self.page(page_size: limits[:page_size], )
94
+
95
+ @version.stream(page,
96
+ limit: limits[:limit],
97
+ page_limit: limits[:page_limit]).each {|x| yield x}
98
+ end
99
+
100
+ ##
101
+ # Retrieve a single page of RateLimitInstance records from the API.
102
+ # Request is executed immediately.
103
+ # @param [String] page_token PageToken provided by the API
104
+ # @param [Integer] page_number Page Number, this value is simply for client state
105
+ # @param [Integer] page_size Number of records to return, defaults to 50
106
+ # @return [Page] Page of RateLimitInstance
107
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
108
+ params = Twilio::Values.of({
109
+ 'PageToken' => page_token,
110
+ 'Page' => page_number,
111
+ 'PageSize' => page_size,
112
+ })
113
+ response = @version.page(
114
+ 'GET',
115
+ @uri,
116
+ params
117
+ )
118
+ RateLimitPage.new(@version, response, @solution)
119
+ end
120
+
121
+ ##
122
+ # Retrieve a single page of RateLimitInstance records from the API.
123
+ # Request is executed immediately.
124
+ # @param [String] target_url API-generated URL for the requested results page
125
+ # @return [Page] Page of RateLimitInstance
126
+ def get_page(target_url)
127
+ response = @version.domain.request(
128
+ 'GET',
129
+ target_url
130
+ )
131
+ RateLimitPage.new(@version, response, @solution)
132
+ end
133
+
134
+ ##
135
+ # Provide a user friendly representation
136
+ def to_s
137
+ '#<Twilio.Verify.V2.RateLimitList>'
138
+ end
139
+ end
140
+
141
+ ##
142
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
143
+ class RateLimitPage < Page
144
+ ##
145
+ # Initialize the RateLimitPage
146
+ # @param [Version] version Version that contains the resource
147
+ # @param [Response] response Response from the API
148
+ # @param [Hash] solution Path solution for the resource
149
+ # @return [RateLimitPage] RateLimitPage
150
+ def initialize(version, response, solution)
151
+ super(version, response)
152
+
153
+ # Path Solution
154
+ @solution = solution
155
+ end
156
+
157
+ ##
158
+ # Build an instance of RateLimitInstance
159
+ # @param [Hash] payload Payload response from the API
160
+ # @return [RateLimitInstance] RateLimitInstance
161
+ def get_instance(payload)
162
+ RateLimitInstance.new(@version, payload, service_sid: @solution[:service_sid], )
163
+ end
164
+
165
+ ##
166
+ # Provide a user friendly representation
167
+ def to_s
168
+ '<Twilio.Verify.V2.RateLimitPage>'
169
+ end
170
+ end
171
+
172
+ ##
173
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
174
+ class RateLimitContext < InstanceContext
175
+ ##
176
+ # Initialize the RateLimitContext
177
+ # @param [Version] version Version that contains the resource
178
+ # @param [String] service_sid The SID of the
179
+ # [Service](https://www.twilio.com/docs/verify/api-beta/service-beta) the resource
180
+ # is associated with.
181
+ # @param [String] sid The Twilio-provided string that uniquely identifies the Rate
182
+ # Limit resource to fetch.
183
+ # @return [RateLimitContext] RateLimitContext
184
+ def initialize(version, service_sid, sid)
185
+ super(version)
186
+
187
+ # Path Solution
188
+ @solution = {service_sid: service_sid, sid: sid, }
189
+ @uri = "/Services/#{@solution[:service_sid]}/RateLimits/#{@solution[:sid]}"
190
+
191
+ # Dependents
192
+ @buckets = nil
193
+ end
194
+
195
+ ##
196
+ # Update the RateLimitInstance
197
+ # @param [String] description Description of this Rate Limit
198
+ # @return [RateLimitInstance] Updated RateLimitInstance
199
+ def update(description: :unset)
200
+ data = Twilio::Values.of({'Description' => description, })
201
+
202
+ payload = @version.update(
203
+ 'POST',
204
+ @uri,
205
+ data: data,
206
+ )
207
+
208
+ RateLimitInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
209
+ end
210
+
211
+ ##
212
+ # Fetch a RateLimitInstance
213
+ # @return [RateLimitInstance] Fetched RateLimitInstance
214
+ def fetch
215
+ params = Twilio::Values.of({})
216
+
217
+ payload = @version.fetch(
218
+ 'GET',
219
+ @uri,
220
+ params,
221
+ )
222
+
223
+ RateLimitInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
224
+ end
225
+
226
+ ##
227
+ # Deletes the RateLimitInstance
228
+ # @return [Boolean] true if delete succeeds, true otherwise
229
+ def delete
230
+ @version.delete('delete', @uri)
231
+ end
232
+
233
+ ##
234
+ # Access the buckets
235
+ # @return [BucketList]
236
+ # @return [BucketContext] if sid was passed.
237
+ def buckets(sid=:unset)
238
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
239
+
240
+ if sid != :unset
241
+ return BucketContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
242
+ end
243
+
244
+ unless @buckets
245
+ @buckets = BucketList.new(
246
+ @version,
247
+ service_sid: @solution[:service_sid],
248
+ rate_limit_sid: @solution[:sid],
249
+ )
250
+ end
251
+
252
+ @buckets
253
+ end
254
+
255
+ ##
256
+ # Provide a user friendly representation
257
+ def to_s
258
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
259
+ "#<Twilio.Verify.V2.RateLimitContext #{context}>"
260
+ end
261
+
262
+ ##
263
+ # Provide a detailed, user friendly representation
264
+ def inspect
265
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
266
+ "#<Twilio.Verify.V2.RateLimitContext #{context}>"
267
+ end
268
+ end
269
+
270
+ ##
271
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
272
+ class RateLimitInstance < InstanceResource
273
+ ##
274
+ # Initialize the RateLimitInstance
275
+ # @param [Version] version Version that contains the resource
276
+ # @param [Hash] payload payload that contains response from Twilio
277
+ # @param [String] service_sid The SID of the
278
+ # [Service](https://www.twilio.com/docs/verify/api-beta/service-beta) the resource
279
+ # is associated with.
280
+ # @param [String] sid The Twilio-provided string that uniquely identifies the Rate
281
+ # Limit resource to fetch.
282
+ # @return [RateLimitInstance] RateLimitInstance
283
+ def initialize(version, payload, service_sid: nil, sid: nil)
284
+ super(version)
285
+
286
+ # Marshaled Properties
287
+ @properties = {
288
+ 'sid' => payload['sid'],
289
+ 'service_sid' => payload['service_sid'],
290
+ 'account_sid' => payload['account_sid'],
291
+ 'unique_name' => payload['unique_name'],
292
+ 'description' => payload['description'],
293
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
294
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
295
+ 'url' => payload['url'],
296
+ 'links' => payload['links'],
297
+ }
298
+
299
+ # Context
300
+ @instance_context = nil
301
+ @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
302
+ end
303
+
304
+ ##
305
+ # Generate an instance context for the instance, the context is capable of
306
+ # performing various actions. All instance actions are proxied to the context
307
+ # @return [RateLimitContext] RateLimitContext for this RateLimitInstance
308
+ def context
309
+ unless @instance_context
310
+ @instance_context = RateLimitContext.new(@version, @params['service_sid'], @params['sid'], )
311
+ end
312
+ @instance_context
313
+ end
314
+
315
+ ##
316
+ # @return [String] A string that uniquely identifies this Rate Limit.
317
+ def sid
318
+ @properties['sid']
319
+ end
320
+
321
+ ##
322
+ # @return [String] The SID of the Service that the resource is associated with
323
+ def service_sid
324
+ @properties['service_sid']
325
+ end
326
+
327
+ ##
328
+ # @return [String] The SID of the Account that created the resource
329
+ def account_sid
330
+ @properties['account_sid']
331
+ end
332
+
333
+ ##
334
+ # @return [String] A unique, developer assigned name of this Rate Limit.
335
+ def unique_name
336
+ @properties['unique_name']
337
+ end
338
+
339
+ ##
340
+ # @return [String] Description of this Rate Limit
341
+ def description
342
+ @properties['description']
343
+ end
344
+
345
+ ##
346
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was created
347
+ def date_created
348
+ @properties['date_created']
349
+ end
350
+
351
+ ##
352
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was last updated
353
+ def date_updated
354
+ @properties['date_updated']
355
+ end
356
+
357
+ ##
358
+ # @return [String] The URL of this resource.
359
+ def url
360
+ @properties['url']
361
+ end
362
+
363
+ ##
364
+ # @return [String] The links
365
+ def links
366
+ @properties['links']
367
+ end
368
+
369
+ ##
370
+ # Update the RateLimitInstance
371
+ # @param [String] description Description of this Rate Limit
372
+ # @return [RateLimitInstance] Updated RateLimitInstance
373
+ def update(description: :unset)
374
+ context.update(description: description, )
375
+ end
376
+
377
+ ##
378
+ # Fetch a RateLimitInstance
379
+ # @return [RateLimitInstance] Fetched RateLimitInstance
380
+ def fetch
381
+ context.fetch
382
+ end
383
+
384
+ ##
385
+ # Deletes the RateLimitInstance
386
+ # @return [Boolean] true if delete succeeds, true otherwise
387
+ def delete
388
+ context.delete
389
+ end
390
+
391
+ ##
392
+ # Access the buckets
393
+ # @return [buckets] buckets
394
+ def buckets
395
+ context.buckets
396
+ end
397
+
398
+ ##
399
+ # Provide a user friendly representation
400
+ def to_s
401
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
402
+ "<Twilio.Verify.V2.RateLimitInstance #{values}>"
403
+ end
404
+
405
+ ##
406
+ # Provide a detailed, user friendly representation
407
+ def inspect
408
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
409
+ "<Twilio.Verify.V2.RateLimitInstance #{values}>"
410
+ end
411
+ end
412
+ end
413
+ end
414
+ end
415
+ end
416
+ end