twilio-ruby 5.34.0 → 5.34.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +32 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +38 -3
  5. data/lib/twilio-ruby/rest/autopilot.rb +6 -0
  6. data/lib/twilio-ruby/rest/autopilot/v1.rb +7 -0
  7. data/lib/twilio-ruby/rest/autopilot/v1/restore_assistant.rb +198 -0
  8. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +26 -0
  9. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb +324 -0
  10. data/lib/twilio-ruby/rest/supersim.rb +8 -0
  11. data/lib/twilio-ruby/rest/supersim/v1.rb +15 -0
  12. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +44 -10
  13. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile.rb +337 -0
  14. data/lib/twilio-ruby/rest/verify/v2/service.rb +22 -3
  15. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +3 -3
  16. data/lib/twilio-ruby/rest/voice.rb +36 -0
  17. data/lib/twilio-ruby/rest/voice/v1.rb +64 -0
  18. data/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb +513 -0
  19. data/lib/twilio-ruby/rest/voice/v1/connection_policy.rb +379 -0
  20. data/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb +458 -0
  21. data/lib/twilio-ruby/rest/voice/v1/ip_record.rb +366 -0
  22. data/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb +346 -0
  23. data/lib/twilio-ruby/version.rb +1 -1
  24. data/spec/integration/api/v2010/account/sip/domain_spec.rb +12 -4
  25. data/spec/integration/api/v2010/account/token_spec.rb +23 -11
  26. data/spec/integration/autopilot/v1/restore_assistant_spec.rb +53 -0
  27. data/spec/integration/numbers/v2/regulatory_compliance/bundle/evaluation_spec.rb +623 -0
  28. data/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb +4 -0
  29. data/spec/integration/supersim/v1/fleet_spec.rb +8 -4
  30. data/spec/integration/supersim/v1/network_access_profile_spec.rb +208 -0
  31. data/spec/integration/verify/v2/service_spec.rb +4 -0
  32. data/spec/integration/voice/v1/byoc_trunk_spec.rb +250 -0
  33. data/spec/integration/voice/v1/connection_policy/connection_policy_target_spec.rb +246 -0
  34. data/spec/integration/voice/v1/connection_policy_spec.rb +226 -0
  35. data/spec/integration/voice/v1/ip_record_spec.rb +223 -0
  36. data/spec/integration/voice/v1/source_ip_mapping_spec.rb +219 -0
  37. data/twilio-ruby.gemspec +1 -1
  38. metadata +28 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3c2f4bbf217f506df9191e83264ccfc2966a7500754885341f4c0bd7626a35a
4
- data.tar.gz: 2f770e917a2b26214707107eaa47ad3052a8ef883ba1293caf47b89a87be9fef
3
+ metadata.gz: 4f3afee506f82f8d295b1b7bd408c090df9f2984bb639c1165559f837282cd0e
4
+ data.tar.gz: 3f3f1b4854f5df815c42617e0b089397925cb27f8207f22b35d0cf49011bdbdf
5
5
  SHA512:
