twilio-ruby 5.6.1 → 5.6.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.
@@ -26,6 +26,14 @@ module Twilio
26
26
  @v1 ||= V1.new self
27
27
  end
28
28
 
29
+ ##
30
+ # @param [String] sid The sid
31
+ # @return [Twilio::REST::Video::V1::CompositionInstance] if sid was passed.
32
+ # @return [Twilio::REST::Video::V1::CompositionList]
33
+ def compositions(sid=:unset)
34
+ self.v1.compositions(sid)
35
+ end
36
+
29
37
  ##
30
38
  # @param [String] sid The sid
31
39
  # @return [Twilio::REST::Video::V1::RecordingInstance] if sid was passed.
@@ -13,10 +13,25 @@ module Twilio
13
13
  def initialize(domain)
14
14
  super
15
15
  @version = 'v1'
16
+ @compositions = nil
16
17
  @recordings = nil
17
18
  @rooms = nil
18
19
  end
19
20
 
21
+ ##
22
+ # @param [String] sid The sid
23
+ # @return [Twilio::REST::Video::V1::CompositionContext] if sid was passed.
24
+ # @return [Twilio::REST::Video::V1::CompositionList]
25
+ def compositions(sid=:unset)
26
+ if sid.nil?
27
+ raise ArgumentError, 'sid cannot be nil'
28
+ elsif sid == :unset
29
+ @compositions ||= CompositionList.new self
30
+ else
31
+ CompositionContext.new(self, sid)
32
+ end
33
+ end
34
+
20
35
  ##
21
36
  # @param [String] sid The sid
22
37
  # @return [Twilio::REST::Video::V1::RecordingContext] if sid was passed.
