twilio 3.68.0 → 3.71.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.
Files changed (85) hide show
  1. package/CHANGES.md +104 -0
  2. package/README.md +1 -1
  3. package/lib/jwt/AccessToken.d.ts +16 -0
  4. package/lib/jwt/AccessToken.js +20 -0
  5. package/lib/jwt/ClientCapability.d.ts +1 -1
  6. package/lib/rest/Media.d.ts +28 -0
  7. package/lib/rest/Media.js +64 -0
  8. package/lib/rest/Twilio.d.ts +2 -0
  9. package/lib/rest/Twilio.js +14 -0
  10. package/lib/rest/Verify.d.ts +2 -2
  11. package/lib/rest/Verify.js +3 -4
  12. package/lib/rest/api/v2010/account/call/siprec.d.ts +776 -0
  13. package/lib/rest/api/v2010/account/call/siprec.js +811 -0
  14. package/lib/rest/api/v2010/account/call.d.ts +8 -1
  15. package/lib/rest/api/v2010/account/call.js +29 -1
  16. package/lib/rest/api/v2010/account/incomingPhoneNumber/local.d.ts +6 -2
  17. package/lib/rest/api/v2010/account/incomingPhoneNumber/local.js +5 -2
  18. package/lib/rest/api/v2010/account/incomingPhoneNumber/mobile.d.ts +6 -2
  19. package/lib/rest/api/v2010/account/incomingPhoneNumber/mobile.js +5 -2
  20. package/lib/rest/api/v2010/account/incomingPhoneNumber/tollFree.d.ts +6 -2
  21. package/lib/rest/api/v2010/account/incomingPhoneNumber/tollFree.js +5 -2
  22. package/lib/rest/api/v2010/account/incomingPhoneNumber.d.ts +7 -3
  23. package/lib/rest/api/v2010/account/incomingPhoneNumber.js +7 -4
  24. package/lib/rest/conversations/v1/service/configuration/notification.d.ts +6 -0
  25. package/lib/rest/conversations/v1/service/configuration/notification.js +11 -1
  26. package/lib/rest/flexApi/v1/configuration.d.ts +2 -0
  27. package/lib/rest/flexApi/v1/configuration.js +2 -0
  28. package/lib/rest/frontlineApi/v1/user.d.ts +4 -0
  29. package/lib/rest/frontlineApi/v1/user.js +10 -1
  30. package/lib/rest/insights/v1/callSummaries.d.ts +27 -27
  31. package/lib/rest/insights/v1/callSummaries.js +36 -36
  32. package/lib/rest/media/V1.d.ts +28 -0
  33. package/lib/rest/media/V1.js +59 -0
  34. package/lib/rest/media/v1/mediaProcessor.d.ts +355 -0
  35. package/lib/rest/media/v1/mediaProcessor.js +702 -0
  36. package/lib/rest/media/v1/playerStreamer/playbackGrant.d.ts +162 -0
  37. package/lib/rest/media/v1/playerStreamer/playbackGrant.js +384 -0
  38. package/lib/rest/media/v1/playerStreamer.d.ts +366 -0
  39. package/lib/rest/media/v1/playerStreamer.js +729 -0
  40. package/lib/rest/messaging/v1/brandRegistration/brandVetting.d.ts +330 -0
  41. package/lib/rest/messaging/v1/brandRegistration/brandVetting.js +655 -0
  42. package/lib/rest/messaging/v1/brandRegistration.d.ts +15 -2
  43. package/lib/rest/messaging/v1/brandRegistration.js +37 -1
  44. package/lib/rest/messaging/v1/service.d.ts +8 -0
  45. package/lib/rest/messaging/v1/service.js +14 -0
  46. package/lib/rest/numbers/v2/regulatoryCompliance/bundle/bundleCopy.d.ts +133 -0
  47. package/lib/rest/numbers/v2/regulatoryCompliance/bundle/bundleCopy.js +268 -0
  48. package/lib/rest/numbers/v2/regulatoryCompliance/bundle/replaceItems.d.ts +127 -0
  49. package/lib/rest/numbers/v2/regulatoryCompliance/bundle/replaceItems.js +271 -0
  50. package/lib/rest/numbers/v2/regulatoryCompliance/bundle.d.ts +14 -0
  51. package/lib/rest/numbers/v2/regulatoryCompliance/bundle.js +56 -0
  52. package/lib/rest/serverless/v1/service/build.d.ts +1 -1
  53. package/lib/rest/serverless/v1/service/environment.js +1 -1
  54. package/lib/rest/serverless/v1/service.d.ts +2 -0
  55. package/lib/rest/serverless/v1/service.js +3 -0
  56. package/lib/rest/taskrouter/v1/workspace/task/reservation.d.ts +2 -0
  57. package/lib/rest/taskrouter/v1/workspace/task/reservation.js +4 -1
  58. package/lib/rest/taskrouter/v1/workspace/worker/reservation.d.ts +2 -0
  59. package/lib/rest/taskrouter/v1/workspace/worker/reservation.js +4 -1
  60. package/lib/rest/taskrouter/v1/workspace/worker.d.ts +27 -2
  61. package/lib/rest/taskrouter/v1/workspace/worker.js +22 -7
  62. package/lib/rest/trunking/v1/trunk.d.ts +9 -1
  63. package/lib/rest/trunking/v1/trunk.js +13 -2
  64. package/lib/rest/verify/V2.d.ts +3 -3
  65. package/lib/rest/verify/V2.js +6 -8
  66. package/lib/rest/verify/v2/service/entity/factor.d.ts +4 -2
  67. package/lib/rest/verify/v2/service/entity/factor.js +8 -3
  68. package/lib/rest/verify/v2/service/entity/newFactor.d.ts +2 -2
  69. package/lib/rest/verify/v2/service/entity/newFactor.js +1 -1
  70. package/lib/rest/verify/v2/service/verification.d.ts +5 -1
  71. package/lib/rest/verify/v2/service/verification.js +7 -2
  72. package/lib/rest/verify/v2/service.d.ts +6 -0
  73. package/lib/rest/verify/v2/service.js +12 -2
  74. package/lib/rest/verify/v2/{verificationTemplate.d.ts → template.d.ts} +35 -37
  75. package/lib/rest/verify/v2/{verificationTemplate.js → template.js} +58 -64
  76. package/lib/rest/verify/v2/verificationAttempt.d.ts +1 -1
  77. package/lib/rest/video/v1/room.d.ts +4 -0
  78. package/lib/rest/video/v1/room.js +7 -1
  79. package/lib/rest/wireless/v1/ratePlan.d.ts +1 -1
  80. package/lib/rest/wireless/v1/ratePlan.js +3 -3
  81. package/lib/rest/wireless/v1/sim.d.ts +4 -4
  82. package/lib/rest/wireless/v1/sim.js +18 -24
  83. package/lib/twiml/VoiceResponse.d.ts +1296 -24
  84. package/lib/twiml/VoiceResponse.js +2170 -82
  85. package/package.json +2 -2