6
- metadata.gz: 236c258000ffa8eacdb7947f3b7268fdfe5c141e0e3de6cd6ba90b2a8591a21c5dbd0fa88da678a6fbd3744aead2fcb951e92de8be9c3fc9ff7d035c132e7342
7
- data.tar.gz: f60524d0983d267aefcf3d01234bcbf39b4de400e08bfd650edbc6a0c29c0dd67f46db2985d87325d28d51649376e8df27db1f38d00c6fd24b12e1517d7b1369
6
+ metadata.gz: 715032b7a617559d21cdacaaaa769567f873ccbdc432ac40b5e3d5761c4f32c9c18d51512a3221fe35527821b0945774a0770a43653fd7815b4a7011e3f76798
7
+ data.tar.gz: 6b305639f5b8ca5fa69e97d185221e13d9b1969d95b3d89b7d112b046e82dbab4c88a8cb7d633e0eefa0bde94d6aec9a424ea2cb3cc5897368c022d35c1d25f8
data/CHANGES.md CHANGED
@@ -1,6 +1,38 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ [2020-05-13] Version 5.34.1
5
+ ---------------------------
6
+ **Api**
7
+ - Add optional `emergency_caller_sid` parameter to SIP Domain
8
+ - Updated `call_reason` optional property to be treated as PII
9
+ - Added optional BYOC Trunk Sid property to Sip Domain API resource
10
+
11
+ **Autopilot**
12
+ - Add Restore resource to Autopilot Assistant
13
+
14
+ **Contacts**
15
+ - Added contacts Create API definition
16
+
17
+ **Events**
18
+ - Subscriptions API initial release
19
+
20
+ **Numbers**
21
+ - Add Evaluations API
22
+
23
+ **Supersim**
24
+ - Allow filtering the Fleets resource by Network Access Profile
25
+ - Allow assigning a Network Access Profile when creating and updating a Fleet
26
+ - Add Network Access Profiles resource
27
+
28
+ **Verify**
29
+ - Add `CustomCode` optional parameter on Verification creation.
30
+ - Add delete action on Service resource.
31
+
32
+ **Voice**
33
+ - Added endpoints for BYOC trunks, SIP connection policies and source IP mappings
34
+
35
+
4
36
  [2020-04-29] Version 5.34.0
5
37
  ---------------------------
6
38
  **Library - Feature**
data/README.md CHANGED
@@ -32,13 +32,13 @@ This library supports the following Ruby implementations:
32
32
  To install using [Bundler][bundler] grab the latest stable version:
33
33
 
34
34
  ```ruby
35
- gem 'twilio-ruby', '~> 5.34.0'
35
+ gem 'twilio-ruby', '~> 5.34.1'
36
36
  ```
37
37
 
38
38
  To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
39
39
 
40
40
  ```bash
41
- gem install twilio-ruby -v 5.34.0
41
+ gem install twilio-ruby -v 5.34.1
42
42
  ```
43
43
 
44
44
  To build and install the development branch yourself from the latest source:
@@ -136,8 +136,13 @@ module Twilio
136
136
  # @param [Boolean] secure Whether secure SIP is enabled for the domain. If
137
137
  # enabled, TLS will be enforced and SRTP will be negotiated on all incoming calls
138
138
  # to this sip domain.
139
+ # @param [String] byoc_trunk_sid The SID of the BYOC Trunk(Bring Your Own Carrier)
140
+ # resource that the Sip Domain will be associated with.
141
+ # @param [String] emergency_caller_sid Whether an emergency caller sid is
142
+ # configured for the domain. If present, this phone number will be used as the
143
+ # callback for the emergency call.
139
144
  # @return [DomainInstance] Newly created DomainInstance
140
- def create(domain_name: nil, friendly_name: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, voice_status_callback_url: :unset, voice_status_callback_method: :unset, sip_registration: :unset, emergency_calling_enabled: :unset, secure: :unset)
145
+ def create(domain_name: nil, friendly_name: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, voice_status_callback_url: :unset, voice_status_callback_method: :unset, sip_registration: :unset, emergency_calling_enabled: :unset, secure: :unset, byoc_trunk_sid: :unset, emergency_caller_sid: :unset)
141
146
  data = Twilio::Values.of({
142
147
  'DomainName' => domain_name,
143
148
  'FriendlyName' => friendly_name,
@@ -150,6 +155,8 @@ module Twilio
150
155
  'SipRegistration' => sip_registration,
151
156
  'EmergencyCallingEnabled' => emergency_calling_enabled,
152
157
  'Secure' => secure,
158
+ 'ByocTrunkSid' => byoc_trunk_sid,
159
+ 'EmergencyCallerSid' => emergency_caller_sid,
153
160
  })
154
161
 
