twilio-ruby 5.33.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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.rubocop_todo.yml +5 -26
  4. data/.travis.yml +9 -1
  5. data/CHANGES.md +110 -0
  6. data/README.md +17 -2
  7. data/lib/twilio-ruby.rb +4 -12
  8. data/lib/twilio-ruby/framework/error.rb +3 -3
  9. data/lib/twilio-ruby/jwt/jwt.rb +6 -0
  10. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +90 -90
  11. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +14 -0
  12. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +75 -72
  13. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +29 -29
  14. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +38 -3
  15. data/lib/twilio-ruby/rest/autopilot.rb +6 -0
  16. data/lib/twilio-ruby/rest/autopilot/v1.rb +7 -0
  17. data/lib/twilio-ruby/rest/autopilot/v1/restore_assistant.rb +198 -0
  18. data/lib/twilio-ruby/rest/client.rb +35 -8
  19. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +19 -3
  20. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +27 -4
  21. data/lib/twilio-ruby/rest/flex_api/v1/channel.rb +2 -1
  22. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +7 -0
  23. data/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +20 -11
  24. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +26 -0
  25. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb +324 -0
  26. data/lib/twilio-ruby/rest/preview/trusted_comms/business.rb +26 -0
  27. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand.rb +239 -0
  28. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel.rb +266 -0
  29. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel/channel.rb +197 -0
  30. data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +7 -0
  31. data/lib/twilio-ruby/rest/studio.rb +2 -2
  32. data/lib/twilio-ruby/rest/studio/v1/flow/execution.rb +26 -0
  33. data/lib/twilio-ruby/rest/studio/v2.rb +3 -3
  34. data/lib/twilio-ruby/rest/studio/v2/flow.rb +7 -0
  35. data/lib/twilio-ruby/rest/studio/v2/flow/execution.rb +71 -24
  36. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb +12 -11
  37. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb +21 -20
  38. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb +18 -15
  39. data/lib/twilio-ruby/rest/supersim.rb +18 -0
  40. data/lib/twilio-ruby/rest/supersim/v1.rb +30 -0
  41. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +53 -10
  42. data/lib/twilio-ruby/rest/supersim/v1/network.rb +315 -0
  43. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile.rb +378 -0
  44. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb +352 -0
  45. data/lib/twilio-ruby/rest/verify.rb +9 -0
  46. data/lib/twilio-ruby/rest/verify/v2.rb +16 -0
  47. data/lib/twilio-ruby/rest/verify/v2/form.rb +197 -0
  48. data/lib/twilio-ruby/rest/verify/v2/service.rb +48 -3
  49. data/lib/twilio-ruby/rest/verify/v2/service/entity.rb +379 -0
  50. data/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb +500 -0
  51. data/lib/twilio-ruby/rest/verify/v2/service/entity/factor/challenge.rb +494 -0
  52. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +3 -3
  53. data/lib/twilio-ruby/rest/video/v1/composition_settings.rb +8 -12
  54. data/lib/twilio-ruby/rest/video/v1/recording_settings.rb +8 -12
  55. data/lib/twilio-ruby/rest/voice.rb +36 -0
  56. data/lib/twilio-ruby/rest/voice/v1.rb +64 -0
  57. data/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb +513 -0
  58. data/lib/twilio-ruby/rest/voice/v1/connection_policy.rb +379 -0
  59. data/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb +458 -0
  60. data/lib/twilio-ruby/rest/voice/v1/ip_record.rb +366 -0
  61. data/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb +346 -0
  62. data/lib/twilio-ruby/twiml/twiml.rb +4 -0
  63. data/lib/twilio-ruby/twiml/voice_response.rb +3 -2
  64. data/lib/twilio-ruby/util/configuration.rb +9 -1
  65. data/lib/twilio-ruby/version.rb +1 -1
  66. data/spec/integration/api/v2010/account/call_spec.rb +5 -5
  67. data/spec/integration/api/v2010/account/conference_spec.rb +42 -14
  68. data/spec/integration/api/v2010/account/sip/domain_spec.rb +12 -4
  69. data/spec/integration/api/v2010/account/token_spec.rb +23 -11
  70. data/spec/integration/autopilot/v1/restore_assistant_spec.rb +53 -0
  71. data/spec/integration/bulkexports/v1/export/day_spec.rb +1 -1
  72. data/spec/integration/conversations/v1/conversation/participant_spec.rb +7 -0
  73. data/spec/integration/conversations/v1/conversation_spec.rb +4 -0
  74. data/spec/integration/flex_api/v1/configuration_spec.rb +3 -0
  75. data/spec/integration/numbers/v2/regulatory_compliance/bundle/evaluation_spec.rb +623 -0
  76. data/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb +4 -0
  77. data/spec/integration/preview/bulk_exports/export/day_spec.rb +1 -1
  78. data/spec/integration/preview/trusted_comms/business/brand/branded_channel/channel_spec.rb +54 -0
  79. data/spec/integration/preview/trusted_comms/business/brand/branded_channel_spec.rb +52 -0
  80. data/spec/integration/preview/trusted_comms/business/brand_spec.rb +49 -0
  81. data/spec/integration/preview/trusted_comms/business_spec.rb +1 -0
  82. data/spec/integration/serverless/v1/service/asset/asset_version_spec.rb +1 -1
  83. data/spec/integration/serverless/v1/service/build_spec.rb +4 -4
  84. data/spec/integration/serverless/v1/service/environment/log_spec.rb +1 -0
  85. data/spec/integration/serverless/v1/service/function/function_version_spec.rb +1 -1
  86. data/spec/integration/studio/v1/flow/execution_spec.rb +46 -0
  87. data/spec/integration/studio/v2/flow/execution_spec.rb +45 -0
  88. data/spec/integration/studio/v2/flow_spec.rb +4 -0
  89. data/spec/integration/studio/v2/flow_validate_spec.rb +2 -2
  90. data/spec/integration/supersim/v1/fleet_spec.rb +12 -4
  91. data/spec/integration/supersim/v1/network_access_profile/network_access_profile_network_spec.rb +179 -0
  92. data/spec/integration/supersim/v1/network_access_profile_spec.rb +223 -0
  93. data/spec/integration/supersim/v1/network_spec.rb +139 -0
  94. data/spec/integration/trunking/v1/trunk/credential_list_spec.rb +13 -13
  95. data/spec/integration/trunking/v1/trunk/ip_access_control_list_spec.rb +23 -23
  96. data/spec/integration/trunking/v1/trunk/origination_url_spec.rb +28 -28
  97. data/spec/integration/trunking/v1/trunk/phone_number_spec.rb +17 -17
  98. data/spec/integration/trunking/v1/trunk_spec.rb +33 -33
  99. data/spec/integration/verify/v2/form_spec.rb +48 -0
  100. data/spec/integration/verify/v2/service/entity/factor/challenge_spec.rb +353 -0
  101. data/spec/integration/verify/v2/service/entity/factor_spec.rb +298 -0
  102. data/spec/integration/verify/v2/service/entity_spec.rb +201 -0
  103. data/spec/integration/verify/v2/service_spec.rb +28 -4
  104. data/spec/integration/video/v1/composition_settings_spec.rb +2 -2
  105. data/spec/integration/video/v1/recording_settings_spec.rb +2 -2
  106. data/spec/integration/video/v1/recording_spec.rb +2 -2
  107. data/spec/integration/video/v1/room/recording_spec.rb +2 -2
  108. data/spec/integration/voice/v1/byoc_trunk_spec.rb +250 -0
  109. data/spec/integration/voice/v1/connection_policy/connection_policy_target_spec.rb +246 -0
  110. data/spec/integration/voice/v1/connection_policy_spec.rb +226 -0
  111. data/spec/integration/voice/v1/ip_record_spec.rb +223 -0
  112. data/spec/integration/voice/v1/source_ip_mapping_spec.rb +219 -0
  113. data/spec/rest/client_spec.rb +173 -23
  114. data/spec/util/configuration_spec.rb +12 -0
  115. data/twilio-ruby.gemspec +4 -4
  116. metadata +67 -10
