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,421 @@
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 IntentList < ListResource
15
+ ##
16
+ # Initialize the IntentList
17
+ # @param [Version] version Version that contains the resource
18
+ # @param [String] service_sid The service_sid
19
+ # @return [IntentList] IntentList
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]}/Intents"
26
+ end
27
+
28
+ ##
29
+ # Lists IntentInstance 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 IntentInstance 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 IntentInstance 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 IntentInstance 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 IntentInstance
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
+ IntentPage.new(@version, response, @solution)
95
+ end
96
+
97
+ ##
98
+ # Retrieve a single page of IntentInstance 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 IntentInstance
102
+ def get_page(target_url)
103
+ response = @version.domain.request(
104
+ 'GET',
105
+ target_url
106
+ )
107
+ IntentPage.new(@version, response, @solution)
108
+ end
109
+
110
+ ##
111
+ # Retrieve a single page of IntentInstance records from the API.
112
+ # Request is executed immediately.
113
+ # @param [String] unique_name The unique_name
114
+ # @param [String] friendly_name The friendly_name
115
+ # @return [IntentInstance] Newly created IntentInstance
116
+ def create(unique_name: nil, friendly_name: :unset)
117
+ data = Twilio::Values.of({'UniqueName' => unique_name, 'FriendlyName' => friendly_name,})
118
+
119
+ payload = @version.create(
120
+ 'POST',
121
+ @uri,
122
+ data: data
123
+ )
124
+
125
+ IntentInstance.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.IntentList>'
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 IntentPage < Page
138
+ ##
139
+ # Initialize the IntentPage
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 [IntentPage] IntentPage
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 IntentInstance
153
+ # @param [Hash] payload Payload response from the API
154
+ # @return [IntentInstance] IntentInstance
155
+ def get_instance(payload)
156
+ IntentInstance.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.IntentPage>'
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 IntentContext < InstanceContext
169
+ ##
170
+ # Initialize the IntentContext
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 [IntentContext] IntentContext
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]}/Intents/#{@solution[:sid]}"
181
+
182
+ # Dependents
183
+ @fields = nil
184
+ @samples = nil
185
+ end
186
+
187
+ ##
188
+ # Fetch a IntentInstance
189
+ # @return [IntentInstance] Fetched IntentInstance
190
+ def fetch
191
+ params = Twilio::Values.of({})
192
+
193
+ payload = @version.fetch(
194
+ 'GET',
195
+ @uri,
196
+ params,
197
+ )
198
+
199
+ IntentInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid],)
200
+ end
201
+
202
+ ##
203
+ # Update the IntentInstance
204
+ # @param [String] friendly_name The friendly_name
205
+ # @param [String] unique_name The unique_name
206
+ # @return [IntentInstance] Updated IntentInstance
207
+ def update(friendly_name: :unset, unique_name: :unset)
208
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, 'UniqueName' => unique_name,})
209
+
210
+ payload = @version.update(
211
+ 'POST',
212
+ @uri,
213
+ data: data,
214
+ )
215
+
216
+ IntentInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid],)
217
+ end
218
+
219
+ ##
220
+ # Deletes the IntentInstance
221
+ # @return [Boolean] true if delete succeeds, true otherwise
222
+ def delete
223
+ @version.delete('delete', @uri)
224
+ end
225
+
226
+ ##
227
+ # Access the fields
228
+ # @return [FieldList]
229
+ # @return [FieldContext] if sid was passed.
230
+ def fields(sid=:unset)
231
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
232
+
233
+ if sid != :unset
234
+ return FieldContext.new(@version, @solution[:service_sid], @solution[:sid], sid,)
235
+ end
236
+
237
+ unless @fields
238
+ @fields = FieldList.new(@version, service_sid: @solution[:service_sid], intent_sid: @solution[:sid],)
239
+ end
240
+
241
+ @fields
242
+ end
243
+
244
+ ##
245
+ # Access the samples
246
+ # @return [SampleList]
247
+ # @return [SampleContext] if sid was passed.
248
+ def samples(sid=:unset)
249
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
250
+
251
+ if sid != :unset
252
+ return SampleContext.new(@version, @solution[:service_sid], @solution[:sid], sid,)
253
+ end
254
+
255
+ unless @samples
256
+ @samples = SampleList.new(@version, service_sid: @solution[:service_sid], intent_sid: @solution[:sid],)
257
+ end
258
+
259
+ @samples
260
+ end
261
+
262
+ ##
263
+ # Provide a user friendly representation
264
+ def to_s
265
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
266
+ "#<Twilio.Preview.Understand.IntentContext #{context}>"
267
+ end
268
+ end
269
+
270
+ ##
271
+ # 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.
272
+ class IntentInstance < InstanceResource
273
+ ##
274
+ # Initialize the IntentInstance
275
+ # @param [Version] version Version that contains the resource
276
+ # @param [Hash] payload payload that contains response from Twilio
277
+ # @param [String] service_sid The service_sid
278
+ # @param [String] sid The sid
279
+ # @return [IntentInstance] IntentInstance
280
+ def initialize(version, payload, service_sid: nil, sid: nil)
281
+ super(version)
282
+
283
+ # Marshaled Properties
284
+ @properties = {
285
+ 'account_sid' => payload['account_sid'],
286
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
287
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
288
+ 'friendly_name' => payload['friendly_name'],
289
+ 'links' => payload['links'],
290
+ 'service_sid' => payload['service_sid'],
291
+ 'sid' => payload['sid'],
292
+ 'unique_name' => payload['unique_name'],
293
+ 'url' => payload['url'],
294
+ }
295
+
296
+ # Context
297
+ @instance_context = nil
298
+ @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'],}
299
+ end
300
+
301
+ ##
302
+ # Generate an instance context for the instance, the context is capable of
303
+ # performing various actions. All instance actions are proxied to the context
304
+ # @return [IntentContext] IntentContext for this IntentInstance
305
+ def context
306
+ unless @instance_context
307
+ @instance_context = IntentContext.new(@version, @params['service_sid'], @params['sid'],)
308
+ end
309
+ @instance_context
310
+ end
311
+
312
+ ##
313
+ # @return [String] The account_sid
314
+ def account_sid
315
+ @properties['account_sid']
316
+ end
317
+
318
+ ##
319
+ # @return [Time] The date_created
320
+ def date_created
321
+ @properties['date_created']
322
+ end
323
+
324
+ ##
325
+ # @return [Time] The date_updated
326
+ def date_updated
327
+ @properties['date_updated']
328
+ end
329
+
330
+ ##
331
+ # @return [String] The friendly_name
332
+ def friendly_name
333
+ @properties['friendly_name']
334
+ end
335
+
336
+ ##
337
+ # @return [String] The links
338
+ def links
339
+ @properties['links']
340
+ end
341
+
342
+ ##
343
+ # @return [String] The service_sid
344
+ def service_sid
345
+ @properties['service_sid']
346
+ end
347
+
348
+ ##
349
+ # @return [String] The sid
350
+ def sid
351
+ @properties['sid']
352
+ end
353
+
354
+ ##
355
+ # @return [String] The unique_name
356
+ def unique_name
357
+ @properties['unique_name']
358
+ end
359
+
360
+ ##
361
+ # @return [String] The url
362
+ def url
363
+ @properties['url']
364
+ end
365
+
366
+ ##
367
+ # Fetch a IntentInstance
368
+ # @return [IntentInstance] Fetched IntentInstance
369
+ def fetch
370
+ context.fetch
371
+ end
372
+
373
+ ##
374
+ # Update the IntentInstance
375
+ # @param [String] friendly_name The friendly_name
376
+ # @param [String] unique_name The unique_name
377
+ # @return [IntentInstance] Updated IntentInstance
378
+ def update(friendly_name: :unset, unique_name: :unset)
379
+ context.update(friendly_name: friendly_name, unique_name: unique_name,)
380
+ end
381
+
382
+ ##
383
+ # Deletes the IntentInstance
384
+ # @return [Boolean] true if delete succeeds, true otherwise
385
+ def delete
386
+ context.delete
387
+ end
388
+
389
+ ##
390
+ # Access the fields
391
+ # @return [fields] fields
392
+ def fields
393
+ context.fields
394
+ end
395
+
396
+ ##
397
+ # Access the samples
398
+ # @return [samples] samples
399
+ def samples
400
+ context.samples
401
+ end
402
+
403
+ ##
404
+ # Provide a user friendly representation
405
+ def to_s
406
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
407
+ "<Twilio.Preview.Understand.IntentInstance #{values}>"
408
+ end
409
+
410
+ ##
411
+ # Provide a detailed, user friendly representation
412
+ def inspect
413
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
414
+ "<Twilio.Preview.Understand.IntentInstance #{values}>"
415
+ end
416
+ end
417
+ end
418
+ end
419
+ end
420
+ end
421
+ end
@@ -0,0 +1,371 @@
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 FieldList < ListResource
16
+ ##
17
+ # Initialize the FieldList
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 [FieldList] FieldList
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]}/Fields"
28
+ end
29
+
30
+ ##
31
+ # Lists FieldInstance 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 [Integer] limit Upper limit for the number of records to return. stream()
35
+ # guarantees to never return more than limit. Default is no limit
36
+ # @param [Integer] page_size Number of records to fetch per request, when
37
+ # not set will use the default value of 50 records. If no page_size is defined
38
+ # but a limit is defined, stream() will attempt to read the limit with the most
39
+ # efficient page size, i.e. min(limit, 1000)
40
+ # @return [Array] Array of up to limit results
41
+ def list(limit: nil, page_size: nil)
42
+ self.stream(limit: limit, page_size: page_size).entries
43
+ end
44
+
45
+ ##
46
+ # Streams FieldInstance records from the API as an Enumerable.
47
+ # This operation lazily loads records as efficiently as possible until the limit
48
+ # is reached.
49
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
50
+ # guarantees to never return more than limit. Default is no limit.
51
+ # @param [Integer] page_size Number of records to fetch per request, when
52
+ # not set will use the default value of 50 records. If no page_size is defined
53
+ # but a limit is defined, stream() will attempt to read the limit with the most
54
+ # efficient page size, i.e. min(limit, 1000)
55
+ # @return [Enumerable] Enumerable that will yield up to limit results
56
+ def stream(limit: nil, page_size: nil)
57
+ limits = @version.read_limits(limit, page_size)
58
+
59
+ page = self.page(page_size: limits[:page_size],)
60
+
61
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
62
+ end
63
+
64
+ ##
65
+ # When passed a block, yields FieldInstance records from the API.
66
+ # This operation lazily loads records as efficiently as possible until the limit
67
+ # is reached.
68
+ def each
69
+ limits = @version.read_limits
70
+
71
+ page = self.page(page_size: limits[:page_size],)
72
+
73
+ @version.stream(page,
74
+ limit: limits[:limit],
75
+ page_limit: limits[:page_limit]).each {|x| yield x}
76
+ end
77
+
78
+ ##
79
+ # Retrieve a single page of FieldInstance records from the API.
80
+ # Request is executed immediately.
81
+ # @param [String] page_token PageToken provided by the API
82
+ # @param [Integer] page_number Page Number, this value is simply for client state
83
+ # @param [Integer] page_size Number of records to return, defaults to 50
84
+ # @return [Page] Page of FieldInstance
85
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
86
+ params = Twilio::Values.of({
87
+ 'PageToken' => page_token,
88
+ 'Page' => page_number,
89
+ 'PageSize' => page_size,
90
+ })
91
+ response = @version.page(
92
+ 'GET',
93
+ @uri,
94
+ params
95
+ )
96
+ FieldPage.new(@version, response, @solution)
97
+ end
98
+
99
+ ##
100
+ # Retrieve a single page of FieldInstance records from the API.
101
+ # Request is executed immediately.
102
+ # @param [String] target_url API-generated URL for the requested results page
103
+ # @return [Page] Page of FieldInstance
104
+ def get_page(target_url)
105
+ response = @version.domain.request(
106
+ 'GET',
107
+ target_url
108
+ )
109
+ FieldPage.new(@version, response, @solution)
110
+ end
111
+
112
+ ##
113
+ # Retrieve a single page of FieldInstance records from the API.
114
+ # Request is executed immediately.
115
+ # @param [String] field_type The field_type
116
+ # @param [String] unique_name The unique_name
117
+ # @return [FieldInstance] Newly created FieldInstance
118
+ def create(field_type: nil, unique_name: nil)
119
+ data = Twilio::Values.of({'FieldType' => field_type, 'UniqueName' => unique_name,})
120
+
121
+ payload = @version.create(
122
+ 'POST',
123
+ @uri,
124
+ data: data
125
+ )
126
+
127
+ FieldInstance.new(
128
+ @version,
129
+ payload,
130
+ service_sid: @solution[:service_sid],
131
+ intent_sid: @solution[:intent_sid],
132
+ )
133
+ end
134
+
135
+ ##
136
+ # Provide a user friendly representation
137
+ def to_s
138
+ '#<Twilio.Preview.Understand.FieldList>'
139
+ end
140
+ end
141
+
142
+ ##
143
+ # 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.
144
+ class FieldPage < Page
145
+ ##
146
+ # Initialize the FieldPage
147
+ # @param [Version] version Version that contains the resource
148
+ # @param [Response] response Response from the API
149
+ # @param [Hash] solution Path solution for the resource
150
+ # @return [FieldPage] FieldPage
151
+ def initialize(version, response, solution)
152
+ super(version, response)
153
+
154
+ # Path Solution
155
+ @solution = solution
156
+ end
157
+
158
+ ##
159
+ # Build an instance of FieldInstance
160
+ # @param [Hash] payload Payload response from the API
161
+ # @return [FieldInstance] FieldInstance
162
+ def get_instance(payload)
163
+ FieldInstance.new(
164
+ @version,
165
+ payload,
166
+ service_sid: @solution[:service_sid],
167
+ intent_sid: @solution[:intent_sid],
168
+ )
169
+ end
170
+
171
+ ##
172
+ # Provide a user friendly representation
173
+ def to_s
174
+ '<Twilio.Preview.Understand.FieldPage>'
175
+ end
176
+ end
177
+
178
+ ##
179
+ # 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.
180
+ class FieldContext < InstanceContext
181
+ ##
182
+ # Initialize the FieldContext
183
+ # @param [Version] version Version that contains the resource
184
+ # @param [String] service_sid The service_sid
185
+ # @param [String] intent_sid The intent_sid
186
+ # @param [String] sid The sid
187
+ # @return [FieldContext] FieldContext
188
+ def initialize(version, service_sid, intent_sid, sid)
189
+ super(version)
190
+
191
+ # Path Solution
192
+ @solution = {service_sid: service_sid, intent_sid: intent_sid, sid: sid,}
193
+ @uri = "/Services/#{@solution[:service_sid]}/Intents/#{@solution[:intent_sid]}/Fields/#{@solution[:sid]}"
194
+ end
195
+
196
+ ##
197
+ # Fetch a FieldInstance
198
+ # @return [FieldInstance] Fetched FieldInstance
199
+ def fetch
200
+ params = Twilio::Values.of({})
201
+
202
+ payload = @version.fetch(
203
+ 'GET',
204
+ @uri,
205
+ params,
206
+ )
207
+
208
+ FieldInstance.new(
209
+ @version,
210
+ payload,
211
+ service_sid: @solution[:service_sid],
212
+ intent_sid: @solution[:intent_sid],
213
+ sid: @solution[:sid],
214
+ )
215
+ end
216
+
217
+ ##
218
+ # Deletes the FieldInstance
219
+ # @return [Boolean] true if delete succeeds, true otherwise
220
+ def delete
221
+ @version.delete('delete', @uri)
222
+ end
223
+
224
+ ##
225
+ # Provide a user friendly representation
226
+ def to_s
227
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
228
+ "#<Twilio.Preview.Understand.FieldContext #{context}>"
229
+ end
230
+ end
231
+
232
+ ##
233
+ # 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.
234
+ class FieldInstance < InstanceResource
235
+ ##
236
+ # Initialize the FieldInstance
237
+ # @param [Version] version Version that contains the resource
238
+ # @param [Hash] payload payload that contains response from Twilio
239
+ # @param [String] service_sid The service_sid
240
+ # @param [String] intent_sid The intent_sid
241
+ # @param [String] sid The sid
242
+ # @return [FieldInstance] FieldInstance
243
+ def initialize(version, payload, service_sid: nil, intent_sid: nil, sid: nil)
244
+ super(version)
245
+
246
+ # Marshaled Properties
247
+ @properties = {
248
+ 'account_sid' => payload['account_sid'],
249
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
250
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
251
+ 'field_type' => payload['field_type'],
252
+ 'intent_sid' => payload['intent_sid'],
253
+ 'service_sid' => payload['service_sid'],
254
+ 'sid' => payload['sid'],
255
+ 'unique_name' => payload['unique_name'],
256
+ 'url' => payload['url'],
257
+ }
258
+
259
+ # Context
260
+ @instance_context = nil
261
+ @params = {
262
+ 'service_sid' => service_sid,
263
+ 'intent_sid' => intent_sid,
264
+ 'sid' => sid || @properties['sid'],
265
+ }
266
+ end
267
+
268
+ ##
269
+ # Generate an instance context for the instance, the context is capable of
270
+ # performing various actions. All instance actions are proxied to the context
271
+ # @return [FieldContext] FieldContext for this FieldInstance
272
+ def context
273
+ unless @instance_context
274
+ @instance_context = FieldContext.new(
275
+ @version,
276
+ @params['service_sid'],
277
+ @params['intent_sid'],
278
+ @params['sid'],
279
+ )
280
+ end
281
+ @instance_context
282
+ end
283
+
284
+ ##
285
+ # @return [String] The account_sid
286
+ def account_sid
287
+ @properties['account_sid']
288
+ end
289
+
290
+ ##
291
+ # @return [Time] The date_created
292
+ def date_created
293
+ @properties['date_created']
294
+ end
295
+
296
+ ##
297
+ # @return [Time] The date_updated
298
+ def date_updated
299
+ @properties['date_updated']
300
+ end
301
+
302
+ ##
303
+ # @return [String] The field_type
304
+ def field_type
305
+ @properties['field_type']
306
+ end
307
+
308
+ ##
309
+ # @return [String] The intent_sid
310
+ def intent_sid
311
+ @properties['intent_sid']
312
+ end
313
+
314
+ ##
315
+ # @return [String] The service_sid
316
+ def service_sid
317
+ @properties['service_sid']
318
+ end
319
+
320
+ ##
321
+ # @return [String] The sid
322
+ def sid
323
+ @properties['sid']
324
+ end
325
+
326
+ ##
327
+ # @return [String] The unique_name
328
+ def unique_name
329
+ @properties['unique_name']
330
+ end
331
+
332
+ ##
333
+ # @return [String] The url
334
+ def url
335
+ @properties['url']
336
+ end
337
+
338
+ ##
339
+ # Fetch a FieldInstance
340
+ # @return [FieldInstance] Fetched FieldInstance
341
+ def fetch
342
+ context.fetch
343
+ end
344
+
345
+ ##
346
+ # Deletes the FieldInstance
347
+ # @return [Boolean] true if delete succeeds, true otherwise
348
+ def delete
349
+ context.delete
350
+ end
351
+
352
+ ##
353
+ # Provide a user friendly representation
354
+ def to_s
355
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
356
+ "<Twilio.Preview.Understand.FieldInstance #{values}>"
357
+ end
358
+
359
+ ##
360
+ # Provide a detailed, user friendly representation
361
+ def inspect
362
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
363
+ "<Twilio.Preview.Understand.FieldInstance #{values}>"
364
+ end
365
+ end
366
+ end
367
+ end
368
+ end
369
+ end
370
+ end
371
+ end