twilio-ruby 5.4.3 → 5.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +12 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/framework/serialize.rb +9 -0
  5. data/lib/twilio-ruby/http/http_client.rb +1 -1
  6. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +1 -1
  7. data/lib/twilio-ruby/rest/api/v2010/account/call/feedback.rb +8 -2
  8. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +2 -2
  9. data/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb +1 -1
  10. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +1 -1
  11. data/lib/twilio-ruby/rest/chat/v1/service.rb +1 -1
  12. data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +1 -1
  13. data/lib/twilio-ruby/rest/chat/v1/service/channel/invite.rb +1 -1
  14. data/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb +1 -1
  15. data/lib/twilio-ruby/rest/chat/v1/service/role.rb +2 -2
  16. data/lib/twilio-ruby/rest/chat/v2/service.rb +1 -1
  17. data/lib/twilio-ruby/rest/chat/v2/service/binding.rb +2 -2
  18. data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +1 -1
  19. data/lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb +1 -1
  20. data/lib/twilio-ruby/rest/chat/v2/service/channel/member.rb +1 -1
  21. data/lib/twilio-ruby/rest/chat/v2/service/role.rb +2 -2
  22. data/lib/twilio-ruby/rest/chat/v2/service/user/user_binding.rb +1 -1
  23. data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +1 -1
  24. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +1 -1
  25. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/invite.rb +1 -1
  26. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/member.rb +1 -1
  27. data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +2 -2
  28. data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +1 -1
  29. data/lib/twilio-ruby/rest/ip_messaging/v2/service/binding.rb +2 -2
  30. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +1 -1
  31. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb +1 -1
  32. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb +1 -1
  33. data/lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb +2 -2
  34. data/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_binding.rb +1 -1
  35. data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +5 -1
  36. data/lib/twilio-ruby/rest/notify/v1/service/binding.rb +3 -3
  37. data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +4 -4
  38. data/lib/twilio-ruby/rest/notify/v1/service/user.rb +5 -2
  39. data/lib/twilio-ruby/rest/notify/v1/service/user/user_binding.rb +2 -2
  40. data/lib/twilio-ruby/rest/preview.rb +10 -3
  41. data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb +4 -4
  42. data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +2 -2
  43. data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +2 -2
  44. data/lib/twilio-ruby/rest/preview/proxy/service/session/participant/message_interaction.rb +1 -1
  45. data/lib/twilio-ruby/rest/preview/understand.rb +41 -0
  46. data/lib/twilio-ruby/rest/preview/understand/service.rb +503 -0
  47. data/lib/twilio-ruby/rest/preview/understand/service/field_type.rb +399 -0
  48. data/lib/twilio-ruby/rest/preview/understand/service/field_type/field_value.rb +375 -0
  49. data/lib/twilio-ruby/rest/preview/understand/service/intent.rb +421 -0
  50. data/lib/twilio-ruby/rest/preview/understand/service/intent/field.rb +371 -0
  51. data/lib/twilio-ruby/rest/preview/understand/service/intent/sample.rb +407 -0
  52. data/lib/twilio-ruby/rest/preview/understand/service/model_build.rb +358 -0
  53. data/lib/twilio-ruby/rest/preview/understand/service/query.rb +422 -0
  54. data/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb +1 -1
  55. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +2 -2
  56. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb +1 -1
  57. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +1 -1
  58. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +3 -3
  59. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +3 -3
  60. data/lib/twilio-ruby/rest/video/v1/recording.rb +1 -1
  61. data/lib/twilio-ruby/rest/video/v1/room.rb +27 -1
  62. data/lib/twilio-ruby/rest/video/v1/room/room_participant.rb +407 -0
  63. data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_published_track.rb +326 -0
  64. data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +1 -1
  65. data/lib/twilio-ruby/version.rb +1 -1
  66. data/spec/framework/serialize_spec.rb +21 -0
  67. data/spec/integration/chat/v1/service/role_spec.rb +6 -2
  68. data/spec/integration/chat/v2/service/role_spec.rb +6 -2
  69. data/spec/integration/ip_messaging/v1/service/role_spec.rb +6 -2
  70. data/spec/integration/ip_messaging/v2/service/role_spec.rb +6 -2
  71. data/spec/integration/preview/hosted_numbers/authorization_document_spec.rb +1 -1
  72. data/spec/integration/preview/understand/service/field_type/field_value_spec.rb +205 -0
  73. data/spec/integration/preview/understand/service/field_type_spec.rb +244 -0
  74. data/spec/integration/preview/understand/service/intent/field_spec.rb +205 -0
  75. data/spec/integration/preview/understand/service/intent/sample_spec.rb +247 -0
  76. data/spec/integration/preview/understand/service/intent_spec.rb +252 -0
  77. data/spec/integration/preview/understand/service/model_build_spec.rb +231 -0
  78. data/spec/integration/preview/understand/service/query_spec.rb +300 -0
  79. data/spec/integration/preview/understand/service_spec.rb +256 -0
  80. data/spec/integration/video/v1/room/room_participant/room_participant_published_track_spec.rb +94 -0
  81. data/spec/integration/video/v1/room/room_participant_spec.rb +182 -0
  82. data/spec/integration/video/v1/room_spec.rb +4 -0
  83. metadata +33 -2