@@ -0,0 +1,702 @@
1
+ 'use strict';
2
+
3
+ /* jshint ignore:start */
4
+ /**
5
+ * This code was generated by
6
+ * \ / _ _ _| _ _
7
+ * | (_)\/(_)(_|\/| |(/_ v1.0.0
8
+ * / /
9
+ */
10
+ /* jshint ignore:end */
11
+
12
+ var Q = require('q'); /* jshint ignore:line */
13
+ var _ = require('lodash'); /* jshint ignore:line */
14
+ var util = require('util'); /* jshint ignore:line */
15
+ var Page = require('../../../base/Page'); /* jshint ignore:line */
16
+ var deserialize = require(
17
+ '../../../base/deserialize'); /* jshint ignore:line */
18
+ var serialize = require('../../../base/serialize'); /* jshint ignore:line */
19
+ var values = require('../../../base/values'); /* jshint ignore:line */
20
+
21
+ var MediaProcessorList;
22
+ var MediaProcessorPage;
23
+ var MediaProcessorInstance;
24
+ var MediaProcessorContext;
25
+
26
+ /* jshint ignore:start */
27
+ /**
28
+ * Initialize the MediaProcessorList
29
+ *
30
+ * @constructor Twilio.Media.V1.MediaProcessorList
31
+ *
32
+ * @param {Twilio.Media.V1} version - Version of the resource
33
+ */
34
+ /* jshint ignore:end */
35
+ MediaProcessorList = function MediaProcessorList(version) {
36
+ /* jshint ignore:start */
37
+ /**
38
+ * @function mediaProcessor
39
+ * @memberof Twilio.Media.V1#
40
+ *
41
+ * @param {string} sid - sid of instance
42
+ *
43
+ * @returns {Twilio.Media.V1.MediaProcessorContext}
44
+ */
45
+ /* jshint ignore:end */
46
+ function MediaProcessorListInstance(sid) {
47
+ return MediaProcessorListInstance.get(sid);
48
+ }
49
+
50
+ MediaProcessorListInstance._version = version;
51
+ // Path Solution
52
+ MediaProcessorListInstance._solution = {};
53
+ MediaProcessorListInstance._uri = `/MediaProcessors`;
54
+ /* jshint ignore:start */
55
+ /**
56
+ * create a MediaProcessorInstance
57
+ *
58
+ * @function create
59
+ * @memberof Twilio.Media.V1.MediaProcessorList#
60
+ *
61
+ * @param {object} opts - Options for request
62
+ * @param {string} opts.extension - The Media Extension name or URL
63
+ * @param {string} opts.extensionContext - The Media Extension context
64
+ * @param {object} [opts.extensionEnvironment] - The Media Extension environment
65
+ * @param {string} [opts.statusCallback] -
66
+ * The URL to send MediaProcessor event updates to your application
67
+ * @param {string} [opts.statusCallbackMethod] -
68
+ * The HTTP method Twilio should use to call the `status_callback` URL
69
+ * @param {function} [callback] - Callback to handle processed record
70
+ *
71
+ * @returns {Promise} Resolves to processed MediaProcessorInstance
72
+ */
73
+ /* jshint ignore:end */
74
+ MediaProcessorListInstance.create = function create(opts, callback) {
75
+ if (_.isUndefined(opts)) {
76
+ throw new Error('Required parameter "opts" missing.');
77
+ }
78
+ if (_.isUndefined(opts.extension)) {
79
+ throw new Error('Required parameter "opts.extension" missing.');
80
+ }
81
+ if (_.isUndefined(opts.extensionContext)) {
82
+ throw new Error('Required parameter "opts.extensionContext" missing.');
83
+ }
84
+
85
+ var deferred = Q.defer();
86
+ var data = values.of({
87
+ 'Extension': _.get(opts, 'extension'),
88
+ 'ExtensionContext': _.get(opts, 'extensionContext'),
89
+ 'ExtensionEnvironment': serialize.object(_.get(opts, 'extensionEnvironment')),
90
+ 'StatusCallback': _.get(opts, 'statusCallback'),
91
+ 'StatusCallbackMethod': _.get(opts, 'statusCallbackMethod')
92
+ });
93
+
94
+ var promise = this._version.create({uri: this._uri, method: 'POST', data: data});
95
+
96
+ promise = promise.then(function(payload) {
97
+ deferred.resolve(new MediaProcessorInstance(this._version, payload, this._solution.sid));
98
+ }.bind(this));
99
+
100
+ promise.catch(function(error) {
101
+ deferred.reject(error);
102
+ });
103
+
104
+ if (_.isFunction(callback)) {
105
+ deferred.promise.nodeify(callback);
106
+ }
107
+
108
+ return deferred.promise;
109
+ };
110
+
111
+ /* jshint ignore:start */
112
+ /**
113
+ * Streams MediaProcessorInstance records from the API.
114
+ *
115
+ * This operation lazily loads records as efficiently as possible until the limit
116
+ * is reached.
117
+ *
118
+ * The results are passed into the callback function, so this operation is memory
119
+ * efficient.
120
+ *
121
+ * If a function is passed as the first argument, it will be used as the callback
122
+ * function.
123
+ *
124
+ * @function each
125
+ * @memberof Twilio.Media.V1.MediaProcessorList#
126
+ *
127
+ * @param {object} [opts] - Options for request
128
+ * @param {media_processor.order} [opts.order] - The sort order of the list
129
+ * @param {media_processor.status} [opts.status] - Status to filter by
130
+ * @param {number} [opts.limit] -
131
+ * Upper limit for the number of records to return.
132
+ * each() guarantees never to return more than limit.
133
+ * Default is no limit
134
+ * @param {number} [opts.pageSize] -
135
+ * Number of records to fetch per request,
136
+ * when not set will use the default value of 50 records.
137
+ * If no pageSize is defined but a limit is defined,
138
+ * each() will attempt to read the limit with the most efficient
139
+ * page size, i.e. min(limit, 1000)
140
+ * @param {Function} [opts.callback] -
141
+ * Function to process each record. If this and a positional
142
+ * callback are passed, this one will be used
143
+ * @param {Function} [opts.done] -
144
+ * Function to be called upon completion of streaming
145
+ * @param {Function} [callback] - Function to process each record
146
+ */
147
+ /* jshint ignore:end */
148
+ MediaProcessorListInstance.each = function each(opts, callback) {
149
+ if (_.isFunction(opts)) {
150
+ callback = opts;
151
+ opts = {};
152
+ }
153
+ opts = opts || {};
154
+ if (opts.callback) {
155
+ callback = opts.callback;
156
+ }
157
+ if (_.isUndefined(callback)) {
158
+ throw new Error('Callback function must be provided');
159
+ }
160
+
161
+ var done = false;
162
+ var currentPage = 1;
163
+ var currentResource = 0;
164
+ var limits = this._version.readLimits({
165
+ limit: opts.limit,
166
+ pageSize: opts.pageSize
167
+ });
168
+
169
+ function onComplete(error) {
170
+ done = true;
171
+ if (_.isFunction(opts.done)) {
172
+ opts.done(error);
173
+ }
174
+ }
175
+
176
+ function fetchNextPage(fn) {
177
+ var promise = fn();
178
+ if (_.isUndefined(promise)) {
179
+ onComplete();
180
+ return;
181
+ }
182
+
183
+ promise.then(function(page) {
184
+ _.each(page.instances, function(instance) {
185
+ if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) {
186
+ done = true;
187
+ return false;
188
+ }
189
+
190
+ currentResource++;
191
+ callback(instance, onComplete);
192
+ });
193
+
194
+ if (!done) {
195
+ currentPage++;
196
+ fetchNextPage(_.bind(page.nextPage, page));
197
+ }
198
+ });
199
+
200
+ promise.catch(onComplete);
201
+ }
202
+
203
+ fetchNextPage(_.bind(this.page, this, _.merge(opts, limits)));
204
+ };
205
+
206
+ /* jshint ignore:start */
207
+ /**
208
+ * Lists MediaProcessorInstance records from the API as a list.
209
+ *
210
+ * If a function is passed as the first argument, it will be used as the callback
211
+ * function.
212
+ *
213
+ * @function list
214
+ * @memberof Twilio.Media.V1.MediaProcessorList#
215
+ *
216
+ * @param {object} [opts] - Options for request
217
+ * @param {media_processor.order} [opts.order] - The sort order of the list
218
+ * @param {media_processor.status} [opts.status] - Status to filter by
219
+ * @param {number} [opts.limit] -
220
+ * Upper limit for the number of records to return.
221
+ * list() guarantees never to return more than limit.
222
+ * Default is no limit
223
+ * @param {number} [opts.pageSize] -
224
+ * Number of records to fetch per request,
225
+ * when not set will use the default value of 50 records.
226
+ * If no page_size is defined but a limit is defined,
227
+ * list() will attempt to read the limit with the most
228
+ * efficient page size, i.e. min(limit, 1000)
229
+ * @param {function} [callback] - Callback to handle list of records
230
+ *
231
+ * @returns {Promise} Resolves to a list of records
232
+ */
233
+ /* jshint ignore:end */
234
+ MediaProcessorListInstance.list = function list(opts, callback) {
235
+ if (_.isFunction(opts)) {
236
+ callback = opts;
237
+ opts = {};
238
+ }
239
+ opts = opts || {};
240
+ var deferred = Q.defer();
241
+ var allResources = [];
242
+ opts.callback = function(resource, done) {
243
+ allResources.push(resource);
244
+
245
+ if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) {
246
+ done();
247
+ }
248
+ };
249
+
250
+ opts.done = function(error) {
251
+ if (_.isUndefined(error)) {
252
+ deferred.resolve(allResources);
253
+ } else {
254
+ deferred.reject(error);
255
+ }
256
+ };
257
+
258
+ if (_.isFunction(callback)) {
259
+ deferred.promise.nodeify(callback);
260
+ }
261
+
262
+ this.each(opts);
263
+ return deferred.promise;
264
+ };
265
+
266
+ /* jshint ignore:start */
267
+ /**
268
+ * Retrieve a single page of MediaProcessorInstance records from the API.
269
+ *
270
+ * The request is executed immediately.
271
+ *
272
+ * If a function is passed as the first argument, it will be used as the callback
273
+ * function.
274
+ *
275
+ * @function page
276
+ * @memberof Twilio.Media.V1.MediaProcessorList#
277
+ *
278
+ * @param {object} [opts] - Options for request
279
+ * @param {media_processor.order} [opts.order] - The sort order of the list
280
+ * @param {media_processor.status} [opts.status] - Status to filter by
281
+ * @param {string} [opts.pageToken] - PageToken provided by the API
282
+ * @param {number} [opts.pageNumber] -
283
+ * Page Number, this value is simply for client state
284
+ * @param {number} [opts.pageSize] - Number of records to return, defaults to 50
285
+ * @param {function} [callback] - Callback to handle list of records
286
+ *
287
+ * @returns {Promise} Resolves to a list of records
288
+ */
289
+ /* jshint ignore:end */
290
+ MediaProcessorListInstance.page = function page(opts, callback) {
291
+ if (_.isFunction(opts)) {
292
+ callback = opts;
293
+ opts = {};
294
+ }
295
+ opts = opts || {};
296
+
297
+ var deferred = Q.defer();
298
+ var data = values.of({
299
+ 'Order': _.get(opts, 'order'),
300
+ 'Status': _.get(opts, 'status'),
301
+ 'PageToken': opts.pageToken,
302
+ 'Page': opts.pageNumber,
303
+ 'PageSize': opts.pageSize
304
+ });
305
+
306
+ var promise = this._version.page({uri: this._uri, method: 'GET', params: data});
307
+
308
+ promise = promise.then(function(payload) {
309
+ deferred.resolve(new MediaProcessorPage(this._version, payload, this._solution));
310
+ }.bind(this));
311
+
312
+ promise.catch(function(error) {
313
+ deferred.reject(error);
314
+ });
315
+
316
+ if (_.isFunction(callback)) {
317
+ deferred.promise.nodeify(callback);
318
+ }
319
+
320
+ return deferred.promise;
321
+ };
322
+
323
+ /* jshint ignore:start */
324
+ /**
325
+ * Retrieve a single target page of MediaProcessorInstance records from the API.
326
+ *
327
+ * The request is executed immediately.
328
+ *
329
+ * If a function is passed as the first argument, it will be used as the callback
330
+ * function.
331
+ *
332
+ * @function getPage
333
+ * @memberof Twilio.Media.V1.MediaProcessorList#
334
+ *
335
+ * @param {string} [targetUrl] - API-generated URL for the requested results page
336
+ * @param {function} [callback] - Callback to handle list of records
337
+ *
338
+ * @returns {Promise} Resolves to a list of records
339
+ */
340
+ /* jshint ignore:end */
341
+ MediaProcessorListInstance.getPage = function getPage(targetUrl, callback) {
342
+ var deferred = Q.defer();
343
+
344
+ var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl});
345
+
346
+ promise = promise.then(function(payload) {
347
+ deferred.resolve(new MediaProcessorPage(this._version, payload, this._solution));
348
+ }.bind(this));
349
+
350
+ promise.catch(function(error) {
351
+ deferred.reject(error);
352
+ });
353
+
354
+ if (_.isFunction(callback)) {
355
+ deferred.promise.nodeify(callback);
356
+ }
357
+
358
+ return deferred.promise;
359
+ };
360
+
361
+ /* jshint ignore:start */
362
+ /**
363
+ * Constructs a media_processor
364
+ *
365
+ * @function get
366
+ * @memberof Twilio.Media.V1.MediaProcessorList#
367
+ *
368
+ * @param {string} sid - The SID that identifies the resource to fetch
369
+ *
370
+ * @returns {Twilio.Media.V1.MediaProcessorContext}
371
+ */
372
+ /* jshint ignore:end */
373
+ MediaProcessorListInstance.get = function get(sid) {
374
+ return new MediaProcessorContext(this._version, sid);
375
+ };
376
+
377
+ /* jshint ignore:start */
378
+ /**
379
+ * Provide a user-friendly representation
380
+ *
381
+ * @function toJSON
382
+ * @memberof Twilio.Media.V1.MediaProcessorList#
383
+ *
384
+ * @returns Object
385
+ */
386
+ /* jshint ignore:end */
387
+ MediaProcessorListInstance.toJSON = function toJSON() {
388
+ return this._solution;
389
+ };
390
+
391
+ MediaProcessorListInstance[util.inspect.custom] = function inspect(depth,
392
+ options) {
393
+ return util.inspect(this.toJSON(), options);
394
+ };
395
+
396
+ return MediaProcessorListInstance;
397
+ };
398
+
399
+
400
+ /* jshint ignore:start */
401
+ /**
402
+ * Initialize the MediaProcessorPage
403
+ *
404
+ * @constructor Twilio.Media.V1.MediaProcessorPage
405
+ *
406
+ * @param {V1} version - Version of the resource
407
+ * @param {Response<string>} response - Response from the API
408
+ * @param {MediaProcessorSolution} solution - Path solution
409
+ *
410
+ * @returns MediaProcessorPage
411
+ */
412
+ /* jshint ignore:end */
413
+ MediaProcessorPage = function MediaProcessorPage(version, response, solution) {
414
+ // Path Solution
415
+ this._solution = solution;
416
+
417
+ Page.prototype.constructor.call(this, version, response, this._solution);
418
+ };
419
+
420
+ _.extend(MediaProcessorPage.prototype, Page.prototype);
421
+ MediaProcessorPage.prototype.constructor = MediaProcessorPage;
422
+
423
+ /* jshint ignore:start */
424
+ /**
425
+ * Build an instance of MediaProcessorInstance
426
+ *
427
+ * @function getInstance
428
+ * @memberof Twilio.Media.V1.MediaProcessorPage#
429
+ *
430
+ * @param {MediaProcessorPayload} payload - Payload response from the API
431
+ *
432
+ * @returns MediaProcessorInstance
433
+ */
434
+ /* jshint ignore:end */
435
+ MediaProcessorPage.prototype.getInstance = function getInstance(payload) {
436
+ return new MediaProcessorInstance(this._version, payload);
437
+ };
438
+
439
+ /* jshint ignore:start */
440
+ /**
441
+ * Provide a user-friendly representation
442
+ *
443
+ * @function toJSON
444
+ * @memberof Twilio.Media.V1.MediaProcessorPage#
445
+ *
446
+ * @returns Object
447
+ */
448
+ /* jshint ignore:end */
449
+ MediaProcessorPage.prototype.toJSON = function toJSON() {
450
+ let clone = {};
451
+ _.forOwn(this, function(value, key) {
452
+ if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
453
+ clone[key] = value;
454
+ }
455
+ });
456
+ return clone;
457
+ };
458
+
459
+ MediaProcessorPage.prototype[util.inspect.custom] = function inspect(depth,
460
+ options) {
461
+ return util.inspect(this.toJSON(), options);
462
+ };
463
+
464
+
465
+ /* jshint ignore:start */
466
+ /**
467
+ * Initialize the MediaProcessorContext
468
+ *
469
+ * @constructor Twilio.Media.V1.MediaProcessorInstance
470
+ *
471
+ * @property {string} accountSid - The SID of the Account that created the resource
472
+ * @property {string} sid - The unique string that identifies the resource
473
+ * @property {Date} dateCreated -
474
+ * The ISO 8601 date and time in GMT when the resource was created
475
+ * @property {Date} dateUpdated -
476
+ * The ISO 8601 date and time in GMT when the resource was last updated
477
+ * @property {string} extension - The Media Extension name or URL
478
+ * @property {string} extensionContext - The Media Extension context
479
+ * @property {media_processor.status} status - The status of the MediaProcessor
480
+ * @property {string} url - The absolute URL of the resource
481
+ * @property {string} endedReason - The reason why a MediaProcessor ended
482
+ * @property {string} statusCallback -
483
+ * The URL to which Twilio will send MediaProcessor event updates
484
+ * @property {string} statusCallbackMethod -
485
+ * The HTTP method Twilio should use to call the `status_callback` URL
486
+ *
487
+ * @param {V1} version - Version of the resource
488
+ * @param {MediaProcessorPayload} payload - The instance payload
489
+ * @param {sid} sid - The SID that identifies the resource to fetch
490
+ */
491
+ /* jshint ignore:end */
492
+ MediaProcessorInstance = function MediaProcessorInstance(version, payload, sid)
493
+ {
494
+ this._version = version;
495
+
496
+ // Marshaled Properties
497
+ this.accountSid = payload.account_sid; // jshint ignore:line
498
+ this.sid = payload.sid; // jshint ignore:line
499
+ this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line
500
+ this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line
501
+ this.extension = payload.extension; // jshint ignore:line
502
+ this.extensionContext = payload.extension_context; // jshint ignore:line
503
+ this.status = payload.status; // jshint ignore:line
504
+ this.url = payload.url; // jshint ignore:line
505
+ this.endedReason = payload.ended_reason; // jshint ignore:line
506
+ this.statusCallback = payload.status_callback; // jshint ignore:line
507
+ this.statusCallbackMethod = payload.status_callback_method; // jshint ignore:line
508
+
509
+ // Context
510
+ this._context = undefined;
511
+ this._solution = {sid: sid || this.sid, };
512
+ };
513
+
514
+ Object.defineProperty(MediaProcessorInstance.prototype,
515
+ '_proxy', {
516
+ get: function() {
517
+ if (!this._context) {
518
+ this._context = new MediaProcessorContext(this._version, this._solution.sid);
519
+ }
520
+
521
+ return this._context;
522
+ }
523
+ });
524
+
525
+ /* jshint ignore:start */
526
+ /**
527
+ * fetch a MediaProcessorInstance
528
+ *
529
+ * @function fetch
530
+ * @memberof Twilio.Media.V1.MediaProcessorInstance#
531
+ *
532
+ * @param {function} [callback] - Callback to handle processed record
533
+ *
534
+ * @returns {Promise} Resolves to processed MediaProcessorInstance
535
+ */
536
+ /* jshint ignore:end */
537
+ MediaProcessorInstance.prototype.fetch = function fetch(callback) {
538
+ return this._proxy.fetch(callback);
539
+ };
540
+
541
+ /* jshint ignore:start */
542
+ /**
543
+ * update a MediaProcessorInstance
544
+ *
545
+ * @function update
546
+ * @memberof Twilio.Media.V1.MediaProcessorInstance#
547
+ *
548
+ * @param {object} opts - Options for request
549
+ * @param {media_processor.update_status} opts.status -
550
+ * The status of the MediaProcessor
551
+ * @param {function} [callback] - Callback to handle processed record
552
+ *
553
+ * @returns {Promise} Resolves to processed MediaProcessorInstance
554
+ */
555
+ /* jshint ignore:end */
556
+ MediaProcessorInstance.prototype.update = function update(opts, callback) {
557
+ return this._proxy.update(opts, callback);
558
+ };
559
+
560
+ /* jshint ignore:start */
561
+ /**
562
+ * Provide a user-friendly representation
563
+ *
564
+ * @function toJSON
565
+ * @memberof Twilio.Media.V1.MediaProcessorInstance#
566
+ *
567
+ * @returns Object
568
+ */
569
+ /* jshint ignore:end */
570
+ MediaProcessorInstance.prototype.toJSON = function toJSON() {
571
+ let clone = {};
572
+ _.forOwn(this, function(value, key) {
573
+ if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
574
+ clone[key] = value;
575
+ }
576
+ });
577
+ return clone;
578
+ };
579
+
580
+ MediaProcessorInstance.prototype[util.inspect.custom] = function inspect(depth,
581
+ options) {
582
+ return util.inspect(this.toJSON(), options);
583
+ };
584
+
585
+
586
+ /* jshint ignore:start */
587
+ /**
588
+ * Initialize the MediaProcessorContext
589
+ *
590
+ * @constructor Twilio.Media.V1.MediaProcessorContext
591
+ *
592
+ * @param {V1} version - Version of the resource
593
+ * @param {sid} sid - The SID that identifies the resource to fetch
594
+ */
595
+ /* jshint ignore:end */
596
+ MediaProcessorContext = function MediaProcessorContext(version, sid) {
597
+ this._version = version;
598
+
599
+ // Path Solution
600
+ this._solution = {sid: sid, };
601
+ this._uri = `/MediaProcessors/${sid}`;
602
+ };
603
+
604
+ /* jshint ignore:start */
605
+ /**
606
+ * fetch a MediaProcessorInstance
607
+ *
608
+ * @function fetch
609
+ * @memberof Twilio.Media.V1.MediaProcessorContext#
610
+ *
611
+ * @param {function} [callback] - Callback to handle processed record
612
+ *
613
+ * @returns {Promise} Resolves to processed MediaProcessorInstance
614
+ */
615
+ /* jshint ignore:end */
616
+ MediaProcessorContext.prototype.fetch = function fetch(callback) {
617
+ var deferred = Q.defer();
618
+ var promise = this._version.fetch({uri: this._uri, method: 'GET'});
619
+
620
+ promise = promise.then(function(payload) {
621
+ deferred.resolve(new MediaProcessorInstance(this._version, payload, this._solution.sid));
622
+ }.bind(this));
623
+
624
+ promise.catch(function(error) {
625
+ deferred.reject(error);
626
+ });
627
+
628
+ if (_.isFunction(callback)) {
629
+ deferred.promise.nodeify(callback);
630
+ }
631
+
632
+ return deferred.promise;
633
+ };
634
+
635
+ /* jshint ignore:start */
636
+ /**
637
+ * update a MediaProcessorInstance
638
+ *
639
+ * @function update
640
+ * @memberof Twilio.Media.V1.MediaProcessorContext#
641
+ *
642
+ * @param {object} opts - Options for request
643
+ * @param {media_processor.update_status} opts.status -
644
+ * The status of the MediaProcessor
645
+ * @param {function} [callback] - Callback to handle processed record
646
+ *
647
+ * @returns {Promise} Resolves to processed MediaProcessorInstance
648
+ */
649
+ /* jshint ignore:end */
650
+ MediaProcessorContext.prototype.update = function update(opts, callback) {
651
+ if (_.isUndefined(opts)) {
652
+ throw new Error('Required parameter "opts" missing.');
653
+ }
654
+ if (_.isUndefined(opts.status)) {
655
+ throw new Error('Required parameter "opts.status" missing.');
656
+ }
657
+
658
+ var deferred = Q.defer();
659
+ var data = values.of({'Status': _.get(opts, 'status')});
660
+
661
+ var promise = this._version.update({uri: this._uri, method: 'POST', data: data});
662
+
663
+ promise = promise.then(function(payload) {
664
+ deferred.resolve(new MediaProcessorInstance(this._version, payload, this._solution.sid));
665
+ }.bind(this));
666
+
667
+ promise.catch(function(error) {
668
+ deferred.reject(error);
669
+ });
670
+
671
+ if (_.isFunction(callback)) {
672
+ deferred.promise.nodeify(callback);
673
+ }
674
+
675
+ return deferred.promise;
676
+ };
677
+
678
+ /* jshint ignore:start */
679
+ /**
680
+ * Provide a user-friendly representation
681
+ *
682
+ * @function toJSON
683
+ * @memberof Twilio.Media.V1.MediaProcessorContext#
684
+ *
685
+ * @returns Object
686
+ */
687
+ /* jshint ignore:end */
688
+ MediaProcessorContext.prototype.toJSON = function toJSON() {
689
+ return this._solution;
690
+ };
691
+
692
+ MediaProcessorContext.prototype[util.inspect.custom] = function inspect(depth,
693
+ options) {
694
+ return util.inspect(this.toJSON(), options);
695
+ };
696
+
697
+ module.exports = {
698
+ MediaProcessorList: MediaProcessorList,
699
+ MediaProcessorPage: MediaProcessorPage,
700
+ MediaProcessorInstance: MediaProcessorInstance,
701
+ MediaProcessorContext: MediaProcessorContext
702
+ };