twilio-ruby 5.25.2 → 5.25.3

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +11 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/authy.rb +8 -8
  5. data/lib/twilio-ruby/rest/authy/v1.rb +15 -15
  6. data/lib/twilio-ruby/rest/client.rb +7 -0
  7. data/lib/twilio-ruby/rest/conversations.rb +53 -0
  8. data/lib/twilio-ruby/rest/conversations/v1.rb +51 -0
  9. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +471 -0
  10. data/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +416 -0
  11. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +407 -0
  12. data/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb +432 -0
  13. data/lib/twilio-ruby/rest/conversations/v1/webhook.rb +272 -0
  14. data/lib/twilio-ruby/rest/flex_api.rb +6 -6
  15. data/lib/twilio-ruby/rest/flex_api/v1.rb +7 -7
  16. data/lib/twilio-ruby/rest/messaging.rb +8 -8
  17. data/lib/twilio-ruby/rest/messaging/v1.rb +14 -14
  18. data/lib/twilio-ruby/rest/preview.rb +20 -20
  19. data/lib/twilio-ruby/rest/preview/marketplace.rb +13 -13
  20. data/lib/twilio-ruby/rest/preview/trusted_comms.rb +14 -14
  21. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +14 -0
  22. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +30 -0
  23. data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +370 -0
  24. data/lib/twilio-ruby/rest/video.rb +9 -9
  25. data/lib/twilio-ruby/rest/video/v1.rb +16 -16
  26. data/lib/twilio-ruby/rest/wireless.rb +6 -6
  27. data/lib/twilio-ruby/rest/wireless/v1.rb +9 -8
  28. data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +27 -18
  29. data/lib/twilio-ruby/twiml/voice_response.rb +161 -11
  30. data/lib/twilio-ruby/version.rb +1 -1
  31. data/spec/integration/conversations/v1/conversation/message_spec.rb +223 -0
  32. data/spec/integration/conversations/v1/conversation/participant_spec.rb +265 -0
  33. data/spec/integration/conversations/v1/conversation/webhook_spec.rb +286 -0
  34. data/spec/integration/conversations/v1/conversation_spec.rb +218 -0
  35. data/spec/integration/conversations/v1/webhook_spec.rb +88 -0
  36. data/spec/integration/serverless/v1/service/build_spec.rb +28 -0
  37. data/spec/integration/serverless/v1/service/environment/log_spec.rb +98 -0
  38. data/spec/integration/serverless/v1/service/environment_spec.rb +4 -2
  39. data/spec/integration/verify/v2/service/verification_spec.rb +36 -0
  40. data/spec/integration/wireless/v1/rate_plan_spec.rb +12 -12
  41. metadata +22 -2
