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,388 @@
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
+ class ConversationContext < InstanceContext
15
+ class MessageContext < InstanceContext
16
+ ##
17
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
18
+ class DeliveryReceiptList < ListResource
19
+ ##
20
+ # Initialize the DeliveryReceiptList
21
+ # @param [Version] version Version that contains the resource
22
+ # @param [String] chat_service_sid The SID of the [Chat
23
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Message
24
+ # resource is associated with.
25
+ # @param [String] conversation_sid The unique id of the
26
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
27
+ # @param [String] message_sid The sid of the message within a
28
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to
29
+ # @return [DeliveryReceiptList] DeliveryReceiptList
30
+ def initialize(version, chat_service_sid: nil, conversation_sid: nil, message_sid: nil)
31
+ super(version)
32
+
33
+ # Path Solution
34
+ @solution = {
35
+ chat_service_sid: chat_service_sid,
36
+ conversation_sid: conversation_sid,
37
+ message_sid: message_sid
38
+ }
39
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Messages/#{@solution[:message_sid]}/Receipts"
40
+ end
41
+
42
+ ##
43
+ # Lists DeliveryReceiptInstance records from the API as a list.
44
+ # Unlike stream(), this operation is eager and will load `limit` records into
45
+ # memory before returning.
46
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
47
+ # guarantees to never return more than limit. Default is no limit
48
+ # @param [Integer] page_size Number of records to fetch per request, when
49
+ # not set will use the default value of 50 records. If no page_size is defined
50
+ # but a limit is defined, stream() will attempt to read the limit with the most
51
+ # efficient page size, i.e. min(limit, 1000)
52
+ # @return [Array] Array of up to limit results
53
+ def list(limit: nil, page_size: nil)
54
+ self.stream(limit: limit, page_size: page_size).entries
55
+ end
56
+
57
+ ##
58
+ # Streams DeliveryReceiptInstance records from the API as an Enumerable.
59
+ # This operation lazily loads records as efficiently as possible until the limit
60
+ # is reached.
61
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
62
+ # guarantees to never return more than limit. Default is no limit.
63
+ # @param [Integer] page_size Number of records to fetch per request, when
64
+ # not set will use the default value of 50 records. If no page_size is defined
65
+ # but a limit is defined, stream() will attempt to read the limit with the most
66
+ # efficient page size, i.e. min(limit, 1000)
67
+ # @return [Enumerable] Enumerable that will yield up to limit results
68
+ def stream(limit: nil, page_size: nil)
69
+ limits = @version.read_limits(limit, page_size)
70
+
71
+ page = self.page(page_size: limits[:page_size], )
72
+
73
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
74
+ end
75
+
76
+ ##
77
+ # When passed a block, yields DeliveryReceiptInstance records from the API.
78
+ # This operation lazily loads records as efficiently as possible until the limit
79
+ # is reached.
80
+ def each
81
+ limits = @version.read_limits
82
+
83
+ page = self.page(page_size: limits[:page_size], )
84
+
85
+ @version.stream(page,
86
+ limit: limits[:limit],
87
+ page_limit: limits[:page_limit]).each {|x| yield x}
88
+ end
89
+
90
+ ##
91
+ # Retrieve a single page of DeliveryReceiptInstance records from the API.
92
+ # Request is executed immediately.
93
+ # @param [String] page_token PageToken provided by the API
94
+ # @param [Integer] page_number Page Number, this value is simply for client state
95
+ # @param [Integer] page_size Number of records to return, defaults to 50
96
+ # @return [Page] Page of DeliveryReceiptInstance
97
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
98
+ params = Twilio::Values.of({
99
+ 'PageToken' => page_token,
100
+ 'Page' => page_number,
101
+ 'PageSize' => page_size,
102
+ })
103
+
104
+ response = @version.page('GET', @uri, params: params)
105
+
106
+ DeliveryReceiptPage.new(@version, response, @solution)
107
+ end
108
+
109
+ ##
110
+ # Retrieve a single page of DeliveryReceiptInstance records from the API.
111
+ # Request is executed immediately.
112
+ # @param [String] target_url API-generated URL for the requested results page
113
+ # @return [Page] Page of DeliveryReceiptInstance
114
+ def get_page(target_url)
115
+ response = @version.domain.request(
116
+ 'GET',
117
+ target_url
118
+ )
119
+ DeliveryReceiptPage.new(@version, response, @solution)
120
+ end
121
+
122
+ ##
123
+ # Provide a user friendly representation
124
+ def to_s
125
+ '#<Twilio.Conversations.V1.DeliveryReceiptList>'
126
+ end
127
+ end
128
+
129
+ ##
130
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
131
+ class DeliveryReceiptPage < Page
132
+ ##
133
+ # Initialize the DeliveryReceiptPage
134
+ # @param [Version] version Version that contains the resource
135
+ # @param [Response] response Response from the API
136
+ # @param [Hash] solution Path solution for the resource
137
+ # @return [DeliveryReceiptPage] DeliveryReceiptPage
138
+ def initialize(version, response, solution)
139
+ super(version, response)
140
+
141
+ # Path Solution
142
+ @solution = solution
143
+ end
144
+
145
+ ##
146
+ # Build an instance of DeliveryReceiptInstance
147
+ # @param [Hash] payload Payload response from the API
148
+ # @return [DeliveryReceiptInstance] DeliveryReceiptInstance
149
+ def get_instance(payload)
150
+ DeliveryReceiptInstance.new(
151
+ @version,
152
+ payload,
153
+ chat_service_sid: @solution[:chat_service_sid],
154
+ conversation_sid: @solution[:conversation_sid],
155
+ message_sid: @solution[:message_sid],
156
+ )
157
+ end
158
+
159
+ ##
160
+ # Provide a user friendly representation
161
+ def to_s
162
+ '<Twilio.Conversations.V1.DeliveryReceiptPage>'
163
+ end
164
+ end
165
+
166
+ ##
167
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
168
+ class DeliveryReceiptContext < InstanceContext
169
+ ##
170
+ # Initialize the DeliveryReceiptContext
171
+ # @param [Version] version Version that contains the resource
172
+ # @param [String] chat_service_sid The SID of the [Chat
173
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Message
174
+ # resource is associated with.
175
+ # @param [String] conversation_sid The unique id of the
176
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
177
+ # @param [String] message_sid The sid of the message within a
178
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to.
179
+ # @param [String] sid A 34 character string that uniquely identifies this
180
+ # resource.
181
+ # @return [DeliveryReceiptContext] DeliveryReceiptContext
182
+ def initialize(version, chat_service_sid, conversation_sid, message_sid, sid)
183
+ super(version)
184
+
185
+ # Path Solution
186
+ @solution = {
187
+ chat_service_sid: chat_service_sid,
188
+ conversation_sid: conversation_sid,
189
+ message_sid: message_sid,
190
+ sid: sid,
191
+ }
192
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Messages/#{@solution[:message_sid]}/Receipts/#{@solution[:sid]}"
193
+ end
194
+
195
+ ##
196
+ # Fetch the DeliveryReceiptInstance
197
+ # @return [DeliveryReceiptInstance] Fetched DeliveryReceiptInstance
198
+ def fetch
199
+ payload = @version.fetch('GET', @uri)
200
+
201
+ DeliveryReceiptInstance.new(
202
+ @version,
203
+ payload,
204
+ chat_service_sid: @solution[:chat_service_sid],
205
+ conversation_sid: @solution[:conversation_sid],
206
+ message_sid: @solution[:message_sid],
207
+ sid: @solution[:sid],
208
+ )
209
+ end
210
+
211
+ ##
212
+ # Provide a user friendly representation
213
+ def to_s
214
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
215
+ "#<Twilio.Conversations.V1.DeliveryReceiptContext #{context}>"
216
+ end
217
+
218
+ ##
219
+ # Provide a detailed, user friendly representation
220
+ def inspect
221
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
222
+ "#<Twilio.Conversations.V1.DeliveryReceiptContext #{context}>"
223
+ end
224
+ end
225
+
226
+ ##
227
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
228
+ class DeliveryReceiptInstance < InstanceResource
229
+ ##
230
+ # Initialize the DeliveryReceiptInstance
231
+ # @param [Version] version Version that contains the resource
232
+ # @param [Hash] payload payload that contains response from Twilio
233
+ # @param [String] chat_service_sid The SID of the [Chat
234
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Message
235
+ # resource is associated with.
236
+ # @param [String] conversation_sid The unique id of the
237
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
238
+ # @param [String] message_sid The sid of the message within a
239
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to
240
+ # @param [String] sid A 34 character string that uniquely identifies this
241
+ # resource.
242
+ # @return [DeliveryReceiptInstance] DeliveryReceiptInstance
243
+ def initialize(version, payload, chat_service_sid: nil, conversation_sid: nil, message_sid: nil, sid: nil)
244
+ super(version)
245
+
246
+ # Marshaled Properties
247
+ @properties = {
248
+ 'account_sid' => payload['account_sid'],
249
+ 'chat_service_sid' => payload['chat_service_sid'],
250
+ 'conversation_sid' => payload['conversation_sid'],
251
+ 'message_sid' => payload['message_sid'],
252
+ 'sid' => payload['sid'],
253
+ 'channel_message_sid' => payload['channel_message_sid'],
254
+ 'participant_sid' => payload['participant_sid'],
255
+ 'status' => payload['status'],
256
+ 'error_code' => payload['error_code'].to_i,
257
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
258
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
259
+ 'url' => payload['url'],
260
+ }
261
+
262
+ # Context
263
+ @instance_context = nil
264
+ @params = {
265
+ 'chat_service_sid' => chat_service_sid,
266
+ 'conversation_sid' => conversation_sid,
267
+ 'message_sid' => message_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 [DeliveryReceiptContext] DeliveryReceiptContext for this DeliveryReceiptInstance
276
+ def context
277
+ unless @instance_context
278
+ @instance_context = DeliveryReceiptContext.new(
279
+ @version,
280
+ @params['chat_service_sid'],
281
+ @params['conversation_sid'],
282
+ @params['message_sid'],
283
+ @params['sid'],
284
+ )
285
+ end
286
+ @instance_context
287
+ end
288
+
289
+ ##
290
+ # @return [String] The unique id of the Account responsible for this participant.
291
+ def account_sid
292
+ @properties['account_sid']
293
+ end
294
+
295
+ ##
296
+ # @return [String] The SID of the Chat Service that the resource is associated with.
297
+ def chat_service_sid
298
+ @properties['chat_service_sid']
299
+ end
300
+
301
+ ##
302
+ # @return [String] The unique id of the Conversation for this message.
303
+ def conversation_sid
304
+ @properties['conversation_sid']
305
+ end
306
+
307
+ ##
308
+ # @return [String] The sid of the message the delivery receipt belongs to
309
+ def message_sid
310
+ @properties['message_sid']
311
+ end
312
+
313
+ ##
314
+ # @return [String] A 34 character string that uniquely identifies this resource.
315
+ def sid
316
+ @properties['sid']
317
+ end
318
+
319
+ ##
320
+ # @return [String] A messaging channel-specific identifier for the message delivered to participant
321
+ def channel_message_sid
322
+ @properties['channel_message_sid']
323
+ end
324
+
325
+ ##
326
+ # @return [String] The unique id of the participant the delivery receipt belongs to.
327
+ def participant_sid
328
+ @properties['participant_sid']
329
+ end
330
+
331
+ ##
332
+ # @return [delivery_receipt.DeliveryStatus] The message delivery status
333
+ def status
334
+ @properties['status']
335
+ end
336
+
337
+ ##
338
+ # @return [String] The message [delivery error code](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors) for a `failed` status
339
+ def error_code
340
+ @properties['error_code']
341
+ end
342
+
343
+ ##
344
+ # @return [Time] The date that this resource was created.
345
+ def date_created
346
+ @properties['date_created']
347
+ end
348
+
349
+ ##
350
+ # @return [Time] The date that this resource was last updated.
351
+ def date_updated
352
+ @properties['date_updated']
353
+ end
354
+
355
+ ##
356
+ # @return [String] An absolute URL for this delivery receipt.
357
+ def url
358
+ @properties['url']
359
+ end
360
+
361
+ ##
362
+ # Fetch the DeliveryReceiptInstance
363
+ # @return [DeliveryReceiptInstance] Fetched DeliveryReceiptInstance
364
+ def fetch
365
+ context.fetch
366
+ end
367
+
368
+ ##
369
+ # Provide a user friendly representation
370
+ def to_s
371
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
372
+ "<Twilio.Conversations.V1.DeliveryReceiptInstance #{values}>"
373
+ end
374
+
375
+ ##
376
+ # Provide a detailed, user friendly representation
377
+ def inspect
378
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
379
+ "<Twilio.Conversations.V1.DeliveryReceiptInstance #{values}>"
380
+ end
381
+ end
382
+ end
383
+ end
384
+ end
385
+ end
386
+ end
387
+ end
388
+ end
@@ -0,0 +1,513 @@
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
+ class ConversationContext < InstanceContext
15
+ ##
16
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
17
+ class ParticipantList < ListResource
18
+ ##
19
+ # Initialize the ParticipantList
20
+ # @param [Version] version Version that contains the resource
21
+ # @param [String] chat_service_sid The SID of the [Chat
22
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Participant
23
+ # resource is associated with.
24
+ # @param [String] conversation_sid The unique id of the
25
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
26
+ # @return [ParticipantList] ParticipantList
27
+ def initialize(version, chat_service_sid: nil, conversation_sid: nil)
28
+ super(version)
29
+
30
+ # Path Solution
31
+ @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid}
32
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Participants"
33
+ end
34
+
35
+ ##
36
+ # Create the ParticipantInstance
37
+ # @param [String] identity A unique string identifier for the conversation
38
+ # participant as [Chat User](https://www.twilio.com/docs/chat/rest/user-resource).
39
+ # This parameter is non-null if (and only if) the participant is using the
40
+ # Programmable Chat SDK to communicate. Limited to 256 characters.
41
+ # @param [String] messaging_binding_address The address of the participant's
42
+ # device, e.g. a phone number or Messenger ID. Together with the Proxy address,
43
+ # this determines a participant uniquely. This field (with proxy_address) is only
44
+ # null when the participant is interacting from a Chat endpoint (see the
45
+ # 'identity' field).
46
+ # @param [String] messaging_binding_proxy_address The address of the Twilio phone
47
+ # number (or WhatsApp number, or Messenger Page ID) that the participant is in
48
+ # contact with. This field, together with participant address, is only null when
49
+ # the participant is interacting from a Chat endpoint (see the 'identity' field).
50
+ # @param [Time] date_created The date that this resource was created.
51
+ # @param [Time] date_updated The date that this resource was last updated.
52
+ # @param [String] attributes An optional string metadata field you can use to
53
+ # store any data you wish. The string value must contain structurally valid JSON
54
+ # if specified. **Note** that if the attributes are not set "{}" will be
55
+ # returned.
56
+ # @param [String] messaging_binding_projected_address The address of the Twilio
57
+ # phone number that is used in Group MMS. Communication mask for the Chat
58
+ # participant with Identity.
59
+ # @param [String] role_sid The SID of the
60
+ # [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
61
+ # participant.
62
+ # @param [participant.WebhookEnabledType] x_twilio_webhook_enabled The
63
+ # X-Twilio-Webhook-Enabled HTTP request header
64
+ # @return [ParticipantInstance] Created ParticipantInstance
65
+ def create(identity: :unset, messaging_binding_address: :unset, messaging_binding_proxy_address: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_binding_projected_address: :unset, role_sid: :unset, x_twilio_webhook_enabled: :unset)
66
+ data = Twilio::Values.of({
67
+ 'Identity' => identity,
68
+ 'MessagingBinding.Address' => messaging_binding_address,
69
+ 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address,
70
+ 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
71
+ 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
72
+ 'Attributes' => attributes,
73
+ 'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address,
74
+ 'RoleSid' => role_sid,
75
+ })
76
+ headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
77
+
78
+ payload = @version.create('POST', @uri, data: data, headers: headers)
79
+
80
+ ParticipantInstance.new(
81
+ @version,
82
+ payload,
83
+ chat_service_sid: @solution[:chat_service_sid],
84
+ conversation_sid: @solution[:conversation_sid],
85
+ )
86
+ end
87
+
88
+ ##
89
+ # Lists ParticipantInstance records from the API as a list.
90
+ # Unlike stream(), this operation is eager and will load `limit` records into
91
+ # memory before returning.
92
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
93
+ # guarantees to never return more than limit. Default is no limit
94
+ # @param [Integer] page_size Number of records to fetch per request, when
95
+ # not set will use the default value of 50 records. If no page_size is defined
96
+ # but a limit is defined, stream() will attempt to read the limit with the most
97
+ # efficient page size, i.e. min(limit, 1000)
98
+ # @return [Array] Array of up to limit results
99
+ def list(limit: nil, page_size: nil)
100
+ self.stream(limit: limit, page_size: page_size).entries
101
+ end
102
+
103
+ ##
104
+ # Streams ParticipantInstance records from the API as an Enumerable.
105
+ # This operation lazily loads records as efficiently as possible until the limit
106
+ # is reached.
107
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
108
+ # guarantees to never return more than limit. Default is no limit.
109
+ # @param [Integer] page_size Number of records to fetch per request, when
110
+ # not set will use the default value of 50 records. If no page_size is defined
111
+ # but a limit is defined, stream() will attempt to read the limit with the most
112
+ # efficient page size, i.e. min(limit, 1000)
113
+ # @return [Enumerable] Enumerable that will yield up to limit results
114
+ def stream(limit: nil, page_size: nil)
115
+ limits = @version.read_limits(limit, page_size)
116
+
117
+ page = self.page(page_size: limits[:page_size], )
118
+
119
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
120
+ end
121
+
122
+ ##
123
+ # When passed a block, yields ParticipantInstance records from the API.
124
+ # This operation lazily loads records as efficiently as possible until the limit
125
+ # is reached.
126
+ def each
127
+ limits = @version.read_limits
128
+
129
+ page = self.page(page_size: limits[:page_size], )
130
+
131
+ @version.stream(page,
132
+ limit: limits[:limit],
133
+ page_limit: limits[:page_limit]).each {|x| yield x}
134
+ end
135
+
136
+ ##
137
+ # Retrieve a single page of ParticipantInstance records from the API.
138
+ # Request is executed immediately.
139
+ # @param [String] page_token PageToken provided by the API
140
+ # @param [Integer] page_number Page Number, this value is simply for client state
141
+ # @param [Integer] page_size Number of records to return, defaults to 50
142
+ # @return [Page] Page of ParticipantInstance
143
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
144
+ params = Twilio::Values.of({
145
+ 'PageToken' => page_token,
146
+ 'Page' => page_number,
147
+ 'PageSize' => page_size,
148
+ })
149
+
150
+ response = @version.page('GET', @uri, params: params)
151
+
152
+ ParticipantPage.new(@version, response, @solution)
153
+ end
154
+
155
+ ##
156
+ # Retrieve a single page of ParticipantInstance records from the API.
157
+ # Request is executed immediately.
158
+ # @param [String] target_url API-generated URL for the requested results page
159
+ # @return [Page] Page of ParticipantInstance
160
+ def get_page(target_url)
161
+ response = @version.domain.request(
162
+ 'GET',
163
+ target_url
164
+ )
165
+ ParticipantPage.new(@version, response, @solution)
166
+ end
167
+
168
+ ##
169
+ # Provide a user friendly representation
170
+ def to_s
171
+ '#<Twilio.Conversations.V1.ParticipantList>'
172
+ end
173
+ end
174
+
175
+ ##
176
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
177
+ class ParticipantPage < Page
178
+ ##
179
+ # Initialize the ParticipantPage
180
+ # @param [Version] version Version that contains the resource
181
+ # @param [Response] response Response from the API
182
+ # @param [Hash] solution Path solution for the resource
183
+ # @return [ParticipantPage] ParticipantPage
184
+ def initialize(version, response, solution)
185
+ super(version, response)
186
+
187
+ # Path Solution
188
+ @solution = solution
189
+ end
190
+
191
+ ##
192
+ # Build an instance of ParticipantInstance
193
+ # @param [Hash] payload Payload response from the API
194
+ # @return [ParticipantInstance] ParticipantInstance
195
+ def get_instance(payload)
196
+ ParticipantInstance.new(
197
+ @version,
198
+ payload,
199
+ chat_service_sid: @solution[:chat_service_sid],
200
+ conversation_sid: @solution[:conversation_sid],
201
+ )
202
+ end
203
+
204
+ ##
205
+ # Provide a user friendly representation
206
+ def to_s
207
+ '<Twilio.Conversations.V1.ParticipantPage>'
208
+ end
209
+ end
210
+
211
+ ##
212
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
213
+ class ParticipantContext < InstanceContext
214
+ ##
215
+ # Initialize the ParticipantContext
216
+ # @param [Version] version Version that contains the resource
217
+ # @param [String] chat_service_sid The SID of the [Chat
218
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Participant
219
+ # resource is associated with.
220
+ # @param [String] conversation_sid The unique id of the
221
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
222
+ # @param [String] sid A 34 character string that uniquely identifies this
223
+ # resource.
224
+ # @return [ParticipantContext] ParticipantContext
225
+ def initialize(version, chat_service_sid, conversation_sid, sid)
226
+ super(version)
227
+
228
+ # Path Solution
229
+ @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid, sid: sid, }
230
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Participants/#{@solution[:sid]}"
231
+ end
232
+
233
+ ##
234
+ # Update the ParticipantInstance
235
+ # @param [Time] date_created The date that this resource was created.
236
+ # @param [Time] date_updated The date that this resource was last updated.
237
+ # @param [String] identity A unique string identifier for the conversation
238
+ # participant as [Chat User](https://www.twilio.com/docs/chat/rest/user-resource).
239
+ # This parameter is non-null if (and only if) the participant is using the
240
+ # Programmable Chat SDK to communicate. Limited to 256 characters.
241
+ # @param [String] attributes An optional string metadata field you can use to
242
+ # store any data you wish. The string value must contain structurally valid JSON
243
+ # if specified. **Note** that if the attributes are not set "{}" will be
244
+ # returned.
245
+ # @param [String] role_sid The SID of the
246
+ # [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
247
+ # participant.
248
+ # @param [String] messaging_binding_proxy_address The address of the Twilio phone
249
+ # number that the participant is in contact with. 'null' value will remove it.
250
+ # @param [String] messaging_binding_projected_address The address of the Twilio
251
+ # phone number that is used in Group MMS. 'null' value will remove it.
252
+ # @param [participant.WebhookEnabledType] x_twilio_webhook_enabled The
253
+ # X-Twilio-Webhook-Enabled HTTP request header
254
+ # @return [ParticipantInstance] Updated ParticipantInstance
255
+ def update(date_created: :unset, date_updated: :unset, identity: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, x_twilio_webhook_enabled: :unset)
256
+ data = Twilio::Values.of({
257
+ 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
258
+ 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
259
+ 'Identity' => identity,
260
+ 'Attributes' => attributes,
261
+ 'RoleSid' => role_sid,
262
+ 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address,
263
+ 'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address,
264
+ })
265
+ headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
266
+
267
+ payload = @version.update('POST', @uri, data: data, headers: headers)
268
+
269
+ ParticipantInstance.new(
270
+ @version,
271
+ payload,
272
+ chat_service_sid: @solution[:chat_service_sid],
273
+ conversation_sid: @solution[:conversation_sid],
274
+ sid: @solution[:sid],
275
+ )
276
+ end
277
+
278
+ ##
279
+ # Delete the ParticipantInstance
280
+ # @param [participant.WebhookEnabledType] x_twilio_webhook_enabled The
281
+ # X-Twilio-Webhook-Enabled HTTP request header
282
+ # @return [Boolean] true if delete succeeds, false otherwise
283
+ def delete(x_twilio_webhook_enabled: :unset)
284
+ headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
285
+
286
+ @version.delete('DELETE', @uri, headers: headers)
287
+ end
288
+
289
+ ##
290
+ # Fetch the ParticipantInstance
291
+ # @return [ParticipantInstance] Fetched ParticipantInstance
292
+ def fetch
293
+ payload = @version.fetch('GET', @uri)
294
+
295
+ ParticipantInstance.new(
296
+ @version,
297
+ payload,
298
+ chat_service_sid: @solution[:chat_service_sid],
299
+ conversation_sid: @solution[:conversation_sid],
300
+ sid: @solution[:sid],
301
+ )
302
+ end
303
+
304
+ ##
305
+ # Provide a user friendly representation
306
+ def to_s
307
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
308
+ "#<Twilio.Conversations.V1.ParticipantContext #{context}>"
309
+ end
310
+
311
+ ##
312
+ # Provide a detailed, user friendly representation
313
+ def inspect
314
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
315
+ "#<Twilio.Conversations.V1.ParticipantContext #{context}>"
316
+ end
317
+ end
318
+
319
+ ##
320
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
321
+ class ParticipantInstance < InstanceResource
322
+ ##
323
+ # Initialize the ParticipantInstance
324
+ # @param [Version] version Version that contains the resource
325
+ # @param [Hash] payload payload that contains response from Twilio
326
+ # @param [String] chat_service_sid The SID of the [Chat
327
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Participant
328
+ # resource is associated with.
329
+ # @param [String] conversation_sid The unique id of the
330
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
331
+ # @param [String] sid A 34 character string that uniquely identifies this
332
+ # resource.
333
+ # @return [ParticipantInstance] ParticipantInstance
334
+ def initialize(version, payload, chat_service_sid: nil, conversation_sid: nil, sid: nil)
335
+ super(version)
336
+
337
+ # Marshaled Properties
338
+ @properties = {
339
+ 'account_sid' => payload['account_sid'],
340
+ 'chat_service_sid' => payload['chat_service_sid'],
341
+ 'conversation_sid' => payload['conversation_sid'],
342
+ 'sid' => payload['sid'],
343
+ 'identity' => payload['identity'],
344
+ 'attributes' => payload['attributes'],
345
+ 'messaging_binding' => payload['messaging_binding'],
346
+ 'role_sid' => payload['role_sid'],
347
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
348
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
349
+ 'url' => payload['url'],
350
+ }
351
+
352
+ # Context
353
+ @instance_context = nil
354
+ @params = {
355
+ 'chat_service_sid' => chat_service_sid,
356
+ 'conversation_sid' => conversation_sid,
357
+ 'sid' => sid || @properties['sid'],
358
+ }
359
+ end
360
+
361
+ ##
362
+ # Generate an instance context for the instance, the context is capable of
363
+ # performing various actions. All instance actions are proxied to the context
364
+ # @return [ParticipantContext] ParticipantContext for this ParticipantInstance
365
+ def context
366
+ unless @instance_context
367
+ @instance_context = ParticipantContext.new(
368
+ @version,
369
+ @params['chat_service_sid'],
370
+ @params['conversation_sid'],
371
+ @params['sid'],
372
+ )
373
+ end
374
+ @instance_context
375
+ end
376
+
377
+ ##
378
+ # @return [String] The unique id of the Account responsible for this participant.
379
+ def account_sid
380
+ @properties['account_sid']
381
+ end
382
+
383
+ ##
384
+ # @return [String] The SID of the Chat Service that the resource is associated with.
385
+ def chat_service_sid
386
+ @properties['chat_service_sid']
387
+ end
388
+
389
+ ##
390
+ # @return [String] The unique id of the Conversation for this participant.
391
+ def conversation_sid
392
+ @properties['conversation_sid']
393
+ end
394
+
395
+ ##
396
+ # @return [String] A 34 character string that uniquely identifies this resource.
397
+ def sid
398
+ @properties['sid']
399
+ end
400
+
401
+ ##
402
+ # @return [String] A unique string identifier for the conversation participant as Chat User.
403
+ def identity
404
+ @properties['identity']
405
+ end
406
+
407
+ ##
408
+ # @return [String] An optional string metadata field you can use to store any data you wish.
409
+ def attributes
410
+ @properties['attributes']
411
+ end
412
+
413
+ ##
414
+ # @return [Hash] Information about how this participant exchanges messages with the conversation.
415
+ def messaging_binding
416
+ @properties['messaging_binding']
417
+ end
418
+
419
+ ##
420
+ # @return [String] The SID of the Role to assign to the participant
421
+ def role_sid
422
+ @properties['role_sid']
423
+ end
424
+
425
+ ##
426
+ # @return [Time] The date that this resource was created.
427
+ def date_created
428
+ @properties['date_created']
429
+ end
430
+
431
+ ##
432
+ # @return [Time] The date that this resource was last updated.
433
+ def date_updated
434
+ @properties['date_updated']
435
+ end
436
+
437
+ ##
438
+ # @return [String] An absolute URL for this participant.
439
+ def url
440
+ @properties['url']
441
+ end
442
+
443
+ ##
444
+ # Update the ParticipantInstance
445
+ # @param [Time] date_created The date that this resource was created.
446
+ # @param [Time] date_updated The date that this resource was last updated.
447
+ # @param [String] identity A unique string identifier for the conversation
448
+ # participant as [Chat User](https://www.twilio.com/docs/chat/rest/user-resource).
449
+ # This parameter is non-null if (and only if) the participant is using the
450
+ # Programmable Chat SDK to communicate. Limited to 256 characters.
451
+ # @param [String] attributes An optional string metadata field you can use to
452
+ # store any data you wish. The string value must contain structurally valid JSON
453
+ # if specified. **Note** that if the attributes are not set "{}" will be
454
+ # returned.
455
+ # @param [String] role_sid The SID of the
456
+ # [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
457
+ # participant.
458
+ # @param [String] messaging_binding_proxy_address The address of the Twilio phone
459
+ # number that the participant is in contact with. 'null' value will remove it.
460
+ # @param [String] messaging_binding_projected_address The address of the Twilio
461
+ # phone number that is used in Group MMS. 'null' value will remove it.
462
+ # @param [participant.WebhookEnabledType] x_twilio_webhook_enabled The
463
+ # X-Twilio-Webhook-Enabled HTTP request header
464
+ # @return [ParticipantInstance] Updated ParticipantInstance
465
+ def update(date_created: :unset, date_updated: :unset, identity: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, x_twilio_webhook_enabled: :unset)
466
+ context.update(
467
+ date_created: date_created,
468
+ date_updated: date_updated,
469
+ identity: identity,
470
+ attributes: attributes,
471
+ role_sid: role_sid,
472
+ messaging_binding_proxy_address: messaging_binding_proxy_address,
473
+ messaging_binding_projected_address: messaging_binding_projected_address,
474
+ x_twilio_webhook_enabled: x_twilio_webhook_enabled,
475
+ )
476
+ end
477
+
478
+ ##
479
+ # Delete the ParticipantInstance
480
+ # @param [participant.WebhookEnabledType] x_twilio_webhook_enabled The
481
+ # X-Twilio-Webhook-Enabled HTTP request header
482
+ # @return [Boolean] true if delete succeeds, false otherwise
483
+ def delete(x_twilio_webhook_enabled: :unset)
484
+ context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
485
+ end
486
+
487
+ ##
488
+ # Fetch the ParticipantInstance
489
+ # @return [ParticipantInstance] Fetched ParticipantInstance
490
+ def fetch
491
+ context.fetch
492
+ end
493
+
494
+ ##
495
+ # Provide a user friendly representation
496
+ def to_s
497
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
498
+ "<Twilio.Conversations.V1.ParticipantInstance #{values}>"
499
+ end
500
+
501
+ ##
502
+ # Provide a detailed, user friendly representation
503
+ def inspect
504
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
505
+ "<Twilio.Conversations.V1.ParticipantInstance #{values}>"
506
+ end
507
+ end
508
+ end
509
+ end
510
+ end
511
+ end
512
+ end
513
+ end