twilio-ruby 5.35.0 → 5.36.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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +28 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +87 -87
  5. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +14 -0
  6. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +71 -71
  7. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +29 -29
  8. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +27 -4
  9. data/lib/twilio-ruby/rest/flex_api/v1/channel.rb +2 -1
  10. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +7 -0
  11. data/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +6 -3
  12. data/lib/twilio-ruby/rest/preview/trusted_comms/business.rb +26 -0
  13. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand.rb +239 -0
  14. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel.rb +266 -0
  15. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel/channel.rb +197 -0
  16. data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +7 -0
  17. data/lib/twilio-ruby/rest/supersim.rb +11 -1
  18. data/lib/twilio-ruby/rest/supersim/v1.rb +16 -1
  19. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +10 -1
  20. data/lib/twilio-ruby/rest/supersim/v1/network.rb +315 -0
  21. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile.rb +53 -12
  22. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb +352 -0
  23. data/lib/twilio-ruby/rest/verify.rb +9 -0
  24. data/lib/twilio-ruby/rest/verify/v2.rb +16 -0
  25. data/lib/twilio-ruby/rest/verify/v2/form.rb +197 -0
  26. data/lib/twilio-ruby/rest/verify/v2/service.rb +26 -0
  27. data/lib/twilio-ruby/rest/verify/v2/service/entity.rb +379 -0
  28. data/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb +500 -0
  29. data/lib/twilio-ruby/rest/verify/v2/service/entity/factor/challenge.rb +494 -0
  30. data/lib/twilio-ruby/rest/video/v1/composition_settings.rb +8 -4
  31. data/lib/twilio-ruby/rest/video/v1/recording_settings.rb +8 -4
  32. data/lib/twilio-ruby/version.rb +1 -1
  33. data/spec/integration/api/v2010/account/call_spec.rb +5 -5
  34. data/spec/integration/api/v2010/account/conference_spec.rb +42 -14
  35. data/spec/integration/conversations/v1/conversation/participant_spec.rb +7 -0
  36. data/spec/integration/flex_api/v1/configuration_spec.rb +3 -0
  37. data/spec/integration/preview/trusted_comms/business/brand/branded_channel/channel_spec.rb +54 -0
  38. data/spec/integration/preview/trusted_comms/business/brand/branded_channel_spec.rb +52 -0
  39. data/spec/integration/preview/trusted_comms/business/brand_spec.rb +49 -0
  40. data/spec/integration/preview/trusted_comms/business_spec.rb +1 -0
  41. data/spec/integration/serverless/v1/service/environment/log_spec.rb +1 -0
  42. data/spec/integration/supersim/v1/fleet_spec.rb +4 -0
  43. data/spec/integration/supersim/v1/network_access_profile/network_access_profile_network_spec.rb +179 -0
  44. data/spec/integration/supersim/v1/network_access_profile_spec.rb +20 -5
  45. data/spec/integration/supersim/v1/network_spec.rb +139 -0
  46. data/spec/integration/trunking/v1/trunk/credential_list_spec.rb +13 -13
  47. data/spec/integration/trunking/v1/trunk/ip_access_control_list_spec.rb +23 -23
  48. data/spec/integration/trunking/v1/trunk/origination_url_spec.rb +28 -28
  49. data/spec/integration/trunking/v1/trunk/phone_number_spec.rb +17 -17
  50. data/spec/integration/trunking/v1/trunk_spec.rb +33 -33
  51. data/spec/integration/verify/v2/form_spec.rb +48 -0
  52. data/spec/integration/verify/v2/service/entity/factor/challenge_spec.rb +353 -0
  53. data/spec/integration/verify/v2/service/entity/factor_spec.rb +298 -0
  54. data/spec/integration/verify/v2/service/entity_spec.rb +201 -0
  55. data/spec/integration/verify/v2/service_spec.rb +24 -4
  56. metadata +29 -2
@@ -208,6 +208,7 @@ module Twilio
208
208
  @verification_checks = nil
209
209
  @rate_limits = nil
210
210
  @messaging_configurations = nil
211
+ @entities = nil
211
212
  end
212
213
 
213
214
  ##
@@ -343,6 +344,24 @@ module Twilio
343
344
  @messaging_configurations