@@ -0,0 +1,416 @@
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 ConversationContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
16
+ class MessageList < ListResource
17
+ ##
18
+ # Initialize the MessageList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] conversation_sid The unique id of the
21
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
22
+ # @return [MessageList] MessageList
23
+ def initialize(version, conversation_sid: nil)
24
+ super(version)
25
+
26
+ # Path Solution
27
+ @solution = {conversation_sid: conversation_sid}
28
+ @uri = "/Conversations/#{@solution[:conversation_sid]}/Messages"
29
+ end
30
+
31
+ ##
32
+ # Retrieve a single page of MessageInstance records from the API.
33
+ # Request is executed immediately.
34
+ # @param [String] author The channel specific identifier of the message's author.
35
+ # Defaults to `system`.
36
+ # @param [String] body The content of the message, can be up to 1,600 characters
37
+ # long.
38
+ # @param [Time] date_created The date that this resource was created.
39
+ # @param [Time] date_updated The date that this resource was last updated. `null`
40
+ # if the message has not been edited.
41
+ # @return [MessageInstance] Newly created MessageInstance
42
+ def create(author: :unset, body: :unset, date_created: :unset, date_updated: :unset)
43
+ data = Twilio::Values.of({
44
+ 'Author' => author,
45
+ 'Body' => body,
46
+ 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
47
+ 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
48
+ })
49
+
50
+ payload = @version.create(
51
+ 'POST',
52
+ @uri,
53
+ data: data
54
+ )
55
+
56
+ MessageInstance.new(@version, payload, conversation_sid: @solution[:conversation_sid], )
57
+ end
58
+
59
+ ##
60
+ # Lists MessageInstance 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 MessageInstance 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 MessageInstance 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 MessageInstance 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 MessageInstance
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
+ response = @version.page(
121
+ 'GET',
122
+ @uri,
123
+ params
124
+ )
125
+ MessagePage.new(@version, response, @solution)
126
+ end
127
+
128
+ ##
129
+ # Retrieve a single page of MessageInstance records from the API.
130
+ # Request is executed immediately.
131
+ # @param [String] target_url API-generated URL for the requested results page
132
+ # @return [Page] Page of MessageInstance
133
+ def get_page(target_url)
134
+ response = @version.domain.request(
135
+ 'GET',
136
+ target_url
137
+ )
138
+ MessagePage.new(@version, response, @solution)
139
+ end
140
+
141
+ ##
142
+ # Provide a user friendly representation
143
+ def to_s
144
+ '#<Twilio.Conversations.V1.MessageList>'
145
+ end
146
+ end
147
+
148
+ ##
149
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
150
+ class MessagePage < Page
151
+ ##
152
+ # Initialize the MessagePage
153
+ # @param [Version] version Version that contains the resource
154
+ # @param [Response] response Response from the API
155
+ # @param [Hash] solution Path solution for the resource
156
+ # @return [MessagePage] MessagePage
157
+ def initialize(version, response, solution)
158
+ super(version, response)
159
+
160
+ # Path Solution
161
+ @solution = solution
162
+ end
163
+
164
+ ##
165
+ # Build an instance of MessageInstance
166
+ # @param [Hash] payload Payload response from the API
167
+ # @return [MessageInstance] MessageInstance
168
+ def get_instance(payload)
169
+ MessageInstance.new(@version, payload, conversation_sid: @solution[:conversation_sid], )
170
+ end
171
+
172
+ ##
173
+ # Provide a user friendly representation
174
+ def to_s
175
+ '<Twilio.Conversations.V1.MessagePage>'
176
+ end
177
+ end
178
+
179
+ ##
180
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
181
+ class MessageContext < InstanceContext
182
+ ##
183
+ # Initialize the MessageContext
184
+ # @param [Version] version Version that contains the resource
185
+ # @param [String] conversation_sid The unique id of the
186
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
187
+ # @param [String] sid A 34 character string that uniquely identifies this
188
+ # resource.
189
+ # @return [MessageContext] MessageContext
190
+ def initialize(version, conversation_sid, sid)
191
+ super(version)
192
+
193
+ # Path Solution
194
+ @solution = {conversation_sid: conversation_sid, sid: sid, }
195
+ @uri = "/Conversations/#{@solution[:conversation_sid]}/Messages/#{@solution[:sid]}"
196
+ end
197
+
198
+ ##
199
+ # Update the MessageInstance
200
+ # @param [String] author The channel specific identifier of the message's author.
201
+ # Defaults to `system`.
202
+ # @param [String] body The content of the message, can be up to 1,600 characters
203
+ # long.
204
+ # @param [Time] date_created The date that this resource was created.
205
+ # @param [Time] date_updated The date that this resource was last updated. `null`
206
+ # if the message has not been edited.
207
+ # @return [MessageInstance] Updated MessageInstance
208
+ def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset)
209
+ data = Twilio::Values.of({
210
+ 'Author' => author,
211
+ 'Body' => body,
212
+ 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
213
+ 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
214
+ })
215
+
216
+ payload = @version.update(
217
+ 'POST',
218
+ @uri,
219
+ data: data,
220
+ )
221
+
222
+ MessageInstance.new(
223
+ @version,
224
+ payload,
225
+ conversation_sid: @solution[:conversation_sid],
226
+ sid: @solution[:sid],
227
+ )
228
+ end
229
+
230
+ ##
231
+ # Deletes the MessageInstance
232
+ # @return [Boolean] true if delete succeeds, true otherwise
233
+ def delete
234
+ @version.delete('delete', @uri)
235
+ end
236
+
237
+ ##
238
+ # Fetch a MessageInstance
239
+ # @return [MessageInstance] Fetched MessageInstance
240
+ def fetch
241
+ params = Twilio::Values.of({})
242
+
243
+ payload = @version.fetch(
244
+ 'GET',
245
+ @uri,
246
+ params,
247
+ )
248
+
249
+ MessageInstance.new(
250
+ @version,
251
+ payload,
252
+ conversation_sid: @solution[:conversation_sid],
253
+ sid: @solution[:sid],
254
+ )
255
+ end
256
+
257
+ ##
258
+ # Provide a user friendly representation
259
+ def to_s
260
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
261
+ "#<Twilio.Conversations.V1.MessageContext #{context}>"
262
+ end
263
+
264
+ ##
265
+ # Provide a detailed, user friendly representation
266
+ def inspect
267
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
268
+ "#<Twilio.Conversations.V1.MessageContext #{context}>"
269
+ end
270
+ end
271
+
272
+ ##
273
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
274
+ class MessageInstance < InstanceResource
275
+ ##
276
+ # Initialize the MessageInstance
277
+ # @param [Version] version Version that contains the resource
278
+ # @param [Hash] payload payload that contains response from Twilio
279
+ # @param [String] conversation_sid The unique id of the
280
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
281
+ # @param [String] sid A 34 character string that uniquely identifies this
282
+ # resource.
283
+ # @return [MessageInstance] MessageInstance
284
+ def initialize(version, payload, conversation_sid: nil, sid: nil)
285
+ super(version)
286
+
287
+ # Marshaled Properties
288
+ @properties = {
289
+ 'account_sid' => payload['account_sid'],
290
+ 'conversation_sid' => payload['conversation_sid'],
291
+ 'sid' => payload['sid'],
292
+ 'index' => payload['index'].to_i,
293
+ 'author' => payload['author'],
294
+ 'body' => payload['body'],
295
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
296
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
297
+ 'url' => payload['url'],
298
+ }
299
+
300
+ # Context
301
+ @instance_context = nil
302
+ @params = {'conversation_sid' => conversation_sid, 'sid' => sid || @properties['sid'], }
303
+ end
304
+
305
+ ##
306
+ # Generate an instance context for the instance, the context is capable of
307
+ # performing various actions. All instance actions are proxied to the context
308
+ # @return [MessageContext] MessageContext for this MessageInstance
309
+ def context
310
+ unless @instance_context
311
+ @instance_context = MessageContext.new(@version, @params['conversation_sid'], @params['sid'], )
312
+ end
313
+ @instance_context
314
+ end
315
+
316
+ ##
317
+ # @return [String] The unique id of the Account responsible for this message.
318
+ def account_sid
319
+ @properties['account_sid']
320
+ end
321
+
322
+ ##
323
+ # @return [String] The unique id of the Conversation for this message.
324
+ def conversation_sid
325
+ @properties['conversation_sid']
326
+ end
327
+
328
+ ##
329
+ # @return [String] A 34 character string that uniquely identifies this resource.
330
+ def sid
331
+ @properties['sid']
332
+ end
333
+
334
+ ##
335
+ # @return [String] The index of the message within the Conversation.
336
+ def index
337
+ @properties['index']
338
+ end
339
+
340
+ ##
341
+ # @return [String] The channel specific identifier of the message's author.
342
+ def author
343
+ @properties['author']
344
+ end
345
+
346
+ ##
347
+ # @return [String] The content of the message.
348
+ def body
349
+ @properties['body']
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 message.
366
+ def url
367
+ @properties['url']
368
+ end
369
+
370
+ ##
371
+ # Update the MessageInstance
372
+ # @param [String] author The channel specific identifier of the message's author.
373
+ # Defaults to `system`.
374
+ # @param [String] body The content of the message, can be up to 1,600 characters
375
+ # long.
376
+ # @param [Time] date_created The date that this resource was created.
377
+ # @param [Time] date_updated The date that this resource was last updated. `null`
378
+ # if the message has not been edited.
379
+ # @return [MessageInstance] Updated MessageInstance
380
+ def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset)
381
+ context.update(author: author, body: body, date_created: date_created, date_updated: date_updated, )
382
+ end
383
+
384
+ ##
385
+ # Deletes the MessageInstance
386
+ # @return [Boolean] true if delete succeeds, true otherwise
387
+ def delete
388
+ context.delete
389
+ end
390
+
391
+ ##
392
+ # Fetch a MessageInstance
393
+ # @return [MessageInstance] Fetched MessageInstance
394
+ def fetch
395
+ context.fetch
396
+ end
397
+
398
+ ##
399
+ # Provide a user friendly representation
400
+ def to_s
401
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
402
+ "<Twilio.Conversations.V1.MessageInstance #{values}>"
403
+ end
404
+
405
+ ##
406
+ # Provide a detailed, user friendly representation
407
+ def inspect
408
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
409
+ "<Twilio.Conversations.V1.MessageInstance #{values}>"
410
+ end
411
+ end
412
+ end
413
+ end
414
+ end
415
+ end
416
+ end
@@ -0,0 +1,407 @@
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 ConversationContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
16
+ class ParticipantList < ListResource
17
+ ##
18
+ # Initialize the ParticipantList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] conversation_sid The unique id of the
21
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
22
+ # @return [ParticipantList] ParticipantList
23
+ def initialize(version, conversation_sid: nil)
24
+ super(version)
25
+
26
+ # Path Solution
27
+ @solution = {conversation_sid: conversation_sid}
28
+ @uri = "/Conversations/#{@solution[:conversation_sid]}/Participants"
29
+ end
30
+
31
+ ##
32
+ # Retrieve a single page of ParticipantInstance records from the API.
33
+ # Request is executed immediately.
34
+ # @param [String] identity A unique string identifier for the conversation
35
+ # participant as [Chat User](https://www.twilio.com/docs/api/chat/rest/users).
36
+ # This parameter is non-null if (and only if) the participant is using the
37
+ # Programmable Chat SDK to communicate. Limited to 256 characters.
38
+ # @param [String] messaging_binding_address The address of the participant's
39
+ # device, e.g. a phone number or Messenger ID. Together with the Proxy address,
40
+ # this determines a participant uniquely. This field (with proxy_address) is only
41
+ # null when the participant is interacting from a Chat endpoint (see the
42
+ # 'identity' field). Limited to 256 characters.
43
+ # @param [String] messaging_binding_proxy_address The address of the Twilio phone
44
+ # number (or WhatsApp number, or Messenger Page ID) that the participant is in
45
+ # contact with. This field, together with participant address, is only null when
46
+ # the participant is interacting from a Chat endpoint (see the 'identity' field).
47
+ # Limited to 256 characters.
48
+ # @param [Time] date_created The date that this resource was created.
49
+ # @param [Time] date_updated The date that this resource was last updated.
50
+ # @return [ParticipantInstance] Newly created ParticipantInstance
51
+ def create(identity: :unset, messaging_binding_address: :unset, messaging_binding_proxy_address: :unset, date_created: :unset, date_updated: :unset)
52
+ data = Twilio::Values.of({
53
+ 'Identity' => identity,
54
+ 'MessagingBinding.Address' => messaging_binding_address,
55
+ 'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address,
56
+ 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
57
+ 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
58
+ })
59
+
60
+ payload = @version.create(
61
+ 'POST',
62
+ @uri,
63
+ data: data
64
+ )
65
+
66
+ ParticipantInstance.new(@version, payload, conversation_sid: @solution[:conversation_sid], )
67
+ end
68
+
69
+ ##
70
+ # Lists ParticipantInstance records from the API as a list.
71
+ # Unlike stream(), this operation is eager and will load `limit` records into
72
+ # memory before returning.
73
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
74
+ # guarantees to never return more than limit. Default is no limit
75
+ # @param [Integer] page_size Number of records to fetch per request, when
76
+ # not set will use the default value of 50 records. If no page_size is defined
77
+ # but a limit is defined, stream() will attempt to read the limit with the most
78
+ # efficient page size, i.e. min(limit, 1000)
79
+ # @return [Array] Array of up to limit results
80
+ def list(limit: nil, page_size: nil)
81
+ self.stream(limit: limit, page_size: page_size).entries
82
+ end
83
+
84
+ ##
85
+ # Streams ParticipantInstance records from the API as an Enumerable.
86
+ # This operation lazily loads records as efficiently as possible until the limit
87
+ # is reached.
88
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
89
+ # guarantees to never return more than limit. Default is no limit.
90
+ # @param [Integer] page_size Number of records to fetch per request, when
91
+ # not set will use the default value of 50 records. If no page_size is defined
92
+ # but a limit is defined, stream() will attempt to read the limit with the most
93
+ # efficient page size, i.e. min(limit, 1000)
94
+ # @return [Enumerable] Enumerable that will yield up to limit results
95
+ def stream(limit: nil, page_size: nil)
96
+ limits = @version.read_limits(limit, page_size)
97
+
98
+ page = self.page(page_size: limits[:page_size], )
99
+
100
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
101
+ end
102
+
103
+ ##
104
+ # When passed a block, yields ParticipantInstance records from the API.
105
+ # This operation lazily loads records as efficiently as possible until the limit
106
+ # is reached.
107
+ def each
108
+ limits = @version.read_limits
109
+
110
+ page = self.page(page_size: limits[:page_size], )
111
+
112
+ @version.stream(page,
113
+ limit: limits[:limit],
114
+ page_limit: limits[:page_limit]).each {|x| yield x}
115
+ end
116
+
117
+ ##
118
+ # Retrieve a single page of ParticipantInstance records from the API.
119
+ # Request is executed immediately.
120
+ # @param [String] page_token PageToken provided by the API
121
+ # @param [Integer] page_number Page Number, this value is simply for client state
122
+ # @param [Integer] page_size Number of records to return, defaults to 50
123
+ # @return [Page] Page of ParticipantInstance
124
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
125
+ params = Twilio::Values.of({
126
+ 'PageToken' => page_token,
127
+ 'Page' => page_number,
128
+ 'PageSize' => page_size,
129
+ })
130
+ response = @version.page(
131
+ 'GET',
132
+ @uri,
133
+ params
134
+ )
135
+ ParticipantPage.new(@version, response, @solution)
136
+ end
137
+
138
+ ##
139
+ # Retrieve a single page of ParticipantInstance records from the API.
140
+ # Request is executed immediately.
141
+ # @param [String] target_url API-generated URL for the requested results page
142
+ # @return [Page] Page of ParticipantInstance
143
+ def get_page(target_url)
144
+ response = @version.domain.request(
145
+ 'GET',
146
+ target_url
147
+ )
148
+ ParticipantPage.new(@version, response, @solution)
149
+ end
150
+
151
+ ##
152
+ # Provide a user friendly representation
153
+ def to_s
154
+ '#<Twilio.Conversations.V1.ParticipantList>'
155
+ end
156
+ end
157
+
158
+ ##
159
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
160
+ class ParticipantPage < Page
161
+ ##
162
+ # Initialize the ParticipantPage
163
+ # @param [Version] version Version that contains the resource
164
+ # @param [Response] response Response from the API
165
+ # @param [Hash] solution Path solution for the resource
166
+ # @return [ParticipantPage] ParticipantPage
167
+ def initialize(version, response, solution)
168
+ super(version, response)
169
+
170
+ # Path Solution
171
+ @solution = solution
172
+ end
173
+
174
+ ##
175
+ # Build an instance of ParticipantInstance
176
+ # @param [Hash] payload Payload response from the API
177
+ # @return [ParticipantInstance] ParticipantInstance
178
+ def get_instance(payload)
179
+ ParticipantInstance.new(@version, payload, conversation_sid: @solution[:conversation_sid], )
180
+ end
181
+
182
+ ##
183
+ # Provide a user friendly representation
184
+ def to_s
185
+ '<Twilio.Conversations.V1.ParticipantPage>'
186
+ end
187
+ end
188
+
189
+ ##
190
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
191
+ class ParticipantContext < InstanceContext
192
+ ##
193
+ # Initialize the ParticipantContext
194
+ # @param [Version] version Version that contains the resource
195
+ # @param [String] conversation_sid The unique id of the
196
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
197
+ # @param [String] sid A 34 character string that uniquely identifies this
198
+ # resource.
199
+ # @return [ParticipantContext] ParticipantContext
200
+ def initialize(version, conversation_sid, sid)
201
+ super(version)
202
+
203
+ # Path Solution
204
+ @solution = {conversation_sid: conversation_sid, sid: sid, }
205
+ @uri = "/Conversations/#{@solution[:conversation_sid]}/Participants/#{@solution[:sid]}"
206
+ end
207
+
208
+ ##
209
+ # Update the ParticipantInstance
210
+ # @param [Time] date_created The date that this resource was created.
211
+ # @param [Time] date_updated The date that this resource was last updated.
212
+ # @return [ParticipantInstance] Updated ParticipantInstance
213
+ def update(date_created: :unset, date_updated: :unset)
214
+ data = Twilio::Values.of({
215
+ 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
216
+ 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
217
+ })
218
+
219
+ payload = @version.update(
220
+ 'POST',
221
+ @uri,
222
+ data: data,
223
+ )
224
+
225
+ ParticipantInstance.new(
226
+ @version,
227
+ payload,
228
+ conversation_sid: @solution[:conversation_sid],
229
+ sid: @solution[:sid],
230
+ )
231
+ end
232
+
233
+ ##
234
+ # Deletes the ParticipantInstance
235
+ # @return [Boolean] true if delete succeeds, true otherwise
236
+ def delete
237
+ @version.delete('delete', @uri)
238
+ end
239
+
240
+ ##
241
+ # Fetch a ParticipantInstance
242
+ # @return [ParticipantInstance] Fetched ParticipantInstance
243
+ def fetch
244
+ params = Twilio::Values.of({})
245
+
246
+ payload = @version.fetch(
247
+ 'GET',
248
+ @uri,
249
+ params,
250
+ )
251
+
252
+ ParticipantInstance.new(
253
+ @version,
254
+ payload,
255
+ conversation_sid: @solution[:conversation_sid],
256
+ sid: @solution[:sid],
257
+ )
258
+ end
259
+
260
+ ##
261
+ # Provide a user friendly representation
262
+ def to_s
263
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
264
+ "#<Twilio.Conversations.V1.ParticipantContext #{context}>"
265
+ end
266
+
267
+ ##
268
+ # Provide a detailed, user friendly representation
269
+ def inspect
270
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
271
+ "#<Twilio.Conversations.V1.ParticipantContext #{context}>"
272
+ end
273
+ end
274
+
275
+ ##
276
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
277
+ class ParticipantInstance < InstanceResource
278
+ ##
279
+ # Initialize the ParticipantInstance
280
+ # @param [Version] version Version that contains the resource
281
+ # @param [Hash] payload payload that contains response from Twilio
282
+ # @param [String] conversation_sid The unique id of the
283
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant.
284
+ # @param [String] sid A 34 character string that uniquely identifies this
285
+ # resource.
286
+ # @return [ParticipantInstance] ParticipantInstance
287
+ def initialize(version, payload, conversation_sid: nil, sid: nil)
288
+ super(version)
289
+
290
+ # Marshaled Properties
291
+ @properties = {
292
+ 'account_sid' => payload['account_sid'],
293
+ 'conversation_sid' => payload['conversation_sid'],
294
+ 'sid' => payload['sid'],
295
+ 'identity' => payload['identity'],
296
+ 'messaging_binding' => payload['messaging_binding'],
297
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
298
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
299
+ 'url' => payload['url'],
300
+ }
301
+
302
+ # Context
303
+ @instance_context = nil
304
+ @params = {'conversation_sid' => conversation_sid, 'sid' => sid || @properties['sid'], }
305
+ end
306
+
307
+ ##
308
+ # Generate an instance context for the instance, the context is capable of
309
+ # performing various actions. All instance actions are proxied to the context
310
+ # @return [ParticipantContext] ParticipantContext for this ParticipantInstance
311
+ def context
312
+ unless @instance_context
313
+ @instance_context = ParticipantContext.new(@version, @params['conversation_sid'], @params['sid'], )
314
+ end
315
+ @instance_context
316
+ end
317
+
318
+ ##
319
+ # @return [String] The unique id of the Account responsible for this participant.
320
+ def account_sid
321
+ @properties['account_sid']
322
+ end
323
+
324
+ ##
325
+ # @return [String] The unique id of the Conversation for this participant.
326
+ def conversation_sid
327
+ @properties['conversation_sid']
328
+ end
329
+
330
+ ##
331
+ # @return [String] A 34 character string that uniquely identifies this resource.
332
+ def sid
333
+ @properties['sid']
334
+ end
335
+
336
+ ##
337
+ # @return [String] A unique string identifier for the conversation participant as Chat User.
338
+ def identity
339
+ @properties['identity']
340
+ end
341
+
342
+ ##
343
+ # @return [Hash] Information about how this participant exchanges messages with the conversation.
344
+ def messaging_binding
345
+ @properties['messaging_binding']
346
+ end
347
+
348
+ ##
349
+ # @return [Time] The date that this resource was created.
350
+ def date_created
351
+ @properties['date_created']
352
+ end
353
+
354
+ ##
355
+ # @return [Time] The date that this resource was last updated.
356
+ def date_updated
357
+ @properties['date_updated']
358
+ end
359
+
360
+ ##
361
+ # @return [String] An absolute URL for this participant.
362
+ def url
363
+ @properties['url']
364
+ end
365
+
366
+ ##
367
+ # Update the ParticipantInstance
368
+ # @param [Time] date_created The date that this resource was created.
369
+ # @param [Time] date_updated The date that this resource was last updated.
370
+ # @return [ParticipantInstance] Updated ParticipantInstance
371
+ def update(date_created: :unset, date_updated: :unset)
372
+ context.update(date_created: date_created, date_updated: date_updated, )
373
+ end
374
+
375
+ ##
376
+ # Deletes the ParticipantInstance
377
+ # @return [Boolean] true if delete succeeds, true otherwise
378
+ def delete
379
+ context.delete
380
+ end
381
+
382
+ ##
383
+ # Fetch a ParticipantInstance
384
+ # @return [ParticipantInstance] Fetched ParticipantInstance
385
+ def fetch
386
+ context.fetch
387
+ end
388
+
389
+ ##
390
+ # Provide a user friendly representation
391
+ def to_s
392
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
393
+ "<Twilio.Conversations.V1.ParticipantInstance #{values}>"
394
+ end
395
+
396
+ ##
397
+ # Provide a detailed, user friendly representation
398
+ def inspect
399
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
400
+ "<Twilio.Conversations.V1.ParticipantInstance #{values}>"
401
+ end
402
+ end
403
+ end
404
+ end
405
+ end
406
+ end
407
+ end