twilio-ruby 5.39.1 → 5.40.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGES.md +101 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/ISSUE_TEMPLATE.md +5 -1
  6. data/Makefile +1 -1
  7. data/PULL_REQUEST_TEMPLATE.md +1 -1
  8. data/README.md +4 -3
  9. data/lib/twilio-ruby/framework/version.rb +2 -7
  10. data/lib/twilio-ruby/rest/api/v2010/account/application.rb +6 -4
  11. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +3 -3
  12. data/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +79 -60
  13. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +14 -0
  14. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +14 -0
  15. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +14 -0
  16. data/lib/twilio-ruby/rest/client.rb +7 -0
  17. data/lib/twilio-ruby/rest/conversations.rb +52 -0
  18. data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
  19. data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
  20. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
  21. data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
  22. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +12 -2
  23. data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
  24. data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
  25. data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
  26. data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
  27. data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
  28. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
  29. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
  30. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
  31. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
  32. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
  33. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
  34. data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
  35. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
  36. data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
  37. data/lib/twilio-ruby/rest/events.rb +63 -0
  38. data/lib/twilio-ruby/rest/events/v1.rb +74 -0
  39. data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
  40. data/lib/twilio-ruby/rest/events/v1/sink.rb +380 -0
  41. data/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +115 -0
  42. data/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +119 -0
  43. data/lib/twilio-ruby/rest/events/v1/subscription.rb +363 -0
  44. data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +322 -0
  45. data/lib/twilio-ruby/rest/messaging.rb +6 -0
  46. data/lib/twilio-ruby/rest/messaging/v1.rb +7 -0
  47. data/lib/twilio-ruby/rest/messaging/v1/deactivation.rb +164 -0
  48. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +3 -3
  49. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb +16 -2
  50. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
  51. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +45 -4
  52. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +14 -1
  53. data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
  54. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
  55. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
  56. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
  57. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
  58. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
  59. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
  60. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  61. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
  62. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
  63. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +12 -11
  64. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +39 -9
  65. data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +75 -9
  66. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
  67. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +25 -3
  68. data/lib/twilio-ruby/rest/verify/v2/service.rb +21 -9
  69. data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +10 -2
  70. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +4 -1
  71. data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb +0 -6
  72. data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +5 -19
  73. data/lib/twilio-ruby/version.rb +1 -1
  74. data/spec/framework/version_spec.rb +42 -0
  75. data/spec/holodeck/holodeck.rb +3 -3
  76. data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +35 -36
  77. data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +39 -40
  78. data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +35 -36
  79. data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +25 -23
  80. data/spec/integration/api/v2010/account/message_spec.rb +37 -0
  81. data/spec/integration/bulkexports/v1/export/day_spec.rb +5 -5
  82. data/spec/integration/bulkexports/v1/export_configuration_spec.rb +4 -4
  83. data/spec/integration/bulkexports/v1/export_spec.rb +3 -3
  84. data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
  85. data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
  86. data/spec/integration/conversations/v1/conversation/message_spec.rb +38 -0
  87. data/spec/integration/conversations/v1/conversation/participant_spec.rb +60 -4
  88. data/spec/integration/conversations/v1/conversation_spec.rb +35 -0
  89. data/spec/integration/conversations/v1/credential_spec.rb +219 -0
  90. data/spec/integration/conversations/v1/notification_spec.rb +107 -0
  91. data/spec/integration/conversations/v1/role_spec.rb +249 -0
  92. data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
  93. data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
  94. data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
  95. data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
  96. data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
  97. data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
  98. data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
  99. data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
  100. data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
  101. data/spec/integration/conversations/v1/service_spec.rb +174 -0
  102. data/spec/integration/conversations/v1/user_spec.rb +220 -0
  103. data/spec/integration/events/v1/event_type_spec.rb +133 -0
  104. data/spec/integration/events/v1/sink/sink_test_spec.rb +42 -0
  105. data/spec/integration/events/v1/sink/sink_validate_spec.rb +44 -0
  106. data/spec/integration/events/v1/sink_spec.rb +217 -0
  107. data/spec/integration/events/v1/subscription/subscribed_event_spec.rb +212 -0
  108. data/spec/integration/events/v1/subscription_spec.rb +205 -0
  109. data/spec/integration/messaging/v1/deactivation_spec.rb +40 -0
  110. data/spec/integration/numbers/v2/regulatory_compliance/end_user_spec.rb +27 -0
  111. data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
  112. data/spec/integration/studio/v1/flow/execution/execution_step_spec.rb +1 -0
  113. data/spec/integration/studio/v2/flow/execution/execution_step_spec.rb +1 -0
  114. data/spec/integration/supersim/v1/sim_spec.rb +23 -0
  115. data/spec/integration/supersim/v1/usage_record_spec.rb +463 -18
  116. data/spec/integration/trunking/v1/trunk_spec.rb +4 -0
  117. data/spec/integration/verify/v2/service/access_token_spec.rb +1 -1
  118. data/spec/integration/verify/v2/service/entity/challenge_spec.rb +8 -8
  119. data/spec/integration/video/v1/room_spec.rb +37 -0
  120. data/spec/integration/wireless/v1/sim/data_session_spec.rb +2 -2
  121. data/spec/spec_helper.rb +1 -1
  122. metadata +70 -2