344
345
  end
345
346
 
347
+ ##
348
+ # Access the entities
349
+ # @return [EntityList]
350
+ # @return [EntityContext] if identity was passed.
351
+ def entities(identity=:unset)
352
+ raise ArgumentError, 'identity cannot be nil' if identity.nil?
353
+
354
+ if identity != :unset
355
+ return EntityContext.new(@version, @solution[:sid], identity, )
356
+ end
357
+
358
+ unless @entities
359
+ @entities = EntityList.new(@version, service_sid: @solution[:sid], )
360
+ end
361
+
362
+ @entities
363
+ end
364
+
346
365
  ##
347
366
  # Provide a user friendly representation
348
367
  def to_s
@@ -573,6 +592,13 @@ module Twilio
573
592
  context.messaging_configurations
574
593
  end
575
594
 
595
+ ##
596
+ # Access the entities
597
+ # @return [entities] entities
598
+ def entities
599
+ context.entities
600
+ end
601
+
576
602
  ##
577
603
  # Provide a user friendly representation
578
604
  def to_s
@@ -0,0 +1,379 @@
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 preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
16
+ class EntityList < ListResource
17
+ ##
18
+ # Initialize the EntityList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] service_sid The unique SID identifier of the Service.
21
+ # @return [EntityList] EntityList
22
+ def initialize(version, service_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {service_sid: service_sid}
27
+ @uri = "/Services/#{@solution[:service_sid]}/Entities"
28
+ end
29
+
30
+ ##
31
+ # Retrieve a single page of EntityInstance records from the API.
32
+ # Request is executed immediately.
33
+ # @param [String] identity Customer unique identity for the Entity of the Service
34
+ # @return [EntityInstance] Newly created EntityInstance
35
+ def create(identity: nil)
36
+ data = Twilio::Values.of({'Identity' => identity, })
37
+
38
+ payload = @version.create(
39
+ 'POST',
40
+ @uri,
41
+ data: data
42
+ )
43
+
44
+ EntityInstance.new(@version, payload, service_sid: @solution[:service_sid], )
45
+ end
46
+
47
+ ##
48
+ # Lists EntityInstance records from the API as a list.
49
+ # Unlike stream(), this operation is eager and will load `limit` records into
50
+ # memory before returning.
51
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
52
+ # guarantees to never return more than limit. Default is no limit
53
+ # @param [Integer] page_size Number of records to fetch per request, when
54
+ # not set will use the default value of 50 records. If no page_size is defined
55
+ # but a limit is defined, stream() will attempt to read the limit with the most
56
+ # efficient page size, i.e. min(limit, 1000)
57
+ # @return [Array] Array of up to limit results
58
+ def list(limit: nil, page_size: nil)
59
+ self.stream(limit: limit, page_size: page_size).entries
60
+ end
61
+
62
+ ##
63
+ # Streams EntityInstance records from the API as an Enumerable.
64
+ # This operation lazily loads records as efficiently as possible until the limit
65
+ # is reached.
66
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
67
+ # guarantees to never return more than limit. Default is no limit.
68
+ # @param [Integer] page_size Number of records to fetch per request, when
69
+ # not set will use the default value of 50 records. If no page_size is defined
70
+ # but a limit is defined, stream() will attempt to read the limit with the most
71
+ # efficient page size, i.e. min(limit, 1000)
72
+ # @return [Enumerable] Enumerable that will yield up to limit results
73
+ def stream(limit: nil, page_size: nil)
74
+ limits = @version.read_limits(limit, page_size)
75
+
76
+ page = self.page(page_size: limits[:page_size], )
77
+
78
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
79
+ end
80
+
81
+ ##
82
+ # When passed a block, yields EntityInstance records from the API.
83
+ # This operation lazily loads records as efficiently as possible until the limit
84
+ # is reached.
85
+ def each
86
+ limits = @version.read_limits
87
+
88
+ page = self.page(page_size: limits[:page_size], )
89
+
90
+ @version.stream(page,
91
+ limit: limits[:limit],
92
+ page_limit: limits[:page_limit]).each {|x| yield x}
93
+ end
94
+
95
+ ##
96
+ # Retrieve a single page of EntityInstance records from the API.
97
+ # Request is executed immediately.
98
+ # @param [String] page_token PageToken provided by the API
99
+ # @param [Integer] page_number Page Number, this value is simply for client state
100
+ # @param [Integer] page_size Number of records to return, defaults to 50
101
+ # @return [Page] Page of EntityInstance
102
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
103
+ params = Twilio::Values.of({
104
+ 'PageToken' => page_token,
105
+ 'Page' => page_number,
106
+ 'PageSize' => page_size,
107
+ })
108
+ response = @version.page(
109
+ 'GET',
110
+ @uri,
111
+ params
112
+ )
113
+ EntityPage.new(@version, response, @solution)
114
+ end
115
+
116
+ ##
117
+ # Retrieve a single page of EntityInstance records from the API.
118
+ # Request is executed immediately.
119
+ # @param [String] target_url API-generated URL for the requested results page
120
+ # @return [Page] Page of EntityInstance
121
+ def get_page(target_url)
122
+ response = @version.domain.request(
123
+ 'GET',
124
+ target_url
125
+ )
126
+ EntityPage.new(@version, response, @solution)
127
+ end
128
+
129
+ ##
130
+ # Provide a user friendly representation
131
+ def to_s
132
+ '#<Twilio.Verify.V2.EntityList>'
133
+ end
134
+ end
135
+
136
+ ##
137
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
138
+ class EntityPage < Page
139
+ ##
140
+ # Initialize the EntityPage
141
+ # @param [Version] version Version that contains the resource
142
+ # @param [Response] response Response from the API
143
+ # @param [Hash] solution Path solution for the resource
144
+ # @return [EntityPage] EntityPage
145
+ def initialize(version, response, solution)
146
+ super(version, response)
147
+
148
+ # Path Solution
149
+ @solution = solution
150
+ end
151
+
152
+ ##
153
+ # Build an instance of EntityInstance
154
+ # @param [Hash] payload Payload response from the API
155
+ # @return [EntityInstance] EntityInstance
156
+ def get_instance(payload)
157
+ EntityInstance.new(@version, payload, service_sid: @solution[:service_sid], )
158
+ end
159
+
160
+ ##
161
+ # Provide a user friendly representation
162
+ def to_s
163
+ '<Twilio.Verify.V2.EntityPage>'
164
+ end
165
+ end
166
+
167
+ ##
168
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
169
+ class EntityContext < InstanceContext
170
+ ##
171
+ # Initialize the EntityContext
172
+ # @param [Version] version Version that contains the resource
173
+ # @param [String] service_sid The unique SID identifier of the Service.
174
+ # @param [String] identity Customer unique identity for the Entity of the Service
175
+ # @return [EntityContext] EntityContext
176
+ def initialize(version, service_sid, identity)
177
+ super(version)
178
+
179
+ # Path Solution
180
+ @solution = {service_sid: service_sid, identity: identity, }
181
+ @uri = "/Services/#{@solution[:service_sid]}/Entities/#{@solution[:identity]}"
182
+
183
+ # Dependents
184
+ @factors = nil
185
+ end
186
+
187
+ ##
188
+ # Deletes the EntityInstance
189
+ # @return [Boolean] true if delete succeeds, false otherwise
190
+ def delete
191
+ @version.delete('delete', @uri)
192
+ end
193
+
194
+ ##
195
+ # Fetch a EntityInstance
196
+ # @return [EntityInstance] Fetched EntityInstance
197
+ def fetch
198
+ params = Twilio::Values.of({})
199
+
200
+ payload = @version.fetch(
201
+ 'GET',
202
+ @uri,
203
+ params,
204
+ )
205
+
206
+ EntityInstance.new(
207
+ @version,
208
+ payload,
209
+ service_sid: @solution[:service_sid],
210
+ identity: @solution[:identity],
211
+ )
212
+ end
213
+
214
+ ##
215
+ # Access the factors
216
+ # @return [FactorList]
217
+ # @return [FactorContext] if sid was passed.
218
+ def factors(sid=:unset)
219
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
220
+
221
+ if sid != :unset
222
+ return FactorContext.new(@version, @solution[:service_sid], @solution[:identity], sid, )
223
+ end
224
+
225
+ unless @factors
226
+ @factors = FactorList.new(
227
+ @version,
228
+ service_sid: @solution[:service_sid],
229
+ identity: @solution[:identity],
230
+ )
231
+ end
232
+
233
+ @factors
234
+ end
235
+
236
+ ##
237
+ # Provide a user friendly representation
238
+ def to_s
239
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
240
+ "#<Twilio.Verify.V2.EntityContext #{context}>"
241
+ end
242
+
243
+ ##
244
+ # Provide a detailed, user friendly representation
245
+ def inspect
246
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
247
+ "#<Twilio.Verify.V2.EntityContext #{context}>"
248
+ end
249
+ end
250
+
251
+ ##
252
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
253
+ class EntityInstance < InstanceResource
254
+ ##
255
+ # Initialize the EntityInstance
256
+ # @param [Version] version Version that contains the resource
257
+ # @param [Hash] payload payload that contains response from Twilio
258
+ # @param [String] service_sid The unique SID identifier of the Service.
259
+ # @param [String] identity Customer unique identity for the Entity of the Service
260
+ # @return [EntityInstance] EntityInstance
261
+ def initialize(version, payload, service_sid: nil, identity: nil)
262
+ super(version)
263
+
264
+ # Marshaled Properties
265
+ @properties = {
266
+ 'sid' => payload['sid'],
267
+ 'identity' => payload['identity'],
268
+ 'account_sid' => payload['account_sid'],
269
+ 'service_sid' => payload['service_sid'],
270
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
271
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
272
+ 'url' => payload['url'],
273
+ 'links' => payload['links'],
274
+ }
275
+
276
+ # Context
277
+ @instance_context = nil
278
+ @params = {'service_sid' => service_sid, 'identity' => identity || @properties['identity'], }
279
+ end
280
+
281
+ ##
282
+ # Generate an instance context for the instance, the context is capable of
283
+ # performing various actions. All instance actions are proxied to the context
284
+ # @return [EntityContext] EntityContext for this EntityInstance
285
+ def context
286
+ unless @instance_context
287
+ @instance_context = EntityContext.new(@version, @params['service_sid'], @params['identity'], )
288
+ end
289
+ @instance_context
290
+ end
291
+
292
+ ##
293
+ # @return [String] A string that uniquely identifies this Entity.
294
+ def sid
295
+ @properties['sid']
296
+ end
297
+
298
+ ##
299
+ # @return [String] Unique identity of the Entity
300
+ def identity
301
+ @properties['identity']
302
+ end
303
+
304
+ ##
305
+ # @return [String] Account Sid.
306
+ def account_sid
307
+ @properties['account_sid']
308
+ end
309
+
310
+ ##
311
+ # @return [String] Service Sid.
312
+ def service_sid
313
+ @properties['service_sid']
314
+ end
315
+
316
+ ##
317
+ # @return [Time] The date this Entity was created
318
+ def date_created
319
+ @properties['date_created']
320
+ end
321
+
322
+ ##
323
+ # @return [Time] The date this Entity was updated
324
+ def date_updated
325
+ @properties['date_updated']
326
+ end
327
+
328
+ ##
329
+ # @return [String] The URL of this resource.
330
+ def url
331
+ @properties['url']
332
+ end
333
+
334
+ ##
335
+ # @return [String] Nested resource URLs.
336
+ def links
337
+ @properties['links']
338
+ end
339
+
340
+ ##
341
+ # Deletes the EntityInstance
342
+ # @return [Boolean] true if delete succeeds, false otherwise
343
+ def delete
344
+ context.delete
345
+ end
346
+
347
+ ##
348
+ # Fetch a EntityInstance
349
+ # @return [EntityInstance] Fetched EntityInstance
350
+ def fetch
351
+ context.fetch
352
+ end
353
+
354
+ ##
355
+ # Access the factors
356
+ # @return [factors] factors
357
+ def factors
358
+ context.factors
359
+ end
360
+
361
+ ##
362
+ # Provide a user friendly representation
363
+ def to_s
364
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
365
+ "<Twilio.Verify.V2.EntityInstance #{values}>"
366
+ end
367
+
368
+ ##
369
+ # Provide a detailed, user friendly representation
370
+ def inspect
371
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
372
+ "<Twilio.Verify.V2.EntityInstance #{values}>"
373
+ end
374
+ end
375
+ end
376
+ end
377
+ end
378
+ end
379
+ end
@@ -0,0 +1,500 @@
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 EntityContext < InstanceContext
15
+ ##
16
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
17
+ class FactorList < ListResource
18
+ ##
19
+ # Initialize the FactorList
20
+ # @param [Version] version Version that contains the resource
21
+ # @param [String] service_sid The unique SID identifier of the Service.
22
+ # @param [String] identity Customer unique identity for the Entity owner of the
23
+ # Factor
24
+ # @return [FactorList] FactorList
25
+ def initialize(version, service_sid: nil, identity: nil)
26
+ super(version)
27
+
28
+ # Path Solution
29
+ @solution = {service_sid: service_sid, identity: identity}
30
+ @uri = "/Services/#{@solution[:service_sid]}/Entities/#{@solution[:identity]}/Factors"
31
+ end
32
+
33
+ ##
34
+ # Retrieve a single page of FactorInstance records from the API.
35
+ # Request is executed immediately.
36
+ # @param [String] binding A unique binding for this Factor that identifies it.
37
+ # E.g. a phone number for `sms` factors. It must be a json string with the
38
+ # required properties for the given factor type. Required when creating a new
39
+ # Factor. This value is never returned because it can contain customer secrets.
40
+ # @param [String] friendly_name The friendly name of this Factor
41
+ # @param [factor.FactorTypes] factor_type The Type of this Factor. One of
42
+ # `app-push`, `sms`, `totp`, etc.
43
+ # @param [String] config The config required for this Factor. It must be a json
44
+ # string with the required properties for the given factor type
45
+ # @return [FactorInstance] Newly created FactorInstance
46
+ def create(binding: nil, friendly_name: nil, factor_type: nil, config: nil)
47
+ data = Twilio::Values.of({
48
+ 'Binding' => binding,
49
+ 'FriendlyName' => friendly_name,
50
+ 'FactorType' => factor_type,
51
+ 'Config' => config,
52
+ })
53
+
54
+ payload = @version.create(
55
+ 'POST',
56
+ @uri,
57
+ data: data
58
+ )
59
+
60
+ FactorInstance.new(
61
+ @version,
62
+ payload,
63
+ service_sid: @solution[:service_sid],
64
+ identity: @solution[:identity],
65
+ )
66
+ end
67
+
68
+ ##
69
+ # Lists FactorInstance records from the API as a list.
70
+ # Unlike stream(), this operation is eager and will load `limit` records into
71
+ # memory before returning.
72
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
73
+ # guarantees to never return more than limit. Default is no limit
74
+ # @param [Integer] page_size Number of records to fetch per request, when
75
+ # not set will use the default value of 50 records. If no page_size is defined
76
+ # but a limit is defined, stream() will attempt to read the limit with the most
77
+ # efficient page size, i.e. min(limit, 1000)
78
+ # @return [Array] Array of up to limit results
79
+ def list(limit: nil, page_size: nil)
80
+ self.stream(limit: limit, page_size: page_size).entries
81
+ end
82
+
83
+ ##
84
+ # Streams FactorInstance records from the API as an Enumerable.
85
+ # This operation lazily loads records as efficiently as possible until the limit
86
+ # is reached.
87
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
88
+ # guarantees to never return more than limit. Default is no limit.
89
+ # @param [Integer] page_size Number of records to fetch per request, when
90
+ # not set will use the default value of 50 records. If no page_size is defined
91
+ # but a limit is defined, stream() will attempt to read the limit with the most
92
+ # efficient page size, i.e. min(limit, 1000)
93
+ # @return [Enumerable] Enumerable that will yield up to limit results
94
+ def stream(limit: nil, page_size: nil)
95
+ limits = @version.read_limits(limit, page_size)
96
+
97
+ page = self.page(page_size: limits[:page_size], )
98
+
99
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
100
+ end
101
+
102
+ ##
103
+ # When passed a block, yields FactorInstance records from the API.
104
+ # This operation lazily loads records as efficiently as possible until the limit
105
+ # is reached.
106
+ def each
107
+ limits = @version.read_limits
108
+
109
+ page = self.page(page_size: limits[:page_size], )
110
+
111
+ @version.stream(page,
112
+ limit: limits[:limit],
113
+ page_limit: limits[:page_limit]).each {|x| yield x}
114
+ end
115
+
116
+ ##
117
+ # Retrieve a single page of FactorInstance records from the API.
118
+ # Request is executed immediately.
119
+ # @param [String] page_token PageToken provided by the API
120
+ # @param [Integer] page_number Page Number, this value is simply for client state
121
+ # @param [Integer] page_size Number of records to return, defaults to 50
122
+ # @return [Page] Page of FactorInstance
123
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
124
+ params = Twilio::Values.of({
125
+ 'PageToken' => page_token,
126
+ 'Page' => page_number,
127
+ 'PageSize' => page_size,
128
+ })
129
+ response = @version.page(
130
+ 'GET',
131
+ @uri,
132
+ params
133
+ )
134
+ FactorPage.new(@version, response, @solution)
135
+ end
136
+
137
+ ##
138
+ # Retrieve a single page of FactorInstance records from the API.
139
+ # Request is executed immediately.
140
+ # @param [String] target_url API-generated URL for the requested results page
141
+ # @return [Page] Page of FactorInstance
142
+ def get_page(target_url)
143
+ response = @version.domain.request(
144
+ 'GET',
145
+ target_url
146
+ )
147
+ FactorPage.new(@version, response, @solution)
148
+ end
149
+
150
+ ##
151
+ # Provide a user friendly representation
152
+ def to_s
153
+ '#<Twilio.Verify.V2.FactorList>'
154
+ end
155
+ end
156
+
157
+ ##
158
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
159
+ class FactorPage < Page
160
+ ##
161
+ # Initialize the FactorPage
162
+ # @param [Version] version Version that contains the resource
163
+ # @param [Response] response Response from the API
164
+ # @param [Hash] solution Path solution for the resource
165
+ # @return [FactorPage] FactorPage
166
+ def initialize(version, response, solution)
167
+ super(version, response)
168
+
169
+ # Path Solution
170
+ @solution = solution
171
+ end
172
+
173
+ ##
174
+ # Build an instance of FactorInstance
175
+ # @param [Hash] payload Payload response from the API
176
+ # @return [FactorInstance] FactorInstance
177
+ def get_instance(payload)
178
+ FactorInstance.new(
179
+ @version,
180
+ payload,
181
+ service_sid: @solution[:service_sid],
182
+ identity: @solution[:identity],
183
+ )
184
+ end
185
+
186
+ ##
187
+ # Provide a user friendly representation
188
+ def to_s
189
+ '<Twilio.Verify.V2.FactorPage>'
190
+ end
191
+ end
192
+
193
+ ##
194
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
195
+ class FactorContext < InstanceContext
196
+ ##
197
+ # Initialize the FactorContext
198
+ # @param [Version] version Version that contains the resource
199
+ # @param [String] service_sid The unique SID identifier of the Service.
200
+ # @param [String] identity Customer unique identity for the Entity owner of the
201
+ # Factor
202
+ # @param [String] sid A 34 character string that uniquely identifies this Factor.
203
+ # @return [FactorContext] FactorContext
204
+ def initialize(version, service_sid, identity, sid)
205
+ super(version)
206
+
207
+ # Path Solution
208
+ @solution = {service_sid: service_sid, identity: identity, sid: sid, }
209
+ @uri = "/Services/#{@solution[:service_sid]}/Entities/#{@solution[:identity]}/Factors/#{@solution[:sid]}"
210
+
211
+ # Dependents
212
+ @challenges = nil
213
+ end
214
+
215
+ ##
216
+ # Deletes the FactorInstance
217
+ # @return [Boolean] true if delete succeeds, false otherwise
218
+ def delete
219
+ @version.delete('delete', @uri)
220
+ end
221
+
222
+ ##
223
+ # Fetch a FactorInstance
224
+ # @return [FactorInstance] Fetched FactorInstance
225
+ def fetch
226
+ params = Twilio::Values.of({})
227
+
228
+ payload = @version.fetch(
229
+ 'GET',
230
+ @uri,
231
+ params,
232
+ )
233
+
234
+ FactorInstance.new(
235
+ @version,
236
+ payload,
237
+ service_sid: @solution[:service_sid],
238
+ identity: @solution[:identity],
239
+ sid: @solution[:sid],
240
+ )
241
+ end
242
+
243
+ ##
244
+ # Update the FactorInstance
245
+ # @param [String] auth_payload The optional payload needed to verify the Factor
246
+ # for the first time. E.g. for a TOTP, the numeric code.
247
+ # @param [String] friendly_name The new friendly name of this Factor
248
+ # @param [String] config The new config for this Factor. It must be a json string
249
+ # with the required properties for the given factor type
250
+ # @return [FactorInstance] Updated FactorInstance
251
+ def update(auth_payload: :unset, friendly_name: :unset, config: :unset)
252
+ data = Twilio::Values.of({
253
+ 'AuthPayload' => auth_payload,
254
+ 'FriendlyName' => friendly_name,
255
+ 'Config' => config,
256
+ })
257
+
258
+ payload = @version.update(
259
+ 'POST',
260
+ @uri,
261
+ data: data,
262
+ )
263
+
264
+ FactorInstance.new(
265
+ @version,
266
+ payload,
267
+ service_sid: @solution[:service_sid],
268
+ identity: @solution[:identity],
269
+ sid: @solution[:sid],
270
+ )
271
+ end
272
+
273
+ ##
274
+ # Access the challenges
275
+ # @return [ChallengeList]
276
+ # @return [ChallengeContext] if sid was passed.
277
+ def challenges(sid=:unset)
278
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
279
+
280
+ if sid != :unset
281
+ return ChallengeContext.new(
282
+ @version,
283
+ @solution[:service_sid],
284
+ @solution[:identity],
285
+ @solution[:sid],
286
+ sid,
287
+ )
288
+ end
289
+
290
+ unless @challenges
291
+ @challenges = ChallengeList.new(
292
+ @version,
293
+ service_sid: @solution[:service_sid],
294
+ identity: @solution[:identity],
295
+ factor_sid: @solution[:sid],
296
+ )
297
+ end
298
+
299
+ @challenges
300
+ end
301
+
302
+ ##
303
+ # Provide a user friendly representation
304
+ def to_s
305
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
306
+ "#<Twilio.Verify.V2.FactorContext #{context}>"
307
+ end
308
+
309
+ ##
310
+ # Provide a detailed, user friendly representation
311
+ def inspect
312
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
313
+ "#<Twilio.Verify.V2.FactorContext #{context}>"
314
+ end
315
+ end
316
+
317
+ ##
318
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
319
+ class FactorInstance < InstanceResource
320
+ ##
321
+ # Initialize the FactorInstance
322
+ # @param [Version] version Version that contains the resource
323
+ # @param [Hash] payload payload that contains response from Twilio
324
+ # @param [String] service_sid The unique SID identifier of the Service.
325
+ # @param [String] identity Customer unique identity for the Entity owner of the
326
+ # Factor
327
+ # @param [String] sid A 34 character string that uniquely identifies this Factor.
328
+ # @return [FactorInstance] FactorInstance
329
+ def initialize(version, payload, service_sid: nil, identity: nil, sid: nil)
330
+ super(version)
331
+
332
+ # Marshaled Properties
333
+ @properties = {
334
+ 'sid' => payload['sid'],
335
+ 'account_sid' => payload['account_sid'],
336
+ 'service_sid' => payload['service_sid'],
337
+ 'entity_sid' => payload['entity_sid'],
338
+ 'identity' => payload['identity'],
339
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
340
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
341
+ 'friendly_name' => payload['friendly_name'],
342
+ 'status' => payload['status'],
343
+ 'factor_type' => payload['factor_type'],
344
+ 'config' => payload['config'],
345
+ 'url' => payload['url'],
346
+ 'links' => payload['links'],
347
+ }
348
+
349
+ # Context
350
+ @instance_context = nil
351
+ @params = {'service_sid' => service_sid, 'identity' => identity, 'sid' => sid || @properties['sid'], }
352
+ end
353
+
354
+ ##
355
+ # Generate an instance context for the instance, the context is capable of
356
+ # performing various actions. All instance actions are proxied to the context
357
+ # @return [FactorContext] FactorContext for this FactorInstance
358
+ def context
359
+ unless @instance_context
360
+ @instance_context = FactorContext.new(
361
+ @version,
362
+ @params['service_sid'],
363
+ @params['identity'],
364
+ @params['sid'],
365
+ )
366
+ end
367
+ @instance_context
368
+ end
369
+
370
+ ##
371
+ # @return [String] A string that uniquely identifies this Factor.
372
+ def sid
373
+ @properties['sid']
374
+ end
375
+
376
+ ##
377
+ # @return [String] Account Sid.
378
+ def account_sid
379
+ @properties['account_sid']
380
+ end
381
+
382
+ ##
383
+ # @return [String] Service Sid.
384
+ def service_sid
385
+ @properties['service_sid']
386
+ end
387
+
388
+ ##
389
+ # @return [String] Entity Sid.
390
+ def entity_sid
391
+ @properties['entity_sid']
392
+ end
393
+
394
+ ##
395
+ # @return [String] Unique identity of the Entity
396
+ def identity
397
+ @properties['identity']
398
+ end
399
+
400
+ ##
401
+ # @return [Time] The date this Factor was created
402
+ def date_created
403
+ @properties['date_created']
404
+ end
405
+
406
+ ##
407
+ # @return [Time] The date this Factor was updated
408
+ def date_updated
409
+ @properties['date_updated']
410
+ end
411
+
412
+ ##
413
+ # @return [String] A human readable description of this resource.
414
+ def friendly_name
415
+ @properties['friendly_name']
416
+ end
417
+
418
+ ##
419
+ # @return [factor.FactorStatuses] The Status of this Factor
420
+ def status
421
+ @properties['status']
422
+ end
423
+
424
+ ##
425
+ # @return [factor.FactorTypes] The Type of this Factor
426
+ def factor_type
427
+ @properties['factor_type']
428
+ end
429
+
430
+ ##
431
+ # @return [Hash] The config
432
+ def config
433
+ @properties['config']
434
+ end
435
+
436
+ ##
437
+ # @return [String] The URL of this resource.
438
+ def url
439
+ @properties['url']
440
+ end
441
+
442
+ ##
443
+ # @return [String] Nested resource URLs.
444
+ def links
445
+ @properties['links']
446
+ end
447
+
448
+ ##
449
+ # Deletes the FactorInstance
450
+ # @return [Boolean] true if delete succeeds, false otherwise
451
+ def delete
452
+ context.delete
453
+ end
454
+
455
+ ##
456
+ # Fetch a FactorInstance
457
+ # @return [FactorInstance] Fetched FactorInstance
458
+ def fetch
459
+ context.fetch
460
+ end
461
+
462
+ ##
463
+ # Update the FactorInstance
464
+ # @param [String] auth_payload The optional payload needed to verify the Factor
465
+ # for the first time. E.g. for a TOTP, the numeric code.
466
+ # @param [String] friendly_name The new friendly name of this Factor
467
+ # @param [String] config The new config for this Factor. It must be a json string
468
+ # with the required properties for the given factor type
469
+ # @return [FactorInstance] Updated FactorInstance
470
+ def update(auth_payload: :unset, friendly_name: :unset, config: :unset)
471
+ context.update(auth_payload: auth_payload, friendly_name: friendly_name, config: config, )
472
+ end
473
+
474
+ ##
475
+ # Access the challenges
476
+ # @return [challenges] challenges
477
+ def challenges
478
+ context.challenges
479
+ end
480
+
481
+ ##
482
+ # Provide a user friendly representation
483
+ def to_s
484
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
485
+ "<Twilio.Verify.V2.FactorInstance #{values}>"
486
+ end
487
+
488
+ ##
489
+ # Provide a detailed, user friendly representation
490
+ def inspect
491
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
492
+ "<Twilio.Verify.V2.FactorInstance #{values}>"
493
+ end
494
+ end
495
+ end
496
+ end
497
+ end
498
+ end
499
+ end
500
+ end