twilio-ruby 5.63.0 → 5.63.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,483 @@
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 Insights < Domain
12
+ class V1 < Version
13
+ class ConferenceContext < InstanceContext
14
+ class ConferenceParticipantList < ListResource
15
+ ##
16
+ # Initialize the ConferenceParticipantList
17
+ # @param [Version] version Version that contains the resource
18
+ # @param [String] conference_sid The conference_sid
19
+ # @return [ConferenceParticipantList] ConferenceParticipantList
20
+ def initialize(version, conference_sid: nil)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {conference_sid: conference_sid}
25
+ @uri = "/Conferences/#{@solution[:conference_sid]}/Participants"
26
+ end
27
+
28
+ ##
29
+ # Lists ConferenceParticipantInstance records from the API as a list.
30
+ # Unlike stream(), this operation is eager and will load `limit` records into
31
+ # memory before returning.
32
+ # @param [String] participant_sid The participant_sid
33
+ # @param [String] label The label
34
+ # @param [String] events The events
35
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
36
+ # guarantees to never return more than limit. Default is no limit
37
+ # @param [Integer] page_size Number of records to fetch per request, when
38
+ # not set will use the default value of 50 records. If no page_size is defined
39
+ # but a limit is defined, stream() will attempt to read the limit with the most
40
+ # efficient page size, i.e. min(limit, 1000)
41
+ # @return [Array] Array of up to limit results
42
+ def list(participant_sid: :unset, label: :unset, events: :unset, limit: nil, page_size: nil)
43
+ self.stream(
44
+ participant_sid: participant_sid,
45
+ label: label,
46
+ events: events,
47
+ limit: limit,
48
+ page_size: page_size
49
+ ).entries
50
+ end
51
+
52
+ ##
53
+ # Streams ConferenceParticipantInstance records from the API as an Enumerable.
54
+ # This operation lazily loads records as efficiently as possible until the limit
55
+ # is reached.
56
+ # @param [String] participant_sid The participant_sid
57
+ # @param [String] label The label
58
+ # @param [String] events The events
59
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
60
+ # guarantees to never return more than limit. Default is no limit.
61
+ # @param [Integer] page_size Number of records to fetch per request, when
62
+ # not set will use the default value of 50 records. If no page_size is defined
63
+ # but a limit is defined, stream() will attempt to read the limit with the most
64
+ # efficient page size, i.e. min(limit, 1000)
65
+ # @return [Enumerable] Enumerable that will yield up to limit results
66
+ def stream(participant_sid: :unset, label: :unset, events: :unset, limit: nil, page_size: nil)
67
+ limits = @version.read_limits(limit, page_size)
68
+
69
+ page = self.page(
70
+ participant_sid: participant_sid,
71
+ label: label,
72
+ events: events,
73
+ page_size: limits[:page_size],
74
+ )
75
+
76
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
77
+ end
78
+
79
+ ##
80
+ # When passed a block, yields ConferenceParticipantInstance records from the API.
81
+ # This operation lazily loads records as efficiently as possible until the limit
82
+ # is reached.
83
+ def each
84
+ limits = @version.read_limits
85
+
86
+ page = self.page(page_size: limits[:page_size], )
87
+
88
+ @version.stream(page,
89
+ limit: limits[:limit],
90
+ page_limit: limits[:page_limit]).each {|x| yield x}
91
+ end
92
+
93
+ ##
94
+ # Retrieve a single page of ConferenceParticipantInstance records from the API.
95
+ # Request is executed immediately.
96
+ # @param [String] participant_sid The participant_sid
97
+ # @param [String] label The label
98
+ # @param [String] events The events
99
+ # @param [String] page_token PageToken provided by the API
100
+ # @param [Integer] page_number Page Number, this value is simply for client state
101
+ # @param [Integer] page_size Number of records to return, defaults to 50
102
+ # @return [Page] Page of ConferenceParticipantInstance
103
+ def page(participant_sid: :unset, label: :unset, events: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
104
+ params = Twilio::Values.of({
105
+ 'ParticipantSid' => participant_sid,
106
+ 'Label' => label,
107
+ 'Events' => events,
108
+ 'PageToken' => page_token,
109
+ 'Page' => page_number,
110
+ 'PageSize' => page_size,
111
+ })
112
+
113
+ response = @version.page('GET', @uri, params: params)
114
+
115
+ ConferenceParticipantPage.new(@version, response, @solution)
116
+ end
117
+
118
+ ##
119
+ # Retrieve a single page of ConferenceParticipantInstance records from the API.
120
+ # Request is executed immediately.
121
+ # @param [String] target_url API-generated URL for the requested results page
122
+ # @return [Page] Page of ConferenceParticipantInstance
123
+ def get_page(target_url)
124
+ response = @version.domain.request(
125
+ 'GET',
126
+ target_url
127
+ )
128
+ ConferenceParticipantPage.new(@version, response, @solution)
129
+ end
130
+
131
+ ##
132
+ # Provide a user friendly representation
133
+ def to_s
134
+ '#<Twilio.Insights.V1.ConferenceParticipantList>'
135
+ end
136
+ end
137
+
138
+ class ConferenceParticipantPage < Page
139
+ ##
140
+ # Initialize the ConferenceParticipantPage
141
+ # @param [Version] version Version that contains the resource
142
+ # @param [Response] response Response from the API
143
+ # @param [Hash] solution Path solution for the resource
144
+ # @return [ConferenceParticipantPage] ConferenceParticipantPage
145
+ def initialize(version, response, solution)
146
+ super(version, response)
147
+
148
+ # Path Solution
149
+ @solution = solution
150
+ end
151
+
152
+ ##
153
+ # Build an instance of ConferenceParticipantInstance
154
+ # @param [Hash] payload Payload response from the API
155
+ # @return [ConferenceParticipantInstance] ConferenceParticipantInstance
156
+ def get_instance(payload)
157
+ ConferenceParticipantInstance.new(@version, payload, conference_sid: @solution[:conference_sid], )
158
+ end
159
+
160
+ ##
161
+ # Provide a user friendly representation
162
+ def to_s
163
+ '<Twilio.Insights.V1.ConferenceParticipantPage>'
164
+ end
165
+ end
166
+
167
+ class ConferenceParticipantContext < InstanceContext
168
+ ##
169
+ # Initialize the ConferenceParticipantContext
170
+ # @param [Version] version Version that contains the resource
171
+ # @param [String] conference_sid The conference_sid
172
+ # @param [String] participant_sid The participant_sid
173
+ # @return [ConferenceParticipantContext] ConferenceParticipantContext
174
+ def initialize(version, conference_sid, participant_sid)
175
+ super(version)
176
+
177
+ # Path Solution
178
+ @solution = {conference_sid: conference_sid, participant_sid: participant_sid, }
179
+ @uri = "/Conferences/#{@solution[:conference_sid]}/Participants/#{@solution[:participant_sid]}"
180
+ end
181
+
182
+ ##
183
+ # Fetch the ConferenceParticipantInstance
184
+ # @param [String] events The events
185
+ # @param [String] metrics The metrics
186
+ # @return [ConferenceParticipantInstance] Fetched ConferenceParticipantInstance
187
+ def fetch(events: :unset, metrics: :unset)
188
+ params = Twilio::Values.of({'Events' => events, 'Metrics' => metrics, })
189
+
190
+ payload = @version.fetch('GET', @uri, params: params)
191
+
192
+ ConferenceParticipantInstance.new(
193
+ @version,
194
+ payload,
195
+ conference_sid: @solution[:conference_sid],
196
+ participant_sid: @solution[:participant_sid],
197
+ )
198
+ end
199
+
200
+ ##
201
+ # Provide a user friendly representation
202
+ def to_s
203
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
204
+ "#<Twilio.Insights.V1.ConferenceParticipantContext #{context}>"
205
+ end
206
+
207
+ ##
208
+ # Provide a detailed, user friendly representation
209
+ def inspect
210
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
211
+ "#<Twilio.Insights.V1.ConferenceParticipantContext #{context}>"
212
+ end
213
+ end
214
+
215
+ class ConferenceParticipantInstance < InstanceResource
216
+ ##
217
+ # Initialize the ConferenceParticipantInstance
218
+ # @param [Version] version Version that contains the resource
219
+ # @param [Hash] payload payload that contains response from Twilio
220
+ # @param [String] conference_sid The conference_sid
221
+ # @param [String] participant_sid The participant_sid
222
+ # @return [ConferenceParticipantInstance] ConferenceParticipantInstance
223
+ def initialize(version, payload, conference_sid: nil, participant_sid: nil)
224
+ super(version)
225
+
226
+ # Marshaled Properties
227
+ @properties = {
228
+ 'participant_sid' => payload['participant_sid'],
229
+ 'label' => payload['label'],
230
+ 'conference_sid' => payload['conference_sid'],
231
+ 'call_sid' => payload['call_sid'],
232
+ 'account_sid' => payload['account_sid'],
233
+ 'call_direction' => payload['call_direction'],
234
+ 'from' => payload['from'],
235
+ 'to' => payload['to'],
236
+ 'call_state' => payload['call_state'],
237
+ 'country_code' => payload['country_code'],
238
+ 'is_moderator' => payload['is_moderator'],
239
+ 'join_time' => Twilio.deserialize_iso8601_datetime(payload['join_time']),
240
+ 'leave_time' => Twilio.deserialize_iso8601_datetime(payload['leave_time']),
241
+ 'duration_seconds' => payload['duration_seconds'] == nil ? payload['duration_seconds'] : payload['duration_seconds'].to_i,
242
+ 'whisper' => payload['whisper'],
243
+ 'agent_audio' => payload['agent_audio'],
244
+ 'outbound_queue_length' => payload['outbound_queue_length'] == nil ? payload['outbound_queue_length'] : payload['outbound_queue_length'].to_i,
245
+ 'outbound_time_in_queue' => payload['outbound_time_in_queue'] == nil ? payload['outbound_time_in_queue'] : payload['outbound_time_in_queue'].to_i,
246
+ 'jitter_buffer_size' => payload['jitter_buffer_size'],
247
+ 'is_coach' => payload['is_coach'],
248
+ 'coached_participants' => payload['coached_participants'],
249
+ 'participant_region' => payload['participant_region'],
250
+ 'conference_region' => payload['conference_region'],
251
+ 'call_type' => payload['call_type'],
252
+ 'quality_issues' => payload['quality_issues'] == nil ? payload['quality_issues'] : payload['quality_issues'].to_i,
253
+ 'properties' => payload['properties'],
254
+ 'events' => payload['events'],
255
+ 'metrics' => payload['metrics'],
256
+ 'url' => payload['url'],
257
+ }
258
+
259
+ # Context
260
+ @instance_context = nil
261
+ @params = {
262
+ 'conference_sid' => conference_sid,
263
+ 'participant_sid' => participant_sid || @properties['participant_sid'],
264
+ }
265
+ end
266
+
267
+ ##
268
+ # Generate an instance context for the instance, the context is capable of
269
+ # performing various actions. All instance actions are proxied to the context
270
+ # @return [ConferenceParticipantContext] ConferenceParticipantContext for this ConferenceParticipantInstance
271
+ def context
272
+ unless @instance_context
273
+ @instance_context = ConferenceParticipantContext.new(
274
+ @version,
275
+ @params['conference_sid'],
276
+ @params['participant_sid'],
277
+ )
278
+ end
279
+ @instance_context
280
+ end
281
+
282
+ ##
283
+ # @return [String] The participant_sid
284
+ def participant_sid
285
+ @properties['participant_sid']
286
+ end
287
+
288
+ ##
289
+ # @return [String] The label
290
+ def label
291
+ @properties['label']
292
+ end
293
+
294
+ ##
295
+ # @return [String] The conference_sid
296
+ def conference_sid
297
+ @properties['conference_sid']
298
+ end
299
+
300
+ ##
301
+ # @return [String] The call_sid
302
+ def call_sid
303
+ @properties['call_sid']
304
+ end
305
+
306
+ ##
307
+ # @return [String] The account_sid
308
+ def account_sid
309
+ @properties['account_sid']
310
+ end
311
+
312
+ ##
313
+ # @return [conference_participant.CallDirection] The call_direction
314
+ def call_direction
315
+ @properties['call_direction']
316
+ end
317
+
318
+ ##
319
+ # @return [String] The from
320
+ def from
321
+ @properties['from']
322
+ end
323
+
324
+ ##
325
+ # @return [String] The to
326
+ def to
327
+ @properties['to']
328
+ end
329
+
330
+ ##
331
+ # @return [conference_participant.CallState] The call_state
332
+ def call_state
333
+ @properties['call_state']
334
+ end
335
+
336
+ ##
337
+ # @return [String] The country_code
338
+ def country_code
339
+ @properties['country_code']
340
+ end
341
+
342
+ ##
343
+ # @return [Boolean] The is_moderator
344
+ def is_moderator
345
+ @properties['is_moderator']
346
+ end
347
+
348
+ ##
349
+ # @return [Time] The join_time
350
+ def join_time
351
+ @properties['join_time']
352
+ end
353
+
354
+ ##
355
+ # @return [Time] The leave_time
356
+ def leave_time
357
+ @properties['leave_time']
358
+ end
359
+
360
+ ##
361
+ # @return [String] The duration_seconds
362
+ def duration_seconds
363
+ @properties['duration_seconds']
364
+ end
365
+
366
+ ##
367
+ # @return [String] The whisper
368
+ def whisper
369
+ @properties['whisper']
370
+ end
371
+
372
+ ##
373
+ # @return [Boolean] The agent_audio
374
+ def agent_audio
375
+ @properties['agent_audio']
376
+ end
377
+
378
+ ##
379
+ # @return [String] The outbound_queue_length
380
+ def outbound_queue_length
381
+ @properties['outbound_queue_length']
382
+ end
383
+
384
+ ##
385
+ # @return [String] The outbound_time_in_queue
386
+ def outbound_time_in_queue
387
+ @properties['outbound_time_in_queue']
388
+ end
389
+
390
+ ##
391
+ # @return [conference_participant.JitterBufferSize] The jitter_buffer_size
392
+ def jitter_buffer_size
393
+ @properties['jitter_buffer_size']
394
+ end
395
+
396
+ ##
397
+ # @return [Boolean] The is_coach
398
+ def is_coach
399
+ @properties['is_coach']
400
+ end
401
+
402
+ ##
403
+ # @return [Array[String]] The coached_participants
404
+ def coached_participants
405
+ @properties['coached_participants']
406
+ end
407
+
408
+ ##
409
+ # @return [conference_participant.Region] The participant_region
410
+ def participant_region
411
+ @properties['participant_region']
412
+ end
413
+
414
+ ##
415
+ # @return [conference_participant.Region] The conference_region
416
+ def conference_region
417
+ @properties['conference_region']
418
+ end
419
+
420
+ ##
421
+ # @return [conference_participant.CallType] The call_type
422
+ def call_type
423
+ @properties['call_type']
424
+ end
425
+
426
+ ##
427
+ # @return [String] The quality_issues
428
+ def quality_issues
429
+ @properties['quality_issues']
430
+ end
431
+
432
+ ##
433
+ # @return [Hash] The properties
434
+ def properties
435
+ @properties['properties']
436
+ end
437
+
438
+ ##
439
+ # @return [Hash] The events
440
+ def events
441
+ @properties['events']
442
+ end
443
+
444
+ ##
445
+ # @return [Hash] The metrics
446
+ def metrics
447
+ @properties['metrics']
448
+ end
449
+
450
+ ##
451
+ # @return [String] The url
452
+ def url
453
+ @properties['url']
454
+ end
455
+
456
+ ##
457
+ # Fetch the ConferenceParticipantInstance
458
+ # @param [String] events The events
459
+ # @param [String] metrics The metrics
460
+ # @return [ConferenceParticipantInstance] Fetched ConferenceParticipantInstance
461
+ def fetch(events: :unset, metrics: :unset)
462
+ context.fetch(events: events, metrics: metrics, )
463
+ end
464
+
465
+ ##
466
+ # Provide a user friendly representation
467
+ def to_s
468
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
469
+ "<Twilio.Insights.V1.ConferenceParticipantInstance #{values}>"
470
+ end
471
+
472
+ ##
473
+ # Provide a detailed, user friendly representation
474
+ def inspect
475
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
476
+ "<Twilio.Insights.V1.ConferenceParticipantInstance #{values}>"
477
+ end
478
+ end
479
+ end
480
+ end
481
+ end
482
+ end
483
+ end