@@ -45,8 +45,11 @@ module Twilio
45
45
  # at the end of an SMS verification body. Disabled by default and applies only to
46
46
  # SMS. Example SMS body: `Your AppName verification code is: 1234. Don’t share
47
47
  # this code with anyone; our employees will never ask for the code`
48
+ # @param [Boolean] custom_code_enabled Whether to allow sending verifications with
49
+ # a custom code instead of a randomly generated one. Not available for all
50
+ # customers.
48
51
  # @return [ServiceInstance] Newly created ServiceInstance
49
- def create(friendly_name: nil, code_length: :unset, lookup_enabled: :unset, skip_sms_to_landlines: :unset, dtmf_input_required: :unset, tts_name: :unset, psd2_enabled: :unset, do_not_share_warning_enabled: :unset)
52
+ def create(friendly_name: nil, code_length: :unset, lookup_enabled: :unset, skip_sms_to_landlines: :unset, dtmf_input_required: :unset, tts_name: :unset, psd2_enabled: :unset, do_not_share_warning_enabled: :unset, custom_code_enabled: :unset)
50
53
  data = Twilio::Values.of({
51
54
  'FriendlyName' => friendly_name,
52
55
  'CodeLength' => code_length,
@@ -56,6 +59,7 @@ module Twilio
56
59
  'TtsName' => tts_name,
57
60
  'Psd2Enabled' => psd2_enabled,
58
61
  'DoNotShareWarningEnabled' => do_not_share_warning_enabled,
62
+ 'CustomCodeEnabled' => custom_code_enabled,
59
63
  })
60
64
 
