twilio 3.80.0 → 3.80.1
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.
- package/lib/rest/Microvisor.d.ts +28 -0
- package/lib/rest/Microvisor.js +62 -0
- package/lib/rest/Preview.d.ts +0 -6
- package/lib/rest/Preview.js +0 -28
- package/lib/rest/Routes.d.ts +30 -0
- package/lib/rest/Routes.js +71 -0
- package/lib/rest/Twilio.d.ts +4 -0
- package/lib/rest/Twilio.js +28 -0
- package/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.d.ts +2 -2
- package/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.js +4 -4
- package/lib/rest/microvisor/V1.d.ts +28 -0
- package/lib/rest/microvisor/V1.js +57 -0
- package/lib/rest/{preview/bulk_exports/export/day.d.ts → microvisor/v1/app.d.ts} +79 -69
- package/lib/rest/{preview/bulk_exports/export/day.js → microvisor/v1/app.js} +160 -122
- package/lib/rest/{preview/bulk_exports/export/exportCustomJob.d.ts → microvisor/v1/device.d.ts} +136 -84
- package/lib/rest/microvisor/v1/device.js +652 -0
- package/lib/rest/routes/V2.d.ts +31 -0
- package/lib/rest/routes/V2.js +69 -0
- package/lib/rest/routes/v2/phoneNumber.d.ts +193 -0
- package/lib/rest/routes/v2/phoneNumber.js +466 -0
- package/lib/rest/routes/v2/sipDomain.d.ts +205 -0
- package/lib/rest/routes/v2/sipDomain.js +447 -0
- package/lib/rest/routes/v2/trunk.d.ts +205 -0
- package/lib/rest/routes/v2/trunk.js +458 -0
- package/lib/rest/supersim/v1/fleet.d.ts +3 -1
- package/lib/rest/supersim/v1/fleet.js +8 -3
- package/package.json +1 -1
- package/lib/rest/preview/BulkExports.d.ts +0 -28
- package/lib/rest/preview/BulkExports.js +0 -59
- package/lib/rest/preview/bulk_exports/export/exportCustomJob.js +0 -540
- package/lib/rest/preview/bulk_exports/export/job.d.ts +0 -163
- package/lib/rest/preview/bulk_exports/export/job.js +0 -390
- package/lib/rest/preview/bulk_exports/export.d.ts +0 -153
- package/lib/rest/preview/bulk_exports/export.js +0 -402
- package/lib/rest/preview/bulk_exports/exportConfiguration.d.ts +0 -180
- package/lib/rest/preview/bulk_exports/exportConfiguration.js +0 -411
|
@@ -0,0 +1,652 @@
|
|
|
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 DeviceList;
|
|
22
|
+
var DevicePage;
|
|
23
|
+
var DeviceInstance;
|
|
24
|
+
var DeviceContext;
|
|
25
|
+
|
|
26
|
+
/* jshint ignore:start */
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the DeviceList
|
|
29
|
+
*
|
|
30
|
+
* PLEASE NOTE that this class contains preview products that are subject to
|
|
31
|
+
* change. Use them with caution. If you currently do not have developer preview
|
|
32
|
+
* access, please contact help@twilio.com.
|
|
33
|
+
*
|
|
34
|
+
* @constructor Twilio.Microvisor.V1.DeviceList
|
|
35
|
+
*
|
|
36
|
+
* @param {Twilio.Microvisor.V1} version - Version of the resource
|
|
37
|
+
*/
|
|
38
|
+
/* jshint ignore:end */
|
|
39
|
+
DeviceList = function DeviceList(version) {
|
|
40
|
+
/* jshint ignore:start */
|
|
41
|
+
/**
|
|
42
|
+
* @function devices
|
|
43
|
+
* @memberof Twilio.Microvisor.V1#
|
|
44
|
+
*
|
|
45
|
+
* @param {string} sid - sid of instance
|
|
46
|
+
*
|
|
47
|
+
* @returns {Twilio.Microvisor.V1.DeviceContext}
|
|
48
|
+
*/
|
|
49
|
+
/* jshint ignore:end */
|
|
50
|
+
function DeviceListInstance(sid) {
|
|
51
|
+
return DeviceListInstance.get(sid);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
DeviceListInstance._version = version;
|
|
55
|
+
// Path Solution
|
|
56
|
+
DeviceListInstance._solution = {};
|
|
57
|
+
DeviceListInstance._uri = `/Devices`;
|
|
58
|
+
/* jshint ignore:start */
|
|
59
|
+
/**
|
|
60
|
+
* Streams DeviceInstance records from the API.
|
|
61
|
+
*
|
|
62
|
+
* This operation lazily loads records as efficiently as possible until the limit
|
|
63
|
+
* is reached.
|
|
64
|
+
*
|
|
65
|
+
* The results are passed into the callback function, so this operation is memory
|
|
66
|
+
* efficient.
|
|
67
|
+
*
|
|
68
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
69
|
+
* function.
|
|
70
|
+
*
|
|
71
|
+
* @function each
|
|
72
|
+
* @memberof Twilio.Microvisor.V1.DeviceList#
|
|
73
|
+
*
|
|
74
|
+
* @param {object} [opts] - Options for request
|
|
75
|
+
* @param {number} [opts.limit] -
|
|
76
|
+
* Upper limit for the number of records to return.
|
|
77
|
+
* each() guarantees never to return more than limit.
|
|
78
|
+
* Default is no limit
|
|
79
|
+
* @param {number} [opts.pageSize] -
|
|
80
|
+
* Number of records to fetch per request,
|
|
81
|
+
* when not set will use the default value of 50 records.
|
|
82
|
+
* If no pageSize is defined but a limit is defined,
|
|
83
|
+
* each() will attempt to read the limit with the most efficient
|
|
84
|
+
* page size, i.e. min(limit, 1000)
|
|
85
|
+
* @param {Function} [opts.callback] -
|
|
86
|
+
* Function to process each record. If this and a positional
|
|
87
|
+
* callback are passed, this one will be used
|
|
88
|
+
* @param {Function} [opts.done] -
|
|
89
|
+
* Function to be called upon completion of streaming
|
|
90
|
+
* @param {Function} [callback] - Function to process each record
|
|
91
|
+
*/
|
|
92
|
+
/* jshint ignore:end */
|
|
93
|
+
DeviceListInstance.each = function each(opts, callback) {
|
|
94
|
+
if (_.isFunction(opts)) {
|
|
95
|
+
callback = opts;
|
|
96
|
+
opts = {};
|
|
97
|
+
}
|
|
98
|
+
opts = opts || {};
|
|
99
|
+
if (opts.callback) {
|
|
100
|
+
callback = opts.callback;
|
|
101
|
+
}
|
|
102
|
+
if (_.isUndefined(callback)) {
|
|
103
|
+
throw new Error('Callback function must be provided');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var done = false;
|
|
107
|
+
var currentPage = 1;
|
|
108
|
+
var currentResource = 0;
|
|
109
|
+
var limits = this._version.readLimits({
|
|
110
|
+
limit: opts.limit,
|
|
111
|
+
pageSize: opts.pageSize
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
function onComplete(error) {
|
|
115
|
+
done = true;
|
|
116
|
+
if (_.isFunction(opts.done)) {
|
|
117
|
+
opts.done(error);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function fetchNextPage(fn) {
|
|
122
|
+
var promise = fn();
|
|
123
|
+
if (_.isUndefined(promise)) {
|
|
124
|
+
onComplete();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
promise.then(function(page) {
|
|
129
|
+
_.each(page.instances, function(instance) {
|
|
130
|
+
if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) {
|
|
131
|
+
done = true;
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
currentResource++;
|
|
136
|
+
callback(instance, onComplete);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (!done) {
|
|
140
|
+
currentPage++;
|
|
141
|
+
fetchNextPage(_.bind(page.nextPage, page));
|
|
142
|
+
} else {
|
|
143
|
+
onComplete();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
promise.catch(onComplete);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
fetchNextPage(_.bind(this.page, this, _.merge(opts, limits)));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/* jshint ignore:start */
|
|
154
|
+
/**
|
|
155
|
+
* Lists DeviceInstance records from the API as a list.
|
|
156
|
+
*
|
|
157
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
158
|
+
* function.
|
|
159
|
+
*
|
|
160
|
+
* @function list
|
|
161
|
+
* @memberof Twilio.Microvisor.V1.DeviceList#
|
|
162
|
+
*
|
|
163
|
+
* @param {object} [opts] - Options for request
|
|
164
|
+
* @param {number} [opts.limit] -
|
|
165
|
+
* Upper limit for the number of records to return.
|
|
166
|
+
* list() guarantees never to return more than limit.
|
|
167
|
+
* Default is no limit
|
|
168
|
+
* @param {number} [opts.pageSize] -
|
|
169
|
+
* Number of records to fetch per request,
|
|
170
|
+
* when not set will use the default value of 50 records.
|
|
171
|
+
* If no page_size is defined but a limit is defined,
|
|
172
|
+
* list() will attempt to read the limit with the most
|
|
173
|
+
* efficient page size, i.e. min(limit, 1000)
|
|
174
|
+
* @param {function} [callback] - Callback to handle list of records
|
|
175
|
+
*
|
|
176
|
+
* @returns {Promise} Resolves to a list of records
|
|
177
|
+
*/
|
|
178
|
+
/* jshint ignore:end */
|
|
179
|
+
DeviceListInstance.list = function list(opts, callback) {
|
|
180
|
+
if (_.isFunction(opts)) {
|
|
181
|
+
callback = opts;
|
|
182
|
+
opts = {};
|
|
183
|
+
}
|
|
184
|
+
opts = opts || {};
|
|
185
|
+
var deferred = Q.defer();
|
|
186
|
+
var allResources = [];
|
|
187
|
+
opts.callback = function(resource, done) {
|
|
188
|
+
allResources.push(resource);
|
|
189
|
+
|
|
190
|
+
if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) {
|
|
191
|
+
done();
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
opts.done = function(error) {
|
|
196
|
+
if (_.isUndefined(error)) {
|
|
197
|
+
deferred.resolve(allResources);
|
|
198
|
+
} else {
|
|
199
|
+
deferred.reject(error);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
if (_.isFunction(callback)) {
|
|
204
|
+
deferred.promise.nodeify(callback);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
this.each(opts);
|
|
208
|
+
return deferred.promise;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/* jshint ignore:start */
|
|
212
|
+
/**
|
|
213
|
+
* Retrieve a single page of DeviceInstance records from the API.
|
|
214
|
+
*
|
|
215
|
+
* The request is executed immediately.
|
|
216
|
+
*
|
|
217
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
218
|
+
* function.
|
|
219
|
+
*
|
|
220
|
+
* @function page
|
|
221
|
+
* @memberof Twilio.Microvisor.V1.DeviceList#
|
|
222
|
+
*
|
|
223
|
+
* @param {object} [opts] - Options for request
|
|
224
|
+
* @param {string} [opts.pageToken] - PageToken provided by the API
|
|
225
|
+
* @param {number} [opts.pageNumber] -
|
|
226
|
+
* Page Number, this value is simply for client state
|
|
227
|
+
* @param {number} [opts.pageSize] - Number of records to return, defaults to 50
|
|
228
|
+
* @param {function} [callback] - Callback to handle list of records
|
|
229
|
+
*
|
|
230
|
+
* @returns {Promise} Resolves to a list of records
|
|
231
|
+
*/
|
|
232
|
+
/* jshint ignore:end */
|
|
233
|
+
DeviceListInstance.page = function page(opts, callback) {
|
|
234
|
+
if (_.isFunction(opts)) {
|
|
235
|
+
callback = opts;
|
|
236
|
+
opts = {};
|
|
237
|
+
}
|
|
238
|
+
opts = opts || {};
|
|
239
|
+
|
|
240
|
+
var deferred = Q.defer();
|
|
241
|
+
var data = values.of({
|
|
242
|
+
'PageToken': opts.pageToken,
|
|
243
|
+
'Page': opts.pageNumber,
|
|
244
|
+
'PageSize': opts.pageSize
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
var promise = this._version.page({uri: this._uri, method: 'GET', params: data});
|
|
248
|
+
|
|
249
|
+
promise = promise.then(function(payload) {
|
|
250
|
+
deferred.resolve(new DevicePage(this._version, payload, this._solution));
|
|
251
|
+
}.bind(this));
|
|
252
|
+
|
|
253
|
+
promise.catch(function(error) {
|
|
254
|
+
deferred.reject(error);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
if (_.isFunction(callback)) {
|
|
258
|
+
deferred.promise.nodeify(callback);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return deferred.promise;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
/* jshint ignore:start */
|
|
265
|
+
/**
|
|
266
|
+
* Retrieve a single target page of DeviceInstance records from the API.
|
|
267
|
+
*
|
|
268
|
+
* The request is executed immediately.
|
|
269
|
+
*
|
|
270
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
271
|
+
* function.
|
|
272
|
+
*
|
|
273
|
+
* @function getPage
|
|
274
|
+
* @memberof Twilio.Microvisor.V1.DeviceList#
|
|
275
|
+
*
|
|
276
|
+
* @param {string} [targetUrl] - API-generated URL for the requested results page
|
|
277
|
+
* @param {function} [callback] - Callback to handle list of records
|
|
278
|
+
*
|
|
279
|
+
* @returns {Promise} Resolves to a list of records
|
|
280
|
+
*/
|
|
281
|
+
/* jshint ignore:end */
|
|
282
|
+
DeviceListInstance.getPage = function getPage(targetUrl, callback) {
|
|
283
|
+
var deferred = Q.defer();
|
|
284
|
+
|
|
285
|
+
var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl});
|
|
286
|
+
|
|
287
|
+
promise = promise.then(function(payload) {
|
|
288
|
+
deferred.resolve(new DevicePage(this._version, payload, this._solution));
|
|
289
|
+
}.bind(this));
|
|
290
|
+
|
|
291
|
+
promise.catch(function(error) {
|
|
292
|
+
deferred.reject(error);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
if (_.isFunction(callback)) {
|
|
296
|
+
deferred.promise.nodeify(callback);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return deferred.promise;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/* jshint ignore:start */
|
|
303
|
+
/**
|
|
304
|
+
* Constructs a device
|
|
305
|
+
*
|
|
306
|
+
* @function get
|
|
307
|
+
* @memberof Twilio.Microvisor.V1.DeviceList#
|
|
308
|
+
*
|
|
309
|
+
* @param {string} sid - A string that uniquely identifies this Device.
|
|
310
|
+
*
|
|
311
|
+
* @returns {Twilio.Microvisor.V1.DeviceContext}
|
|
312
|
+
*/
|
|
313
|
+
/* jshint ignore:end */
|
|
314
|
+
DeviceListInstance.get = function get(sid) {
|
|
315
|
+
return new DeviceContext(this._version, sid);
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/* jshint ignore:start */
|
|
319
|
+
/**
|
|
320
|
+
* Provide a user-friendly representation
|
|
321
|
+
*
|
|
322
|
+
* @function toJSON
|
|
323
|
+
* @memberof Twilio.Microvisor.V1.DeviceList#
|
|
324
|
+
*
|
|
325
|
+
* @returns Object
|
|
326
|
+
*/
|
|
327
|
+
/* jshint ignore:end */
|
|
328
|
+
DeviceListInstance.toJSON = function toJSON() {
|
|
329
|
+
return this._solution;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
DeviceListInstance[util.inspect.custom] = function inspect(depth, options) {
|
|
333
|
+
return util.inspect(this.toJSON(), options);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
return DeviceListInstance;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
/* jshint ignore:start */
|
|
341
|
+
/**
|
|
342
|
+
* Initialize the DevicePage
|
|
343
|
+
*
|
|
344
|
+
* PLEASE NOTE that this class contains preview products that are subject to
|
|
345
|
+
* change. Use them with caution. If you currently do not have developer preview
|
|
346
|
+
* access, please contact help@twilio.com.
|
|
347
|
+
*
|
|
348
|
+
* @constructor Twilio.Microvisor.V1.DevicePage
|
|
349
|
+
*
|
|
350
|
+
* @param {V1} version - Version of the resource
|
|
351
|
+
* @param {Response<string>} response - Response from the API
|
|
352
|
+
* @param {DeviceSolution} solution - Path solution
|
|
353
|
+
*
|
|
354
|
+
* @returns DevicePage
|
|
355
|
+
*/
|
|
356
|
+
/* jshint ignore:end */
|
|
357
|
+
DevicePage = function DevicePage(version, response, solution) {
|
|
358
|
+
// Path Solution
|
|
359
|
+
this._solution = solution;
|
|
360
|
+
|
|
361
|
+
Page.prototype.constructor.call(this, version, response, this._solution);
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
_.extend(DevicePage.prototype, Page.prototype);
|
|
365
|
+
DevicePage.prototype.constructor = DevicePage;
|
|
366
|
+
|
|
367
|
+
/* jshint ignore:start */
|
|
368
|
+
/**
|
|
369
|
+
* Build an instance of DeviceInstance
|
|
370
|
+
*
|
|
371
|
+
* @function getInstance
|
|
372
|
+
* @memberof Twilio.Microvisor.V1.DevicePage#
|
|
373
|
+
*
|
|
374
|
+
* @param {DevicePayload} payload - Payload response from the API
|
|
375
|
+
*
|
|
376
|
+
* @returns DeviceInstance
|
|
377
|
+
*/
|
|
378
|
+
/* jshint ignore:end */
|
|
379
|
+
DevicePage.prototype.getInstance = function getInstance(payload) {
|
|
380
|
+
return new DeviceInstance(this._version, payload);
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
/* jshint ignore:start */
|
|
384
|
+
/**
|
|
385
|
+
* Provide a user-friendly representation
|
|
386
|
+
*
|
|
387
|
+
* @function toJSON
|
|
388
|
+
* @memberof Twilio.Microvisor.V1.DevicePage#
|
|
389
|
+
*
|
|
390
|
+
* @returns Object
|
|
391
|
+
*/
|
|
392
|
+
/* jshint ignore:end */
|
|
393
|
+
DevicePage.prototype.toJSON = function toJSON() {
|
|
394
|
+
let clone = {};
|
|
395
|
+
_.forOwn(this, function(value, key) {
|
|
396
|
+
if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
|
|
397
|
+
clone[key] = value;
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
return clone;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
DevicePage.prototype[util.inspect.custom] = function inspect(depth, options) {
|
|
404
|
+
return util.inspect(this.toJSON(), options);
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
/* jshint ignore:start */
|
|
409
|
+
/**
|
|
410
|
+
* Initialize the DeviceContext
|
|
411
|
+
*
|
|
412
|
+
* PLEASE NOTE that this class contains preview products that are subject to
|
|
413
|
+
* change. Use them with caution. If you currently do not have developer preview
|
|
414
|
+
* access, please contact help@twilio.com.
|
|
415
|
+
*
|
|
416
|
+
* @constructor Twilio.Microvisor.V1.DeviceInstance
|
|
417
|
+
*
|
|
418
|
+
* @property {string} sid - A string that uniquely identifies this Device.
|
|
419
|
+
* @property {string} uniqueName -
|
|
420
|
+
* A developer-defined string that uniquely identifies the Device.
|
|
421
|
+
* @property {string} accountSid - Account SID.
|
|
422
|
+
* @property {object} app -
|
|
423
|
+
* Information about the target App and the App reported by this Device.
|
|
424
|
+
* @property {object} logging -
|
|
425
|
+
* Object specifying whether application logging is enabled for this Device.
|
|
426
|
+
* @property {Date} dateCreated - The date that this Device was created.
|
|
427
|
+
* @property {Date} dateUpdated - The date that this Device was last updated.
|
|
428
|
+
* @property {string} url - The URL of this resource.
|
|
429
|
+
*
|
|
430
|
+
* @param {V1} version - Version of the resource
|
|
431
|
+
* @param {DevicePayload} payload - The instance payload
|
|
432
|
+
* @param {sid_like} sid - A string that uniquely identifies this Device.
|
|
433
|
+
*/
|
|
434
|
+
/* jshint ignore:end */
|
|
435
|
+
DeviceInstance = function DeviceInstance(version, payload, sid) {
|
|
436
|
+
this._version = version;
|
|
437
|
+
|
|
438
|
+
// Marshaled Properties
|
|
439
|
+
this.sid = payload.sid; // jshint ignore:line
|
|
440
|
+
this.uniqueName = payload.unique_name; // jshint ignore:line
|
|
441
|
+
this.accountSid = payload.account_sid; // jshint ignore:line
|
|
442
|
+
this.app = payload.app; // jshint ignore:line
|
|
443
|
+
this.logging = payload.logging; // jshint ignore:line
|
|
444
|
+
this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line
|
|
445
|
+
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line
|
|
446
|
+
this.url = payload.url; // jshint ignore:line
|
|
447
|
+
|
|
448
|
+
// Context
|
|
449
|
+
this._context = undefined;
|
|
450
|
+
this._solution = {sid: sid || this.sid, };
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
Object.defineProperty(DeviceInstance.prototype,
|
|
454
|
+
'_proxy', {
|
|
455
|
+
get: function() {
|
|
456
|
+
if (!this._context) {
|
|
457
|
+
this._context = new DeviceContext(this._version, this._solution.sid);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return this._context;
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
/* jshint ignore:start */
|
|
465
|
+
/**
|
|
466
|
+
* fetch a DeviceInstance
|
|
467
|
+
*
|
|
468
|
+
* @function fetch
|
|
469
|
+
* @memberof Twilio.Microvisor.V1.DeviceInstance#
|
|
470
|
+
*
|
|
471
|
+
* @param {function} [callback] - Callback to handle processed record
|
|
472
|
+
*
|
|
473
|
+
* @returns {Promise} Resolves to processed DeviceInstance
|
|
474
|
+
*/
|
|
475
|
+
/* jshint ignore:end */
|
|
476
|
+
DeviceInstance.prototype.fetch = function fetch(callback) {
|
|
477
|
+
return this._proxy.fetch(callback);
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
/* jshint ignore:start */
|
|
481
|
+
/**
|
|
482
|
+
* update a DeviceInstance
|
|
483
|
+
*
|
|
484
|
+
* @function update
|
|
485
|
+
* @memberof Twilio.Microvisor.V1.DeviceInstance#
|
|
486
|
+
*
|
|
487
|
+
* @param {object} [opts] - Options for request
|
|
488
|
+
* @param {string} [opts.uniqueName] -
|
|
489
|
+
* A unique, developer-assigned name for this Device.
|
|
490
|
+
* @param {string} [opts.targetApp] - The target App SID or unique name.
|
|
491
|
+
* @param {boolean} [opts.loggingEnabled] - Whether to enable logging.
|
|
492
|
+
* @param {function} [callback] - Callback to handle processed record
|
|
493
|
+
*
|
|
494
|
+
* @returns {Promise} Resolves to processed DeviceInstance
|
|
495
|
+
*/
|
|
496
|
+
/* jshint ignore:end */
|
|
497
|
+
DeviceInstance.prototype.update = function update(opts, callback) {
|
|
498
|
+
return this._proxy.update(opts, callback);
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/* jshint ignore:start */
|
|
502
|
+
/**
|
|
503
|
+
* Provide a user-friendly representation
|
|
504
|
+
*
|
|
505
|
+
* @function toJSON
|
|
506
|
+
* @memberof Twilio.Microvisor.V1.DeviceInstance#
|
|
507
|
+
*
|
|
508
|
+
* @returns Object
|
|
509
|
+
*/
|
|
510
|
+
/* jshint ignore:end */
|
|
511
|
+
DeviceInstance.prototype.toJSON = function toJSON() {
|
|
512
|
+
let clone = {};
|
|
513
|
+
_.forOwn(this, function(value, key) {
|
|
514
|
+
if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
|
|
515
|
+
clone[key] = value;
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
return clone;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
DeviceInstance.prototype[util.inspect.custom] = function inspect(depth, options)
|
|
522
|
+
{
|
|
523
|
+
return util.inspect(this.toJSON(), options);
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
/* jshint ignore:start */
|
|
528
|
+
/**
|
|
529
|
+
* Initialize the DeviceContext
|
|
530
|
+
*
|
|
531
|
+
* PLEASE NOTE that this class contains preview products that are subject to
|
|
532
|
+
* change. Use them with caution. If you currently do not have developer preview
|
|
533
|
+
* access, please contact help@twilio.com.
|
|
534
|
+
*
|
|
535
|
+
* @constructor Twilio.Microvisor.V1.DeviceContext
|
|
536
|
+
*
|
|
537
|
+
* @param {V1} version - Version of the resource
|
|
538
|
+
* @param {sid_like} sid - A string that uniquely identifies this Device.
|
|
539
|
+
*/
|
|
540
|
+
/* jshint ignore:end */
|
|
541
|
+
DeviceContext = function DeviceContext(version, sid) {
|
|
542
|
+
this._version = version;
|
|
543
|
+
|
|
544
|
+
// Path Solution
|
|
545
|
+
this._solution = {sid: sid, };
|
|
546
|
+
this._uri = `/Devices/${sid}`;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
/* jshint ignore:start */
|
|
550
|
+
/**
|
|
551
|
+
* fetch a DeviceInstance
|
|
552
|
+
*
|
|
553
|
+
* @function fetch
|
|
554
|
+
* @memberof Twilio.Microvisor.V1.DeviceContext#
|
|
555
|
+
*
|
|
556
|
+
* @param {function} [callback] - Callback to handle processed record
|
|
557
|
+
*
|
|
558
|
+
* @returns {Promise} Resolves to processed DeviceInstance
|
|
559
|
+
*/
|
|
560
|
+
/* jshint ignore:end */
|
|
561
|
+
DeviceContext.prototype.fetch = function fetch(callback) {
|
|
562
|
+
var deferred = Q.defer();
|
|
563
|
+
var promise = this._version.fetch({uri: this._uri, method: 'GET'});
|
|
564
|
+
|
|
565
|
+
promise = promise.then(function(payload) {
|
|
566
|
+
deferred.resolve(new DeviceInstance(this._version, payload, this._solution.sid));
|
|
567
|
+
}.bind(this));
|
|
568
|
+
|
|
569
|
+
promise.catch(function(error) {
|
|
570
|
+
deferred.reject(error);
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
if (_.isFunction(callback)) {
|
|
574
|
+
deferred.promise.nodeify(callback);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
return deferred.promise;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
/* jshint ignore:start */
|
|
581
|
+
/**
|
|
582
|
+
* update a DeviceInstance
|
|
583
|
+
*
|
|
584
|
+
* @function update
|
|
585
|
+
* @memberof Twilio.Microvisor.V1.DeviceContext#
|
|
586
|
+
*
|
|
587
|
+
* @param {object} [opts] - Options for request
|
|
588
|
+
* @param {string} [opts.uniqueName] -
|
|
589
|
+
* A unique, developer-assigned name for this Device.
|
|
590
|
+
* @param {string} [opts.targetApp] - The target App SID or unique name.
|
|
591
|
+
* @param {boolean} [opts.loggingEnabled] - Whether to enable logging.
|
|
592
|
+
* @param {function} [callback] - Callback to handle processed record
|
|
593
|
+
*
|
|
594
|
+
* @returns {Promise} Resolves to processed DeviceInstance
|
|
595
|
+
*/
|
|
596
|
+
/* jshint ignore:end */
|
|
597
|
+
DeviceContext.prototype.update = function update(opts, callback) {
|
|
598
|
+
if (_.isFunction(opts)) {
|
|
599
|
+
callback = opts;
|
|
600
|
+
opts = {};
|
|
601
|
+
}
|
|
602
|
+
opts = opts || {};
|
|
603
|
+
|
|
604
|
+
var deferred = Q.defer();
|
|
605
|
+
var data = values.of({
|
|
606
|
+
'UniqueName': _.get(opts, 'uniqueName'),
|
|
607
|
+
'TargetApp': _.get(opts, 'targetApp'),
|
|
608
|
+
'LoggingEnabled': serialize.bool(_.get(opts, 'loggingEnabled'))
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
var promise = this._version.update({uri: this._uri, method: 'POST', data: data});
|
|
612
|
+
|
|
613
|
+
promise = promise.then(function(payload) {
|
|
614
|
+
deferred.resolve(new DeviceInstance(this._version, payload, this._solution.sid));
|
|
615
|
+
}.bind(this));
|
|
616
|
+
|
|
617
|
+
promise.catch(function(error) {
|
|
618
|
+
deferred.reject(error);
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
if (_.isFunction(callback)) {
|
|
622
|
+
deferred.promise.nodeify(callback);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return deferred.promise;
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
/* jshint ignore:start */
|
|
629
|
+
/**
|
|
630
|
+
* Provide a user-friendly representation
|
|
631
|
+
*
|
|
632
|
+
* @function toJSON
|
|
633
|
+
* @memberof Twilio.Microvisor.V1.DeviceContext#
|
|
634
|
+
*
|
|
635
|
+
* @returns Object
|
|
636
|
+
*/
|
|
637
|
+
/* jshint ignore:end */
|
|
638
|
+
DeviceContext.prototype.toJSON = function toJSON() {
|
|
639
|
+
return this._solution;
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
DeviceContext.prototype[util.inspect.custom] = function inspect(depth, options)
|
|
643
|
+
{
|
|
644
|
+
return util.inspect(this.toJSON(), options);
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
module.exports = {
|
|
648
|
+
DeviceList: DeviceList,
|
|
649
|
+
DevicePage: DevicePage,
|
|
650
|
+
DeviceInstance: DeviceInstance,
|
|
651
|
+
DeviceContext: DeviceContext
|
|
652
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by
|
|
3
|
+
* \ / _ _ _| _ _
|
|
4
|
+
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
|
5
|
+
* / /
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Routes = require('../Routes');
|
|
9
|
+
import Version = require('../../base/Version');
|
|
10
|
+
import { PhoneNumberList } from './v2/phoneNumber';
|
|
11
|
+
import { PhoneNumberListInstance } from './v2/phoneNumber';
|
|
12
|
+
import { SipDomainList } from './v2/sipDomain';
|
|
13
|
+
import { SipDomainListInstance } from './v2/sipDomain';
|
|
14
|
+
import { TrunkList } from './v2/trunk';
|
|
15
|
+
import { TrunkListInstance } from './v2/trunk';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
declare class V2 extends Version {
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the V2 version of Routes
|
|
21
|
+
*
|
|
22
|
+
* @param domain - The twilio domain
|
|
23
|
+
*/
|
|
24
|
+
constructor(domain: Routes);
|
|
25
|
+
|
|
26
|
+
readonly phoneNumbers: PhoneNumberListInstance;
|
|
27
|
+
readonly sipDomains: SipDomainListInstance;
|
|
28
|
+
readonly trunks: TrunkListInstance;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export = V2;
|