155
162
  payload = @version.create(
@@ -261,8 +268,13 @@ module Twilio
261
268
  # @param [Boolean] secure Whether secure SIP is enabled for the domain. If
262
269
  # enabled, TLS will be enforced and SRTP will be negotiated on all incoming calls
263
270
  # to this sip domain.
271
+ # @param [String] byoc_trunk_sid The SID of the BYOC Trunk(Bring Your Own Carrier)
272
+ # resource that the Sip Domain will be associated with.
273
+ # @param [String] emergency_caller_sid Whether an emergency caller sid is
274
+ # configured for the domain. If present, this phone number will be used as the
275
+ # callback for the emergency call.
264
276
  # @return [DomainInstance] Updated DomainInstance
265
- def update(friendly_name: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_status_callback_method: :unset, voice_status_callback_url: :unset, voice_url: :unset, sip_registration: :unset, domain_name: :unset, emergency_calling_enabled: :unset, secure: :unset)
277
+ def update(friendly_name: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_status_callback_method: :unset, voice_status_callback_url: :unset, voice_url: :unset, sip_registration: :unset, domain_name: :unset, emergency_calling_enabled: :unset, secure: :unset, byoc_trunk_sid: :unset, emergency_caller_sid: :unset)
266
278
  data = Twilio::Values.of({
267
279
  'FriendlyName' => friendly_name,
268
280
  'VoiceFallbackMethod' => voice_fallback_method,
@@ -275,6 +287,8 @@ module Twilio
275
287
  'DomainName' => domain_name,
276
288
  'EmergencyCallingEnabled' => emergency_calling_enabled,
277
289
  'Secure' => secure,
290
+ 'ByocTrunkSid' => byoc_trunk_sid,
291
+ 'EmergencyCallerSid' => emergency_caller_sid,
278
292
  })
279
293
 
280
294
  payload = @version.update(
@@ -407,6 +421,8 @@ module Twilio
407
421
  'sip_registration' => payload['sip_registration'],
408
422
  'emergency_calling_enabled' => payload['emergency_calling_enabled'],
409
423
  'secure' => payload['secure'],
424
+ 'byoc_trunk_sid' => payload['byoc_trunk_sid'],
425
+ 'emergency_caller_sid' => payload['emergency_caller_sid'],
410
426
  }
411
427
 
412
428
  # Context
@@ -539,6 +555,18 @@ module Twilio
539
555
  @properties['secure']
540
556
  end
541
557
 
558
+ ##
559
+ # @return [String] The SID of the BYOC Trunk resource.
560
+ def byoc_trunk_sid
561
+ @properties['byoc_trunk_sid']
562
+ end
563
+
564
+ ##
565
+ # @return [String] Whether an emergency caller sid is configured for the domain.
566
+ def emergency_caller_sid
567
+ @properties['emergency_caller_sid']
568
+ end
569
+
542
570
  ##
543
571
  # Fetch a DomainInstance
544
572
  # @return [DomainInstance] Fetched DomainInstance
@@ -572,8 +600,13 @@ module Twilio
572
600
  # @param [Boolean] secure Whether secure SIP is enabled for the domain. If
573
601
  # enabled, TLS will be enforced and SRTP will be negotiated on all incoming calls
574
602
  # to this sip domain.
603
+ # @param [String] byoc_trunk_sid The SID of the BYOC Trunk(Bring Your Own Carrier)
604
+ # resource that the Sip Domain will be associated with.
605
+ # @param [String] emergency_caller_sid Whether an emergency caller sid is
606
+ # configured for the domain. If present, this phone number will be used as the
607
+ # callback for the emergency call.
575
608
  # @return [DomainInstance] Updated DomainInstance
576
- def update(friendly_name: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_status_callback_method: :unset, voice_status_callback_url: :unset, voice_url: :unset, sip_registration: :unset, domain_name: :unset, emergency_calling_enabled: :unset, secure: :unset)
609
+ def update(friendly_name: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_status_callback_method: :unset, voice_status_callback_url: :unset, voice_url: :unset, sip_registration: :unset, domain_name: :unset, emergency_calling_enabled: :unset, secure: :unset, byoc_trunk_sid: :unset, emergency_caller_sid: :unset)
577
610
  context.update(
578
611
  friendly_name: friendly_name,
579
612
  voice_fallback_method: voice_fallback_method,
@@ -586,6 +619,8 @@ module Twilio
586
619
  domain_name: domain_name,
587
620
  emergency_calling_enabled: emergency_calling_enabled,
588
621
  secure: secure,
622
+ byoc_trunk_sid: byoc_trunk_sid,
623
+ emergency_caller_sid: emergency_caller_sid,
589
624
  )
590
625
  end
591
626
 
@@ -37,6 +37,12 @@ module Twilio
37
37
  self.v1.assistants(sid)
38
38
  end
39
39
 
40
+ ##
41
+ # @return [Twilio::REST::Autopilot::V1::RestoreAssistantInstance]
42
+ def restore_assistant
43
+ self.v1.restore_assistant()
44
+ end
45
+
40
46
  ##
41
47
  # Provide a user friendly representation
42
48
  def to_s
@@ -16,6 +16,7 @@ module Twilio
16
16
  super
17
17
  @version = 'v1'
18
18
  @assistants = nil
19
+ @restore_assistant = nil
19
20
  end
20
21
 
21
22
  ##
@@ -33,6 +34,12 @@ module Twilio
33
34
  end
34
35
  end
35
36
 
37
+ ##
38
+ # @return [Twilio::REST::Autopilot::V1::RestoreAssistantContext]
39
+ def restore_assistant
40
+ @restore_assistant ||= RestoreAssistantList.new self
41
+ end
42
+
36
43
  ##
37
44
  # Provide a user friendly representation
38
45
  def to_s
@@ -0,0 +1,198 @@
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 Autopilot < Domain
12
+ class V1 < Version
13
+ ##
14
+ # 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.
15
+ class RestoreAssistantList < ListResource
16
+ ##
17
+ # Initialize the RestoreAssistantList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [RestoreAssistantList] RestoreAssistantList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Assistants/Restore"
26
+ end
27
+
28
+ ##
29
+ # Update the RestoreAssistantInstance
30
+ # @param [String] assistant The Twilio-provided string that uniquely identifies
31
+ # the Assistant resource to restore.
32
+ # @return [RestoreAssistantInstance] Updated RestoreAssistantInstance
33
+ def update(assistant: nil)
34
+ data = Twilio::Values.of({'Assistant' => assistant, })
35
+
36
+ payload = @version.update(
37
+ 'POST',
38
+ @uri,
39
+ data: data,
40
+ )
41
+
42
+ RestoreAssistantInstance.new(@version, payload, )
43
+ end
44
+
45
+ ##
46
+ # Provide a user friendly representation
47
+ def to_s
48
+ '#<Twilio.Autopilot.V1.RestoreAssistantList>'
49
+ end
50
+ end
51
+
52
+ ##
53
+ # 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.
54
+ class RestoreAssistantPage < Page
55
+ ##
56
+ # Initialize the RestoreAssistantPage
57
+ # @param [Version] version Version that contains the resource
58
+ # @param [Response] response Response from the API
59
+ # @param [Hash] solution Path solution for the resource
60
+ # @return [RestoreAssistantPage] RestoreAssistantPage
61
+ def initialize(version, response, solution)
62
+ super(version, response)
63
+
64
+ # Path Solution
65
+ @solution = solution
66
+ end
67
+
68
+ ##
69
+ # Build an instance of RestoreAssistantInstance
70
+ # @param [Hash] payload Payload response from the API
71
+ # @return [RestoreAssistantInstance] RestoreAssistantInstance
72
+ def get_instance(payload)
73
+ RestoreAssistantInstance.new(@version, payload, )
74
+ end
75
+
76
+ ##
77
+ # Provide a user friendly representation
78
+ def to_s
79
+ '<Twilio.Autopilot.V1.RestoreAssistantPage>'
80
+ end
81
+ end
82
+
83
+ ##
84
+ # 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.
85
+ class RestoreAssistantInstance < InstanceResource
86
+ ##
87
+ # Initialize the RestoreAssistantInstance
88
+ # @param [Version] version Version that contains the resource
89
+ # @param [Hash] payload payload that contains response from Twilio
90
+ # @return [RestoreAssistantInstance] RestoreAssistantInstance
91
+ def initialize(version, payload)
92
+ super(version)
93
+
94
+ # Marshaled Properties
95
+ @properties = {
96
+ 'account_sid' => payload['account_sid'],
97
+ 'sid' => payload['sid'],
98
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
99
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
100
+ 'unique_name' => payload['unique_name'],
101
+ 'friendly_name' => payload['friendly_name'],
102
+ 'needs_model_build' => payload['needs_model_build'],
103
+ 'latest_model_build_sid' => payload['latest_model_build_sid'],
104
+ 'log_queries' => payload['log_queries'],
105
+ 'development_stage' => payload['development_stage'],
106
+ 'callback_url' => payload['callback_url'],
107
+ 'callback_events' => payload['callback_events'],
108
+ }
109
+ end
110
+
111
+ ##
112
+ # @return [String] The SID of the Account that created the resource
113
+ def account_sid
114
+ @properties['account_sid']
115
+ end
116
+
117
+ ##
118
+ # @return [String] The unique string that identifies the resource
119
+ def sid
120
+ @properties['sid']
121
+ end
122
+
123
+ ##
124
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was created
125
+ def date_created
126
+ @properties['date_created']
127
+ end
128
+
129
+ ##
130
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was last updated
131
+ def date_updated
132
+ @properties['date_updated']
133
+ end
134
+
135
+ ##
136
+ # @return [String] An application-defined string that uniquely identifies the resource
137
+ def unique_name
138
+ @properties['unique_name']
139
+ end
140
+
141
+ ##
142
+ # @return [String] The string that you assigned to describe the resource
143
+ def friendly_name
144
+ @properties['friendly_name']
145
+ end
146
+
147
+ ##
148
+ # @return [Boolean] Whether model needs to be rebuilt
149
+ def needs_model_build
150
+ @properties['needs_model_build']
151
+ end
152
+
153
+ ##
154
+ # @return [String] Reserved
155
+ def latest_model_build_sid
156
+ @properties['latest_model_build_sid']
157
+ end
158
+
159
+ ##
160
+ # @return [Boolean] Whether queries should be logged and kept after training
161
+ def log_queries
162
+ @properties['log_queries']
163
+ end
164
+
165
+ ##
166
+ # @return [String] A string describing the state of the assistant.
167
+ def development_stage
168
+ @properties['development_stage']
169
+ end
170
+
171
+ ##
172
+ # @return [String] Reserved
173
+ def callback_url
174
+ @properties['callback_url']
175
+ end
176
+
177
+ ##
178
+ # @return [String] Reserved
179
+ def callback_events
180
+ @properties['callback_events']
181
+ end
182
+
183
+ ##
184
+ # Provide a user friendly representation
185
+ def to_s
186
+ "<Twilio.Autopilot.V1.RestoreAssistantInstance>"
187
+ end
188
+
189
+ ##
190
+ # Provide a detailed, user friendly representation
191
+ def inspect
192
+ "<Twilio.Autopilot.V1.RestoreAssistantInstance>"
193
+ end
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
@@ -242,6 +242,7 @@ module Twilio
242
242
  @uri = "/RegulatoryCompliance/Bundles/#{@solution[:sid]}"
243
243
 
244
244
  # Dependents
245
+ @evaluations = nil
245
246
  @item_assignments = nil
246
247
  end
247
248
 
@@ -287,6 +288,24 @@ module Twilio
287
288
  BundleInstance.new(@version, payload, sid: @solution[:sid], )
288
289
  end
289
290
 
291
+ ##
292
+ # Access the evaluations
293
+ # @return [EvaluationList]
294
+ # @return [EvaluationContext] if sid was passed.
295
+ def evaluations(sid=:unset)
296
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
297
+
298
+ if sid != :unset
299
+ return EvaluationContext.new(@version, @solution[:sid], sid, )
300
+ end
301
+
302
+ unless @evaluations
303
+ @evaluations = EvaluationList.new(@version, bundle_sid: @solution[:sid], )
304
+ end
305
+
306
+ @evaluations
307
+ end
308
+
290
309
  ##
291
310
  # Access the item_assignments
292
311
  # @return [ItemAssignmentList]
@@ -454,6 +473,13 @@ module Twilio
454
473
  )
