twilio-ruby 5.40.1 → 5.40.2

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +27 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/framework/version.rb +2 -7
  5. data/lib/twilio-ruby/rest/conversations.rb +52 -0
  6. data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
  7. data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
  8. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
  9. data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
  10. data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
  11. data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
  12. data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
  13. data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
  14. data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
  15. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
  16. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
  17. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
  18. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
  19. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
  20. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
  21. data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
  22. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
  23. data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
  24. data/lib/twilio-ruby/rest/events.rb +8 -0
  25. data/lib/twilio-ruby/rest/events/v1.rb +15 -0
  26. data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
  27. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +2 -2
  28. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
  29. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +27 -24
  30. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +12 -11
  31. data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
  32. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
  33. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
  34. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
  35. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
  36. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
  37. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
  38. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  39. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
  40. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
  41. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
  42. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
  43. data/lib/twilio-ruby/version.rb +1 -1
  44. data/spec/framework/version_spec.rb +42 -0
  45. data/spec/holodeck/holodeck.rb +3 -3
  46. data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
  47. data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
  48. data/spec/integration/conversations/v1/conversation/participant_spec.rb +6 -6
  49. data/spec/integration/conversations/v1/conversation_spec.rb +5 -0
  50. data/spec/integration/conversations/v1/credential_spec.rb +219 -0
  51. data/spec/integration/conversations/v1/notification_spec.rb +107 -0
  52. data/spec/integration/conversations/v1/role_spec.rb +249 -0
  53. data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
  54. data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
  55. data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
  56. data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
  57. data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
  58. data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
  59. data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
  60. data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
  61. data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
  62. data/spec/integration/conversations/v1/service_spec.rb +174 -0
  63. data/spec/integration/conversations/v1/user_spec.rb +220 -0
  64. data/spec/integration/events/v1/event_type_spec.rb +133 -0
  65. data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
  66. data/spec/integration/supersim/v1/sim_spec.rb +23 -0
  67. metadata +50 -2