61
65
  payload = @version.create(
@@ -204,6 +208,7 @@ module Twilio
204
208
  @verification_checks = nil
205
209
  @rate_limits = nil
206
210
  @messaging_configurations = nil
211
+ @entities = nil
207
212
  end
208
213
 
209
214
  ##
@@ -247,8 +252,11 @@ module Twilio
247
252
  # starting a verification.
248
253
  # @param [Boolean] do_not_share_warning_enabled Whether to add a privacy warning
249
254
  # at the end of an SMS. **Disabled by default and applies only for SMS.**
255
+ # @param [Boolean] custom_code_enabled Whether to allow sending verifications with
256
+ # a custom code instead of a randomly generated one. Not available for all
257
+ # customers.
250
258
  # @return [ServiceInstance] Updated ServiceInstance
251
- def update(friendly_name: :unset, code_length: :unset, lookup_enabled: :unset, skip_sms_to_landlines: :unset, dtmf_input_required: :unset, tts_name: :unset, psd2_enabled: :unset, do_not_share_warning_enabled: :unset)
259
+ def update(friendly_name: :unset, code_length: :unset, lookup_enabled: :unset, skip_sms_to_landlines: :unset, dtmf_input_required: :unset, tts_name: :unset, psd2_enabled: :unset, do_not_share_warning_enabled: :unset, custom_code_enabled: :unset)
252
260
  data = Twilio::Values.of({
253
261
  'FriendlyName' => friendly_name,
254
262
  'CodeLength' => code_length,
@@ -258,6 +266,7 @@ module Twilio
258
266
  'TtsName' => tts_name,
259
267
  'Psd2Enabled' => psd2_enabled,
260
268
  'DoNotShareWarningEnabled' => do_not_share_warning_enabled,
269
+ 'CustomCodeEnabled' => custom_code_enabled,
261
270
  })
262
271
 
263
272
  payload = @version.update(
@@ -335,6 +344,24 @@ module Twilio
335
344
  @messaging_configurations
336
345
  end
337
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
+
338
365
  ##
339
366
  # Provide a user friendly representation
340
367
  def to_s
@@ -373,6 +400,7 @@ module Twilio
373
400
  'dtmf_input_required' => payload['dtmf_input_required'],
374
401
  'tts_name' => payload['tts_name'],
375
402
  'do_not_share_warning_enabled' => payload['do_not_share_warning_enabled'],
403
+ 'custom_code_enabled' => payload['custom_code_enabled'],
376
404
  'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
377
405
  'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
378
406
  'url' => payload['url'],
@@ -455,6 +483,12 @@ module Twilio
455
483
  @properties['do_not_share_warning_enabled']
456
484
  end
457
485
 
486
+ ##
487
+ # @return [Boolean] Whether to allow sending verifications with a custom code.
488
+ def custom_code_enabled
489
+ @properties['custom_code_enabled']
490
+ end
491
+
458
492
  ##
459
493
  # @return [Time] The RFC 2822 date and time in GMT when the resource was created
460
494
  def date_created
@@ -512,8 +546,11 @@ module Twilio
512
546
  # starting a verification.
513
547
  # @param [Boolean] do_not_share_warning_enabled Whether to add a privacy warning
514
548
  # at the end of an SMS. **Disabled by default and applies only for SMS.**
549
+ # @param [Boolean] custom_code_enabled Whether to allow sending verifications with
550
+ # a custom code instead of a randomly generated one. Not available for all
551
+ # customers.
515
552
  # @return [ServiceInstance] Updated ServiceInstance
516
- def update(friendly_name: :unset, code_length: :unset, lookup_enabled: :unset, skip_sms_to_landlines: :unset, dtmf_input_required: :unset, tts_name: :unset, psd2_enabled: :unset, do_not_share_warning_enabled: :unset)
553
+ def update(friendly_name: :unset, code_length: :unset, lookup_enabled: :unset, skip_sms_to_landlines: :unset, dtmf_input_required: :unset, tts_name: :unset, psd2_enabled: :unset, do_not_share_warning_enabled: :unset, custom_code_enabled: :unset)
517
554
  context.update(
518
555
  friendly_name: friendly_name,
519
556
  code_length: code_length,
@@ -523,6 +560,7 @@ module Twilio
523
560
  tts_name: tts_name,
524
561
  psd2_enabled: psd2_enabled,
525
562
  do_not_share_warning_enabled: do_not_share_warning_enabled,
563
+ custom_code_enabled: custom_code_enabled,
526
564
  )
527
565
  end
528
566
 
@@ -554,6 +592,13 @@ module Twilio
554
592
  context.messaging_configurations
555
593
  end
556
594
 
595
+ ##
596
+ # Access the entities
597
+ # @return [entities] entities
598
+ def entities
599
+ context.entities
600
+ end
601
+
557
602
  ##
558
603
  # Provide a user friendly representation
559
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