twilio-ruby 5.4.3 → 5.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,399 @@
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 FieldTypeList < ListResource
15
+ ##
16
+ # Initialize the FieldTypeList
17
+ # @param [Version] version Version that contains the resource
18
+ # @param [String] service_sid The service_sid
19
+ # @return [FieldTypeList] FieldTypeList
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]}/FieldTypes"
26
+ end
27
+
28
+ ##
29
+ # Lists FieldTypeInstance 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 FieldTypeInstance 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 FieldTypeInstance 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 FieldTypeInstance 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 FieldTypeInstance
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
+ FieldTypePage.new(@version, response, @solution)
95
+ end
96
+
97
+ ##
98
+ # Retrieve a single page of FieldTypeInstance 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 FieldTypeInstance
102
+ def get_page(target_url)
103
+ response = @version.domain.request(
104
+ 'GET',
105
+ target_url
106
+ )
107
+ FieldTypePage.new(@version, response, @solution)
108
+ end
109
+
110
+ ##
111
+ # Retrieve a single page of FieldTypeInstance 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 [FieldTypeInstance] Newly created FieldTypeInstance
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
+ FieldTypeInstance.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.FieldTypeList>'
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 FieldTypePage < Page
138
+ ##
139
+ # Initialize the FieldTypePage
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 [FieldTypePage] FieldTypePage
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 FieldTypeInstance
153
+ # @param [Hash] payload Payload response from the API
154
+ # @return [FieldTypeInstance] FieldTypeInstance
155
+ def get_instance(payload)
156
+ FieldTypeInstance.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.FieldTypePage>'
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 FieldTypeContext < InstanceContext
169
+ ##
170
+ # Initialize the FieldTypeContext
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 [FieldTypeContext] FieldTypeContext
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]}/FieldTypes/#{@solution[:sid]}"
181
+
182
+ # Dependents
183
+ @field_values = nil
184
+ end
185
+
186
+ ##
187
+ # Fetch a FieldTypeInstance
188
+ # @return [FieldTypeInstance] Fetched FieldTypeInstance
189
+ def fetch
190
+ params = Twilio::Values.of({})
191
+
192
+ payload = @version.fetch(
193
+ 'GET',
194
+ @uri,
195
+ params,
196
+ )
197
+
198
+ FieldTypeInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid],)
199
+ end
200
+
201
+ ##
202
+ # Update the FieldTypeInstance
203
+ # @param [String] friendly_name The friendly_name
204
+ # @param [String] unique_name The unique_name
205
+ # @return [FieldTypeInstance] Updated FieldTypeInstance
206
+ def update(friendly_name: :unset, unique_name: :unset)
207
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, 'UniqueName' => unique_name,})
208
+
209
+ payload = @version.update(
210
+ 'POST',
211
+ @uri,
212
+ data: data,
213
+ )
214
+
215
+ FieldTypeInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid],)
216
+ end
217
+
218
+ ##
219
+ # Deletes the FieldTypeInstance
220
+ # @return [Boolean] true if delete succeeds, true otherwise
221
+ def delete
222
+ @version.delete('delete', @uri)
223
+ end
224
+
225
+ ##
226
+ # Access the field_values
227
+ # @return [FieldValueList]
228
+ # @return [FieldValueContext] if sid was passed.
229
+ def field_values(sid=:unset)
230
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
231
+
232
+ if sid != :unset
233
+ return FieldValueContext.new(@version, @solution[:service_sid], @solution[:sid], sid,)
234
+ end
235
+
236
+ unless @field_values
237
+ @field_values = FieldValueList.new(
238
+ @version,
239
+ service_sid: @solution[:service_sid],
240
+ field_type_sid: @solution[:sid],
241
+ )
242
+ end
243
+
244
+ @field_values
245
+ end
246
+
247
+ ##
248
+ # Provide a user friendly representation
249
+ def to_s
250
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
251
+ "#<Twilio.Preview.Understand.FieldTypeContext #{context}>"
252
+ end
253
+ end
254
+
255
+ ##
256
+ # 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.
257
+ class FieldTypeInstance < InstanceResource
258
+ ##
259
+ # Initialize the FieldTypeInstance
260
+ # @param [Version] version Version that contains the resource
261
+ # @param [Hash] payload payload that contains response from Twilio
262
+ # @param [String] service_sid The service_sid
263
+ # @param [String] sid The sid
264
+ # @return [FieldTypeInstance] FieldTypeInstance
265
+ def initialize(version, payload, service_sid: nil, sid: nil)
266
+ super(version)
267
+
268
+ # Marshaled Properties
269
+ @properties = {
270
+ 'account_sid' => payload['account_sid'],
271
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
272
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
273
+ 'friendly_name' => payload['friendly_name'],
274
+ 'links' => payload['links'],
275
+ 'service_sid' => payload['service_sid'],
276
+ 'sid' => payload['sid'],
277
+ 'unique_name' => payload['unique_name'],
278
+ 'url' => payload['url'],
279
+ }
280
+
281
+ # Context
282
+ @instance_context = nil
283
+ @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'],}
284
+ end
285
+
286
+ ##
287
+ # Generate an instance context for the instance, the context is capable of
288
+ # performing various actions. All instance actions are proxied to the context
289
+ # @return [FieldTypeContext] FieldTypeContext for this FieldTypeInstance
290
+ def context
291
+ unless @instance_context
292
+ @instance_context = FieldTypeContext.new(@version, @params['service_sid'], @params['sid'],)
293
+ end
294
+ @instance_context
295
+ end
296
+
297
+ ##
298
+ # @return [String] The account_sid
299
+ def account_sid
300
+ @properties['account_sid']
301
+ end
302
+
303
+ ##
304
+ # @return [Time] The date_created
305
+ def date_created
306
+ @properties['date_created']
307
+ end
308
+
309
+ ##
310
+ # @return [Time] The date_updated
311
+ def date_updated
312
+ @properties['date_updated']
313
+ end
314
+
315
+ ##
316
+ # @return [String] The friendly_name
317
+ def friendly_name
318
+ @properties['friendly_name']
319
+ end
320
+
321
+ ##
322
+ # @return [String] The links
323
+ def links
324
+ @properties['links']
325
+ end
326
+
327
+ ##
328
+ # @return [String] The service_sid
329
+ def service_sid
330
+ @properties['service_sid']
331
+ end
332
+
333
+ ##
334
+ # @return [String] The sid
335
+ def sid
336
+ @properties['sid']
337
+ end
338
+
339
+ ##
340
+ # @return [String] The unique_name
341
+ def unique_name
342
+ @properties['unique_name']
343
+ end
344
+
345
+ ##
346
+ # @return [String] The url
347
+ def url
348
+ @properties['url']
349
+ end
350
+
351
+ ##
352
+ # Fetch a FieldTypeInstance
353
+ # @return [FieldTypeInstance] Fetched FieldTypeInstance
354
+ def fetch
355
+ context.fetch
356
+ end
357
+
358
+ ##
359
+ # Update the FieldTypeInstance
360
+ # @param [String] friendly_name The friendly_name
361
+ # @param [String] unique_name The unique_name
362
+ # @return [FieldTypeInstance] Updated FieldTypeInstance
363
+ def update(friendly_name: :unset, unique_name: :unset)
364
+ context.update(friendly_name: friendly_name, unique_name: unique_name,)
365
+ end
366
+
367
+ ##
368
+ # Deletes the FieldTypeInstance
369
+ # @return [Boolean] true if delete succeeds, true otherwise
370
+ def delete
371
+ context.delete
372
+ end
373
+
374
+ ##
375
+ # Access the field_values
376
+ # @return [field_values] field_values
377
+ def field_values
378
+ context.field_values
379
+ end
380
+
381
+ ##
382
+ # Provide a user friendly representation
383
+ def to_s
384
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
385
+ "<Twilio.Preview.Understand.FieldTypeInstance #{values}>"
386
+ end
387
+
388
+ ##
389
+ # Provide a detailed, user friendly representation
390
+ def inspect
391
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
392
+ "<Twilio.Preview.Understand.FieldTypeInstance #{values}>"
393
+ end
394
+ end
395
+ end
396
+ end
397
+ end
398
+ end
399
+ end
@@ -0,0 +1,375 @@
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 FieldTypeContext < 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 FieldValueList < ListResource
16
+ ##
17
+ # Initialize the FieldValueList
18
+ # @param [Version] version Version that contains the resource
19
+ # @param [String] service_sid The service_sid
20
+ # @param [String] field_type_sid The field_type_sid
21
+ # @return [FieldValueList] FieldValueList
22
+ def initialize(version, service_sid: nil, field_type_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {service_sid: service_sid, field_type_sid: field_type_sid}
27
+ @uri = "/Services/#{@solution[:service_sid]}/FieldTypes/#{@solution[:field_type_sid]}/FieldValues"
28
+ end
29
+
30
+ ##
31
+ # Lists FieldValueInstance 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 FieldValueInstance 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 FieldValueInstance 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 FieldValueInstance 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 FieldValueInstance
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
+ FieldValuePage.new(@version, response, @solution)
101
+ end
102
+
103
+ ##
104
+ # Retrieve a single page of FieldValueInstance 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 FieldValueInstance
108
+ def get_page(target_url)
109
+ response = @version.domain.request(
110
+ 'GET',
111
+ target_url
112
+ )
113
+ FieldValuePage.new(@version, response, @solution)
114
+ end
115
+
116
+ ##
117
+ # Retrieve a single page of FieldValueInstance records from the API.
118
+ # Request is executed immediately.
119
+ # @param [String] language The language
120
+ # @param [String] value The value
121
+ # @return [FieldValueInstance] Newly created FieldValueInstance
122
+ def create(language: nil, value: nil)
123
+ data = Twilio::Values.of({'Language' => language, 'Value' => value,})
124
+
125
+ payload = @version.create(
126
+ 'POST',
127
+ @uri,
128
+ data: data
129
+ )
130
+
131
+ FieldValueInstance.new(
132
+ @version,
133
+ payload,
134
+ service_sid: @solution[:service_sid],
135
+ field_type_sid: @solution[:field_type_sid],
136
+ )
137
+ end
138
+
139
+ ##
140
+ # Provide a user friendly representation
141
+ def to_s
142
+ '#<Twilio.Preview.Understand.FieldValueList>'
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 FieldValuePage < Page
149
+ ##
150
+ # Initialize the FieldValuePage
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 [FieldValuePage] FieldValuePage
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 FieldValueInstance
164
+ # @param [Hash] payload Payload response from the API
165
+ # @return [FieldValueInstance] FieldValueInstance
166
+ def get_instance(payload)
167
+ FieldValueInstance.new(
168
+ @version,
169
+ payload,
170
+ service_sid: @solution[:service_sid],
171
+ field_type_sid: @solution[:field_type_sid],
172
+ )
173
+ end
174
+
175
+ ##
176
+ # Provide a user friendly representation
177
+ def to_s
178
+ '<Twilio.Preview.Understand.FieldValuePage>'
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 FieldValueContext < InstanceContext
185
+ ##
186
+ # Initialize the FieldValueContext
187
+ # @param [Version] version Version that contains the resource
188
+ # @param [String] service_sid The service_sid
189
+ # @param [String] field_type_sid The field_type_sid
190
+ # @param [String] sid The sid
191
+ # @return [FieldValueContext] FieldValueContext
192
+ def initialize(version, service_sid, field_type_sid, sid)
193
+ super(version)
194
+
195
+ # Path Solution
196
+ @solution = {service_sid: service_sid, field_type_sid: field_type_sid, sid: sid,}
197
+ @uri = "/Services/#{@solution[:service_sid]}/FieldTypes/#{@solution[:field_type_sid]}/FieldValues/#{@solution[:sid]}"
198
+ end
199
+
200
+ ##
201
+ # Fetch a FieldValueInstance
202
+ # @return [FieldValueInstance] Fetched FieldValueInstance
203
+ def fetch
204
+ params = Twilio::Values.of({})
205
+
206
+ payload = @version.fetch(
207
+ 'GET',
208
+ @uri,
209
+ params,
210
+ )
211
+
212
+ FieldValueInstance.new(
213
+ @version,
214
+ payload,
215
+ service_sid: @solution[:service_sid],
216
+ field_type_sid: @solution[:field_type_sid],
217
+ sid: @solution[:sid],
218
+ )
219
+ end
220
+
221
+ ##
222
+ # Deletes the FieldValueInstance
223
+ # @return [Boolean] true if delete succeeds, true otherwise
224
+ def delete
225
+ @version.delete('delete', @uri)
226
+ end
227
+
228
+ ##
229
+ # Provide a user friendly representation
230
+ def to_s
231
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
232
+ "#<Twilio.Preview.Understand.FieldValueContext #{context}>"
233
+ end
234
+ end
235
+
236
+ ##
237
+ # 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.
238
+ class FieldValueInstance < InstanceResource
239
+ ##
240
+ # Initialize the FieldValueInstance
241
+ # @param [Version] version Version that contains the resource
242
+ # @param [Hash] payload payload that contains response from Twilio
243
+ # @param [String] service_sid The service_sid
244
+ # @param [String] field_type_sid The field_type_sid
245
+ # @param [String] sid The sid
246
+ # @return [FieldValueInstance] FieldValueInstance
247
+ def initialize(version, payload, service_sid: nil, field_type_sid: nil, sid: nil)
248
+ super(version)
249
+
250
+ # Marshaled Properties
251
+ @properties = {
252
+ 'account_sid' => payload['account_sid'],
253
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
254
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
255
+ 'field_type_sid' => payload['field_type_sid'],
256
+ 'language' => payload['language'],
257
+ 'service_sid' => payload['service_sid'],
258
+ 'sid' => payload['sid'],
259
+ 'value' => payload['value'],
260
+ 'url' => payload['url'],
261
+ }
262
+
263
+ # Context
264
+ @instance_context = nil
265
+ @params = {
266
+ 'service_sid' => service_sid,
267
+ 'field_type_sid' => field_type_sid,
268
+ 'sid' => sid || @properties['sid'],
269
+ }
270
+ end
271
+
272
+ ##
273
+ # Generate an instance context for the instance, the context is capable of
274
+ # performing various actions. All instance actions are proxied to the context
275
+ # @return [FieldValueContext] FieldValueContext for this FieldValueInstance
276
+ def context
277
+ unless @instance_context
278
+ @instance_context = FieldValueContext.new(
279
+ @version,
280
+ @params['service_sid'],
281
+ @params['field_type_sid'],
282
+ @params['sid'],
283
+ )
284
+ end
285
+ @instance_context
286
+ end
287
+
288
+ ##
289
+ # @return [String] The account_sid
290
+ def account_sid
291
+ @properties['account_sid']
292
+ end
293
+
294
+ ##
295
+ # @return [Time] The date_created
296
+ def date_created
297
+ @properties['date_created']
298
+ end
299
+
300
+ ##
301
+ # @return [Time] The date_updated
302
+ def date_updated
303
+ @properties['date_updated']
304
+ end
305
+
306
+ ##
307
+ # @return [String] The field_type_sid
308
+ def field_type_sid
309
+ @properties['field_type_sid']
310
+ end
311
+
312
+ ##
313
+ # @return [String] The language
314
+ def language
315
+ @properties['language']
316
+ end
317
+
318
+ ##
319
+ # @return [String] The service_sid
320
+ def service_sid
321
+ @properties['service_sid']
322
+ end
323
+
324
+ ##
325
+ # @return [String] The sid
326
+ def sid
327
+ @properties['sid']
328
+ end
329
+
330
+ ##
331
+ # @return [String] The value
332
+ def value
333
+ @properties['value']
334
+ end
335
+
336
+ ##
337
+ # @return [String] The url
338
+ def url
339
+ @properties['url']
340
+ end
341
+
342
+ ##
343
+ # Fetch a FieldValueInstance
344
+ # @return [FieldValueInstance] Fetched FieldValueInstance
345
+ def fetch
346
+ context.fetch
347
+ end
348
+
349
+ ##
350
+ # Deletes the FieldValueInstance
351
+ # @return [Boolean] true if delete succeeds, true otherwise
352
+ def delete
353
+ context.delete
354
+ end
355
+
356
+ ##
357
+ # Provide a user friendly representation
358
+ def to_s
359
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
360
+ "<Twilio.Preview.Understand.FieldValueInstance #{values}>"
361
+ end
362
+
363
+ ##
364
+ # Provide a detailed, user friendly representation
365
+ def inspect
366
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
367
+ "<Twilio.Preview.Understand.FieldValueInstance #{values}>"
368
+ end
369
+ end
370
+ end
371
+ end
372
+ end
373
+ end
374
+ end
375
+ end