455
474
  end
456
475
 
476
+ ##
477
+ # Access the evaluations
478
+ # @return [evaluations] evaluations
479
+ def evaluations
480
+ context.evaluations
481
+ end
482
+
457
483
  ##
458
484
  # Access the item_assignments
459
485
  # @return [item_assignments] item_assignments
@@ -0,0 +1,324 @@
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 Numbers < Domain
12
+ class V2 < Version
13
+ class RegulatoryComplianceList < ListResource
14
+ class BundleContext < InstanceContext
15
+ class EvaluationList < ListResource
16
+ ##
17
+ # Initialize the EvaluationList
18
+ # @param [Version] version Version that contains the resource
19
+ # @param [String] bundle_sid The unique string that we created to identify the
20
+ # Bundle resource.
21
+ # @return [EvaluationList] EvaluationList
22
+ def initialize(version, bundle_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {bundle_sid: bundle_sid}
27
+ @uri = "/RegulatoryCompliance/Bundles/#{@solution[:bundle_sid]}/Evaluations"
28
+ end
29
+
30
+ ##
31
+ # Retrieve a single page of EvaluationInstance records from the API.
32
+ # Request is executed immediately.
33
+ # @return [EvaluationInstance] Newly created EvaluationInstance
34
+ def create
35
+ data = Twilio::Values.of({})
36
+
37
+ payload = @version.create(
38
+ 'POST',
39
+ @uri,
40
+ data: data
41
+ )
42
+
43
+ EvaluationInstance.new(@version, payload, bundle_sid: @solution[:bundle_sid], )
44
+ end
45
+
46
+ ##
47
+ # Lists EvaluationInstance records from the API as a list.
48
+ # Unlike stream(), this operation is eager and will load `limit` records into
49
+ # memory before returning.
50
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
51
+ # guarantees to never return more than limit. Default is no limit
52
+ # @param [Integer] page_size Number of records to fetch per request, when
53
+ # not set will use the default value of 50 records. If no page_size is defined
54
+ # but a limit is defined, stream() will attempt to read the limit with the most
55
+ # efficient page size, i.e. min(limit, 1000)
56
+ # @return [Array] Array of up to limit results
57
+ def list(limit: nil, page_size: nil)
58
+ self.stream(limit: limit, page_size: page_size).entries
59
+ end
60
+
61
+ ##
62
+ # Streams EvaluationInstance records from the API as an Enumerable.
63
+ # This operation lazily loads records as efficiently as possible until the limit
64
+ # is reached.
65
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
66
+ # guarantees to never return more than limit. Default is no limit.
67
+ # @param [Integer] page_size Number of records to fetch per request, when
68
+ # not set will use the default value of 50 records. If no page_size is defined
69
+ # but a limit is defined, stream() will attempt to read the limit with the most
70
+ # efficient page size, i.e. min(limit, 1000)
71
+ # @return [Enumerable] Enumerable that will yield up to limit results
72
+ def stream(limit: nil, page_size: nil)
73
+ limits = @version.read_limits(limit, page_size)
74
+
75
+ page = self.page(page_size: limits[:page_size], )
76
+
77
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
78
+ end
79
+
80
+ ##
81
+ # When passed a block, yields EvaluationInstance records from the API.
82
+ # This operation lazily loads records as efficiently as possible until the limit
83
+ # is reached.
84
+ def each
85
+ limits = @version.read_limits
86
+
87
+ page = self.page(page_size: limits[:page_size], )
88
+
89
+ @version.stream(page,
90
+ limit: limits[:limit],
91
+ page_limit: limits[:page_limit]).each {|x| yield x}
92
+ end
93
+
94
+ ##
95
+ # Retrieve a single page of EvaluationInstance records from the API.
96
+ # Request is executed immediately.
97
+ # @param [String] page_token PageToken provided by the API
98
+ # @param [Integer] page_number Page Number, this value is simply for client state
99
+ # @param [Integer] page_size Number of records to return, defaults to 50
100
+ # @return [Page] Page of EvaluationInstance
101
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
102
+ params = Twilio::Values.of({
103
+ 'PageToken' => page_token,
104
+ 'Page' => page_number,
105
+ 'PageSize' => page_size,
106
+ })
107
+ response = @version.page(
108
+ 'GET',
109
+ @uri,
110
+ params
111
+ )
112
+ EvaluationPage.new(@version, response, @solution)
113
+ end
114
+
115
+ ##
116
+ # Retrieve a single page of EvaluationInstance records from the API.
117
+ # Request is executed immediately.
118
+ # @param [String] target_url API-generated URL for the requested results page
119
+ # @return [Page] Page of EvaluationInstance
120
+ def get_page(target_url)
121
+ response = @version.domain.request(
122
+ 'GET',
123
+ target_url
124
+ )
125
+ EvaluationPage.new(@version, response, @solution)
126
+ end
127
+
128
+ ##
129
+ # Provide a user friendly representation
130
+ def to_s
131
+ '#<Twilio.Numbers.V2.EvaluationList>'
132
+ end
133
+ end
134
+
135
+ class EvaluationPage < Page
136
+ ##
137
+ # Initialize the EvaluationPage
138
+ # @param [Version] version Version that contains the resource
139
+ # @param [Response] response Response from the API
140
+ # @param [Hash] solution Path solution for the resource
141
+ # @return [EvaluationPage] EvaluationPage
142
+ def initialize(version, response, solution)
143
+ super(version, response)
144
+
145
+ # Path Solution
146
+ @solution = solution
147
+ end
148
+
149
+ ##
150
+ # Build an instance of EvaluationInstance
151
+ # @param [Hash] payload Payload response from the API
152
+ # @return [EvaluationInstance] EvaluationInstance
153
+ def get_instance(payload)
154
+ EvaluationInstance.new(@version, payload, bundle_sid: @solution[:bundle_sid], )
155
+ end
156
+
157
+ ##
158
+ # Provide a user friendly representation
159
+ def to_s
160
+ '<Twilio.Numbers.V2.EvaluationPage>'
161
+ end
162
+ end
163
+
164
+ class EvaluationContext < InstanceContext
165
+ ##
166
+ # Initialize the EvaluationContext
167
+ # @param [Version] version Version that contains the resource
168
+ # @param [String] bundle_sid The unique string that we created to identify the
169
+ # Bundle resource.
170
+ # @param [String] sid The unique string that identifies the Evaluation resource.
171
+ # @return [EvaluationContext] EvaluationContext
172
+ def initialize(version, bundle_sid, sid)
173
+ super(version)
174
+
175
+ # Path Solution
176
+ @solution = {bundle_sid: bundle_sid, sid: sid, }
177
+ @uri = "/RegulatoryCompliance/Bundles/#{@solution[:bundle_sid]}/Evaluations/#{@solution[:sid]}"
178
+ end
179
+
180
+ ##
181
+ # Fetch a EvaluationInstance
182
+ # @return [EvaluationInstance] Fetched EvaluationInstance
183
+ def fetch
184
+ params = Twilio::Values.of({})
185
+
186
+ payload = @version.fetch(
187
+ 'GET',
188
+ @uri,
189
+ params,
190
+ )
191
+
192
+ EvaluationInstance.new(@version, payload, bundle_sid: @solution[:bundle_sid], sid: @solution[:sid], )
193
+ end
194
+
195
+ ##
196
+ # Provide a user friendly representation
197
+ def to_s
198
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
199
+ "#<Twilio.Numbers.V2.EvaluationContext #{context}>"
200
+ end
201
+
202
+ ##
203
+ # Provide a detailed, user friendly representation
204
+ def inspect
205
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
206
+ "#<Twilio.Numbers.V2.EvaluationContext #{context}>"
207
+ end
208
+ end
209
+
210
+ class EvaluationInstance < InstanceResource
211
+ ##
212
+ # Initialize the EvaluationInstance
213
+ # @param [Version] version Version that contains the resource
214
+ # @param [Hash] payload payload that contains response from Twilio
215
+ # @param [String] bundle_sid The unique string that we created to identify the
216
+ # Bundle resource.
217
+ # @param [String] sid The unique string that identifies the Evaluation resource.
218
+ # @return [EvaluationInstance] EvaluationInstance
219
+ def initialize(version, payload, bundle_sid: nil, sid: nil)
220
+ super(version)
221
+
222
+ # Marshaled Properties
223
+ @properties = {
224
+ 'sid' => payload['sid'],
225
+ 'account_sid' => payload['account_sid'],
226
+ 'regulation_sid' => payload['regulation_sid'],
227
+ 'bundle_sid' => payload['bundle_sid'],
228
+ 'status' => payload['status'],
229
+ 'results' => payload['results'],
230
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
231
+ 'url' => payload['url'],
232
+ }
233
+
234
+ # Context
235
+ @instance_context = nil
236
+ @params = {'bundle_sid' => bundle_sid, 'sid' => sid || @properties['sid'], }
237
+ end
238
+
239
+ ##
240
+ # Generate an instance context for the instance, the context is capable of
241
+ # performing various actions. All instance actions are proxied to the context
242
+ # @return [EvaluationContext] EvaluationContext for this EvaluationInstance
243
+ def context
244
+ unless @instance_context
245
+ @instance_context = EvaluationContext.new(@version, @params['bundle_sid'], @params['sid'], )
246
+ end
247
+ @instance_context
248
+ end
249
+
250
+ ##
251
+ # @return [String] The unique string that identifies the Evaluation resource
252
+ def sid
253
+ @properties['sid']
254
+ end
255
+
256
+ ##
257
+ # @return [String] The SID of the Account that created the resource
258
+ def account_sid
259
+ @properties['account_sid']
260
+ end
261
+
262
+ ##
263
+ # @return [String] The unique string of a regulation
264
+ def regulation_sid
265
+ @properties['regulation_sid']
266
+ end
267
+
268
+ ##
269
+ # @return [String] The unique string that identifies the resource
270
+ def bundle_sid
271
+ @properties['bundle_sid']
272
+ end
273
+
274
+ ##
275
+ # @return [evaluation.Status] The compliance status of the Evaluation resource
276
+ def status
277
+ @properties['status']
278
+ end
279
+
280
+ ##
281
+ # @return [Hash] The results of the Evaluation resource
282
+ def results
283
+ @properties['results']
284
+ end
285
+
286
+ ##
287
+ # @return [Time] The date_created
288
+ def date_created
289
+ @properties['date_created']
290
+ end
291
+
292
+ ##
293
+ # @return [String] The url
294
+ def url
295
+ @properties['url']
296
+ end
297
+
298
+ ##
299
+ # Fetch a EvaluationInstance
300
+ # @return [EvaluationInstance] Fetched EvaluationInstance
301
+ def fetch
302
+ context.fetch
303
+ end
304
+
305
+ ##
306
+ # Provide a user friendly representation
307
+ def to_s
308
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
309
+ "<Twilio.Numbers.V2.EvaluationInstance #{values}>"
310
+ end
311
+
312
+ ##
313
+ # Provide a detailed, user friendly representation
314
+ def inspect
315
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
316
+ "<Twilio.Numbers.V2.EvaluationInstance #{values}>"
317
+ end
318
+ end
319
+ end
320
+ end
321
+ end
322
+ end
323
+ end
324
+ end