twilio-ruby 7.0.0.pre.rc.3 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,424 +0,0 @@
1
- ##
2
- # This code was generated by
3
- # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
- # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
- # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
- #
7
- # Twilio - Media
8
- # This is the public Twilio REST API.
9
- #
10
- # NOTE: This class is auto generated by OpenAPI Generator.
11
- # https://openapi-generator.tech
12
- # Do not edit the class manually.
13
- #
14
-
15
-
16
- module Twilio
17
- module REST
18
- class Media < MediaBase
19
- class V1 < Version
20
- class MediaProcessorList < ListResource
21
-
22
- ##
23
- # Initialize the MediaProcessorList
24
- # @param [Version] version Version that contains the resource
25
- # @return [MediaProcessorList] MediaProcessorList
26
- def initialize(version)
27
- super(version)
28
- # Path Solution
29
- @solution = { }
30
- @uri = "/MediaProcessors"
31
-
32
- end
33
- ##
34
- # Create the MediaProcessorInstance
35
- # @param [String] extension The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2`
36
- # @param [String] extension_context The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send.
37
- # @param [Object] extension_environment User-defined environment variables for the Media Extension, represented as a JSON dictionary of key/value strings. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about whether you need to provide this.
38
- # @param [String] status_callback The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details.
39
- # @param [String] status_callback_method The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
40
- # @param [String] max_duration The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming.
41
- # @return [MediaProcessorInstance] Created MediaProcessorInstance
42
- def create(
43
- extension: nil,
44
- extension_context: nil,
45
- extension_environment: :unset,
46
- status_callback: :unset,
47
- status_callback_method: :unset,
48
- max_duration: :unset
49
- )
50
-
51
- data = Twilio::Values.of({
52
- 'Extension' => extension,
53
- 'ExtensionContext' => extension_context,
54
- 'ExtensionEnvironment' => Twilio.serialize_object(extension_environment),
55
- 'StatusCallback' => status_callback,
56
- 'StatusCallbackMethod' => status_callback_method,
57
- 'MaxDuration' => max_duration,
58
- })
59
-
60
-
61
- payload = @version.create('POST', @uri, data: data)
62
- MediaProcessorInstance.new(
63
- @version,
64
- payload,
65
- )
66
- end
67
-
68
-
69
- ##
70
- # Lists MediaProcessorInstance 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 [Order] order The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
74
- # @param [Status] status Status to filter by, with possible values `started`, `ended` or `failed`.
75
- # @param [Integer] limit Upper limit for the number of records to return. stream()
76
- # guarantees to never return more than limit. Default is no limit
77
- # @param [Integer] page_size Number of records to fetch per request, when
78
- # not set will use the default value of 50 records. If no page_size is defined
79
- # but a limit is defined, stream() will attempt to read the limit with the most
80
- # efficient page size, i.e. min(limit, 1000)
81
- # @return [Array] Array of up to limit results
82
- def list(order: :unset, status: :unset, limit: nil, page_size: nil)
83
- self.stream(
84
- order: order,
85
- status: status,
86
- limit: limit,
87
- page_size: page_size
88
- ).entries
89
- end
90
-
91
- ##
92
- # Streams Instance records from the API as an Enumerable.
93
- # This operation lazily loads records as efficiently as possible until the limit
94
- # is reached.
95
- # @param [Order] order The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
96
- # @param [Status] status Status to filter by, with possible values `started`, `ended` or `failed`.
97
- # @param [Integer] limit Upper limit for the number of records to return. stream()
98
- # guarantees to never return more than limit. Default is no limit
99
- # @param [Integer] page_size Number of records to fetch per request, when
100
- # not set will use the default value of 50 records. If no page_size is defined
101
- # but a limit is defined, stream() will attempt to read the limit with the most
102
- # efficient page size, i.e. min(limit, 1000)
103
- # @return [Enumerable] Enumerable that will yield up to limit results
104
- def stream(order: :unset, status: :unset, limit: nil, page_size: nil)
105
- limits = @version.read_limits(limit, page_size)
106
-
107
- page = self.page(
108
- order: order,
109
- status: status,
110
- page_size: limits[:page_size], )
111
-
112
- @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
113
- end
114
-
115
- ##
116
- # When passed a block, yields MediaProcessorInstance records from the API.
117
- # This operation lazily loads records as efficiently as possible until the limit
118
- # is reached.
119
- def each
120
- limits = @version.read_limits
121
-
122
- page = self.page(page_size: limits[:page_size], )
123
-
124
- @version.stream(page,
125
- limit: limits[:limit],
126
- page_limit: limits[:page_limit]).each {|x| yield x}
127
- end
128
-
129
- ##
130
- # Retrieve a single page of MediaProcessorInstance records from the API.
131
- # Request is executed immediately.
132
- # @param [Order] order The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default.
133
- # @param [Status] status Status to filter by, with possible values `started`, `ended` or `failed`.
134
- # @param [String] page_token PageToken provided by the API
135
- # @param [Integer] page_number Page Number, this value is simply for client state
136
- # @param [Integer] page_size Number of records to return, defaults to 50
137
- # @return [Page] Page of MediaProcessorInstance
138
- def page(order: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
139
- params = Twilio::Values.of({
140
- 'Order' => order,
141
- 'Status' => status,
142
- 'PageToken' => page_token,
143
- 'Page' => page_number,
144
- 'PageSize' => page_size,
145
- })
146
-
147
- response = @version.page('GET', @uri, params: params)
148
-
149
- MediaProcessorPage.new(@version, response, @solution)
150
- end
151
-
152
- ##
153
- # Retrieve a single page of MediaProcessorInstance records from the API.
154
- # Request is executed immediately.
155
- # @param [String] target_url API-generated URL for the requested results page
156
- # @return [Page] Page of MediaProcessorInstance
157
- def get_page(target_url)
158
- response = @version.domain.request(
159
- 'GET',
160
- target_url
161
- )
162
- MediaProcessorPage.new(@version, response, @solution)
163
- end
164
-
165
-
166
-
167
- # Provide a user friendly representation
168
- def to_s
169
- '#<Twilio.Media.V1.MediaProcessorList>'
170
- end
171
- end
172
-
173
-
174
- class MediaProcessorContext < InstanceContext
175
- ##
176
- # Initialize the MediaProcessorContext
177
- # @param [Version] version Version that contains the resource
178
- # @param [String] sid The SID of the MediaProcessor resource to update.
179
- # @return [MediaProcessorContext] MediaProcessorContext
180
- def initialize(version, sid)
181
- super(version)
182
-
183
- # Path Solution
184
- @solution = { sid: sid, }
185
- @uri = "/MediaProcessors/#{@solution[:sid]}"
186
-
187
-
188
- end
189
- ##
190
- # Fetch the MediaProcessorInstance
191
- # @return [MediaProcessorInstance] Fetched MediaProcessorInstance
192
- def fetch
193
-
194
-
195
- payload = @version.fetch('GET', @uri)
196
- MediaProcessorInstance.new(
197
- @version,
198
- payload,
199
- sid: @solution[:sid],
200
- )
201
- end
202
-
203
- ##
204
- # Update the MediaProcessorInstance
205
- # @param [UpdateStatus] status
206
- # @return [MediaProcessorInstance] Updated MediaProcessorInstance
207
- def update(
208
- status: nil
209
- )
210
-
211
- data = Twilio::Values.of({
212
- 'Status' => status,
213
- })
214
-
215
-
216
- payload = @version.update('POST', @uri, data: data)
217
- MediaProcessorInstance.new(
218
- @version,
219
- payload,
220
- sid: @solution[:sid],
221
- )
222
- end
223
-
224
-
225
- ##
226
- # Provide a user friendly representation
227
- def to_s
228
- context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
229
- "#<Twilio.Media.V1.MediaProcessorContext #{context}>"
230
- end
231
-
232
- ##
233
- # Provide a detailed, user friendly representation
234
- def inspect
235
- context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
236
- "#<Twilio.Media.V1.MediaProcessorContext #{context}>"
237
- end
238
- end
239
-
240
- class MediaProcessorPage < Page
241
- ##
242
- # Initialize the MediaProcessorPage
243
- # @param [Version] version Version that contains the resource
244
- # @param [Response] response Response from the API
245
- # @param [Hash] solution Path solution for the resource
246
- # @return [MediaProcessorPage] MediaProcessorPage
247
- def initialize(version, response, solution)
248
- super(version, response)
249
-
250
- # Path Solution
251
- @solution = solution
252
- end
253
-
254
- ##
255
- # Build an instance of MediaProcessorInstance
256
- # @param [Hash] payload Payload response from the API
257
- # @return [MediaProcessorInstance] MediaProcessorInstance
258
- def get_instance(payload)
259
- MediaProcessorInstance.new(@version, payload)
260
- end
261
-
262
- ##
263
- # Provide a user friendly representation
264
- def to_s
265
- '<Twilio.Media.V1.MediaProcessorPage>'
266
- end
267
- end
268
- class MediaProcessorInstance < InstanceResource
269
- ##
270
- # Initialize the MediaProcessorInstance
271
- # @param [Version] version Version that contains the resource
272
- # @param [Hash] payload payload that contains response from Twilio
273
- # @param [String] account_sid The SID of the
274
- # {Account}[https://www.twilio.com/docs/iam/api/account] that created this MediaProcessor
275
- # resource.
276
- # @param [String] sid The SID of the Call resource to fetch.
277
- # @return [MediaProcessorInstance] MediaProcessorInstance
278
- def initialize(version, payload , sid: nil)
279
- super(version)
280
-
281
- # Marshaled Properties
282
- @properties = {
283
- 'account_sid' => payload['account_sid'],
284
- 'sid' => payload['sid'],
285
- 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
286
- 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
287
- 'extension' => payload['extension'],
288
- 'extension_context' => payload['extension_context'],
289
- 'status' => payload['status'],
290
- 'url' => payload['url'],
291
- 'ended_reason' => payload['ended_reason'],
292
- 'status_callback' => payload['status_callback'],
293
- 'status_callback_method' => payload['status_callback_method'],
294
- 'max_duration' => payload['max_duration'] == nil ? payload['max_duration'] : payload['max_duration'].to_i,
295
- }
296
-
297
- # Context
298
- @instance_context = nil
299
- @params = { 'sid' => sid || @properties['sid'] , }
300
- end
301
-
302
- ##
303
- # Generate an instance context for the instance, the context is capable of
304
- # performing various actions. All instance actions are proxied to the context
305
- # @return [MediaProcessorContext] CallContext for this CallInstance
306
- def context
307
- unless @instance_context
308
- @instance_context = MediaProcessorContext.new(@version , @params['sid'])
309
- end
310
- @instance_context
311
- end
312
-
313
- ##
314
- # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MediaProcessor resource.
315
- def account_sid
316
- @properties['account_sid']
317
- end
318
-
319
- ##
320
- # @return [String] The unique string generated to identify the MediaProcessor resource.
321
- def sid
322
- @properties['sid']
323
- end
324
-
325
- ##
326
- # @return [Time] The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
327
- def date_created
328
- @properties['date_created']
329
- end
330
-
331
- ##
332
- # @return [Time] The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
333
- def date_updated
334
- @properties['date_updated']
335
- end
336
-
337
- ##
338
- # @return [String] The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2`
339
- def extension
340
- @properties['extension']
341
- end
342
-
343
- ##
344
- # @return [String] The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send.
345
- def extension_context
346
- @properties['extension_context']
347
- end
348
-
349
- ##
350
- # @return [Status]
351
- def status
352
- @properties['status']
353
- end
354
-
355
- ##
356
- # @return [String] The absolute URL of the resource.
357
- def url
358
- @properties['url']
359
- end
360
-
361
- ##
362
- # @return [String] The reason why a MediaProcessor ended. When a MediaProcessor is in progress, will be `null`. When a MediaProcessor is completed, can be `ended-via-api`, `max-duration-exceeded`, `error-loading-extension`, `error-streaming-media` or `internal-service-error`. See [ended reasons](/docs/live/api/mediaprocessors#mediaprocessor-ended-reason-values) for more details.
363
- def ended_reason
364
- @properties['ended_reason']
365
- end
366
-
367
- ##
368
- # @return [String] The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details.
369
- def status_callback
370
- @properties['status_callback']
371
- end
372
-
373
- ##
374
- # @return [String] The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`.
375
- def status_callback_method
376
- @properties['status_callback_method']
377
- end
378
-
379
- ##
380
- # @return [String] The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming.
381
- def max_duration
382
- @properties['max_duration']
383
- end
384
-
385
- ##
386
- # Fetch the MediaProcessorInstance
387
- # @return [MediaProcessorInstance] Fetched MediaProcessorInstance
388
- def fetch
389
-
390
- context.fetch
391
- end
392
-
393
- ##
394
- # Update the MediaProcessorInstance
395
- # @param [UpdateStatus] status
396
- # @return [MediaProcessorInstance] Updated MediaProcessorInstance
397
- def update(
398
- status: nil
399
- )
400
-
401
- context.update(
402
- status: status,
403
- )
404
- end
405
-
406
- ##
407
- # Provide a user friendly representation
408
- def to_s
409
- values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
410
- "<Twilio.Media.V1.MediaProcessorInstance #{values}>"
411
- end
412
-
413
- ##
414
- # Provide a detailed, user friendly representation
415
- def inspect
416
- values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
417
- "<Twilio.Media.V1.MediaProcessorInstance #{values}>"
418
- end
419
- end
420
-
421
- end
422
- end
423
- end
424
- end