@@ -0,0 +1,393 @@
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 RoleList < ListResource
17
+ ##
18
+ # Initialize the RoleList
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 Role
22
+ # resource is associated with.
23
+ # @return [RoleList] RoleList
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]}/Roles"
30
+ end
31
+
32
+ ##
33
+ # Create the RoleInstance
34
+ # @param [String] friendly_name A descriptive string that you create to describe
35
+ # the new resource. It can be up to 64 characters long.
36
+ # @param [role.RoleType] type The type of role. Can be: `conversation` for
37
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) roles or `service` for [Service](https://www.twilio.com/docs/chat/rest/service-resource) roles.
38
+ # @param [String] permission A permission that you grant to the new role. Only one
39
+ # permission can be granted per parameter. To assign more than one permission,
40
+ # repeat this parameter for each permission value. The values for this parameter
41
+ # depend on the role's `type`.
42
+ # @return [RoleInstance] Created RoleInstance
43
+ def create(friendly_name: nil, type: nil, permission: nil)
44
+ data = Twilio::Values.of({
45
+ 'FriendlyName' => friendly_name,
46
+ 'Type' => type,
47
+ 'Permission' => Twilio.serialize_list(permission) { |e| e },
48
+ })
49
+
50
+ payload = @version.create('POST', @uri, data: data)
51
+
52
+ RoleInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
53
+ end
54
+
55
+ ##
56
+ # Lists RoleInstance records from the API as a list.
57
+ # Unlike stream(), this operation is eager and will load `limit` records into
58
+ # memory before returning.
59
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
60
+ # guarantees to never return more than limit. Default is no limit
61
+ # @param [Integer] page_size Number of records to fetch per request, when
62
+ # not set will use the default value of 50 records. If no page_size is defined
63
+ # but a limit is defined, stream() will attempt to read the limit with the most
64
+ # efficient page size, i.e. min(limit, 1000)
65
+ # @return [Array] Array of up to limit results
66
+ def list(limit: nil, page_size: nil)
67
+ self.stream(limit: limit, page_size: page_size).entries
68
+ end
69
+
70
+ ##
71
+ # Streams RoleInstance records from the API as an Enumerable.
72
+ # This operation lazily loads records as efficiently as possible until the limit
73
+ # is reached.
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(limit: nil, page_size: nil)
82
+ limits = @version.read_limits(limit, page_size)
83
+
84
+ page = self.page(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 RoleInstance 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 RoleInstance records from the API.
105
+ # Request is executed immediately.
106
+ # @param [String] page_token PageToken provided by the API
107
+ # @param [Integer] page_number Page Number, this value is simply for client state
108
+ # @param [Integer] page_size Number of records to return, defaults to 50
109
+ # @return [Page] Page of RoleInstance
110
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
111
+ params = Twilio::Values.of({
112
+ 'PageToken' => page_token,
113
+ 'Page' => page_number,
114
+ 'PageSize' => page_size,
115
+ })
116
+
117
+ response = @version.page('GET', @uri, params: params)
118
+
119
+ RolePage.new(@version, response, @solution)
120
+ end
121
+
122
+ ##
123
+ # Retrieve a single page of RoleInstance records from the API.
124
+ # Request is executed immediately.
125
+ # @param [String] target_url API-generated URL for the requested results page
126
+ # @return [Page] Page of RoleInstance
127
+ def get_page(target_url)
128
+ response = @version.domain.request(
129
+ 'GET',
130
+ target_url
131
+ )
132
+ RolePage.new(@version, response, @solution)
133
+ end
134
+
135
+ ##
136
+ # Provide a user friendly representation
137
+ def to_s
138
+ '#<Twilio.Conversations.V1.RoleList>'
139
+ end
140
+ end
141
+
142
+ ##
143
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
144
+ class RolePage < Page
145
+ ##
146
+ # Initialize the RolePage
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 [RolePage] RolePage
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 RoleInstance
160
+ # @param [Hash] payload Payload response from the API
161
+ # @return [RoleInstance] RoleInstance
162
+ def get_instance(payload)
163
+ RoleInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
164
+ end
165
+
166
+ ##
167
+ # Provide a user friendly representation
168
+ def to_s
169
+ '<Twilio.Conversations.V1.RolePage>'
170
+ end
171
+ end
172
+
173
+ ##
174
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
175
+ class RoleContext < InstanceContext
176
+ ##
177
+ # Initialize the RoleContext
178
+ # @param [Version] version Version that contains the resource
179
+ # @param [String] chat_service_sid The SID of the [Chat
180
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) to fetch the
181
+ # Role resource from.
182
+ # @param [String] sid The SID of the Role resource to fetch.
183
+ # @return [RoleContext] RoleContext
184
+ def initialize(version, chat_service_sid, sid)
185
+ super(version)
186
+
187
+ # Path Solution
188
+ @solution = {chat_service_sid: chat_service_sid, sid: sid, }
189
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Roles/#{@solution[:sid]}"
190
+ end
191
+
192
+ ##
193
+ # Update the RoleInstance
194
+ # @param [String] permission A permission that you grant to the role. Only one
195
+ # permission can be granted per parameter. To assign more than one permission,
196
+ # repeat this parameter for each permission value. Note that the update action
197
+ # replaces all previously assigned permissions with those defined in the update
198
+ # action. To remove a permission, do not include it in the subsequent update
199
+ # action. The values for this parameter depend on the role's `type`.
200
+ # @return [RoleInstance] Updated RoleInstance
201
+ def update(permission: nil)
202
+ data = Twilio::Values.of({'Permission' => Twilio.serialize_list(permission) { |e| e }, })
203
+
204
+ payload = @version.update('POST', @uri, data: data)
205
+
206
+ RoleInstance.new(
207
+ @version,
208
+ payload,
209
+ chat_service_sid: @solution[:chat_service_sid],
210
+ sid: @solution[:sid],
211
+ )
212
+ end
213
+
214
+ ##
215
+ # Delete the RoleInstance
216
+ # @return [Boolean] true if delete succeeds, false otherwise
217
+ def delete
218
+ @version.delete('DELETE', @uri)
219
+ end
220
+
221
+ ##
222
+ # Fetch the RoleInstance
223
+ # @return [RoleInstance] Fetched RoleInstance
224
+ def fetch
225
+ payload = @version.fetch('GET', @uri)
226
+
227
+ RoleInstance.new(
228
+ @version,
229
+ payload,
230
+ chat_service_sid: @solution[:chat_service_sid],
231
+ sid: @solution[:sid],
232
+ )
233
+ end
234
+
235
+ ##
236
+ # Provide a user friendly representation
237
+ def to_s
238
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
239
+ "#<Twilio.Conversations.V1.RoleContext #{context}>"
240
+ end
241
+
242
+ ##
243
+ # Provide a detailed, user friendly representation
244
+ def inspect
245
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
246
+ "#<Twilio.Conversations.V1.RoleContext #{context}>"
247
+ end
248
+ end
249
+
250
+ ##
251
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
252
+ class RoleInstance < InstanceResource
253
+ ##
254
+ # Initialize the RoleInstance
255
+ # @param [Version] version Version that contains the resource
256
+ # @param [Hash] payload payload that contains response from Twilio
257
+ # @param [String] chat_service_sid The SID of the [Chat
258
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Role
259
+ # resource is associated with.
260
+ # @param [String] sid The SID of the Role resource to fetch.
261
+ # @return [RoleInstance] RoleInstance
262
+ def initialize(version, payload, chat_service_sid: nil, sid: nil)
263
+ super(version)
264
+
265
+ # Marshaled Properties
266
+ @properties = {
267
+ 'sid' => payload['sid'],
268
+ 'account_sid' => payload['account_sid'],
269
+ 'chat_service_sid' => payload['chat_service_sid'],
270
+ 'friendly_name' => payload['friendly_name'],
271
+ 'type' => payload['type'],
272
+ 'permissions' => payload['permissions'],
273
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
274
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
275
+ 'url' => payload['url'],
276
+ }
277
+
278
+ # Context
279
+ @instance_context = nil
280
+ @params = {'chat_service_sid' => chat_service_sid, 'sid' => sid || @properties['sid'], }
281
+ end
282
+
283
+ ##
284
+ # Generate an instance context for the instance, the context is capable of
285
+ # performing various actions. All instance actions are proxied to the context
286
+ # @return [RoleContext] RoleContext for this RoleInstance
287
+ def context
288
+ unless @instance_context
289
+ @instance_context = RoleContext.new(@version, @params['chat_service_sid'], @params['sid'], )
290
+ end
291
+ @instance_context
292
+ end
293
+
294
+ ##
295
+ # @return [String] The unique string that identifies the resource
296
+ def sid
297
+ @properties['sid']
298
+ end
299
+
300
+ ##
301
+ # @return [String] The SID of the Account that created the resource
302
+ def account_sid
303
+ @properties['account_sid']
304
+ end
305
+
306
+ ##
307
+ # @return [String] The SID of the Service that the resource is associated with
308
+ def chat_service_sid
309
+ @properties['chat_service_sid']
310
+ end
311
+
312
+ ##
313
+ # @return [String] The string that you assigned to describe the resource
314
+ def friendly_name
315
+ @properties['friendly_name']
316
+ end
317
+
318
+ ##
319
+ # @return [role.RoleType] The type of role
320
+ def type
321
+ @properties['type']
322
+ end
323
+
324
+ ##
325
+ # @return [String] An array of the permissions the role has been granted
326
+ def permissions
327
+ @properties['permissions']
328
+ end
329
+
330
+ ##
331
+ # @return [Time] The ISO 8601 date and time in GMT when the resource was created
332
+ def date_created
333
+ @properties['date_created']
334
+ end
335
+
336
+ ##
337
+ # @return [Time] The ISO 8601 date and time in GMT when the resource was last updated
338
+ def date_updated
339
+ @properties['date_updated']
340
+ end
341
+
342
+ ##
343
+ # @return [String] The absolute URL of the Role resource
344
+ def url
345
+ @properties['url']
346
+ end
347
+
348
+ ##
349
+ # Update the RoleInstance
350
+ # @param [String] permission A permission that you grant to the role. Only one
351
+ # permission can be granted per parameter. To assign more than one permission,
352
+ # repeat this parameter for each permission value. Note that the update action
353
+ # replaces all previously assigned permissions with those defined in the update
354
+ # action. To remove a permission, do not include it in the subsequent update
355
+ # action. The values for this parameter depend on the role's `type`.
356
+ # @return [RoleInstance] Updated RoleInstance
357
+ def update(permission: nil)
358
+ context.update(permission: permission, )
359
+ end
360
+
361
+ ##
362
+ # Delete the RoleInstance
363
+ # @return [Boolean] true if delete succeeds, false otherwise
364
+ def delete
365
+ context.delete
366
+ end
367
+
368
+ ##
369
+ # Fetch the RoleInstance
370
+ # @return [RoleInstance] Fetched RoleInstance
371
+ def fetch
372
+ context.fetch
373
+ end
374
+
375
+ ##
376
+ # Provide a user friendly representation
377
+ def to_s
378
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
379
+ "<Twilio.Conversations.V1.RoleInstance #{values}>"
380
+ end
381
+
382
+ ##
383
+ # Provide a detailed, user friendly representation
384
+ def inspect
385
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
386
+ "<Twilio.Conversations.V1.RoleInstance #{values}>"
387
+ end
388
+ end
389
+ end
390
+ end
391
+ end
392
+ end
393
+ end
@@ -0,0 +1,419 @@
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 UserList < ListResource
17
+ ##
18
+ # Initialize the UserList
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 User
22
+ # resource is associated with.
23
+ # @return [UserList] UserList
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]}/Users"
30
+ end
31
+
32
+ ##
33
+ # Create the UserInstance
34
+ # @param [String] identity The application-defined string that uniquely identifies
35
+ # the resource's User within the
36
+ # [Service](https://www.twilio.com/docs/chat/rest/service-resource). This value is
37
+ # often a username or an email address, and is case-sensitive.
38
+ # @param [String] friendly_name The string that you assigned to describe the
39
+ # resource.
40
+ # @param [String] attributes The JSON Object string that stores
41
+ # application-specific data. If attributes have not been set, `{}` is returned.
42
+ # @param [String] role_sid The SID of the
43
+ # [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
44
+ # user.
45
+ # @return [UserInstance] Created UserInstance
46
+ def create(identity: nil, friendly_name: :unset, attributes: :unset, role_sid: :unset)
47
+ data = Twilio::Values.of({
48
+ 'Identity' => identity,
49
+ 'FriendlyName' => friendly_name,
50
+ 'Attributes' => attributes,
51
+ 'RoleSid' => role_sid,
52
+ })
53
+
54
+ payload = @version.create('POST', @uri, data: data)
55
+
56
+ UserInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
57
+ end
58
+
59
+ ##
60
+ # Lists UserInstance records from the API as a list.
61
+ # Unlike stream(), this operation is eager and will load `limit` records into
62
+ # memory before returning.
63
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
64
+ # guarantees to never return more than limit. Default is no limit
65
+ # @param [Integer] page_size Number of records to fetch per request, when
66
+ # not set will use the default value of 50 records. If no page_size is defined
67
+ # but a limit is defined, stream() will attempt to read the limit with the most
68
+ # efficient page size, i.e. min(limit, 1000)
69
+ # @return [Array] Array of up to limit results
70
+ def list(limit: nil, page_size: nil)
71
+ self.stream(limit: limit, page_size: page_size).entries
72
+ end
73
+
74
+ ##
75
+ # Streams UserInstance records from the API as an Enumerable.
76
+ # This operation lazily loads records as efficiently as possible until the limit
77
+ # is reached.
78
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
79
+ # guarantees to never return more than limit. Default is no limit.
80
+ # @param [Integer] page_size Number of records to fetch per request, when
81
+ # not set will use the default value of 50 records. If no page_size is defined
82
+ # but a limit is defined, stream() will attempt to read the limit with the most
83
+ # efficient page size, i.e. min(limit, 1000)
84
+ # @return [Enumerable] Enumerable that will yield up to limit results
85
+ def stream(limit: nil, page_size: nil)
86
+ limits = @version.read_limits(limit, page_size)
87
+
88
+ page = self.page(page_size: limits[:page_size], )
89
+
90
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
91
+ end
92
+
93
+ ##
94
+ # When passed a block, yields UserInstance records from the API.
95
+ # This operation lazily loads records as efficiently as possible until the limit
96
+ # is reached.
97
+ def each
98
+ limits = @version.read_limits
99
+
100
+ page = self.page(page_size: limits[:page_size], )
101
+
102
+ @version.stream(page,
103
+ limit: limits[:limit],
104
+ page_limit: limits[:page_limit]).each {|x| yield x}
105
+ end
106
+
107
+ ##
108
+ # Retrieve a single page of UserInstance records from the API.
109
+ # Request is executed immediately.
110
+ # @param [String] page_token PageToken provided by the API
111
+ # @param [Integer] page_number Page Number, this value is simply for client state
112
+ # @param [Integer] page_size Number of records to return, defaults to 50
113
+ # @return [Page] Page of UserInstance
114
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
115
+ params = Twilio::Values.of({
116
+ 'PageToken' => page_token,
117
+ 'Page' => page_number,
118
+ 'PageSize' => page_size,
119
+ })
120
+
121
+ response = @version.page('GET', @uri, params: params)
122
+
123
+ UserPage.new(@version, response, @solution)
124
+ end
125
+
126
+ ##
127
+ # Retrieve a single page of UserInstance records from the API.
128
+ # Request is executed immediately.
129
+ # @param [String] target_url API-generated URL for the requested results page
130
+ # @return [Page] Page of UserInstance
131
+ def get_page(target_url)
132
+ response = @version.domain.request(
133
+ 'GET',
134
+ target_url
135
+ )
136
+ UserPage.new(@version, response, @solution)
137
+ end
138
+
139
+ ##
140
+ # Provide a user friendly representation
141
+ def to_s
142
+ '#<Twilio.Conversations.V1.UserList>'
143
+ end
144
+ end
145
+
146
+ ##
147
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
148
+ class UserPage < Page
149
+ ##
150
+ # Initialize the UserPage
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 [UserPage] UserPage
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 UserInstance
164
+ # @param [Hash] payload Payload response from the API
165
+ # @return [UserInstance] UserInstance
166
+ def get_instance(payload)
167
+ UserInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
168
+ end
169
+
170
+ ##
171
+ # Provide a user friendly representation
172
+ def to_s
173
+ '<Twilio.Conversations.V1.UserPage>'
174
+ end
175
+ end
176
+
177
+ ##
178
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
179
+ class UserContext < InstanceContext
180
+ ##
181
+ # Initialize the UserContext
182
+ # @param [Version] version Version that contains the resource
183
+ # @param [String] chat_service_sid The SID of the
184
+ # [Service](https://www.twilio.com/docs/chat/rest/service-resource) to fetch the
185
+ # User resource from.
186
+ # @param [String] sid The SID of the User resource to fetch. This value can be
187
+ # either the `sid` or the `identity` of the User resource to fetch.
188
+ # @return [UserContext] UserContext
189
+ def initialize(version, chat_service_sid, sid)
190
+ super(version)
191
+
192
+ # Path Solution
193
+ @solution = {chat_service_sid: chat_service_sid, sid: sid, }
194
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Users/#{@solution[:sid]}"
195
+ end
196
+
197
+ ##
198
+ # Update the UserInstance
199
+ # @param [String] friendly_name The string that you assigned to describe the
200
+ # resource.
201
+ # @param [String] attributes The JSON Object string that stores
202
+ # application-specific data. If attributes have not been set, `{}` is returned.
203
+ # @param [String] role_sid The SID of the
204
+ # [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
205
+ # user.
206
+ # @return [UserInstance] Updated UserInstance
207
+ def update(friendly_name: :unset, attributes: :unset, role_sid: :unset)
208
+ data = Twilio::Values.of({
209
+ 'FriendlyName' => friendly_name,
210
+ 'Attributes' => attributes,
211
+ 'RoleSid' => role_sid,
212
+ })
213
+
214
+ payload = @version.update('POST', @uri, data: data)
215
+
216
+ UserInstance.new(
217
+ @version,
218
+ payload,
219
+ chat_service_sid: @solution[:chat_service_sid],
220
+ sid: @solution[:sid],
221
+ )
222
+ end
223
+
224
+ ##
225
+ # Delete the UserInstance
226
+ # @return [Boolean] true if delete succeeds, false otherwise
227
+ def delete
228
+ @version.delete('DELETE', @uri)
229
+ end
230
+
231
+ ##
232
+ # Fetch the UserInstance
233
+ # @return [UserInstance] Fetched UserInstance
234
+ def fetch
235
+ payload = @version.fetch('GET', @uri)
236
+
237
+ UserInstance.new(
238
+ @version,
239
+ payload,
240
+ chat_service_sid: @solution[:chat_service_sid],
241
+ sid: @solution[:sid],
242
+ )
243
+ end
244
+
245
+ ##
246
+ # Provide a user friendly representation
247
+ def to_s
248
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
249
+ "#<Twilio.Conversations.V1.UserContext #{context}>"
250
+ end
251
+
252
+ ##
253
+ # Provide a detailed, user friendly representation
254
+ def inspect
255
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
256
+ "#<Twilio.Conversations.V1.UserContext #{context}>"
257
+ end
258
+ end
259
+
260
+ ##
261
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
262
+ class UserInstance < InstanceResource
263
+ ##
264
+ # Initialize the UserInstance
265
+ # @param [Version] version Version that contains the resource
266
+ # @param [Hash] payload payload that contains response from Twilio
267
+ # @param [String] chat_service_sid The SID of the [Chat
268
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the User
269
+ # resource is associated with.
270
+ # @param [String] sid The SID of the User resource to fetch. This value can be
271
+ # either the `sid` or the `identity` of the User resource to fetch.
272
+ # @return [UserInstance] UserInstance
273
+ def initialize(version, payload, chat_service_sid: nil, sid: nil)
274
+ super(version)
275
+
276
+ # Marshaled Properties
277
+ @properties = {
278
+ 'sid' => payload['sid'],
279
+ 'account_sid' => payload['account_sid'],
280
+ 'chat_service_sid' => payload['chat_service_sid'],
281
+ 'role_sid' => payload['role_sid'],
282
+ 'identity' => payload['identity'],
283
+ 'friendly_name' => payload['friendly_name'],
284
+ 'attributes' => payload['attributes'],
285
+ 'is_online' => payload['is_online'],
286
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
287
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
288
+ 'url' => payload['url'],
289
+ }
290
+
291
+ # Context
292
+ @instance_context = nil
293
+ @params = {'chat_service_sid' => chat_service_sid, 'sid' => sid || @properties['sid'], }
294
+ end
295
+
296
+ ##
297
+ # Generate an instance context for the instance, the context is capable of
298
+ # performing various actions. All instance actions are proxied to the context
299
+ # @return [UserContext] UserContext for this UserInstance
300
+ def context
301
+ unless @instance_context
302
+ @instance_context = UserContext.new(@version, @params['chat_service_sid'], @params['sid'], )
303
+ end
304
+ @instance_context
305
+ end
306
+
307
+ ##
308
+ # @return [String] The unique string that identifies the resource
309
+ def sid
310
+ @properties['sid']
311
+ end
312
+
313
+ ##
314
+ # @return [String] The SID of the Account that created the resource
315
+ def account_sid
316
+ @properties['account_sid']
317
+ end
318
+
319
+ ##
320
+ # @return [String] The SID of the Service that the resource is associated with
321
+ def chat_service_sid
322
+ @properties['chat_service_sid']
323
+ end
324
+
325
+ ##
326
+ # @return [String] The SID of the Role assigned to the user
327
+ def role_sid
328
+ @properties['role_sid']
329
+ end
330
+
331
+ ##
332
+ # @return [String] The string that identifies the resource's User
333
+ def identity
334
+ @properties['identity']
335
+ end
336
+
337
+ ##
338
+ # @return [String] The string that you assigned to describe the resource
339
+ def friendly_name
340
+ @properties['friendly_name']
341
+ end
342
+
343
+ ##
344
+ # @return [String] The JSON Object string that stores application-specific data
345
+ def attributes
346
+ @properties['attributes']
347
+ end
348
+
349
+ ##
350
+ # @return [Boolean] Whether the User is actively connected to the Service instance and online
351
+ def is_online
352
+ @properties['is_online']
353
+ end
354
+
355
+ ##
356
+ # @return [Time] The ISO 8601 date and time in GMT when the resource was created
357
+ def date_created
358
+ @properties['date_created']
359
+ end
360
+
361
+ ##
362
+ # @return [Time] The ISO 8601 date and time in GMT when the resource was last updated
363
+ def date_updated
364
+ @properties['date_updated']
365
+ end
366
+
367
+ ##
368
+ # @return [String] The absolute URL of the User resource
369
+ def url
370
+ @properties['url']
371
+ end
372
+
373
+ ##
374
+ # Update the UserInstance
375
+ # @param [String] friendly_name The string that you assigned to describe the
376
+ # resource.
377
+ # @param [String] attributes The JSON Object string that stores
378
+ # application-specific data. If attributes have not been set, `{}` is returned.
379
+ # @param [String] role_sid The SID of the
380
+ # [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
381
+ # user.
382
+ # @return [UserInstance] Updated UserInstance
383
+ def update(friendly_name: :unset, attributes: :unset, role_sid: :unset)
384
+ context.update(friendly_name: friendly_name, attributes: attributes, role_sid: role_sid, )
385
+ end
386
+
387
+ ##
388
+ # Delete the UserInstance
389
+ # @return [Boolean] true if delete succeeds, false otherwise
390
+ def delete
391
+ context.delete
392
+ end
393
+
394
+ ##
395
+ # Fetch the UserInstance
396
+ # @return [UserInstance] Fetched UserInstance
397
+ def fetch
398
+ context.fetch
399
+ end
400
+
401
+ ##
402
+ # Provide a user friendly representation
403
+ def to_s
404
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
405
+ "<Twilio.Conversations.V1.UserInstance #{values}>"
406
+ end
407
+
408
+ ##
409
+ # Provide a detailed, user friendly representation
410
+ def inspect
411
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
412
+ "<Twilio.Conversations.V1.UserInstance #{values}>"
413
+ end
414
+ end
415
+ end
416
+ end
417
+ end
418
+ end
419
+ end