@@ -0,0 +1,407 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Preview < Domain
10
+ class Understand < Version
11
+ class ServiceContext < InstanceContext
12
+ class IntentContext < InstanceContext
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 SampleList < ListResource
16
+ ##
17
+ # Initialize the SampleList
18
+ # @param [Version] version Version that contains the resource
19
+ # @param [String] service_sid The service_sid
20
+ # @param [String] intent_sid The intent_sid
21
+ # @return [SampleList] SampleList
22
+ def initialize(version, service_sid: nil, intent_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {service_sid: service_sid, intent_sid: intent_sid}
27
+ @uri = "/Services/#{@solution[:service_sid]}/Intents/#{@solution[:intent_sid]}/Samples"
28
+ end
29
+
30
+ ##
31
+ # Lists SampleInstance records from the API as a list.
32
+ # Unlike stream(), this operation is eager and will load `limit` records into
33
+ # memory before returning.
34
+ # @param [String] language The language
35
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
36
+ # guarantees to never return more than limit. Default is no limit
37
+ # @param [Integer] page_size Number of records to fetch per request, when
38
+ # not set will use the default value of 50 records. If no page_size is defined
39
+ # but a limit is defined, stream() will attempt to read the limit with the most
40
+ # efficient page size, i.e. min(limit, 1000)
41
+ # @return [Array] Array of up to limit results
42
+ def list(language: :unset, limit: nil, page_size: nil)
43
+ self.stream(language: language, limit: limit, page_size: page_size).entries
44
+ end
45
+
46
+ ##
47
+ # Streams SampleInstance records from the API as an Enumerable.
48
+ # This operation lazily loads records as efficiently as possible until the limit
49
+ # is reached.
50
+ # @param [String] language The language
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 [Enumerable] Enumerable that will yield up to limit results
58
+ def stream(language: :unset, limit: nil, page_size: nil)
59
+ limits = @version.read_limits(limit, page_size)
60
+
61
+ page = self.page(language: language, page_size: limits[:page_size],)
62
+
63
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
64
+ end
65
+
66
+ ##
67
+ # When passed a block, yields SampleInstance records from the API.
68
+ # This operation lazily loads records as efficiently as possible until the limit
69
+ # is reached.
70
+ def each
71
+ limits = @version.read_limits
72
+
73
+ page = self.page(page_size: limits[:page_size],)
74
+
75
+ @version.stream(page,
76
+ limit: limits[:limit],
77
+ page_limit: limits[:page_limit]).each {|x| yield x}
78
+ end
79
+
80
+ ##
81
+ # Retrieve a single page of SampleInstance records from the API.
82
+ # Request is executed immediately.
83
+ # @param [String] language The language
84
+ # @param [String] page_token PageToken provided by the API
85
+ # @param [Integer] page_number Page Number, this value is simply for client state
86
+ # @param [Integer] page_size Number of records to return, defaults to 50
87
+ # @return [Page] Page of SampleInstance
88
+ def page(language: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
89
+ params = Twilio::Values.of({
90
+ 'Language' => language,
91
+ 'PageToken' => page_token,
92
+ 'Page' => page_number,
93
+ 'PageSize' => page_size,
94
+ })
95
+ response = @version.page(
96
+ 'GET',
97
+ @uri,
98
+ params
99
+ )
100
+ SamplePage.new(@version, response, @solution)
101
+ end
102
+
103
+ ##
104
+ # Retrieve a single page of SampleInstance records from the API.
105
+ # Request is executed immediately.
106
+ # @param [String] target_url API-generated URL for the requested results page
107
+ # @return [Page] Page of SampleInstance
108
+ def get_page(target_url)
109
+ response = @version.domain.request(
110
+ 'GET',
111
+ target_url
112
+ )
113
+ SamplePage.new(@version, response, @solution)
114
+ end
115
+
116
+ ##
117
+ # Retrieve a single page of SampleInstance records from the API.
118
+ # Request is executed immediately.
119
+ # @param [String] language The language
120
+ # @param [String] tagged_text The tagged_text
121
+ # @return [SampleInstance] Newly created SampleInstance
122
+ def create(language: nil, tagged_text: nil)
123
+ data = Twilio::Values.of({'Language' => language, 'TaggedText' => tagged_text,})
124
+
125
+ payload = @version.create(
126
+ 'POST',
127
+ @uri,
128
+ data: data
129
+ )
130
+
131
+ SampleInstance.new(
132
+ @version,
133
+ payload,
134
+ service_sid: @solution[:service_sid],
135
+ intent_sid: @solution[:intent_sid],
136
+ )
137
+ end
138
+
139
+ ##
140
+ # Provide a user friendly representation
141
+ def to_s
142
+ '#<Twilio.Preview.Understand.SampleList>'
143
+ end
144
+ end
145
+
146
+ ##
147
+ # 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.
148
+ class SamplePage < Page
149
+ ##
150
+ # Initialize the SamplePage
151
+ # @param [Version] version Version that contains the resource
152
+ # @param [Response] response Response from the API
153
+ # @param [Hash] solution Path solution for the resource
154
+ # @return [SamplePage] SamplePage
155
+ def initialize(version, response, solution)
156
+ super(version, response)
157
+
158
+ # Path Solution
159
+ @solution = solution
160
+ end
161
+
162
+ ##
163
+ # Build an instance of SampleInstance
164
+ # @param [Hash] payload Payload response from the API
165
+ # @return [SampleInstance] SampleInstance
166
+ def get_instance(payload)
167
+ SampleInstance.new(
168
+ @version,
169
+ payload,
170
+ service_sid: @solution[:service_sid],
171
+ intent_sid: @solution[:intent_sid],
172
+ )
173
+ end
174
+
175
+ ##
176
+ # Provide a user friendly representation
177
+ def to_s
178
+ '<Twilio.Preview.Understand.SamplePage>'
179
+ end
180
+ end
181
+
182
+ ##
183
+ # 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.
184
+ class SampleContext < InstanceContext
185
+ ##
186
+ # Initialize the SampleContext
187
+ # @param [Version] version Version that contains the resource
188
+ # @param [String] service_sid The service_sid
189
+ # @param [String] intent_sid The intent_sid
190
+ # @param [String] sid The sid
191
+ # @return [SampleContext] SampleContext
192
+ def initialize(version, service_sid, intent_sid, sid)
193
+ super(version)
194
+
195
+ # Path Solution
196
+ @solution = {service_sid: service_sid, intent_sid: intent_sid, sid: sid,}
197
+ @uri = "/Services/#{@solution[:service_sid]}/Intents/#{@solution[:intent_sid]}/Samples/#{@solution[:sid]}"
198
+ end
199
+
200
+ ##
201
+ # Fetch a SampleInstance
202
+ # @return [SampleInstance] Fetched SampleInstance
203
+ def fetch
204
+ params = Twilio::Values.of({})
205
+
206
+ payload = @version.fetch(
207
+ 'GET',
208
+ @uri,
209
+ params,
210
+ )
211
+
212
+ SampleInstance.new(
213
+ @version,
214
+ payload,
215
+ service_sid: @solution[:service_sid],
216
+ intent_sid: @solution[:intent_sid],
217
+ sid: @solution[:sid],
218
+ )
219
+ end
220
+
221
+ ##
222
+ # Update the SampleInstance
223
+ # @param [String] language The language
224
+ # @param [String] tagged_text The tagged_text
225
+ # @return [SampleInstance] Updated SampleInstance
226
+ def update(language: :unset, tagged_text: :unset)
227
+ data = Twilio::Values.of({'Language' => language, 'TaggedText' => tagged_text,})
228
+
229
+ payload = @version.update(
230
+ 'POST',
231
+ @uri,
232
+ data: data,
233
+ )
234
+
235
+ SampleInstance.new(
236
+ @version,
237
+ payload,
238
+ service_sid: @solution[:service_sid],
239
+ intent_sid: @solution[:intent_sid],
240
+ sid: @solution[:sid],
241
+ )
242
+ end
243
+
244
+ ##
245
+ # Deletes the SampleInstance
246
+ # @return [Boolean] true if delete succeeds, true otherwise
247
+ def delete
248
+ @version.delete('delete', @uri)
249
+ end
250
+
251
+ ##
252
+ # Provide a user friendly representation
253
+ def to_s
254
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
255
+ "#<Twilio.Preview.Understand.SampleContext #{context}>"
256
+ end
257
+ end
258
+
259
+ ##
260
+ # 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.
261
+ class SampleInstance < InstanceResource
262
+ ##
263
+ # Initialize the SampleInstance
264
+ # @param [Version] version Version that contains the resource
265
+ # @param [Hash] payload payload that contains response from Twilio
266
+ # @param [String] service_sid The service_sid
267
+ # @param [String] intent_sid The intent_sid
268
+ # @param [String] sid The sid
269
+ # @return [SampleInstance] SampleInstance
270
+ def initialize(version, payload, service_sid: nil, intent_sid: nil, sid: nil)
271
+ super(version)
272
+
273
+ # Marshaled Properties
274
+ @properties = {
275
+ 'account_sid' => payload['account_sid'],
276
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
277
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
278
+ 'intent_sid' => payload['intent_sid'],
279
+ 'language' => payload['language'],
280
+ 'service_sid' => payload['service_sid'],
281
+ 'sid' => payload['sid'],
282
+ 'tagged_text' => payload['tagged_text'],
283
+ 'url' => payload['url'],
284
+ }
285
+
286
+ # Context
287
+ @instance_context = nil
288
+ @params = {
289
+ 'service_sid' => service_sid,
290
+ 'intent_sid' => intent_sid,
291
+ 'sid' => sid || @properties['sid'],
292
+ }
293
+ end
294
+
295
+ ##
296
+ # Generate an instance context for the instance, the context is capable of
297
+ # performing various actions. All instance actions are proxied to the context
298
+ # @return [SampleContext] SampleContext for this SampleInstance
299
+ def context
300
+ unless @instance_context
301
+ @instance_context = SampleContext.new(
302
+ @version,
303
+ @params['service_sid'],
304
+ @params['intent_sid'],
305
+ @params['sid'],
306
+ )
307
+ end
308
+ @instance_context
309
+ end
310
+
311
+ ##
312
+ # @return [String] The account_sid
313
+ def account_sid
314
+ @properties['account_sid']
315
+ end
316
+
317
+ ##
318
+ # @return [Time] The date_created
319
+ def date_created
320
+ @properties['date_created']
321
+ end
322
+
323
+ ##
324
+ # @return [Time] The date_updated
325
+ def date_updated
326
+ @properties['date_updated']
327
+ end
328
+
329
+ ##
330
+ # @return [String] The intent_sid
331
+ def intent_sid
332
+ @properties['intent_sid']
333
+ end
334
+
335
+ ##
336
+ # @return [String] The language
337
+ def language
338
+ @properties['language']
339
+ end
340
+
341
+ ##
342
+ # @return [String] The service_sid
343
+ def service_sid
344
+ @properties['service_sid']
345
+ end
346
+
347
+ ##
348
+ # @return [String] The sid
349
+ def sid
350
+ @properties['sid']
351
+ end
352
+
353
+ ##
354
+ # @return [String] The tagged_text
355
+ def tagged_text
356
+ @properties['tagged_text']
357
+ end
358
+
359
+ ##
360
+ # @return [String] The url
361
+ def url
362
+ @properties['url']
363
+ end
364
+
365
+ ##
366
+ # Fetch a SampleInstance
367
+ # @return [SampleInstance] Fetched SampleInstance
368
+ def fetch
369
+ context.fetch
370
+ end
371
+
372
+ ##
373
+ # Update the SampleInstance
374
+ # @param [String] language The language
375
+ # @param [String] tagged_text The tagged_text
376
+ # @return [SampleInstance] Updated SampleInstance
377
+ def update(language: :unset, tagged_text: :unset)
378
+ context.update(language: language, tagged_text: tagged_text,)
379
+ end
380
+
381
+ ##
382
+ # Deletes the SampleInstance
383
+ # @return [Boolean] true if delete succeeds, true otherwise
384
+ def delete
385
+ context.delete
386
+ end
387
+
388
+ ##
389
+ # Provide a user friendly representation
390
+ def to_s
391
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
392
+ "<Twilio.Preview.Understand.SampleInstance #{values}>"
393
+ end
394
+
395
+ ##
396
+ # Provide a detailed, user friendly representation
397
+ def inspect
398
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
399
+ "<Twilio.Preview.Understand.SampleInstance #{values}>"
400
+ end
401
+ end
402
+ end
403
+ end
404
+ end
405
+ end
406
+ end
407
+ end
@@ -0,0 +1,358 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Preview < Domain
10
+ class Understand < Version
11
+ class ServiceContext < InstanceContext
12
+ ##
13
+ # 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.
14
+ class ModelBuildList < ListResource
15
+ ##
16
+ # Initialize the ModelBuildList
17
+ # @param [Version] version Version that contains the resource
18
+ # @param [String] service_sid The service_sid
19
+ # @return [ModelBuildList] ModelBuildList
20
+ def initialize(version, service_sid: nil)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {service_sid: service_sid}
25
+ @uri = "/Services/#{@solution[:service_sid]}/ModelBuilds"
26
+ end
27
+
28
+ ##
29
+ # Lists ModelBuildInstance records from the API as a list.
30
+ # Unlike stream(), this operation is eager and will load `limit` records into
31
+ # memory before returning.
32
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
33
+ # guarantees to never return more than limit. Default is no limit
34
+ # @param [Integer] page_size Number of records to fetch per request, when
35
+ # not set will use the default value of 50 records. If no page_size is defined
36
+ # but a limit is defined, stream() will attempt to read the limit with the most
37
+ # efficient page size, i.e. min(limit, 1000)
38
+ # @return [Array] Array of up to limit results
39
+ def list(limit: nil, page_size: nil)
40
+ self.stream(limit: limit, page_size: page_size).entries
41
+ end
42
+
43
+ ##
44
+ # Streams ModelBuildInstance records from the API as an Enumerable.
45
+ # This operation lazily loads records as efficiently as possible until the limit
46
+ # is reached.
47
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
48
+ # guarantees to never return more than limit. Default is no limit.
49
+ # @param [Integer] page_size Number of records to fetch per request, when
50
+ # not set will use the default value of 50 records. If no page_size is defined
51
+ # but a limit is defined, stream() will attempt to read the limit with the most
52
+ # efficient page size, i.e. min(limit, 1000)
53
+ # @return [Enumerable] Enumerable that will yield up to limit results
54
+ def stream(limit: nil, page_size: nil)
55
+ limits = @version.read_limits(limit, page_size)
56
+
57
+ page = self.page(page_size: limits[:page_size],)
58
+
59
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
60
+ end
61
+
62
+ ##
63
+ # When passed a block, yields ModelBuildInstance records from the API.
64
+ # This operation lazily loads records as efficiently as possible until the limit
65
+ # is reached.
66
+ def each
67
+ limits = @version.read_limits
68
+
69
+ page = self.page(page_size: limits[:page_size],)
70
+
71
+ @version.stream(page,
72
+ limit: limits[:limit],
73
+ page_limit: limits[:page_limit]).each {|x| yield x}
74
+ end
75
+
76
+ ##
77
+ # Retrieve a single page of ModelBuildInstance records from the API.
78
+ # Request is executed immediately.
79
+ # @param [String] page_token PageToken provided by the API
80
+ # @param [Integer] page_number Page Number, this value is simply for client state
81
+ # @param [Integer] page_size Number of records to return, defaults to 50
82
+ # @return [Page] Page of ModelBuildInstance
83
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
84
+ params = Twilio::Values.of({
85
+ 'PageToken' => page_token,
86
+ 'Page' => page_number,
87
+ 'PageSize' => page_size,
88
+ })
89
+ response = @version.page(
90
+ 'GET',
91
+ @uri,
92
+ params
93
+ )
94
+ ModelBuildPage.new(@version, response, @solution)
95
+ end
96
+
97
+ ##
98
+ # Retrieve a single page of ModelBuildInstance records from the API.
99
+ # Request is executed immediately.
100
+ # @param [String] target_url API-generated URL for the requested results page
101
+ # @return [Page] Page of ModelBuildInstance
102
+ def get_page(target_url)
103
+ response = @version.domain.request(
104
+ 'GET',
105
+ target_url
106
+ )
107
+ ModelBuildPage.new(@version, response, @solution)
108
+ end
109
+
110
+ ##
111
+ # Retrieve a single page of ModelBuildInstance records from the API.
112
+ # Request is executed immediately.
113
+ # @param [String] status_callback The status_callback
114
+ # @param [String] unique_name The unique_name
115
+ # @return [ModelBuildInstance] Newly created ModelBuildInstance
116
+ def create(status_callback: :unset, unique_name: :unset)
117
+ data = Twilio::Values.of({'StatusCallback' => status_callback, 'UniqueName' => unique_name,})
118
+
119
+ payload = @version.create(
120
+ 'POST',
121
+ @uri,
122
+ data: data
123
+ )
124
+
125
+ ModelBuildInstance.new(@version, payload, service_sid: @solution[:service_sid],)
126
+ end
127
+
128
+ ##
129
+ # Provide a user friendly representation
130
+ def to_s
131
+ '#<Twilio.Preview.Understand.ModelBuildList>'
132
+ end
133
+ end
134
+
135
+ ##
136
+ # 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.
137
+ class ModelBuildPage < Page
138
+ ##
139
+ # Initialize the ModelBuildPage
140
+ # @param [Version] version Version that contains the resource
141
+ # @param [Response] response Response from the API
142
+ # @param [Hash] solution Path solution for the resource
143
+ # @return [ModelBuildPage] ModelBuildPage
144
+ def initialize(version, response, solution)
145
+ super(version, response)
146
+
147
+ # Path Solution
148
+ @solution = solution
149
+ end
150
+
151
+ ##
152
+ # Build an instance of ModelBuildInstance
153
+ # @param [Hash] payload Payload response from the API
154
+ # @return [ModelBuildInstance] ModelBuildInstance
155
+ def get_instance(payload)
156
+ ModelBuildInstance.new(@version, payload, service_sid: @solution[:service_sid],)
157
+ end
158
+
159
+ ##
160
+ # Provide a user friendly representation
161
+ def to_s
162
+ '<Twilio.Preview.Understand.ModelBuildPage>'
163
+ end
164
+ end
165
+
166
+ ##
167
+ # 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.
168
+ class ModelBuildContext < InstanceContext
169
+ ##
170
+ # Initialize the ModelBuildContext
171
+ # @param [Version] version Version that contains the resource
172
+ # @param [String] service_sid The service_sid
173
+ # @param [String] sid The sid
174
+ # @return [ModelBuildContext] ModelBuildContext
175
+ def initialize(version, service_sid, sid)
176
+ super(version)
177
+
178
+ # Path Solution
179
+ @solution = {service_sid: service_sid, sid: sid,}
180
+ @uri = "/Services/#{@solution[:service_sid]}/ModelBuilds/#{@solution[:sid]}"
181
+ end
182
+
183
+ ##
184
+ # Fetch a ModelBuildInstance
185
+ # @return [ModelBuildInstance] Fetched ModelBuildInstance
186
+ def fetch
187
+ params = Twilio::Values.of({})
188
+
189
+ payload = @version.fetch(
190
+ 'GET',
191
+ @uri,
192
+ params,
193
+ )
194
+
195
+ ModelBuildInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid],)
196
+ end
197
+
198
+ ##
199
+ # Update the ModelBuildInstance
200
+ # @param [String] unique_name The unique_name
201
+ # @return [ModelBuildInstance] Updated ModelBuildInstance
202
+ def update(unique_name: :unset)
203
+ data = Twilio::Values.of({'UniqueName' => unique_name,})
204
+
205
+ payload = @version.update(
206
+ 'POST',
207
+ @uri,
208
+ data: data,
209
+ )
210
+
211
+ ModelBuildInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid],)
212
+ end
213
+
214
+ ##
215
+ # Deletes the ModelBuildInstance
216
+ # @return [Boolean] true if delete succeeds, true otherwise
217
+ def delete
218
+ @version.delete('delete', @uri)
219
+ end
220
+
221
+ ##
222
+ # Provide a user friendly representation
223
+ def to_s
224
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
225
+ "#<Twilio.Preview.Understand.ModelBuildContext #{context}>"
226
+ end
227
+ end
228
+
229
+ ##
230
+ # 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.
231
+ class ModelBuildInstance < InstanceResource
232
+ ##
233
+ # Initialize the ModelBuildInstance
234
+ # @param [Version] version Version that contains the resource
235
+ # @param [Hash] payload payload that contains response from Twilio
236
+ # @param [String] service_sid The service_sid
237
+ # @param [String] sid The sid
238
+ # @return [ModelBuildInstance] ModelBuildInstance
239
+ def initialize(version, payload, service_sid: nil, sid: nil)
240
+ super(version)
241
+
242
+ # Marshaled Properties
243
+ @properties = {
244
+ 'account_sid' => payload['account_sid'],
245
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
246
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
247
+ 'service_sid' => payload['service_sid'],
248
+ 'sid' => payload['sid'],
249
+ 'status' => payload['status'],
250
+ 'unique_name' => payload['unique_name'],
251
+ 'url' => payload['url'],
252
+ }
253
+
254
+ # Context
255
+ @instance_context = nil
256
+ @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'],}
257
+ end
258
+
259
+ ##
260
+ # Generate an instance context for the instance, the context is capable of
261
+ # performing various actions. All instance actions are proxied to the context
262
+ # @return [ModelBuildContext] ModelBuildContext for this ModelBuildInstance
263
+ def context
264
+ unless @instance_context
265
+ @instance_context = ModelBuildContext.new(@version, @params['service_sid'], @params['sid'],)
266
+ end
267
+ @instance_context
268
+ end
269
+
270
+ ##
271
+ # @return [String] The account_sid
272
+ def account_sid
273
+ @properties['account_sid']
274
+ end
275
+
276
+ ##
277
+ # @return [Time] The date_created
278
+ def date_created
279
+ @properties['date_created']
280
+ end
281
+
282
+ ##
283
+ # @return [Time] The date_updated
284
+ def date_updated
285
+ @properties['date_updated']
286
+ end
287
+
288
+ ##
289
+ # @return [String] The service_sid
290
+ def service_sid
291
+ @properties['service_sid']
292
+ end
293
+
294
+ ##
295
+ # @return [String] The sid
296
+ def sid
297
+ @properties['sid']
298
+ end
299
+
300
+ ##
301
+ # @return [model_build.Status] The status
302
+ def status
303
+ @properties['status']
304
+ end
305
+
306
+ ##
307
+ # @return [String] The unique_name
308
+ def unique_name
309
+ @properties['unique_name']
310
+ end
311
+
312
+ ##
313
+ # @return [String] The url
314
+ def url
315
+ @properties['url']
316
+ end
317
+
318
+ ##
319
+ # Fetch a ModelBuildInstance
320
+ # @return [ModelBuildInstance] Fetched ModelBuildInstance
321
+ def fetch
322
+ context.fetch
323
+ end
324
+
325
+ ##
326
+ # Update the ModelBuildInstance
327
+ # @param [String] unique_name The unique_name
328
+ # @return [ModelBuildInstance] Updated ModelBuildInstance
329
+ def update(unique_name: :unset)
330
+ context.update(unique_name: unique_name,)
331
+ end
332
+
333
+ ##
334
+ # Deletes the ModelBuildInstance
335
+ # @return [Boolean] true if delete succeeds, true otherwise
336
+ def delete
337
+ context.delete
338
+ end
339
+
340
+ ##
341
+ # Provide a user friendly representation
342
+ def to_s
343
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
344
+ "<Twilio.Preview.Understand.ModelBuildInstance #{values}>"
345
+ end
346
+
347
+ ##
348
+ # Provide a detailed, user friendly representation
349
+ def inspect
350
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
351
+ "<Twilio.Preview.Understand.ModelBuildInstance #{values}>"
352
+ end
353
+ end
354
+ end
355
+ end
356
+ end
357
+ end
358
+ end