@@ -0,0 +1,442 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Conversations < Domain
12
+ class V1 < Version
13
+ ##
14
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
15
+ class ServiceList < ListResource
16
+ ##
17
+ # Initialize the ServiceList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [ServiceList] ServiceList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Services"
26
+ end
27
+
28
+ ##
29
+ # Create the ServiceInstance
30
+ # @param [String] friendly_name The human-readable name of this service, limited
31
+ # to 256 characters. Optional.
32
+ # @return [ServiceInstance] Created ServiceInstance
33
+ def create(friendly_name: nil)
34
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, })
35
+
36
+ payload = @version.create('POST', @uri, data: data)
37
+
38
+ ServiceInstance.new(@version, payload, )
39
+ end
40
+
41
+ ##
42
+ # Lists ServiceInstance records from the API as a list.
43
+ # Unlike stream(), this operation is eager and will load `limit` records into
44
+ # memory before returning.
45
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
46
+ # guarantees to never return more than limit. Default is no limit
47
+ # @param [Integer] page_size Number of records to fetch per request, when
48
+ # not set will use the default value of 50 records. If no page_size is defined
49
+ # but a limit is defined, stream() will attempt to read the limit with the most
50
+ # efficient page size, i.e. min(limit, 1000)
51
+ # @return [Array] Array of up to limit results
52
+ def list(limit: nil, page_size: nil)
53
+ self.stream(limit: limit, page_size: page_size).entries
54
+ end
55
+
56
+ ##
57
+ # Streams ServiceInstance records from the API as an Enumerable.
58
+ # This operation lazily loads records as efficiently as possible until the limit
59
+ # is reached.
60
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
61
+ # guarantees to never return more than limit. Default is no limit.
62
+ # @param [Integer] page_size Number of records to fetch per request, when
63
+ # not set will use the default value of 50 records. If no page_size is defined
64
+ # but a limit is defined, stream() will attempt to read the limit with the most
65
+ # efficient page size, i.e. min(limit, 1000)
66
+ # @return [Enumerable] Enumerable that will yield up to limit results
67
+ def stream(limit: nil, page_size: nil)
68
+ limits = @version.read_limits(limit, page_size)
69
+
70
+ page = self.page(page_size: limits[:page_size], )
71
+
72
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
73
+ end
74
+
75
+ ##
76
+ # When passed a block, yields ServiceInstance records from the API.
77
+ # This operation lazily loads records as efficiently as possible until the limit
78
+ # is reached.
79
+ def each
80
+ limits = @version.read_limits
81
+
82
+ page = self.page(page_size: limits[:page_size], )
83
+
84
+ @version.stream(page,
85
+ limit: limits[:limit],
86
+ page_limit: limits[:page_limit]).each {|x| yield x}
87
+ end
88
+
89
+ ##
90
+ # Retrieve a single page of ServiceInstance records from the API.
91
+ # Request is executed immediately.
92
+ # @param [String] page_token PageToken provided by the API
93
+ # @param [Integer] page_number Page Number, this value is simply for client state
94
+ # @param [Integer] page_size Number of records to return, defaults to 50
95
+ # @return [Page] Page of ServiceInstance
96
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
97
+ params = Twilio::Values.of({
98
+ 'PageToken' => page_token,
99
+ 'Page' => page_number,
100
+ 'PageSize' => page_size,
101
+ })
102
+
103
+ response = @version.page('GET', @uri, params: params)
104
+
105
+ ServicePage.new(@version, response, @solution)
106
+ end
107
+
108
+ ##
109
+ # Retrieve a single page of ServiceInstance records from the API.
110
+ # Request is executed immediately.
111
+ # @param [String] target_url API-generated URL for the requested results page
112
+ # @return [Page] Page of ServiceInstance
113
+ def get_page(target_url)
114
+ response = @version.domain.request(
115
+ 'GET',
116
+ target_url
117
+ )
118
+ ServicePage.new(@version, response, @solution)
119
+ end
120
+
121
+ ##
122
+ # Provide a user friendly representation
123
+ def to_s
124
+ '#<Twilio.Conversations.V1.ServiceList>'
125
+ end
126
+ end
127
+
128
+ ##
129
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
130
+ class ServicePage < Page
131
+ ##
132
+ # Initialize the ServicePage
133
+ # @param [Version] version Version that contains the resource
134
+ # @param [Response] response Response from the API
135
+ # @param [Hash] solution Path solution for the resource
136
+ # @return [ServicePage] ServicePage
137
+ def initialize(version, response, solution)
138
+ super(version, response)
139
+
140
+ # Path Solution
141
+ @solution = solution
142
+ end
143
+
144
+ ##
145
+ # Build an instance of ServiceInstance
146
+ # @param [Hash] payload Payload response from the API
147
+ # @return [ServiceInstance] ServiceInstance
148
+ def get_instance(payload)
149
+ ServiceInstance.new(@version, payload, )
150
+ end
151
+
152
+ ##
153
+ # Provide a user friendly representation
154
+ def to_s
155
+ '<Twilio.Conversations.V1.ServicePage>'
156
+ end
157
+ end
158
+
159
+ ##
160
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
161
+ class ServiceContext < InstanceContext
162
+ ##
163
+ # Initialize the ServiceContext
164
+ # @param [Version] version Version that contains the resource
165
+ # @param [String] sid A 34 character string that uniquely identifies this
166
+ # resource.
167
+ # @return [ServiceContext] ServiceContext
168
+ def initialize(version, sid)
169
+ super(version)
170
+
171
+ # Path Solution
172
+ @solution = {sid: sid, }
173
+ @uri = "/Services/#{@solution[:sid]}"
174
+
175
+ # Dependents
176
+ @conversations = nil
177
+ @bindings = nil
178
+ @users = nil
179
+ @roles = nil
180
+ @configuration = nil
181
+ end
182
+
183
+ ##
184
+ # Delete the ServiceInstance
185
+ # @return [Boolean] true if delete succeeds, false otherwise
186
+ def delete
187
+ @version.delete('DELETE', @uri)
188
+ end
189
+
190
+ ##
191
+ # Fetch the ServiceInstance
192
+ # @return [ServiceInstance] Fetched ServiceInstance
193
+ def fetch
194
+ payload = @version.fetch('GET', @uri)
195
+
196
+ ServiceInstance.new(@version, payload, sid: @solution[:sid], )
197
+ end
198
+
199
+ ##
200
+ # Access the conversations
201
+ # @return [ConversationList]
202
+ # @return [ConversationContext] if sid was passed.
203
+ def conversations(sid=:unset)
204
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
205
+
206
+ if sid != :unset
207
+ return ConversationContext.new(@version, @solution[:sid], sid, )
208
+ end
209
+
210
+ unless @conversations
211
+ @conversations = ConversationList.new(@version, chat_service_sid: @solution[:sid], )
212
+ end
213
+
214
+ @conversations
215
+ end
216
+
217
+ ##
218
+ # Access the bindings
219
+ # @return [BindingList]
220
+ # @return [BindingContext] if sid was passed.
221
+ def bindings(sid=:unset)
222
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
223
+
224
+ if sid != :unset
225
+ return BindingContext.new(@version, @solution[:sid], sid, )
226
+ end
227
+
228
+ unless @bindings
229
+ @bindings = BindingList.new(@version, chat_service_sid: @solution[:sid], )
230
+ end
231
+
232
+ @bindings
233
+ end
234
+
235
+ ##
236
+ # Access the users
237
+ # @return [UserList]
238
+ # @return [UserContext] if sid was passed.
239
+ def users(sid=:unset)
240
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
241
+
242
+ if sid != :unset
243
+ return UserContext.new(@version, @solution[:sid], sid, )
244
+ end
245
+
246
+ unless @users
247
+ @users = UserList.new(@version, chat_service_sid: @solution[:sid], )
248
+ end
249
+
250
+ @users
251
+ end
252
+
253
+ ##
254
+ # Access the roles
255
+ # @return [RoleList]
256
+ # @return [RoleContext] if sid was passed.
257
+ def roles(sid=:unset)
258
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
259
+
260
+ if sid != :unset
261
+ return RoleContext.new(@version, @solution[:sid], sid, )
262
+ end
263
+
264
+ unless @roles
265
+ @roles = RoleList.new(@version, chat_service_sid: @solution[:sid], )
266
+ end
267
+
268
+ @roles
269
+ end
270
+
271
+ ##
272
+ # Access the configuration
273
+ # @return [ConfigurationList]
274
+ # @return [ConfigurationContext]
275
+ def configuration
276
+ ConfigurationContext.new(@version, @solution[:sid], )
277
+ end
278
+
279
+ ##
280
+ # Provide a user friendly representation
281
+ def to_s
282
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
283
+ "#<Twilio.Conversations.V1.ServiceContext #{context}>"
284
+ end
285
+
286
+ ##
287
+ # Provide a detailed, user friendly representation
288
+ def inspect
289
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
290
+ "#<Twilio.Conversations.V1.ServiceContext #{context}>"
291
+ end
292
+ end
293
+
294
+ ##
295
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
296
+ class ServiceInstance < InstanceResource
297
+ ##
298
+ # Initialize the ServiceInstance
299
+ # @param [Version] version Version that contains the resource
300
+ # @param [Hash] payload payload that contains response from Twilio
301
+ # @param [String] sid A 34 character string that uniquely identifies this
302
+ # resource.
303
+ # @return [ServiceInstance] ServiceInstance
304
+ def initialize(version, payload, sid: nil)
305
+ super(version)
306
+
307
+ # Marshaled Properties
308
+ @properties = {
309
+ 'account_sid' => payload['account_sid'],
310
+ 'sid' => payload['sid'],
311
+ 'friendly_name' => payload['friendly_name'],
312
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
313
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
314
+ 'url' => payload['url'],
315
+ 'links' => payload['links'],
316
+ }
317
+
318
+ # Context
319
+ @instance_context = nil
320
+ @params = {'sid' => sid || @properties['sid'], }
321
+ end
322
+
323
+ ##
324
+ # Generate an instance context for the instance, the context is capable of
325
+ # performing various actions. All instance actions are proxied to the context
326
+ # @return [ServiceContext] ServiceContext for this ServiceInstance
327
+ def context
328
+ unless @instance_context
329
+ @instance_context = ServiceContext.new(@version, @params['sid'], )
330
+ end
331
+ @instance_context
332
+ end
333
+
334
+ ##
335
+ # @return [String] The unique id of the Account responsible for this service.
336
+ def account_sid
337
+ @properties['account_sid']
338
+ end
339
+
340
+ ##
341
+ # @return [String] A 34 character string that uniquely identifies this resource.
342
+ def sid
343
+ @properties['sid']
344
+ end
345
+
346
+ ##
347
+ # @return [String] The human-readable name of this service.
348
+ def friendly_name
349
+ @properties['friendly_name']
350
+ end
351
+
352
+ ##
353
+ # @return [Time] The date that this resource was created.
354
+ def date_created
355
+ @properties['date_created']
356
+ end
357
+
358
+ ##
359
+ # @return [Time] The date that this resource was last updated.
360
+ def date_updated
361
+ @properties['date_updated']
362
+ end
363
+
364
+ ##
365
+ # @return [String] An absolute URL for this service.
366
+ def url
367
+ @properties['url']
368
+ end
369
+
370
+ ##
371
+ # @return [String] Absolute URLs to access the Conversations, Users, Roles and Bindings of this Service.
372
+ def links
373
+ @properties['links']
374
+ end
375
+
376
+ ##
377
+ # Delete the ServiceInstance
378
+ # @return [Boolean] true if delete succeeds, false otherwise
379
+ def delete
380
+ context.delete
381
+ end
382
+
383
+ ##
384
+ # Fetch the ServiceInstance
385
+ # @return [ServiceInstance] Fetched ServiceInstance
386
+ def fetch
387
+ context.fetch
388
+ end
389
+
390
+ ##
391
+ # Access the conversations
392
+ # @return [conversations] conversations
393
+ def conversations
394
+ context.conversations
395
+ end
396
+
397
+ ##
398
+ # Access the bindings
399
+ # @return [bindings] bindings
400
+ def bindings
401
+ context.bindings
402
+ end
403
+
404
+ ##
405
+ # Access the users
406
+ # @return [users] users
407
+ def users
408
+ context.users
409
+ end
410
+
411
+ ##
412
+ # Access the roles
413
+ # @return [roles] roles
414
+ def roles
415
+ context.roles
416
+ end
417
+
418
+ ##
419
+ # Access the configuration
420
+ # @return [configuration] configuration
421
+ def configuration
422
+ context.configuration
423
+ end
424
+
425
+ ##
426
+ # Provide a user friendly representation
427
+ def to_s
428
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
429
+ "<Twilio.Conversations.V1.ServiceInstance #{values}>"
430
+ end
431
+
432
+ ##
433
+ # Provide a detailed, user friendly representation
434
+ def inspect
435
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
436
+ "<Twilio.Conversations.V1.ServiceInstance #{values}>"
437
+ end
438
+ end
439
+ end
440
+ end
441
+ end
442
+ end
@@ -0,0 +1,385 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Conversations < Domain
12
+ class V1 < Version
13
+ class ServiceContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
16
+ class BindingList < ListResource
17
+ ##
18
+ # Initialize the BindingList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] chat_service_sid The SID of the [Chat
21
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Binding
22
+ # resource is associated with.
23
+ # @return [BindingList] BindingList
24
+ def initialize(version, chat_service_sid: nil)
25
+ super(version)
26
+
27
+ # Path Solution
28
+ @solution = {chat_service_sid: chat_service_sid}
29
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Bindings"
30
+ end
31
+
32
+ ##
33
+ # Lists BindingInstance records from the API as a list.
34
+ # Unlike stream(), this operation is eager and will load `limit` records into
35
+ # memory before returning.
36
+ # @param [binding.BindingType] binding_type The push technology used by the
37
+ # Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push
38
+ # notification
39
+ # configuration](https://www.twilio.com/docs/chat/push-notification-configuration)
40
+ # for more info.
41
+ # @param [String] identity The
42
+ # [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value
43
+ # of the resources to read. See [access
44
+ # tokens](https://www.twilio.com/docs/chat/create-tokens) for more details.
45
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
46
+ # guarantees to never return more than limit. Default is no limit
47
+ # @param [Integer] page_size Number of records to fetch per request, when
48
+ # not set will use the default value of 50 records. If no page_size is defined
49
+ # but a limit is defined, stream() will attempt to read the limit with the most
50
+ # efficient page size, i.e. min(limit, 1000)
51
+ # @return [Array] Array of up to limit results
52
+ def list(binding_type: :unset, identity: :unset, limit: nil, page_size: nil)
53
+ self.stream(
54
+ binding_type: binding_type,
55
+ identity: identity,
56
+ limit: limit,
57
+ page_size: page_size
58
+ ).entries
59
+ end
60
+
61
+ ##
62
+ # Streams BindingInstance records from the API as an Enumerable.
63
+ # This operation lazily loads records as efficiently as possible until the limit
64
+ # is reached.
65
+ # @param [binding.BindingType] binding_type The push technology used by the
66
+ # Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push
67
+ # notification
68
+ # configuration](https://www.twilio.com/docs/chat/push-notification-configuration)
69
+ # for more info.
70
+ # @param [String] identity The
71
+ # [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value
72
+ # of the resources to read. See [access
73
+ # tokens](https://www.twilio.com/docs/chat/create-tokens) for more details.
74
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
75
+ # guarantees to never return more than limit. Default is no limit.
76
+ # @param [Integer] page_size Number of records to fetch per request, when
77
+ # not set will use the default value of 50 records. If no page_size is defined
78
+ # but a limit is defined, stream() will attempt to read the limit with the most
79
+ # efficient page size, i.e. min(limit, 1000)
80
+ # @return [Enumerable] Enumerable that will yield up to limit results
81
+ def stream(binding_type: :unset, identity: :unset, limit: nil, page_size: nil)
82
+ limits = @version.read_limits(limit, page_size)
83
+
84
+ page = self.page(binding_type: binding_type, identity: identity, page_size: limits[:page_size], )
85
+
86
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
87
+ end
88
+
89
+ ##
90
+ # When passed a block, yields BindingInstance records from the API.
91
+ # This operation lazily loads records as efficiently as possible until the limit
92
+ # is reached.
93
+ def each
94
+ limits = @version.read_limits
95
+
96
+ page = self.page(page_size: limits[:page_size], )
97
+
98
+ @version.stream(page,
99
+ limit: limits[:limit],
100
+ page_limit: limits[:page_limit]).each {|x| yield x}
101
+ end
102
+
103
+ ##
104
+ # Retrieve a single page of BindingInstance records from the API.
105
+ # Request is executed immediately.
106
+ # @param [binding.BindingType] binding_type The push technology used by the
107
+ # Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push
108
+ # notification
109
+ # configuration](https://www.twilio.com/docs/chat/push-notification-configuration)
110
+ # for more info.
111
+ # @param [String] identity The
112
+ # [User](https://www.twilio.com/docs/chat/rest/user-resource)'s `identity` value
113
+ # of the resources to read. See [access
114
+ # tokens](https://www.twilio.com/docs/chat/create-tokens) for more details.
115
+ # @param [String] page_token PageToken provided by the API
116
+ # @param [Integer] page_number Page Number, this value is simply for client state
117
+ # @param [Integer] page_size Number of records to return, defaults to 50
118
+ # @return [Page] Page of BindingInstance
119
+ def page(binding_type: :unset, identity: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
120
+ params = Twilio::Values.of({
121
+ 'BindingType' => Twilio.serialize_list(binding_type) { |e| e },
122
+ 'Identity' => Twilio.serialize_list(identity) { |e| e },
123
+ 'PageToken' => page_token,
124
+ 'Page' => page_number,
125
+ 'PageSize' => page_size,
126
+ })
127
+
128
+ response = @version.page('GET', @uri, params: params)
129
+
130
+ BindingPage.new(@version, response, @solution)
131
+ end
132
+
133
+ ##
134
+ # Retrieve a single page of BindingInstance records from the API.
135
+ # Request is executed immediately.
136
+ # @param [String] target_url API-generated URL for the requested results page
137
+ # @return [Page] Page of BindingInstance
138
+ def get_page(target_url)
139
+ response = @version.domain.request(
140
+ 'GET',
141
+ target_url
142
+ )
143
+ BindingPage.new(@version, response, @solution)
144
+ end
145
+
146
+ ##
147
+ # Provide a user friendly representation
148
+ def to_s
149
+ '#<Twilio.Conversations.V1.BindingList>'
150
+ end
151
+ end
152
+
153
+ ##
154
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
155
+ class BindingPage < Page
156
+ ##
157
+ # Initialize the BindingPage
158
+ # @param [Version] version Version that contains the resource
159
+ # @param [Response] response Response from the API
160
+ # @param [Hash] solution Path solution for the resource
161
+ # @return [BindingPage] BindingPage
162
+ def initialize(version, response, solution)
163
+ super(version, response)
164
+
165
+ # Path Solution
166
+ @solution = solution
167
+ end
168
+
169
+ ##
170
+ # Build an instance of BindingInstance
171
+ # @param [Hash] payload Payload response from the API
172
+ # @return [BindingInstance] BindingInstance
173
+ def get_instance(payload)
174
+ BindingInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
175
+ end
176
+
177
+ ##
178
+ # Provide a user friendly representation
179
+ def to_s
180
+ '<Twilio.Conversations.V1.BindingPage>'
181
+ end
182
+ end
183
+
184
+ ##
185
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
186
+ class BindingContext < InstanceContext
187
+ ##
188
+ # Initialize the BindingContext
189
+ # @param [Version] version Version that contains the resource
190
+ # @param [String] chat_service_sid The SID of the [Chat
191
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Binding
192
+ # resource is associated with.
193
+ # @param [String] sid A 34 character string that uniquely identifies this
194
+ # resource.
195
+ # @return [BindingContext] BindingContext
196
+ def initialize(version, chat_service_sid, sid)
197
+ super(version)
198
+
199
+ # Path Solution
200
+ @solution = {chat_service_sid: chat_service_sid, sid: sid, }
201
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Bindings/#{@solution[:sid]}"
202
+ end
203
+
204
+ ##
205
+ # Delete the BindingInstance
206
+ # @return [Boolean] true if delete succeeds, false otherwise
207
+ def delete
208
+ @version.delete('DELETE', @uri)
209
+ end
210
+
211
+ ##
212
+ # Fetch the BindingInstance
213
+ # @return [BindingInstance] Fetched BindingInstance
214
+ def fetch
215
+ payload = @version.fetch('GET', @uri)
216
+
217
+ BindingInstance.new(
218
+ @version,
219
+ payload,
220
+ chat_service_sid: @solution[:chat_service_sid],
221
+ sid: @solution[:sid],
222
+ )
223
+ end
224
+
225
+ ##
226
+ # Provide a user friendly representation
227
+ def to_s
228
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
229
+ "#<Twilio.Conversations.V1.BindingContext #{context}>"
230
+ end
231
+
232
+ ##
233
+ # Provide a detailed, user friendly representation
234
+ def inspect
235
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
236
+ "#<Twilio.Conversations.V1.BindingContext #{context}>"
237
+ end
238
+ end
239
+
240
+ ##
241
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
242
+ class BindingInstance < InstanceResource
243
+ ##
244
+ # Initialize the BindingInstance
245
+ # @param [Version] version Version that contains the resource
246
+ # @param [Hash] payload payload that contains response from Twilio
247
+ # @param [String] chat_service_sid The SID of the [Chat
248
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Binding
249
+ # resource is associated with.
250
+ # @param [String] sid A 34 character string that uniquely identifies this
251
+ # resource.
252
+ # @return [BindingInstance] BindingInstance
253
+ def initialize(version, payload, chat_service_sid: nil, sid: nil)
254
+ super(version)
255
+
256
+ # Marshaled Properties
257
+ @properties = {
258
+ 'sid' => payload['sid'],
259
+ 'account_sid' => payload['account_sid'],
260
+ 'chat_service_sid' => payload['chat_service_sid'],
261
+ 'credential_sid' => payload['credential_sid'],
262
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
263
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
264
+ 'endpoint' => payload['endpoint'],
265
+ 'identity' => payload['identity'],
266
+ 'binding_type' => payload['binding_type'],
267
+ 'message_types' => payload['message_types'],
268
+ 'url' => payload['url'],
269
+ }
270
+
271
+ # Context
272
+ @instance_context = nil
273
+ @params = {'chat_service_sid' => chat_service_sid, 'sid' => sid || @properties['sid'], }
274
+ end
275
+
276
+ ##
277
+ # Generate an instance context for the instance, the context is capable of
278
+ # performing various actions. All instance actions are proxied to the context
279
+ # @return [BindingContext] BindingContext for this BindingInstance
280
+ def context
281
+ unless @instance_context
282
+ @instance_context = BindingContext.new(@version, @params['chat_service_sid'], @params['sid'], )
283
+ end
284
+ @instance_context
285
+ end
286
+
287
+ ##
288
+ # @return [String] A 34 character string that uniquely identifies this resource.
289
+ def sid
290
+ @properties['sid']
291
+ end
292
+
293
+ ##
294
+ # @return [String] The unique id of the Account responsible for this binding.
295
+ def account_sid
296
+ @properties['account_sid']
297
+ end
298
+
299
+ ##
300
+ # @return [String] The SID of the Chat Service that the resource is associated with.
301
+ def chat_service_sid
302
+ @properties['chat_service_sid']
303
+ end
304
+
305
+ ##
306
+ # @return [String] The SID of the Credential for the binding.
307
+ def credential_sid
308
+ @properties['credential_sid']
309
+ end
310
+
311
+ ##
312
+ # @return [Time] The date that this resource was created.
313
+ def date_created
314
+ @properties['date_created']
315
+ end
316
+
317
+ ##
318
+ # @return [Time] The date that this resource was last updated.
319
+ def date_updated
320
+ @properties['date_updated']
321
+ end
322
+
323
+ ##
324
+ # @return [String] The unique endpoint identifier for the Binding.
325
+ def endpoint
326
+ @properties['endpoint']
327
+ end
328
+
329
+ ##
330
+ # @return [String] The string that identifies the resource's User.
331
+ def identity
332
+ @properties['identity']
333
+ end
334
+
335
+ ##
336
+ # @return [binding.BindingType] The push technology to use for the binding.
337
+ def binding_type
338
+ @properties['binding_type']
339
+ end
340
+
341
+ ##
342
+ # @return [String] The Chat message types the binding is subscribed to.
343
+ def message_types
344
+ @properties['message_types']
345
+ end
346
+
347
+ ##
348
+ # @return [String] An absolute URL for this binding.
349
+ def url
350
+ @properties['url']
351
+ end
352
+
353
+ ##
354
+ # Delete the BindingInstance
355
+ # @return [Boolean] true if delete succeeds, false otherwise
356
+ def delete
357
+ context.delete
358
+ end
359
+
360
+ ##
361
+ # Fetch the BindingInstance
362
+ # @return [BindingInstance] Fetched BindingInstance
363
+ def fetch
364
+ context.fetch
365
+ end
366
+
367
+ ##
368
+ # Provide a user friendly representation
369
+ def to_s
370
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
371
+ "<Twilio.Conversations.V1.BindingInstance #{values}>"
372
+ end
373
+
374
+ ##
375
+ # Provide a detailed, user friendly representation
376
+ def inspect
377
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
378
+ "<Twilio.Conversations.V1.BindingInstance #{values}>"
379
+ end
380
+ end
381
+ end
382
+ end
383
+ end
384
+ end
385
+ end