twilio-ruby 5.0.0.rc20 → 5.0.0.rc21

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +9 -3
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/http/http_client.rb +0 -1
  5. data/lib/twilio-ruby/rest/preview/bulk_exports/export/day.rb +196 -0
  6. data/lib/twilio-ruby/rest/preview/bulk_exports/export.rb +197 -0
  7. data/lib/twilio-ruby/rest/preview/bulk_exports/export_configuration.rb +232 -0
  8. data/lib/twilio-ruby/rest/preview/bulk_exports.rb +44 -0
  9. data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +517 -0
  10. data/lib/twilio-ruby/rest/preview/hosted_numbers.rb +35 -0
  11. data/lib/twilio-ruby/rest/preview/proxy/service/phone_number.rb +336 -0
  12. data/lib/twilio-ruby/rest/preview/proxy/service/session/interaction.rb +393 -0
  13. data/lib/twilio-ruby/rest/preview/proxy/service/session/participant/message_interaction.rb +409 -0
  14. data/lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb +479 -0
  15. data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +506 -0
  16. data/lib/twilio-ruby/rest/preview/proxy/service/short_code.rb +336 -0
  17. data/lib/twilio-ruby/rest/preview/proxy/service.rb +467 -0
  18. data/lib/twilio-ruby/rest/preview/proxy.rb +35 -0
  19. data/lib/twilio-ruby/rest/preview.rb +34 -1
  20. data/lib/twilio-ruby/version.rb +1 -1
  21. data/spec/integration/preview/bulk_exports/export/day_spec.rb +56 -0
  22. data/spec/integration/preview/bulk_exports/export_configuration_spec.rb +79 -0
  23. data/spec/integration/preview/bulk_exports/export_spec.rb +43 -0
  24. data/spec/integration/preview/hosted_numbers/hosted_number_order_spec.rb +277 -0
  25. data/spec/integration/preview/proxy/service/phone_number_spec.rb +173 -0
  26. data/spec/integration/preview/proxy/service/session/interaction_spec.rb +104 -0
  27. data/spec/integration/preview/proxy/service/session/participant/message_interaction_spec.rb +164 -0
  28. data/spec/integration/preview/proxy/service/session/participant_spec.rb +226 -0
  29. data/spec/integration/preview/proxy/service/session_spec.rb +216 -0
  30. data/spec/integration/preview/proxy/service/short_code_spec.rb +173 -0
  31. data/spec/integration/preview/proxy/service_spec.rb +200 -0
  32. metadata +38 -2
