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