@@ -0,0 +1,425 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Video < Domain
10
+ class V1 < Version
11
+ ##
12
+ # 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.
13
+ class CompositionList < ListResource
14
+ ##
15
+ # Initialize the CompositionList
16
+ # @param [Version] version Version that contains the resource
17
+ # @return [CompositionList] CompositionList
18
+ def initialize(version)
19
+ super(version)
20
+
21
+ # Path Solution
22
+ @solution = {}
23
+ @uri = "/Compositions"
24
+ end
25
+
26
+ ##
27
+ # Lists CompositionInstance records from the API as a list.
28
+ # Unlike stream(), this operation is eager and will load `limit` records into
29
+ # memory before returning.
30
+ # @param [composition.Status] status The status
31
+ # @param [Time] date_created_after The date_created_after
32
+ # @param [Time] date_created_before The date_created_before
33
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
34
+ # guarantees to never return more than limit. Default is no limit
35
+ # @param [Integer] page_size Number of records to fetch per request, when
36
+ # not set will use the default value of 50 records. If no page_size is defined
37
+ # but a limit is defined, stream() will attempt to read the limit with the most
38
+ # efficient page size, i.e. min(limit, 1000)
39
+ # @return [Array] Array of up to limit results
40
+ def list(status: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil)
41
+ self.stream(
42
+ status: status,
43
+ date_created_after: date_created_after,
44
+ date_created_before: date_created_before,
45
+ limit: limit,
46
+ page_size: page_size
47
+ ).entries
48
+ end
49
+
50
+ ##
51
+ # Streams CompositionInstance records from the API as an Enumerable.
52
+ # This operation lazily loads records as efficiently as possible until the limit
53
+ # is reached.
54
+ # @param [composition.Status] status The status
55
+ # @param [Time] date_created_after The date_created_after
56
+ # @param [Time] date_created_before The date_created_before
57
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
58
+ # guarantees to never return more than limit. Default is no limit.
59
+ # @param [Integer] page_size Number of records to fetch per request, when
60
+ # not set will use the default value of 50 records. If no page_size is defined
61
+ # but a limit is defined, stream() will attempt to read the limit with the most
62
+ # efficient page size, i.e. min(limit, 1000)
63
+ # @return [Enumerable] Enumerable that will yield up to limit results
64
+ def stream(status: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil)
65
+ limits = @version.read_limits(limit, page_size)
66
+
67
+ page = self.page(
68
+ status: status,
69
+ date_created_after: date_created_after,
70
+ date_created_before: date_created_before,
71
+ page_size: limits[:page_size],
72
+ )
73
+
74
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
75
+ end
76
+
77
+ ##
78
+ # When passed a block, yields CompositionInstance records from the API.
79
+ # This operation lazily loads records as efficiently as possible until the limit
80
+ # is reached.
81
+ def each
82
+ limits = @version.read_limits
83
+
84
+ page = self.page(page_size: limits[:page_size], )
85
+
86
+ @version.stream(page,
87
+ limit: limits[:limit],
88
+ page_limit: limits[:page_limit]).each {|x| yield x}
89
+ end
90
+
91
+ ##
92
+ # Retrieve a single page of CompositionInstance records from the API.
93
+ # Request is executed immediately.
94
+ # @param [composition.Status] status The status
95
+ # @param [Time] date_created_after The date_created_after
96
+ # @param [Time] date_created_before The date_created_before
97
+ # @param [String] page_token PageToken provided by the API
98
+ # @param [Integer] page_number Page Number, this value is simply for client state
99
+ # @param [Integer] page_size Number of records to return, defaults to 50
100
+ # @return [Page] Page of CompositionInstance
101
+ def page(status: :unset, date_created_after: :unset, date_created_before: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
102
+ params = Twilio::Values.of({
103
+ 'Status' => status,
104
+ 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after),
105
+ 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before),
106
+ 'PageToken' => page_token,
107
+ 'Page' => page_number,
108
+ 'PageSize' => page_size,
109
+ })
110
+ response = @version.page(
111
+ 'GET',
112
+ @uri,
113
+ params
114
+ )
115
+ CompositionPage.new(@version, response, @solution)
116
+ end
117
+
118
+ ##
119
+ # Retrieve a single page of CompositionInstance 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 CompositionInstance
123
+ def get_page(target_url)
124
+ response = @version.domain.request(
125
+ 'GET',
126
+ target_url
127
+ )
128
+ CompositionPage.new(@version, response, @solution)
129
+ end
130
+
131
+ ##
132
+ # Retrieve a single page of CompositionInstance records from the API.
133
+ # Request is executed immediately.
134
+ # @param [String] audio_sources The audio_sources
135
+ # @param [String] video_sources The video_sources
136
+ # @param [composition.VideoLayout] video_layout The video_layout
137
+ # @param [String] resolution The resolution
138
+ # @param [composition.Format] format The format
139
+ # @param [String] desired_bitrate The desired_bitrate
140
+ # @param [String] desired_max_duration The desired_max_duration
141
+ # @param [String] status_callback The status_callback
142
+ # @param [String] status_callback_method The status_callback_method
143
+ # @return [CompositionInstance] Newly created CompositionInstance
144
+ def create(audio_sources: :unset, video_sources: :unset, video_layout: :unset, resolution: :unset, format: :unset, desired_bitrate: :unset, desired_max_duration: :unset, status_callback: :unset, status_callback_method: :unset)
145
+ data = Twilio::Values.of({
146
+ 'AudioSources' => Twilio.serialize_list(audio_sources) { |e| e },
147
+ 'VideoSources' => Twilio.serialize_list(video_sources) { |e| e },
148
+ 'VideoLayout' => video_layout,
149
+ 'Resolution' => resolution,
150
+ 'Format' => format,
151
+ 'DesiredBitrate' => desired_bitrate,
152
+ 'DesiredMaxDuration' => desired_max_duration,
153
+ 'StatusCallback' => status_callback,
154
+ 'StatusCallbackMethod' => status_callback_method,
155
+ })
156
+
157
+ payload = @version.create(
158
+ 'POST',
159
+ @uri,
160
+ data: data
161
+ )
162
+
163
+ CompositionInstance.new(@version, payload, )
164
+ end
165
+
166
+ ##
167
+ # Provide a user friendly representation
168
+ def to_s
169
+ '#<Twilio.Video.V1.CompositionList>'
170
+ end
171
+ end
172
+
173
+ ##
174
+ # 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.
175
+ class CompositionPage < Page
176
+ ##
177
+ # Initialize the CompositionPage
178
+ # @param [Version] version Version that contains the resource
179
+ # @param [Response] response Response from the API
180
+ # @param [Hash] solution Path solution for the resource
181
+ # @return [CompositionPage] CompositionPage
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 CompositionInstance
191
+ # @param [Hash] payload Payload response from the API
192
+ # @return [CompositionInstance] CompositionInstance
193
+ def get_instance(payload)
194
+ CompositionInstance.new(@version, payload, )
195
+ end
196
+
197
+ ##
198
+ # Provide a user friendly representation
199
+ def to_s
200
+ '<Twilio.Video.V1.CompositionPage>'
201
+ end
202
+ end
203
+
204
+ ##
205
+ # 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.
206
+ class CompositionContext < InstanceContext
207
+ ##
208
+ # Initialize the CompositionContext
209
+ # @param [Version] version Version that contains the resource
210
+ # @param [String] sid The sid
211
+ # @return [CompositionContext] CompositionContext
212
+ def initialize(version, sid)
213
+ super(version)
214
+
215
+ # Path Solution
216
+ @solution = {sid: sid, }
217
+ @uri = "/Compositions/#{@solution[:sid]}"
218
+ end
219
+
220
+ ##
221
+ # Fetch a CompositionInstance
222
+ # @return [CompositionInstance] Fetched CompositionInstance
223
+ def fetch
224
+ params = Twilio::Values.of({})
225
+
226
+ payload = @version.fetch(
227
+ 'GET',
228
+ @uri,
229
+ params,
230
+ )
231
+
232
+ CompositionInstance.new(@version, payload, sid: @solution[:sid], )
233
+ end
234
+
235
+ ##
236
+ # Deletes the CompositionInstance
237
+ # @return [Boolean] true if delete succeeds, true otherwise
238
+ def delete
239
+ @version.delete('delete', @uri)
240
+ end
241
+
242
+ ##
243
+ # Provide a user friendly representation
244
+ def to_s
245
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
246
+ "#<Twilio.Video.V1.CompositionContext #{context}>"
247
+ end
248
+ end
249
+
250
+ ##
251
+ # 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.
252
+ class CompositionInstance < InstanceResource
253
+ ##
254
+ # Initialize the CompositionInstance
255
+ # @param [Version] version Version that contains the resource
256
+ # @param [Hash] payload payload that contains response from Twilio
257
+ # @param [String] sid The sid
258
+ # @return [CompositionInstance] CompositionInstance
259
+ def initialize(version, payload, sid: nil)
260
+ super(version)
261
+
262
+ # Marshaled Properties
263
+ @properties = {
264
+ 'account_sid' => payload['account_sid'],
265
+ 'status' => payload['status'],
266
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
267
+ 'date_completed' => payload['date_completed'],
268
+ 'date_deleted' => payload['date_deleted'],
269
+ 'sid' => payload['sid'],
270
+ 'audio_sources' => payload['audio_sources'],
271
+ 'video_sources' => payload['video_sources'],
272
+ 'video_layout' => payload['video_layout'],
273
+ 'resolution' => payload['resolution'],
274
+ 'format' => payload['format'],
275
+ 'bitrate' => payload['bitrate'].to_i,
276
+ 'size' => payload['size'].to_i,
277
+ 'duration' => payload['duration'].to_i,
278
+ 'url' => payload['url'],
279
+ 'links' => payload['links'],
280
+ }
281
+
282
+ # Context
283
+ @instance_context = nil
284
+ @params = {'sid' => sid || @properties['sid'], }
285
+ end
286
+
287
+ ##
288
+ # Generate an instance context for the instance, the context is capable of
289
+ # performing various actions. All instance actions are proxied to the context
290
+ # @return [CompositionContext] CompositionContext for this CompositionInstance
291
+ def context
292
+ unless @instance_context
293
+ @instance_context = CompositionContext.new(@version, @params['sid'], )
294
+ end
295
+ @instance_context
296
+ end
297
+
298
+ ##
299
+ # @return [String] The account_sid
300
+ def account_sid
301
+ @properties['account_sid']
302
+ end
303
+
304
+ ##
305
+ # @return [composition.Status] The status
306
+ def status
307
+ @properties['status']
308
+ end
309
+
310
+ ##
311
+ # @return [Time] The date_created
312
+ def date_created
313
+ @properties['date_created']
314
+ end
315
+
316
+ ##
317
+ # @return [String] The date_completed
318
+ def date_completed
319
+ @properties['date_completed']
320
+ end
321
+
322
+ ##
323
+ # @return [String] The date_deleted
324
+ def date_deleted
325
+ @properties['date_deleted']
326
+ end
327
+
328
+ ##
329
+ # @return [String] The sid
330
+ def sid
331
+ @properties['sid']
332
+ end
333
+
334
+ ##
335
+ # @return [String] The audio_sources
336
+ def audio_sources
337
+ @properties['audio_sources']
338
+ end
339
+
340
+ ##
341
+ # @return [String] The video_sources
342
+ def video_sources
343
+ @properties['video_sources']
344
+ end
345
+
346
+ ##
347
+ # @return [composition.VideoLayout] The video_layout
348
+ def video_layout
349
+ @properties['video_layout']
350
+ end
351
+
352
+ ##
353
+ # @return [String] The resolution
354
+ def resolution
355
+ @properties['resolution']
356
+ end
357
+
358
+ ##
359
+ # @return [composition.Format] The format
360
+ def format
361
+ @properties['format']
362
+ end
363
+
364
+ ##
365
+ # @return [String] The bitrate
366
+ def bitrate
367
+ @properties['bitrate']
368
+ end
369
+
370
+ ##
371
+ # @return [String] The size
372
+ def size
373
+ @properties['size']
374
+ end
375
+
376
+ ##
377
+ # @return [String] The duration
378
+ def duration
379
+ @properties['duration']
380
+ end
381
+
382
+ ##
383
+ # @return [String] The url
384
+ def url
385
+ @properties['url']
386
+ end
387
+
388
+ ##
389
+ # @return [String] The links
390
+ def links
391
+ @properties['links']
392
+ end
393
+
394
+ ##
395
+ # Fetch a CompositionInstance
396
+ # @return [CompositionInstance] Fetched CompositionInstance
397
+ def fetch
398
+ context.fetch
399
+ end
400
+
401
+ ##
402
+ # Deletes the CompositionInstance
403
+ # @return [Boolean] true if delete succeeds, true otherwise
404
+ def delete
405
+ context.delete
406
+ end
407
+
408
+ ##
409
+ # Provide a user friendly representation
410
+ def to_s
411
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
412
+ "<Twilio.Video.V1.CompositionInstance #{values}>"
413
+ end
414
+
415
+ ##
416
+ # Provide a detailed, user friendly representation
417
+ def inspect
418
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
419
+ "<Twilio.Video.V1.CompositionInstance #{values}>"
420
+ end
421
+ end
422
+ end
423
+ end
424
+ end
425
+ end