twilio 3.23.0 → 3.25.0
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/CHANGES.md +55 -0
- package/lib/rest/Api.d.ts +2 -0
- package/lib/rest/Api.js +9 -0
- package/lib/rest/Authy.js +5 -5
- package/lib/rest/Preview.d.ts +0 -2
- package/lib/rest/Preview.js +12 -23
- package/lib/rest/Twilio.d.ts +1 -0
- package/lib/rest/Twilio.js +9 -0
- package/lib/rest/Video.js +8 -8
- package/lib/rest/api/V2010.d.ts +3 -0
- package/lib/rest/api/V2010.js +9 -0
- package/lib/rest/api/v2010/account/balance.d.ts +87 -0
- package/lib/rest/api/v2010/account/balance.js +162 -0
- package/lib/rest/api/v2010/account/message.d.ts +2 -0
- package/lib/rest/api/v2010/account/message.js +4 -1
- package/lib/rest/api/v2010/account/sip/ipAccessControlList.d.ts +3 -3
- package/lib/rest/api/v2010/account/sip/ipAccessControlList.js +3 -3
- package/lib/rest/api/v2010/account/usage/record/allTime.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/record/daily.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/record/lastMonth.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/record/monthly.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/record/thisMonth.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/record/today.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/record/yearly.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/record/yesterday.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/record.d.ts +1 -1
- package/lib/rest/api/v2010/account/usage/trigger.d.ts +1 -1
- package/lib/rest/api/v2010/account.d.ts +8 -0
- package/lib/rest/api/v2010/account.js +25 -0
- package/lib/rest/authy/V1.d.ts +1 -1
- package/lib/rest/authy/V1.js +8 -8
- package/lib/rest/authy/v1/form.d.ts +13 -13
- package/lib/rest/authy/v1/form.js +17 -17
- package/lib/rest/authy/v1/service/entity/factor/challenge.d.ts +12 -13
- package/lib/rest/authy/v1/service/entity/factor/challenge.js +4 -6
- package/lib/rest/authy/v1/service/entity/factor.d.ts +9 -9
- package/lib/rest/authy/v1/service/entity/factor.js +7 -9
- package/lib/rest/autopilot/v1/assistant/fieldType/fieldValue.d.ts +5 -5
- package/lib/rest/autopilot/v1/assistant/fieldType/fieldValue.js +9 -5
- package/lib/rest/autopilot/v1/assistant/fieldType.d.ts +5 -5
- package/lib/rest/autopilot/v1/assistant/fieldType.js +8 -5
- package/lib/rest/autopilot/v1/assistant/modelBuild.d.ts +5 -5
- package/lib/rest/autopilot/v1/assistant/modelBuild.js +8 -5
- package/lib/rest/autopilot/v1/assistant/query.d.ts +17 -17
- package/lib/rest/autopilot/v1/assistant/query.js +24 -18
- package/lib/rest/autopilot/v1/assistant/task/field.d.ts +11 -11
- package/lib/rest/autopilot/v1/assistant/task/field.js +15 -11
- package/lib/rest/autopilot/v1/assistant/task/sample.d.ts +18 -18
- package/lib/rest/autopilot/v1/assistant/task/sample.js +23 -21
- package/lib/rest/autopilot/v1/assistant/task/taskActions.d.ts +2 -2
- package/lib/rest/autopilot/v1/assistant/task/taskActions.js +4 -3
- package/lib/rest/autopilot/v1/assistant/task/taskStatistics.d.ts +6 -6
- package/lib/rest/autopilot/v1/assistant/task/taskStatistics.js +7 -6
- package/lib/rest/autopilot/v1/assistant/task.d.ts +10 -10
- package/lib/rest/autopilot/v1/assistant/task.js +21 -12
- package/lib/rest/autopilot/v1/assistant.d.ts +15 -15
- package/lib/rest/autopilot/v1/assistant.js +25 -20
- package/lib/rest/chat/v2/service/channel/member.d.ts +7 -0
- package/lib/rest/chat/v2/service/channel/member.js +13 -2
- package/lib/rest/ipMessaging/v2/service/channel/member.d.ts +7 -0
- package/lib/rest/ipMessaging/v2/service/channel/member.js +13 -2
- package/lib/rest/preview/Marketplace.d.ts +1 -1
- package/lib/rest/preview/Marketplace.js +9 -9
- package/lib/rest/proxy/v1/service.d.ts +7 -0
- package/lib/rest/proxy/v1/service.js +13 -2
- package/lib/rest/sync/v1/service/syncList/syncListItem.d.ts +10 -2
- package/lib/rest/sync/v1/service/syncList/syncListItem.js +24 -5
- package/lib/rest/sync/v1/service/syncList.d.ts +6 -2
- package/lib/rest/sync/v1/service/syncList.js +12 -5
- package/lib/rest/sync/v1/service/syncMap/syncMapItem.d.ts +10 -2
- package/lib/rest/sync/v1/service/syncMap/syncMapItem.js +24 -6
- package/lib/rest/sync/v1/service/syncMap.d.ts +6 -2
- package/lib/rest/sync/v1/service/syncMap.js +12 -5
- package/lib/rest/verify/v1/service/verification.d.ts +4 -0
- package/lib/rest/verify/v1/service/verification.js +5 -1
- package/lib/rest/video/V1.d.ts +1 -1
- package/lib/rest/video/V1.js +10 -10
- package/lib/twiml/VoiceResponse.d.ts +124 -0
- package/lib/twiml/VoiceResponse.js +960 -0
- package/package.json +1 -1
- package/lib/rest/preview/Authy.d.ts +0 -27
- package/lib/rest/preview/Authy.js +0 -44
- package/lib/rest/preview/authy/service/entity.d.ts +0 -250
- package/lib/rest/preview/authy/service/entity.js +0 -514
- package/lib/rest/preview/authy/service.d.ts +0 -275
- package/lib/rest/preview/authy/service.js +0 -578
|
@@ -1,578 +0,0 @@
|
|
|
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 EntityList = require('./service/entity').EntityList;
|
|
15
|
-
var Page = require('../../../base/Page'); /* jshint ignore:line */
|
|
16
|
-
var deserialize = require(
|
|
17
|
-
'../../../base/deserialize'); /* jshint ignore:line */
|
|
18
|
-
var values = require('../../../base/values'); /* jshint ignore:line */
|
|
19
|
-
|
|
20
|
-
var ServiceList;
|
|
21
|
-
var ServicePage;
|
|
22
|
-
var ServiceInstance;
|
|
23
|
-
var ServiceContext;
|
|
24
|
-
|
|
25
|
-
/* jshint ignore:start */
|
|
26
|
-
/**
|
|
27
|
-
* @description Initialize the ServiceList
|
|
28
|
-
* 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.
|
|
29
|
-
*
|
|
30
|
-
* @param {Twilio.Preview.Authy} version - Version of the resource
|
|
31
|
-
*/
|
|
32
|
-
/* jshint ignore:end */
|
|
33
|
-
ServiceList = function ServiceList(version) {
|
|
34
|
-
/* jshint ignore:start */
|
|
35
|
-
/**
|
|
36
|
-
* @param {string} sid - sid of instance
|
|
37
|
-
*
|
|
38
|
-
* @returns {Twilio.Preview.Authy.ServiceContext}
|
|
39
|
-
*/
|
|
40
|
-
/* jshint ignore:end */
|
|
41
|
-
function ServiceListInstance(sid) {
|
|
42
|
-
return ServiceListInstance.get(sid);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
ServiceListInstance._version = version;
|
|
46
|
-
// Path Solution
|
|
47
|
-
ServiceListInstance._solution = {};
|
|
48
|
-
ServiceListInstance._uri = _.template(
|
|
49
|
-
'/Services' // jshint ignore:line
|
|
50
|
-
)(ServiceListInstance._solution);
|
|
51
|
-
/* jshint ignore:start */
|
|
52
|
-
/**
|
|
53
|
-
* create a ServiceInstance
|
|
54
|
-
*
|
|
55
|
-
* @param {object} opts - Options for request
|
|
56
|
-
* @param {string} opts.friendlyName -
|
|
57
|
-
* A human readable description of this resource.
|
|
58
|
-
* @param {function} [callback] - Callback to handle processed record
|
|
59
|
-
*
|
|
60
|
-
* @returns {Promise} Resolves to processed ServiceInstance
|
|
61
|
-
*/
|
|
62
|
-
/* jshint ignore:end */
|
|
63
|
-
ServiceListInstance.create = function create(opts, callback) {
|
|
64
|
-
if (_.isUndefined(opts)) {
|
|
65
|
-
throw new Error('Required parameter "opts" missing.');
|
|
66
|
-
}
|
|
67
|
-
if (_.isUndefined(opts.friendlyName)) {
|
|
68
|
-
throw new Error('Required parameter "opts.friendlyName" missing.');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
var deferred = Q.defer();
|
|
72
|
-
var data = values.of({'FriendlyName': _.get(opts, 'friendlyName')});
|
|
73
|
-
|
|
74
|
-
var promise = this._version.create({uri: this._uri, method: 'POST', data: data});
|
|
75
|
-
|
|
76
|
-
promise = promise.then(function(payload) {
|
|
77
|
-
deferred.resolve(new ServiceInstance(this._version, payload, this._solution.sid));
|
|
78
|
-
}.bind(this));
|
|
79
|
-
|
|
80
|
-
promise.catch(function(error) {
|
|
81
|
-
deferred.reject(error);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (_.isFunction(callback)) {
|
|
85
|
-
deferred.promise.nodeify(callback);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return deferred.promise;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/* jshint ignore:start */
|
|
92
|
-
/**
|
|
93
|
-
* Streams ServiceInstance records from the API.
|
|
94
|
-
*
|
|
95
|
-
* This operation lazily loads records as efficiently as possible until the limit
|
|
96
|
-
* is reached.
|
|
97
|
-
*
|
|
98
|
-
* The results are passed into the callback function, so this operation is memory efficient.
|
|
99
|
-
*
|
|
100
|
-
* If a function is passed as the first argument, it will be used as the callback function.
|
|
101
|
-
*
|
|
102
|
-
* @param {object} [opts] - Options for request
|
|
103
|
-
* @param {number} [opts.limit] -
|
|
104
|
-
* Upper limit for the number of records to return.
|
|
105
|
-
* each() guarantees never to return more than limit.
|
|
106
|
-
* Default is no limit
|
|
107
|
-
* @param {number} [opts.pageSize] -
|
|
108
|
-
* Number of records to fetch per request,
|
|
109
|
-
* when not set will use the default value of 50 records.
|
|
110
|
-
* If no pageSize is defined but a limit is defined,
|
|
111
|
-
* each() will attempt to read the limit with the most efficient
|
|
112
|
-
* page size, i.e. min(limit, 1000)
|
|
113
|
-
* @param {Function} [opts.callback] -
|
|
114
|
-
* Function to process each record. If this and a positional
|
|
115
|
-
* callback are passed, this one will be used
|
|
116
|
-
* @param {Function} [opts.done] -
|
|
117
|
-
* Function to be called upon completion of streaming
|
|
118
|
-
* @param {Function} [callback] - Function to process each record
|
|
119
|
-
*/
|
|
120
|
-
/* jshint ignore:end */
|
|
121
|
-
ServiceListInstance.each = function each(opts, callback) {
|
|
122
|
-
if (_.isFunction(opts)) {
|
|
123
|
-
callback = opts;
|
|
124
|
-
opts = {};
|
|
125
|
-
}
|
|
126
|
-
opts = opts || {};
|
|
127
|
-
if (opts.callback) {
|
|
128
|
-
callback = opts.callback;
|
|
129
|
-
}
|
|
130
|
-
if (_.isUndefined(callback)) {
|
|
131
|
-
throw new Error('Callback function must be provided');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
var done = false;
|
|
135
|
-
var currentPage = 1;
|
|
136
|
-
var currentResource = 0;
|
|
137
|
-
var limits = this._version.readLimits({
|
|
138
|
-
limit: opts.limit,
|
|
139
|
-
pageSize: opts.pageSize
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
function onComplete(error) {
|
|
143
|
-
done = true;
|
|
144
|
-
if (_.isFunction(opts.done)) {
|
|
145
|
-
opts.done(error);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function fetchNextPage(fn) {
|
|
150
|
-
var promise = fn();
|
|
151
|
-
if (_.isUndefined(promise)) {
|
|
152
|
-
onComplete();
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
promise.then(function(page) {
|
|
157
|
-
_.each(page.instances, function(instance) {
|
|
158
|
-
if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) {
|
|
159
|
-
done = true;
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
currentResource++;
|
|
164
|
-
callback(instance, onComplete);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
if ((limits.pageLimit && limits.pageLimit <= currentPage)) {
|
|
168
|
-
onComplete();
|
|
169
|
-
} else if (!done) {
|
|
170
|
-
currentPage++;
|
|
171
|
-
fetchNextPage(_.bind(page.nextPage, page));
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
promise.catch(onComplete);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
fetchNextPage(_.bind(this.page, this, _.merge(opts, limits)));
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
/* jshint ignore:start */
|
|
182
|
-
/**
|
|
183
|
-
* Lists ServiceInstance records from the API as a list.
|
|
184
|
-
*
|
|
185
|
-
* If a function is passed as the first argument, it will be used as the callback function.
|
|
186
|
-
*
|
|
187
|
-
* @param {object} [opts] - Options for request
|
|
188
|
-
* @param {number} [opts.limit] -
|
|
189
|
-
* Upper limit for the number of records to return.
|
|
190
|
-
* list() guarantees never to return more than limit.
|
|
191
|
-
* Default is no limit
|
|
192
|
-
* @param {number} [opts.pageSize] -
|
|
193
|
-
* Number of records to fetch per request,
|
|
194
|
-
* when not set will use the default value of 50 records.
|
|
195
|
-
* If no page_size is defined but a limit is defined,
|
|
196
|
-
* list() will attempt to read the limit with the most
|
|
197
|
-
* efficient page size, i.e. min(limit, 1000)
|
|
198
|
-
* @param {function} [callback] - Callback to handle list of records
|
|
199
|
-
*
|
|
200
|
-
* @returns {Promise} Resolves to a list of records
|
|
201
|
-
*/
|
|
202
|
-
/* jshint ignore:end */
|
|
203
|
-
ServiceListInstance.list = function list(opts, callback) {
|
|
204
|
-
if (_.isFunction(opts)) {
|
|
205
|
-
callback = opts;
|
|
206
|
-
opts = {};
|
|
207
|
-
}
|
|
208
|
-
opts = opts || {};
|
|
209
|
-
var deferred = Q.defer();
|
|
210
|
-
var allResources = [];
|
|
211
|
-
opts.callback = function(resource, done) {
|
|
212
|
-
allResources.push(resource);
|
|
213
|
-
|
|
214
|
-
if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) {
|
|
215
|
-
done();
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
opts.done = function(error) {
|
|
220
|
-
if (_.isUndefined(error)) {
|
|
221
|
-
deferred.resolve(allResources);
|
|
222
|
-
} else {
|
|
223
|
-
deferred.reject(error);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
if (_.isFunction(callback)) {
|
|
228
|
-
deferred.promise.nodeify(callback);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
this.each(opts);
|
|
232
|
-
return deferred.promise;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
/* jshint ignore:start */
|
|
236
|
-
/**
|
|
237
|
-
* Retrieve a single page of ServiceInstance records from the API.
|
|
238
|
-
* Request is executed immediately
|
|
239
|
-
*
|
|
240
|
-
* If a function is passed as the first argument, it will be used as the callback function.
|
|
241
|
-
*
|
|
242
|
-
* @param {object} [opts] - Options for request
|
|
243
|
-
* @param {string} [opts.pageToken] - PageToken provided by the API
|
|
244
|
-
* @param {number} [opts.pageNumber] -
|
|
245
|
-
* Page Number, this value is simply for client state
|
|
246
|
-
* @param {number} [opts.pageSize] - Number of records to return, defaults to 50
|
|
247
|
-
* @param {function} [callback] - Callback to handle list of records
|
|
248
|
-
*
|
|
249
|
-
* @returns {Promise} Resolves to a list of records
|
|
250
|
-
*/
|
|
251
|
-
/* jshint ignore:end */
|
|
252
|
-
ServiceListInstance.page = function page(opts, callback) {
|
|
253
|
-
if (_.isFunction(opts)) {
|
|
254
|
-
callback = opts;
|
|
255
|
-
opts = {};
|
|
256
|
-
}
|
|
257
|
-
opts = opts || {};
|
|
258
|
-
|
|
259
|
-
var deferred = Q.defer();
|
|
260
|
-
var data = values.of({
|
|
261
|
-
'PageToken': opts.pageToken,
|
|
262
|
-
'Page': opts.pageNumber,
|
|
263
|
-
'PageSize': opts.pageSize
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
var promise = this._version.page({uri: this._uri, method: 'GET', params: data});
|
|
267
|
-
|
|
268
|
-
promise = promise.then(function(payload) {
|
|
269
|
-
deferred.resolve(new ServicePage(this._version, payload, this._solution));
|
|
270
|
-
}.bind(this));
|
|
271
|
-
|
|
272
|
-
promise.catch(function(error) {
|
|
273
|
-
deferred.reject(error);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
if (_.isFunction(callback)) {
|
|
277
|
-
deferred.promise.nodeify(callback);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return deferred.promise;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
/* jshint ignore:start */
|
|
284
|
-
/**
|
|
285
|
-
* Retrieve a single target page of ServiceInstance records from the API.
|
|
286
|
-
* Request is executed immediately
|
|
287
|
-
*
|
|
288
|
-
* If a function is passed as the first argument, it will be used as the callback function.
|
|
289
|
-
*
|
|
290
|
-
* @param {string} [targetUrl] - API-generated URL for the requested results page
|
|
291
|
-
* @param {function} [callback] - Callback to handle list of records
|
|
292
|
-
*
|
|
293
|
-
* @returns {Promise} Resolves to a list of records
|
|
294
|
-
*/
|
|
295
|
-
/* jshint ignore:end */
|
|
296
|
-
ServiceListInstance.getPage = function getPage(targetUrl, callback) {
|
|
297
|
-
var deferred = Q.defer();
|
|
298
|
-
|
|
299
|
-
var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl});
|
|
300
|
-
|
|
301
|
-
promise = promise.then(function(payload) {
|
|
302
|
-
deferred.resolve(new ServicePage(this._version, payload, this._solution));
|
|
303
|
-
}.bind(this));
|
|
304
|
-
|
|
305
|
-
promise.catch(function(error) {
|
|
306
|
-
deferred.reject(error);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
if (_.isFunction(callback)) {
|
|
310
|
-
deferred.promise.nodeify(callback);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return deferred.promise;
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
/* jshint ignore:start */
|
|
317
|
-
/**
|
|
318
|
-
* Constructs a service
|
|
319
|
-
*
|
|
320
|
-
* @param {string} sid - A string that uniquely identifies this Service.
|
|
321
|
-
*
|
|
322
|
-
* @returns {Twilio.Preview.Authy.ServiceContext}
|
|
323
|
-
*/
|
|
324
|
-
/* jshint ignore:end */
|
|
325
|
-
ServiceListInstance.get = function get(sid) {
|
|
326
|
-
return new ServiceContext(this._version, sid);
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
return ServiceListInstance;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
/* jshint ignore:start */
|
|
334
|
-
/**
|
|
335
|
-
* Initialize the ServicePagePLEASE 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.
|
|
336
|
-
*
|
|
337
|
-
* @param {Authy} version - Version of the resource
|
|
338
|
-
* @param {Response<string>} response - Response from the API
|
|
339
|
-
* @param {ServiceSolution} solution - Path solution
|
|
340
|
-
*
|
|
341
|
-
* @returns ServicePage
|
|
342
|
-
*/
|
|
343
|
-
/* jshint ignore:end */
|
|
344
|
-
ServicePage = function ServicePage(version, response, solution) {
|
|
345
|
-
// Path Solution
|
|
346
|
-
this._solution = solution;
|
|
347
|
-
|
|
348
|
-
Page.prototype.constructor.call(this, version, response, this._solution);
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
_.extend(ServicePage.prototype, Page.prototype);
|
|
352
|
-
ServicePage.prototype.constructor = ServicePage;
|
|
353
|
-
|
|
354
|
-
/* jshint ignore:start */
|
|
355
|
-
/**
|
|
356
|
-
* Build an instance of ServiceInstance
|
|
357
|
-
*
|
|
358
|
-
* @param {ServicePayload} payload - Payload response from the API
|
|
359
|
-
*
|
|
360
|
-
* @returns ServiceInstance
|
|
361
|
-
*/
|
|
362
|
-
/* jshint ignore:end */
|
|
363
|
-
ServicePage.prototype.getInstance = function getInstance(payload) {
|
|
364
|
-
return new ServiceInstance(this._version, payload);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
/* jshint ignore:start */
|
|
369
|
-
/**
|
|
370
|
-
* Initialize the ServiceContextPLEASE 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.
|
|
371
|
-
*
|
|
372
|
-
* @property {string} sid - A string that uniquely identifies this Service.
|
|
373
|
-
* @property {string} friendlyName - A human readable description of this resource.
|
|
374
|
-
* @property {string} accountSid - Account Sid.
|
|
375
|
-
* @property {Date} dateCreated - The date this Service was created
|
|
376
|
-
* @property {Date} dateUpdated - The date this Service was updated
|
|
377
|
-
* @property {string} url - The URL of this resource.
|
|
378
|
-
* @property {string} links - Nested resource URLs.
|
|
379
|
-
*
|
|
380
|
-
* @param {Authy} version - Version of the resource
|
|
381
|
-
* @param {ServicePayload} payload - The instance payload
|
|
382
|
-
* @param {sid} sid - A string that uniquely identifies this Service.
|
|
383
|
-
*/
|
|
384
|
-
/* jshint ignore:end */
|
|
385
|
-
ServiceInstance = function ServiceInstance(version, payload, sid) {
|
|
386
|
-
this._version = version;
|
|
387
|
-
|
|
388
|
-
// Marshaled Properties
|
|
389
|
-
this.sid = payload.sid; // jshint ignore:line
|
|
390
|
-
this.friendlyName = payload.friendly_name; // jshint ignore:line
|
|
391
|
-
this.accountSid = payload.account_sid; // jshint ignore:line
|
|
392
|
-
this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line
|
|
393
|
-
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line
|
|
394
|
-
this.url = payload.url; // jshint ignore:line
|
|
395
|
-
this.links = payload.links; // jshint ignore:line
|
|
396
|
-
|
|
397
|
-
// Context
|
|
398
|
-
this._context = undefined;
|
|
399
|
-
this._solution = {sid: sid || this.sid, };
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
Object.defineProperty(ServiceInstance.prototype,
|
|
403
|
-
'_proxy', {
|
|
404
|
-
get: function() {
|
|
405
|
-
if (!this._context) {
|
|
406
|
-
this._context = new ServiceContext(this._version, this._solution.sid);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return this._context;
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
/* jshint ignore:start */
|
|
414
|
-
/**
|
|
415
|
-
* fetch a ServiceInstance
|
|
416
|
-
*
|
|
417
|
-
* @param {function} [callback] - Callback to handle processed record
|
|
418
|
-
*
|
|
419
|
-
* @returns {Promise} Resolves to processed ServiceInstance
|
|
420
|
-
*/
|
|
421
|
-
/* jshint ignore:end */
|
|
422
|
-
ServiceInstance.prototype.fetch = function fetch(callback) {
|
|
423
|
-
return this._proxy.fetch(callback);
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
/* jshint ignore:start */
|
|
427
|
-
/**
|
|
428
|
-
* update a ServiceInstance
|
|
429
|
-
*
|
|
430
|
-
* @param {object} [opts] - Options for request
|
|
431
|
-
* @param {string} [opts.friendlyName] -
|
|
432
|
-
* A human readable description of this resource.
|
|
433
|
-
* @param {function} [callback] - Callback to handle processed record
|
|
434
|
-
*
|
|
435
|
-
* @returns {Promise} Resolves to processed ServiceInstance
|
|
436
|
-
*/
|
|
437
|
-
/* jshint ignore:end */
|
|
438
|
-
ServiceInstance.prototype.update = function update(opts, callback) {
|
|
439
|
-
return this._proxy.update(opts, callback);
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
/* jshint ignore:start */
|
|
443
|
-
/**
|
|
444
|
-
* Access the entities
|
|
445
|
-
*
|
|
446
|
-
* @returns {Twilio.Preview.Authy.ServiceContext.EntityList}
|
|
447
|
-
*/
|
|
448
|
-
/* jshint ignore:end */
|
|
449
|
-
ServiceInstance.prototype.entities = function entities() {
|
|
450
|
-
return this._proxy.entities;
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
/* jshint ignore:start */
|
|
454
|
-
/**
|
|
455
|
-
* Produce a plain JSON object version of the ServiceInstance for serialization.
|
|
456
|
-
* Removes any circular references in the object.
|
|
457
|
-
*
|
|
458
|
-
* @returns Object
|
|
459
|
-
*/
|
|
460
|
-
/* jshint ignore:end */
|
|
461
|
-
ServiceInstance.prototype.toJSON = function toJSON() {
|
|
462
|
-
let clone = {};
|
|
463
|
-
_.forOwn(this, function(value, key) {
|
|
464
|
-
if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
|
|
465
|
-
clone[key] = value;
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
return clone;
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
/* jshint ignore:start */
|
|
473
|
-
/**
|
|
474
|
-
* Initialize the ServiceContextPLEASE 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.
|
|
475
|
-
*
|
|
476
|
-
* @property {Twilio.Preview.Authy.ServiceContext.EntityList} entities -
|
|
477
|
-
* entities resource
|
|
478
|
-
*
|
|
479
|
-
* @param {Authy} version - Version of the resource
|
|
480
|
-
* @param {sid} sid - A string that uniquely identifies this Service.
|
|
481
|
-
*/
|
|
482
|
-
/* jshint ignore:end */
|
|
483
|
-
ServiceContext = function ServiceContext(version, sid) {
|
|
484
|
-
this._version = version;
|
|
485
|
-
|
|
486
|
-
// Path Solution
|
|
487
|
-
this._solution = {sid: sid, };
|
|
488
|
-
this._uri = _.template(
|
|
489
|
-
'/Services/<%= sid %>' // jshint ignore:line
|
|
490
|
-
)(this._solution);
|
|
491
|
-
|
|
492
|
-
// Dependents
|
|
493
|
-
this._entities = undefined;
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
/* jshint ignore:start */
|
|
497
|
-
/**
|
|
498
|
-
* fetch a ServiceInstance
|
|
499
|
-
*
|
|
500
|
-
* @param {function} [callback] - Callback to handle processed record
|
|
501
|
-
*
|
|
502
|
-
* @returns {Promise} Resolves to processed ServiceInstance
|
|
503
|
-
*/
|
|
504
|
-
/* jshint ignore:end */
|
|
505
|
-
ServiceContext.prototype.fetch = function fetch(callback) {
|
|
506
|
-
var deferred = Q.defer();
|
|
507
|
-
var promise = this._version.fetch({uri: this._uri, method: 'GET'});
|
|
508
|
-
|
|
509
|
-
promise = promise.then(function(payload) {
|
|
510
|
-
deferred.resolve(new ServiceInstance(this._version, payload, this._solution.sid));
|
|
511
|
-
}.bind(this));
|
|
512
|
-
|
|
513
|
-
promise.catch(function(error) {
|
|
514
|
-
deferred.reject(error);
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
if (_.isFunction(callback)) {
|
|
518
|
-
deferred.promise.nodeify(callback);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
return deferred.promise;
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
/* jshint ignore:start */
|
|
525
|
-
/**
|
|
526
|
-
* update a ServiceInstance
|
|
527
|
-
*
|
|
528
|
-
* @param {object} [opts] - Options for request
|
|
529
|
-
* @param {string} [opts.friendlyName] -
|
|
530
|
-
* A human readable description of this resource.
|
|
531
|
-
* @param {function} [callback] - Callback to handle processed record
|
|
532
|
-
*
|
|
533
|
-
* @returns {Promise} Resolves to processed ServiceInstance
|
|
534
|
-
*/
|
|
535
|
-
/* jshint ignore:end */
|
|
536
|
-
ServiceContext.prototype.update = function update(opts, callback) {
|
|
537
|
-
if (_.isFunction(opts)) {
|
|
538
|
-
callback = opts;
|
|
539
|
-
opts = {};
|
|
540
|
-
}
|
|
541
|
-
opts = opts || {};
|
|
542
|
-
|
|
543
|
-
var deferred = Q.defer();
|
|
544
|
-
var data = values.of({'FriendlyName': _.get(opts, 'friendlyName')});
|
|
545
|
-
|
|
546
|
-
var promise = this._version.update({uri: this._uri, method: 'POST', data: data});
|
|
547
|
-
|
|
548
|
-
promise = promise.then(function(payload) {
|
|
549
|
-
deferred.resolve(new ServiceInstance(this._version, payload, this._solution.sid));
|
|
550
|
-
}.bind(this));
|
|
551
|
-
|
|
552
|
-
promise.catch(function(error) {
|
|
553
|
-
deferred.reject(error);
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
if (_.isFunction(callback)) {
|
|
557
|
-
deferred.promise.nodeify(callback);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
return deferred.promise;
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
Object.defineProperty(ServiceContext.prototype,
|
|
564
|
-
'entities', {
|
|
565
|
-
get: function() {
|
|
566
|
-
if (!this._entities) {
|
|
567
|
-
this._entities = new EntityList(this._version, this._solution.sid);
|
|
568
|
-
}
|
|
569
|
-
return this._entities;
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
module.exports = {
|
|
574
|
-
ServiceList: ServiceList,
|
|
575
|
-
ServicePage: ServicePage,
|
|
576
|
-
ServiceInstance: ServiceInstance,
|
|
577
|
-
ServiceContext: ServiceContext
|
|
578
|
-
};
|