@@ -0,0 +1,409 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Preview < Domain
10
+ class Proxy < Version
11
+ class ServiceContext < InstanceContext
12
+ class SessionContext < InstanceContext
13
+ class ParticipantContext < InstanceContext
14
+ class MessageInteractionList < ListResource
15
+ ##
16
+ # Initialize the MessageInteractionList
17
+ # @param [Version] version Version that contains the resource
18
+ # @param [String] service_sid The unique SID identifier of the Service.
19
+ # @param [String] session_sid The unique SID identifier of the Session.
20
+ # @param [String] participant_sid The participant_sid
21
+ # @return [MessageInteractionList] MessageInteractionList
22
+ def initialize(version, service_sid: nil, session_sid: nil, participant_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {
27
+ service_sid: service_sid,
28
+ session_sid: session_sid,
29
+ participant_sid: participant_sid
30
+ }
31
+ @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:session_sid]}/Participants/#{@solution[:participant_sid]}/MessageInteractions"
32
+ end
33
+
34
+ ##
35
+ # Retrieve a single page of MessageInteractionInstance records from the API.
36
+ # Request is executed immediately.
37
+ # @param [String] body The text body of the message to send to the Participant. Up
38
+ # to 1600 characters long.
39
+ # @param [String] media_url The public url of an image or video to send to the
40
+ # Participant.
41
+ # @return [MessageInteractionInstance] Newly created MessageInteractionInstance
42
+ def create(body: nil, media_url: nil)
43
+ data = {
44
+ 'Body' => body,
45
+ 'MediaUrl' => media_url,
46
+ }
47
+
48
+ payload = @version.create(
49
+ 'POST',
50
+ @uri,
51
+ data: data
52
+ )
53
+
54
+ return MessageInteractionInstance.new(
55
+ @version,
56
+ payload,
57
+ service_sid: @solution[:service_sid],
58
+ session_sid: @solution[:session_sid],
59
+ participant_sid: @solution[:participant_sid],
60
+ )
61
+ end
62
+
63
+ ##
64
+ # Lists MessageInteractionInstance records from the API as a list.
65
+ # Unlike stream(), this operation is eager and will load `limit` records into
66
+ # memory before returning.
67
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
68
+ # guarantees to never return more than limit. Default is no limit
69
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
70
+ # the default value of 50 records. If no page_size is defined
71
+ # but a limit is defined, stream() will attempt to read the
72
+ # limit with the most efficient page size, i.e. min(limit, 1000)
73
+ # @return [Array] Array of up to limit results
74
+ def list(limit: nil, page_size: nil)
75
+ self.stream(
76
+ limit: limit,
77
+ page_size: page_size
78
+ ).entries
79
+ end
80
+
81
+ ##
82
+ # Streams MessageInteractionInstance records from the API as an Enumerable.
83
+ # This operation lazily loads records as efficiently as possible until the limit
84
+ # is reached.
85
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
86
+ # guarantees to never return more than limit. Default is no limit
87
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
88
+ # the default value of 50 records. If no page_size is defined
89
+ # but a limit is defined, stream() will attempt to read the
90
+ # limit with the most efficient page size, i.e. min(limit, 1000)
91
+ # @return [Enumerable] Enumerable that will yield up to limit results
92
+ def stream(limit: nil, page_size: nil)
93
+ limits = @version.read_limits(limit, page_size)
94
+
95
+ page = self.page(
96
+ page_size: limits[:page_size],
97
+ )
98
+
99
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
100
+ end
101
+
102
+ ##
103
+ # When passed a block, yields MessageInteractionInstance records from the API.
104
+ # This operation lazily loads records as efficiently as possible until the limit
105
+ # is reached.
106
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
107
+ # guarantees to never return more than limit. Default is no limit
108
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
109
+ # the default value of 50 records. If no page_size is defined
110
+ # but a limit is defined, stream() will attempt to read the
111
+ # limit with the most efficient page size, i.e. min(limit, 1000)
112
+ def each
113
+ limits = @version.read_limits
114
+
115
+ page = self.page(
116
+ page_size: limits[:page_size],
117
+ )
118
+
119
+ @version.stream(page,
120
+ limit: limits[:limit],
121
+ page_limit: limits[:page_limit]).each {|x| yield x}
122
+ end
123
+
124
+ ##
125
+ # Retrieve a single page of MessageInteractionInstance records from the API.
126
+ # Request is executed immediately.
127
+ # @param [String] page_token PageToken provided by the API
128
+ # @param [Integer] page_number Page Number, this value is simply for client state
129
+ # @param [Integer] page_size Number of records to return, defaults to 50
130
+ # @return [Page] Page of MessageInteractionInstance
131
+ def page(page_token: nil, page_number: nil, page_size: nil)
132
+ params = {
133
+ 'PageToken' => page_token,
134
+ 'Page' => page_number,
135
+ 'PageSize' => page_size,
136
+ }
137
+ response = @version.page(
138
+ 'GET',
139
+ @uri,
140
+ params
141
+ )
142
+ return MessageInteractionPage.new(@version, response, @solution)
143
+ end
144
+
145
+ ##
146
+ # Provide a user friendly representation
147
+ def to_s
148
+ '#<Twilio.Preview.Proxy.MessageInteractionList>'
149
+ end
150
+ end
151
+
152
+ class MessageInteractionPage < Page
153
+ ##
154
+ # Initialize the MessageInteractionPage
155
+ # @param [Version] version Version that contains the resource
156
+ # @param [Response] response Response from the API
157
+ # @param [Hash] solution Path solution for the resource
158
+ # @param [String] service_sid The unique SID identifier of the Service.
159
+ # @param [String] session_sid The unique SID identifier of the Session.
160
+ # @param [String] participant_sid The participant_sid
161
+ # @return [MessageInteractionPage] MessageInteractionPage
162
+ def initialize(version, response, solution)
163
+ super(version, response)
164
+
165
+ # Path Solution
166
+ @solution = solution
167
+ end
168
+
169
+ ##
170
+ # Build an instance of MessageInteractionInstance
171
+ # @param [Hash] payload Payload response from the API
172
+ # @return [MessageInteractionInstance] MessageInteractionInstance
173
+ def get_instance(payload)
174
+ return MessageInteractionInstance.new(
175
+ @version,
176
+ payload,
177
+ service_sid: @solution[:service_sid],
178
+ session_sid: @solution[:session_sid],
179
+ participant_sid: @solution[:participant_sid],
180
+ )
181
+ end
182
+
183
+ ##
184
+ # Provide a user friendly representation
185
+ def to_s
186
+ '<Twilio.Preview.Proxy.MessageInteractionPage>'
187
+ end
188
+ end
189
+
190
+ class MessageInteractionContext < InstanceContext
191
+ ##
192
+ # Initialize the MessageInteractionContext
193
+ # @param [Version] version Version that contains the resource
194
+ # @param [String] service_sid The unique SID identifier of the Service.
195
+ # @param [String] session_sid The unique SID identifier of the Session.
196
+ # @param [String] participant_sid The unique SID identifier of the Participant.
197
+ # @param [String] sid A 34 character string that uniquely identifies this
198
+ # Interaction.
199
+ # @return [MessageInteractionContext] MessageInteractionContext
200
+ def initialize(version, service_sid, session_sid, participant_sid, sid)
201
+ super(version)
202
+
203
+ # Path Solution
204
+ @solution = {
205
+ service_sid: service_sid,
206
+ session_sid: session_sid,
207
+ participant_sid: participant_sid,
208
+ sid: sid,
209
+ }
210
+ @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:session_sid]}/Participants/#{@solution[:participant_sid]}/MessageInteractions/#{@solution[:sid]}"
211
+ end
212
+
213
+ ##
214
+ # Fetch a MessageInteractionInstance
215
+ # @return [MessageInteractionInstance] Fetched MessageInteractionInstance
216
+ def fetch
217
+ params = {}
218
+
219
+ payload = @version.fetch(
220
+ 'GET',
221
+ @uri,
222
+ params,
223
+ )
224
+
225
+ return MessageInteractionInstance.new(
226
+ @version,
227
+ payload,
228
+ service_sid: @solution[:service_sid],
229
+ session_sid: @solution[:session_sid],
230
+ participant_sid: @solution[:participant_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.Preview.Proxy.MessageInteractionContext #{context}>"
240
+ end
241
+ end
242
+
243
+ class MessageInteractionInstance < InstanceResource
244
+ ##
245
+ # Initialize the MessageInteractionInstance
246
+ # @param [Version] version Version that contains the resource
247
+ # @param [Hash] payload payload that contains response from Twilio
248
+ # @param [String] service_sid The unique SID identifier of the Service.
249
+ # @param [String] session_sid The unique SID identifier of the Session.
250
+ # @param [String] participant_sid The participant_sid
251
+ # @param [String] sid A 34 character string that uniquely identifies this
252
+ # Interaction.
253
+ # @return [MessageInteractionInstance] MessageInteractionInstance
254
+ def initialize(version, payload, service_sid: nil, session_sid: nil, participant_sid: nil, sid: nil)
255
+ super(version)
256
+
257
+ # Marshaled Properties
258
+ @properties = {
259
+ 'sid' => payload['sid'],
260
+ 'session_sid' => payload['session_sid'],
261
+ 'service_sid' => payload['service_sid'],
262
+ 'account_sid' => payload['account_sid'],
263
+ 'data' => payload['data'],
264
+ 'status' => payload['status'],
265
+ 'participant_sid' => payload['participant_sid'],
266
+ 'inbound_participant_sid' => payload['inbound_participant_sid'],
267
+ 'inbound_resource_sid' => payload['inbound_resource_sid'],
268
+ 'inbound_resource_status' => payload['inbound_resource_status'],
269
+ 'inbound_resource_type' => payload['inbound_resource_type'],
270
+ 'inbound_resource_url' => payload['inbound_resource_url'],
271
+ 'outbound_participant_sid' => payload['outbound_participant_sid'],
272
+ 'outbound_resource_sid' => payload['outbound_resource_sid'],
273
+ 'outbound_resource_status' => payload['outbound_resource_status'],
274
+ 'outbound_resource_type' => payload['outbound_resource_type'],
275
+ 'outbound_resource_url' => payload['outbound_resource_url'],
276
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
277
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
278
+ 'url' => payload['url'],
279
+ }
280
+
281
+ # Context
282
+ @instance_context = nil
283
+ @params = {
284
+ 'service_sid' => service_sid,
285
+ 'session_sid' => session_sid,
286
+ 'participant_sid' => participant_sid,
287
+ 'sid' => sid || @properties['sid'],
288
+ }
289
+ end
290
+
291
+ ##
292
+ # Generate an instance context for the instance, the context is capable of
293
+ # performing various actions. All instance actions are proxied to the context
294
+ # @param [Version] version Version that contains the resource
295
+ # @return [MessageInteractionContext] MessageInteractionContext for this MessageInteractionInstance
296
+ def context
297
+ unless @instance_context
298
+ @instance_context = MessageInteractionContext.new(
299
+ @version,
300
+ @params['service_sid'],
301
+ @params['session_sid'],
302
+ @params['participant_sid'],
303
+ @params['sid'],
304
+ )
305
+ end
306
+ @instance_context
307
+ end
308
+
309
+ def sid
310
+ @properties['sid']
311
+ end
312
+
313
+ def session_sid
314
+ @properties['session_sid']
315
+ end
316
+
317
+ def service_sid
318
+ @properties['service_sid']
319
+ end
320
+
321
+ def account_sid
322
+ @properties['account_sid']
323
+ end
324
+
325
+ def data
326
+ @properties['data']
327
+ end
328
+
329
+ def status
330
+ @properties['status']
331
+ end
332
+
333
+ def participant_sid
334
+ @properties['participant_sid']
335
+ end
336
+
337
+ def inbound_participant_sid
338
+ @properties['inbound_participant_sid']
339
+ end
340
+
341
+ def inbound_resource_sid
342
+ @properties['inbound_resource_sid']
343
+ end
344
+
345
+ def inbound_resource_status
346
+ @properties['inbound_resource_status']
347
+ end
348
+
349
+ def inbound_resource_type
350
+ @properties['inbound_resource_type']
351
+ end
352
+
353
+ def inbound_resource_url
354
+ @properties['inbound_resource_url']
355
+ end
356
+
357
+ def outbound_participant_sid
358
+ @properties['outbound_participant_sid']
359
+ end
360
+
361
+ def outbound_resource_sid
362
+ @properties['outbound_resource_sid']
363
+ end
364
+
365
+ def outbound_resource_status
366
+ @properties['outbound_resource_status']
367
+ end
368
+
369
+ def outbound_resource_type
370
+ @properties['outbound_resource_type']
371
+ end
372
+
373
+ def outbound_resource_url
374
+ @properties['outbound_resource_url']
375
+ end
376
+
377
+ def date_created
378
+ @properties['date_created']
379
+ end
380
+
381
+ def date_updated
382
+ @properties['date_updated']
383
+ end
384
+
385
+ def url
386
+ @properties['url']
387
+ end
388
+
389
+ ##
390
+ # Fetch a MessageInteractionInstance
391
+ # @return [MessageInteractionInstance] Fetched MessageInteractionInstance
392
+ def fetch
393
+ context.fetch
394
+ end
395
+
396
+ ##
397
+ # Provide a user friendly representation
398
+ def to_s
399
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
400
+ "<Twilio.Preview.Proxy.MessageInteractionInstance #{values}>"
401
+ end
402
+ end
403
+ end
404
+ end
405
+ end
406
+ end
407
+ end
408
+ end
409
+ end
@@ -0,0 +1,479 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Preview < Domain
10
+ class Proxy < Version
11
+ class ServiceContext < InstanceContext
12
+ class SessionContext < InstanceContext
13
+ class ParticipantList < ListResource
14
+ ##
15
+ # Initialize the ParticipantList
16
+ # @param [Version] version Version that contains the resource
17
+ # @param [String] service_sid The unique SID identifier of the Service.
18
+ # @param [String] session_sid The unique SID identifier of the Session.
19
+ # @return [ParticipantList] ParticipantList
20
+ def initialize(version, service_sid: nil, session_sid: nil)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {
25
+ service_sid: service_sid,
26
+ session_sid: session_sid
27
+ }
28
+ @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:session_sid]}/Participants"
29
+ end
30
+
31
+ ##
32
+ # Lists ParticipantInstance records from the API as a list.
33
+ # Unlike stream(), this operation is eager and will load `limit` records into
34
+ # memory before returning.
35
+ # @param [String] identifier The Participant's contact identifier, normally a
36
+ # phone number.
37
+ # @param [participant.ParticipantType] participant_type The Type of this
38
+ # Participant. One of `sms`, `voice` or `phone`.
39
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
40
+ # guarantees to never return more than limit. Default is no limit
41
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
42
+ # the default value of 50 records. If no page_size is defined
43
+ # but a limit is defined, stream() will attempt to read the
44
+ # limit with the most efficient page size, i.e. min(limit, 1000)
45
+ # @return [Array] Array of up to limit results
46
+ def list(identifier: nil, participant_type: nil, limit: nil, page_size: nil)
47
+ self.stream(
48
+ identifier: identifier,
49
+ participant_type: participant_type,
50
+ limit: limit,
51
+ page_size: page_size
52
+ ).entries
53
+ end
54
+
55
+ ##
56
+ # Streams ParticipantInstance records from the API as an Enumerable.
57
+ # This operation lazily loads records as efficiently as possible until the limit
58
+ # is reached.
59
+ # @param [String] identifier The Participant's contact identifier, normally a
60
+ # phone number.
61
+ # @param [participant.ParticipantType] participant_type The Type of this
62
+ # Participant. One of `sms`, `voice` or `phone`.
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 not set will use
66
+ # the default value of 50 records. If no page_size is defined
67
+ # but a limit is defined, stream() will attempt to read the
68
+ # limit with the most efficient page size, i.e. min(limit, 1000)
69
+ # @return [Enumerable] Enumerable that will yield up to limit results
70
+ def stream(identifier: nil, participant_type: nil, limit: nil, page_size: nil)
71
+ limits = @version.read_limits(limit, page_size)
72
+
73
+ page = self.page(
74
+ identifier: identifier,
75
+ participant_type: participant_type,
76
+ page_size: limits[:page_size],
77
+ )
78
+
79
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
80
+ end
81
+
82
+ ##
83
+ # When passed a block, yields ParticipantInstance records from the API.
84
+ # This operation lazily loads records as efficiently as possible until the limit
85
+ # is reached.
86
+ # @param [String] identifier The Participant's contact identifier, normally a
87
+ # phone number.
88
+ # @param [participant.ParticipantType] participant_type The Type of this
89
+ # Participant. One of `sms`, `voice` or `phone`.
90
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
91
+ # guarantees to never return more than limit. Default is no limit
92
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
93
+ # the default value of 50 records. If no page_size is defined
94
+ # but a limit is defined, stream() will attempt to read the
95
+ # limit with the most efficient page size, i.e. min(limit, 1000)
96
+ def each
97
+ limits = @version.read_limits
98
+
99
+ page = self.page(
100
+ page_size: limits[:page_size],
101
+ )
102
+
103
+ @version.stream(page,
104
+ limit: limits[:limit],
105
+ page_limit: limits[:page_limit]).each {|x| yield x}
106
+ end
107
+
108
+ ##
109
+ # Retrieve a single page of ParticipantInstance records from the API.
110
+ # Request is executed immediately.
111
+ # @param [String] identifier The Participant's contact identifier, normally a
112
+ # phone number.
113
+ # @param [participant.ParticipantType] participant_type The Type of this
114
+ # Participant. One of `sms`, `voice` or `phone`.
115
+ # @param [String] page_token PageToken provided by the API
116
+ # @param [Integer] page_number Page Number, this value is simply for client state
117
+ # @param [Integer] page_size Number of records to return, defaults to 50
118
+ # @return [Page] Page of ParticipantInstance
119
+ def page(identifier: nil, participant_type: nil, page_token: nil, page_number: nil, page_size: nil)
120
+ params = {
121
+ 'Identifier' => identifier,
122
+ 'ParticipantType' => participant_type,
123
+ 'PageToken' => page_token,
124
+ 'Page' => page_number,
125
+ 'PageSize' => page_size,
126
+ }
127
+ response = @version.page(
128
+ 'GET',
129
+ @uri,
130
+ params
131
+ )
132
+ return ParticipantPage.new(@version, response, @solution)
133
+ end
134
+
135
+ ##
136
+ # Retrieve a single page of ParticipantInstance records from the API.
137
+ # Request is executed immediately.
138
+ # @param [String] identifier The Participant's contact identifier, normally a
139
+ # phone number.
140
+ # @param [String] friendly_name A human readable description of this resource, up
141
+ # to 64 characters.
142
+ # @param [participant.ParticipantType] participant_type The Type of this
143
+ # Participant. One of `sms`, `voice` or `phone`.
144
+ # @return [ParticipantInstance] Newly created ParticipantInstance
145
+ def create(identifier: nil, friendly_name: nil, participant_type: nil)
146
+ data = {
147
+ 'Identifier' => identifier,
148
+ 'FriendlyName' => friendly_name,
149
+ 'ParticipantType' => participant_type,
150
+ }
151
+
152
+ payload = @version.create(
153
+ 'POST',
154
+ @uri,
155
+ data: data
156
+ )
157
+
158
+ return ParticipantInstance.new(
159
+ @version,
160
+ payload,
161
+ service_sid: @solution[:service_sid],
162
+ session_sid: @solution[:session_sid],
163
+ )
164
+ end
165
+
166
+ ##
167
+ # Provide a user friendly representation
168
+ def to_s
169
+ '#<Twilio.Preview.Proxy.ParticipantList>'
170
+ end
171
+ end
172
+
173
+ class ParticipantPage < Page
174
+ ##
175
+ # Initialize the ParticipantPage
176
+ # @param [Version] version Version that contains the resource
177
+ # @param [Response] response Response from the API
178
+ # @param [Hash] solution Path solution for the resource
179
+ # @param [String] service_sid The unique SID identifier of the Service.
180
+ # @param [String] session_sid The unique SID identifier of the Session.
181
+ # @return [ParticipantPage] ParticipantPage
182
+ def initialize(version, response, solution)
183
+ super(version, response)
184
+
185
+ # Path Solution
186
+ @solution = solution
187
+ end
188
+
189
+ ##
190
+ # Build an instance of ParticipantInstance
191
+ # @param [Hash] payload Payload response from the API
192
+ # @return [ParticipantInstance] ParticipantInstance
193
+ def get_instance(payload)
194
+ return ParticipantInstance.new(
195
+ @version,
196
+ payload,
197
+ service_sid: @solution[:service_sid],
198
+ session_sid: @solution[:session_sid],
199
+ )
200
+ end
201
+
202
+ ##
203
+ # Provide a user friendly representation
204
+ def to_s
205
+ '<Twilio.Preview.Proxy.ParticipantPage>'
206
+ end
207
+ end
208
+
209
+ class ParticipantContext < InstanceContext
210
+ ##
211
+ # Initialize the ParticipantContext
212
+ # @param [Version] version Version that contains the resource
213
+ # @param [String] service_sid The unique SID identifier of the Service.
214
+ # @param [String] session_sid The unique SID identifier of the Session.
215
+ # @param [String] sid A 34 character string that uniquely identifies this
216
+ # Participant.
217
+ # @return [ParticipantContext] ParticipantContext
218
+ def initialize(version, service_sid, session_sid, sid)
219
+ super(version)
220
+
221
+ # Path Solution
222
+ @solution = {
223
+ service_sid: service_sid,
224
+ session_sid: session_sid,
225
+ sid: sid,
226
+ }
227
+ @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:session_sid]}/Participants/#{@solution[:sid]}"
228
+
229
+ # Dependents
230
+ @message_interactions = nil
231
+ end
232
+
233
+ ##
234
+ # Fetch a ParticipantInstance
235
+ # @return [ParticipantInstance] Fetched ParticipantInstance
236
+ def fetch
237
+ params = {}
238
+
239
+ payload = @version.fetch(
240
+ 'GET',
241
+ @uri,
242
+ params,
243
+ )
244
+
245
+ return ParticipantInstance.new(
246
+ @version,
247
+ payload,
248
+ service_sid: @solution[:service_sid],
249
+ session_sid: @solution[:session_sid],
250
+ sid: @solution[:sid],
251
+ )
252
+ end
253
+
254
+ ##
255
+ # Deletes the ParticipantInstance
256
+ # @return [Boolean] true if delete succeeds, true otherwise
257
+ def delete
258
+ return @version.delete('delete', @uri)
259
+ end
260
+
261
+ ##
262
+ # Update the ParticipantInstance
263
+ # @param [participant.ParticipantType] participant_type The Type of this
264
+ # Participant. One of `sms`, `voice` or `phone`.
265
+ # @param [String] identifier The Participant's contact identifier, normally a
266
+ # phone number.
267
+ # @param [String] friendly_name A human readable description of this resource, up
268
+ # to 64 characters.
269
+ # @return [ParticipantInstance] Updated ParticipantInstance
270
+ def update(participant_type: nil, identifier: nil, friendly_name: nil)
271
+ data = {
272
+ 'ParticipantType' => participant_type,
273
+ 'Identifier' => identifier,
274
+ 'FriendlyName' => friendly_name,
275
+ }
276
+
277
+ payload = @version.update(
278
+ 'POST',
279
+ @uri,
280
+ data: data,
281
+ )
282
+
283
+ return ParticipantInstance.new(
284
+ @version,
285
+ payload,
286
+ service_sid: @solution[:service_sid],
287
+ session_sid: @solution[:session_sid],
288
+ sid: @solution[:sid],
289
+ )
290
+ end
291
+
292
+ ##
293
+ # Access the message_interactions
294
+ # @return [MessageInteractionList] MessageInteractionList
295
+ def message_interactions(sid=:unset)
296
+ if sid != :unset
297
+ return MessageInteractionContext.new(
298
+ @version,
299
+ @solution[:service_sid],
300
+ @solution[:session_sid],
301
+ @solution[:sid],
302
+ sid,
303
+ )
304
+ end
305
+
306
+ unless @message_interactions
307
+ @message_interactions = MessageInteractionList.new(
308
+ @version,
309
+ service_sid: @solution[:service_sid],
310
+ session_sid: @solution[:session_sid],
311
+ participant_sid: @solution[:sid],
312
+ )
313
+ end
314
+
315
+ @message_interactions
316
+ end
317
+
318
+ ##
319
+ # Provide a user friendly representation
320
+ def to_s
321
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
322
+ "#<Twilio.Preview.Proxy.ParticipantContext #{context}>"
323
+ end
324
+ end
325
+
326
+ class ParticipantInstance < InstanceResource
327
+ ##
328
+ # Initialize the ParticipantInstance
329
+ # @param [Version] version Version that contains the resource
330
+ # @param [Hash] payload payload that contains response from Twilio
331
+ # @param [String] service_sid The unique SID identifier of the Service.
332
+ # @param [String] session_sid The unique SID identifier of the Session.
333
+ # @param [String] sid A 34 character string that uniquely identifies this
334
+ # Participant.
335
+ # @return [ParticipantInstance] ParticipantInstance
336
+ def initialize(version, payload, service_sid: nil, session_sid: nil, sid: nil)
337
+ super(version)
338
+
339
+ # Marshaled Properties
340
+ @properties = {
341
+ 'sid' => payload['sid'],
342
+ 'session_sid' => payload['session_sid'],
343
+ 'service_sid' => payload['service_sid'],
344
+ 'account_sid' => payload['account_sid'],
345
+ 'friendly_name' => payload['friendly_name'],
346
+ 'participant_type' => payload['participant_type'],
347
+ 'identifier' => payload['identifier'],
348
+ 'proxy_identifier' => payload['proxy_identifier'],
349
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
350
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
351
+ 'url' => payload['url'],
352
+ 'links' => payload['links'],
353
+ }
354
+
355
+ # Context
356
+ @instance_context = nil
357
+ @params = {
358
+ 'service_sid' => service_sid,
359
+ 'session_sid' => session_sid,
360
+ 'sid' => sid || @properties['sid'],
361
+ }
362
+ end
363
+
364
+ ##
365
+ # Generate an instance context for the instance, the context is capable of
366
+ # performing various actions. All instance actions are proxied to the context
367
+ # @param [Version] version Version that contains the resource
368
+ # @return [ParticipantContext] ParticipantContext for this ParticipantInstance
369
+ def context
370
+ unless @instance_context
371
+ @instance_context = ParticipantContext.new(
372
+ @version,
373
+ @params['service_sid'],
374
+ @params['session_sid'],
375
+ @params['sid'],
376
+ )
377
+ end
378
+ @instance_context
379
+ end
380
+
381
+ def sid
382
+ @properties['sid']
383
+ end
384
+
385
+ def session_sid
386
+ @properties['session_sid']
387
+ end
388
+
389
+ def service_sid
390
+ @properties['service_sid']
391
+ end
392
+
393
+ def account_sid
394
+ @properties['account_sid']
395
+ end
396
+
397
+ def friendly_name
398
+ @properties['friendly_name']
399
+ end
400
+
401
+ def participant_type
402
+ @properties['participant_type']
403
+ end
404
+
405
+ def identifier
406
+ @properties['identifier']
407
+ end
408
+
409
+ def proxy_identifier
410
+ @properties['proxy_identifier']
411
+ end
412
+
413
+ def date_created
414
+ @properties['date_created']
415
+ end
416
+
417
+ def date_updated
418
+ @properties['date_updated']
419
+ end
420
+
421
+ def url
422
+ @properties['url']
423
+ end
424
+
425
+ def links
426
+ @properties['links']
427
+ end
428
+
429
+ ##
430
+ # Fetch a ParticipantInstance
431
+ # @return [ParticipantInstance] Fetched ParticipantInstance
432
+ def fetch
433
+ context.fetch
434
+ end
435
+
436
+ ##
437
+ # Deletes the ParticipantInstance
438
+ # @return [Boolean] true if delete succeeds, true otherwise
439
+ def delete
440
+ context.delete
441
+ end
442
+
443
+ ##
444
+ # Update the ParticipantInstance
445
+ # @param [participant.ParticipantType] participant_type The Type of this
446
+ # Participant. One of `sms`, `voice` or `phone`.
447
+ # @param [String] identifier The Participant's contact identifier, normally a
448
+ # phone number.
449
+ # @param [String] friendly_name A human readable description of this resource, up
450
+ # to 64 characters.
451
+ # @return [ParticipantInstance] Updated ParticipantInstance
452
+ def update(participant_type: nil, identifier: nil, friendly_name: nil)
453
+ context.update(
454
+ participant_type: participant_type,
455
+ identifier: identifier,
456
+ friendly_name: friendly_name,
457
+ )
458
+ end
459
+
460
+ ##
461
+ # Access the message_interactions
462
+ # @return [message_interactions] message_interactions
463
+ def message_interactions
464
+ context.message_interactions
465
+ end
466
+
467
+ ##
468
+ # Provide a user friendly representation
469
+ def to_s
470
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
471
+ "<Twilio.Preview.Proxy.ParticipantInstance #{values}>"
472
+ end
473
+ end
474
+ end
475
+ end
476
+ end
477
+ end
478
+ end
479
+ end