twilio 3.77.3 → 3.80.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/README.md +6 -2
- package/lib/base/RequestClient.d.ts +15 -5
- package/lib/base/RequestClient.js +36 -7
- package/lib/rest/Insights.d.ts +0 -2
- package/lib/rest/Insights.js +0 -8
- 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/conversations/v1/conversation/participant.js +4 -2
- package/lib/rest/conversations/v1/service/conversation/participant.js +4 -2
- package/lib/rest/flexApi/v1/interaction/interactionChannel.d.ts +12 -4
- package/lib/rest/flexApi/v1/interaction/interactionChannel.js +12 -3
- package/lib/rest/insights/V1.d.ts +0 -3
- package/lib/rest/insights/V1.js +0 -11
- package/lib/rest/insights/v1/{annotation.d.ts → call/annotation.d.ts} +29 -17
- package/lib/rest/insights/v1/{annotation.js → call/annotation.js} +72 -55
- package/lib/rest/insights/v1/call/summary.d.ts +2 -0
- package/lib/rest/insights/v1/call/summary.js +2 -0
- package/lib/rest/insights/v1/call.d.ts +7 -16
- package/lib/rest/insights/v1/call.js +28 -16
- package/lib/rest/lookups/v2/phoneNumber.d.ts +0 -2
- package/lib/rest/lookups/v2/phoneNumber.js +0 -3
- package/lib/rest/media/v1/mediaRecording.d.ts +0 -2
- package/lib/rest/media/v1/mediaRecording.js +0 -2
- package/lib/rest/supersim/v1/sim/simIpAddress.d.ts +246 -0
- package/lib/rest/supersim/v1/sim/simIpAddress.js +448 -0
- package/lib/rest/supersim/v1/sim.d.ts +7 -0
- package/lib/rest/supersim/v1/sim.js +28 -0
- package/lib/rest/verify/v2/service/verificationCheck.d.ts +10 -2
- package/lib/rest/verify/v2/service/verificationCheck.js +9 -7
- package/lib/twiml/VoiceResponse.d.ts +2 -0
- package/lib/twiml/VoiceResponse.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by
|
|
3
|
+
* \ / _ _ _| _ _
|
|
4
|
+
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
|
5
|
+
* / /
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Page = require('../../../../base/Page');
|
|
9
|
+
import Response = require('../../../../http/response');
|
|
10
|
+
import V1 = require('../../V1');
|
|
11
|
+
import { SerializableClass } from '../../../../interfaces';
|
|
12
|
+
|
|
13
|
+
type SimIpAddressIpAddressVersion = 'IPv4'|'IPv6';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the SimIpAddressList
|
|
17
|
+
*
|
|
18
|
+
* PLEASE NOTE that this class contains beta products that are subject to change.
|
|
19
|
+
* Use them with caution.
|
|
20
|
+
*
|
|
21
|
+
* @param version - Version of the resource
|
|
22
|
+
* @param simSid - The unique string that identifies the resource
|
|
23
|
+
*/
|
|
24
|
+
declare function SimIpAddressList(version: V1, simSid: string): SimIpAddressListInstance;
|
|
25
|
+
|
|
26
|
+
interface SimIpAddressListInstance {
|
|
27
|
+
/**
|
|
28
|
+
* Streams SimIpAddressInstance records from the API.
|
|
29
|
+
*
|
|
30
|
+
* This operation lazily loads records as efficiently as possible until the limit
|
|
31
|
+
* is reached.
|
|
32
|
+
*
|
|
33
|
+
* The results are passed into the callback function, so this operation is memory
|
|
34
|
+
* efficient.
|
|
35
|
+
*
|
|
36
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
37
|
+
* function.
|
|
38
|
+
*
|
|
39
|
+
* @param callback - Function to process each record
|
|
40
|
+
*/
|
|
41
|
+
each(callback?: (item: SimIpAddressInstance, done: (err?: Error) => void) => void): void;
|
|
42
|
+
/**
|
|
43
|
+
* Streams SimIpAddressInstance records from the API.
|
|
44
|
+
*
|
|
45
|
+
* This operation lazily loads records as efficiently as possible until the limit
|
|
46
|
+
* is reached.
|
|
47
|
+
*
|
|
48
|
+
* The results are passed into the callback function, so this operation is memory
|
|
49
|
+
* efficient.
|
|
50
|
+
*
|
|
51
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
52
|
+
* function.
|
|
53
|
+
*
|
|
54
|
+
* @param opts - Options for request
|
|
55
|
+
* @param callback - Function to process each record
|
|
56
|
+
*/
|
|
57
|
+
each(opts?: SimIpAddressListInstanceEachOptions, callback?: (item: SimIpAddressInstance, done: (err?: Error) => void) => void): void;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve a single target page of SimIpAddressInstance records from the API.
|
|
60
|
+
*
|
|
61
|
+
* The request is executed immediately.
|
|
62
|
+
*
|
|
63
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
64
|
+
* function.
|
|
65
|
+
*
|
|
66
|
+
* @param callback - Callback to handle list of records
|
|
67
|
+
*/
|
|
68
|
+
getPage(callback?: (error: Error | null, items: SimIpAddressPage) => any): Promise<SimIpAddressPage>;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve a single target page of SimIpAddressInstance records from the API.
|
|
71
|
+
*
|
|
72
|
+
* The request is executed immediately.
|
|
73
|
+
*
|
|
74
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
75
|
+
* function.
|
|
76
|
+
*
|
|
77
|
+
* @param targetUrl - API-generated URL for the requested results page
|
|
78
|
+
* @param callback - Callback to handle list of records
|
|
79
|
+
*/
|
|
80
|
+
getPage(targetUrl?: string, callback?: (error: Error | null, items: SimIpAddressPage) => any): Promise<SimIpAddressPage>;
|
|
81
|
+
/**
|
|
82
|
+
* Lists SimIpAddressInstance records from the API as a list.
|
|
83
|
+
*
|
|
84
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
85
|
+
* function.
|
|
86
|
+
*
|
|
87
|
+
* @param callback - Callback to handle list of records
|
|
88
|
+
*/
|
|
89
|
+
list(callback?: (error: Error | null, items: SimIpAddressInstance[]) => any): Promise<SimIpAddressInstance[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Lists SimIpAddressInstance records from the API as a list.
|
|
92
|
+
*
|
|
93
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
94
|
+
* function.
|
|
95
|
+
*
|
|
96
|
+
* @param opts - Options for request
|
|
97
|
+
* @param callback - Callback to handle list of records
|
|
98
|
+
*/
|
|
99
|
+
list(opts?: SimIpAddressListInstanceOptions, callback?: (error: Error | null, items: SimIpAddressInstance[]) => any): Promise<SimIpAddressInstance[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Retrieve a single page of SimIpAddressInstance records from the API.
|
|
102
|
+
*
|
|
103
|
+
* The request is executed immediately.
|
|
104
|
+
*
|
|
105
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
106
|
+
* function.
|
|
107
|
+
*
|
|
108
|
+
* @param callback - Callback to handle list of records
|
|
109
|
+
*/
|
|
110
|
+
page(callback?: (error: Error | null, items: SimIpAddressPage) => any): Promise<SimIpAddressPage>;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieve a single page of SimIpAddressInstance records from the API.
|
|
113
|
+
*
|
|
114
|
+
* The request is executed immediately.
|
|
115
|
+
*
|
|
116
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
117
|
+
* function.
|
|
118
|
+
*
|
|
119
|
+
* @param opts - Options for request
|
|
120
|
+
* @param callback - Callback to handle list of records
|
|
121
|
+
*/
|
|
122
|
+
page(opts?: SimIpAddressListInstancePageOptions, callback?: (error: Error | null, items: SimIpAddressPage) => any): Promise<SimIpAddressPage>;
|
|
123
|
+
/**
|
|
124
|
+
* Provide a user-friendly representation
|
|
125
|
+
*/
|
|
126
|
+
toJSON(): any;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Options to pass to each
|
|
131
|
+
*
|
|
132
|
+
* @property callback -
|
|
133
|
+
* Function to process each record. If this and a positional
|
|
134
|
+
* callback are passed, this one will be used
|
|
135
|
+
* @property done - Function to be called upon completion of streaming
|
|
136
|
+
* @property limit -
|
|
137
|
+
* Upper limit for the number of records to return.
|
|
138
|
+
* each() guarantees never to return more than limit.
|
|
139
|
+
* Default is no limit
|
|
140
|
+
* @property pageSize -
|
|
141
|
+
* Number of records to fetch per request,
|
|
142
|
+
* when not set will use the default value of 50 records.
|
|
143
|
+
* If no pageSize is defined but a limit is defined,
|
|
144
|
+
* each() will attempt to read the limit with the most efficient
|
|
145
|
+
* page size, i.e. min(limit, 1000)
|
|
146
|
+
*/
|
|
147
|
+
interface SimIpAddressListInstanceEachOptions {
|
|
148
|
+
callback?: (item: SimIpAddressInstance, done: (err?: Error) => void) => void;
|
|
149
|
+
done?: Function;
|
|
150
|
+
limit?: number;
|
|
151
|
+
pageSize?: number;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Options to pass to list
|
|
156
|
+
*
|
|
157
|
+
* @property limit -
|
|
158
|
+
* Upper limit for the number of records to return.
|
|
159
|
+
* list() guarantees never to return more than limit.
|
|
160
|
+
* Default is no limit
|
|
161
|
+
* @property pageSize -
|
|
162
|
+
* Number of records to fetch per request,
|
|
163
|
+
* when not set will use the default value of 50 records.
|
|
164
|
+
* If no page_size is defined but a limit is defined,
|
|
165
|
+
* list() will attempt to read the limit with the most
|
|
166
|
+
* efficient page size, i.e. min(limit, 1000)
|
|
167
|
+
*/
|
|
168
|
+
interface SimIpAddressListInstanceOptions {
|
|
169
|
+
limit?: number;
|
|
170
|
+
pageSize?: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Options to pass to page
|
|
175
|
+
*
|
|
176
|
+
* @property pageNumber - Page Number, this value is simply for client state
|
|
177
|
+
* @property pageSize - Number of records to return, defaults to 50
|
|
178
|
+
* @property pageToken - PageToken provided by the API
|
|
179
|
+
*/
|
|
180
|
+
interface SimIpAddressListInstancePageOptions {
|
|
181
|
+
pageNumber?: number;
|
|
182
|
+
pageSize?: number;
|
|
183
|
+
pageToken?: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
interface SimIpAddressPayload extends SimIpAddressResource, Page.TwilioResponsePayload {
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
interface SimIpAddressResource {
|
|
190
|
+
ip_address: string;
|
|
191
|
+
ip_address_version: SimIpAddressIpAddressVersion;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
interface SimIpAddressSolution {
|
|
195
|
+
simSid?: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
declare class SimIpAddressInstance extends SerializableClass {
|
|
200
|
+
/**
|
|
201
|
+
* Initialize the SimIpAddressContext
|
|
202
|
+
*
|
|
203
|
+
* PLEASE NOTE that this class contains beta products that are subject to change.
|
|
204
|
+
* Use them with caution.
|
|
205
|
+
*
|
|
206
|
+
* @param version - Version of the resource
|
|
207
|
+
* @param payload - The instance payload
|
|
208
|
+
* @param simSid - The unique string that identifies the resource
|
|
209
|
+
*/
|
|
210
|
+
constructor(version: V1, payload: SimIpAddressPayload, simSid: string);
|
|
211
|
+
|
|
212
|
+
ipAddress: string;
|
|
213
|
+
ipAddressVersion: SimIpAddressIpAddressVersion;
|
|
214
|
+
/**
|
|
215
|
+
* Provide a user-friendly representation
|
|
216
|
+
*/
|
|
217
|
+
toJSON(): any;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
declare class SimIpAddressPage extends Page<V1, SimIpAddressPayload, SimIpAddressResource, SimIpAddressInstance> {
|
|
222
|
+
/**
|
|
223
|
+
* Initialize the SimIpAddressPage
|
|
224
|
+
*
|
|
225
|
+
* PLEASE NOTE that this class contains beta products that are subject to change.
|
|
226
|
+
* Use them with caution.
|
|
227
|
+
*
|
|
228
|
+
* @param version - Version of the resource
|
|
229
|
+
* @param response - Response from the API
|
|
230
|
+
* @param solution - Path solution
|
|
231
|
+
*/
|
|
232
|
+
constructor(version: V1, response: Response<string>, solution: SimIpAddressSolution);
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Build an instance of SimIpAddressInstance
|
|
236
|
+
*
|
|
237
|
+
* @param payload - Payload response from the API
|
|
238
|
+
*/
|
|
239
|
+
getInstance(payload: SimIpAddressPayload): SimIpAddressInstance;
|
|
240
|
+
/**
|
|
241
|
+
* Provide a user-friendly representation
|
|
242
|
+
*/
|
|
243
|
+
toJSON(): any;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export { SimIpAddressInstance, SimIpAddressIpAddressVersion, SimIpAddressList, SimIpAddressListInstance, SimIpAddressListInstanceEachOptions, SimIpAddressListInstanceOptions, SimIpAddressListInstancePageOptions, SimIpAddressPage, SimIpAddressPayload, SimIpAddressResource, SimIpAddressSolution }
|
|
@@ -0,0 +1,448 @@
|
|
|
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 values = require('../../../../base/values'); /* jshint ignore:line */
|
|
17
|
+
|
|
18
|
+
var SimIpAddressList;
|
|
19
|
+
var SimIpAddressPage;
|
|
20
|
+
var SimIpAddressInstance;
|
|
21
|
+
|
|
22
|
+
/* jshint ignore:start */
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the SimIpAddressList
|
|
25
|
+
*
|
|
26
|
+
* PLEASE NOTE that this class contains beta products that are subject to change.
|
|
27
|
+
* Use them with caution.
|
|
28
|
+
*
|
|
29
|
+
* @constructor Twilio.Supersim.V1.SimContext.SimIpAddressList
|
|
30
|
+
*
|
|
31
|
+
* @param {Twilio.Supersim.V1} version - Version of the resource
|
|
32
|
+
* @param {string} simSid - The unique string that identifies the resource
|
|
33
|
+
*/
|
|
34
|
+
/* jshint ignore:end */
|
|
35
|
+
SimIpAddressList = function SimIpAddressList(version, simSid) {
|
|
36
|
+
/* jshint ignore:start */
|
|
37
|
+
/**
|
|
38
|
+
* @function simIpAddresses
|
|
39
|
+
* @memberof Twilio.Supersim.V1.SimContext#
|
|
40
|
+
*
|
|
41
|
+
* @param {string} sid - sid of instance
|
|
42
|
+
*
|
|
43
|
+
* @returns {Twilio.Supersim.V1.SimContext.SimIpAddressContext}
|
|
44
|
+
*/
|
|
45
|
+
/* jshint ignore:end */
|
|
46
|
+
function SimIpAddressListInstance(sid) {
|
|
47
|
+
return SimIpAddressListInstance.get(sid);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
SimIpAddressListInstance._version = version;
|
|
51
|
+
// Path Solution
|
|
52
|
+
SimIpAddressListInstance._solution = {simSid: simSid};
|
|
53
|
+
SimIpAddressListInstance._uri = `/Sims/${simSid}/IpAddresses`;
|
|
54
|
+
/* jshint ignore:start */
|
|
55
|
+
/**
|
|
56
|
+
* Streams SimIpAddressInstance records from the API.
|
|
57
|
+
*
|
|
58
|
+
* This operation lazily loads records as efficiently as possible until the limit
|
|
59
|
+
* is reached.
|
|
60
|
+
*
|
|
61
|
+
* The results are passed into the callback function, so this operation is memory
|
|
62
|
+
* efficient.
|
|
63
|
+
*
|
|
64
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
65
|
+
* function.
|
|
66
|
+
*
|
|
67
|
+
* @function each
|
|
68
|
+
* @memberof Twilio.Supersim.V1.SimContext.SimIpAddressList#
|
|
69
|
+
*
|
|
70
|
+
* @param {object} [opts] - Options for request
|
|
71
|
+
* @param {number} [opts.limit] -
|
|
72
|
+
* Upper limit for the number of records to return.
|
|
73
|
+
* each() guarantees never to return more than limit.
|
|
74
|
+
* Default is no limit
|
|
75
|
+
* @param {number} [opts.pageSize] -
|
|
76
|
+
* Number of records to fetch per request,
|
|
77
|
+
* when not set will use the default value of 50 records.
|
|
78
|
+
* If no pageSize is defined but a limit is defined,
|
|
79
|
+
* each() will attempt to read the limit with the most efficient
|
|
80
|
+
* page size, i.e. min(limit, 1000)
|
|
81
|
+
* @param {Function} [opts.callback] -
|
|
82
|
+
* Function to process each record. If this and a positional
|
|
83
|
+
* callback are passed, this one will be used
|
|
84
|
+
* @param {Function} [opts.done] -
|
|
85
|
+
* Function to be called upon completion of streaming
|
|
86
|
+
* @param {Function} [callback] - Function to process each record
|
|
87
|
+
*/
|
|
88
|
+
/* jshint ignore:end */
|
|
89
|
+
SimIpAddressListInstance.each = function each(opts, callback) {
|
|
90
|
+
if (_.isFunction(opts)) {
|
|
91
|
+
callback = opts;
|
|
92
|
+
opts = {};
|
|
93
|
+
}
|
|
94
|
+
opts = opts || {};
|
|
95
|
+
if (opts.callback) {
|
|
96
|
+
callback = opts.callback;
|
|
97
|
+
}
|
|
98
|
+
if (_.isUndefined(callback)) {
|
|
99
|
+
throw new Error('Callback function must be provided');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
var done = false;
|
|
103
|
+
var currentPage = 1;
|
|
104
|
+
var currentResource = 0;
|
|
105
|
+
var limits = this._version.readLimits({
|
|
106
|
+
limit: opts.limit,
|
|
107
|
+
pageSize: opts.pageSize
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
function onComplete(error) {
|
|
111
|
+
done = true;
|
|
112
|
+
if (_.isFunction(opts.done)) {
|
|
113
|
+
opts.done(error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function fetchNextPage(fn) {
|
|
118
|
+
var promise = fn();
|
|
119
|
+
if (_.isUndefined(promise)) {
|
|
120
|
+
onComplete();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
promise.then(function(page) {
|
|
125
|
+
_.each(page.instances, function(instance) {
|
|
126
|
+
if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) {
|
|
127
|
+
done = true;
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
currentResource++;
|
|
132
|
+
callback(instance, onComplete);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (!done) {
|
|
136
|
+
currentPage++;
|
|
137
|
+
fetchNextPage(_.bind(page.nextPage, page));
|
|
138
|
+
} else {
|
|
139
|
+
onComplete();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
promise.catch(onComplete);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
fetchNextPage(_.bind(this.page, this, _.merge(opts, limits)));
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/* jshint ignore:start */
|
|
150
|
+
/**
|
|
151
|
+
* Lists SimIpAddressInstance records from the API as a list.
|
|
152
|
+
*
|
|
153
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
154
|
+
* function.
|
|
155
|
+
*
|
|
156
|
+
* @function list
|
|
157
|
+
* @memberof Twilio.Supersim.V1.SimContext.SimIpAddressList#
|
|
158
|
+
*
|
|
159
|
+
* @param {object} [opts] - Options for request
|
|
160
|
+
* @param {number} [opts.limit] -
|
|
161
|
+
* Upper limit for the number of records to return.
|
|
162
|
+
* list() guarantees never to return more than limit.
|
|
163
|
+
* Default is no limit
|
|
164
|
+
* @param {number} [opts.pageSize] -
|
|
165
|
+
* Number of records to fetch per request,
|
|
166
|
+
* when not set will use the default value of 50 records.
|
|
167
|
+
* If no page_size is defined but a limit is defined,
|
|
168
|
+
* list() will attempt to read the limit with the most
|
|
169
|
+
* efficient page size, i.e. min(limit, 1000)
|
|
170
|
+
* @param {function} [callback] - Callback to handle list of records
|
|
171
|
+
*
|
|
172
|
+
* @returns {Promise} Resolves to a list of records
|
|
173
|
+
*/
|
|
174
|
+
/* jshint ignore:end */
|
|
175
|
+
SimIpAddressListInstance.list = function list(opts, callback) {
|
|
176
|
+
if (_.isFunction(opts)) {
|
|
177
|
+
callback = opts;
|
|
178
|
+
opts = {};
|
|
179
|
+
}
|
|
180
|
+
opts = opts || {};
|
|
181
|
+
var deferred = Q.defer();
|
|
182
|
+
var allResources = [];
|
|
183
|
+
opts.callback = function(resource, done) {
|
|
184
|
+
allResources.push(resource);
|
|
185
|
+
|
|
186
|
+
if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) {
|
|
187
|
+
done();
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
opts.done = function(error) {
|
|
192
|
+
if (_.isUndefined(error)) {
|
|
193
|
+
deferred.resolve(allResources);
|
|
194
|
+
} else {
|
|
195
|
+
deferred.reject(error);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
if (_.isFunction(callback)) {
|
|
200
|
+
deferred.promise.nodeify(callback);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this.each(opts);
|
|
204
|
+
return deferred.promise;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/* jshint ignore:start */
|
|
208
|
+
/**
|
|
209
|
+
* Retrieve a single page of SimIpAddressInstance records from the API.
|
|
210
|
+
*
|
|
211
|
+
* The request is executed immediately.
|
|
212
|
+
*
|
|
213
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
214
|
+
* function.
|
|
215
|
+
*
|
|
216
|
+
* @function page
|
|
217
|
+
* @memberof Twilio.Supersim.V1.SimContext.SimIpAddressList#
|
|
218
|
+
*
|
|
219
|
+
* @param {object} [opts] - Options for request
|
|
220
|
+
* @param {string} [opts.pageToken] - PageToken provided by the API
|
|
221
|
+
* @param {number} [opts.pageNumber] -
|
|
222
|
+
* Page Number, this value is simply for client state
|
|
223
|
+
* @param {number} [opts.pageSize] - Number of records to return, defaults to 50
|
|
224
|
+
* @param {function} [callback] - Callback to handle list of records
|
|
225
|
+
*
|
|
226
|
+
* @returns {Promise} Resolves to a list of records
|
|
227
|
+
*/
|
|
228
|
+
/* jshint ignore:end */
|
|
229
|
+
SimIpAddressListInstance.page = function page(opts, callback) {
|
|
230
|
+
if (_.isFunction(opts)) {
|
|
231
|
+
callback = opts;
|
|
232
|
+
opts = {};
|
|
233
|
+
}
|
|
234
|
+
opts = opts || {};
|
|
235
|
+
|
|
236
|
+
var deferred = Q.defer();
|
|
237
|
+
var data = values.of({
|
|
238
|
+
'PageToken': opts.pageToken,
|
|
239
|
+
'Page': opts.pageNumber,
|
|
240
|
+
'PageSize': opts.pageSize
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
var promise = this._version.page({uri: this._uri, method: 'GET', params: data});
|
|
244
|
+
|
|
245
|
+
promise = promise.then(function(payload) {
|
|
246
|
+
deferred.resolve(new SimIpAddressPage(this._version, payload, this._solution));
|
|
247
|
+
}.bind(this));
|
|
248
|
+
|
|
249
|
+
promise.catch(function(error) {
|
|
250
|
+
deferred.reject(error);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (_.isFunction(callback)) {
|
|
254
|
+
deferred.promise.nodeify(callback);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return deferred.promise;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/* jshint ignore:start */
|
|
261
|
+
/**
|
|
262
|
+
* Retrieve a single target page of SimIpAddressInstance records from the API.
|
|
263
|
+
*
|
|
264
|
+
* The request is executed immediately.
|
|
265
|
+
*
|
|
266
|
+
* If a function is passed as the first argument, it will be used as the callback
|
|
267
|
+
* function.
|
|
268
|
+
*
|
|
269
|
+
* @function getPage
|
|
270
|
+
* @memberof Twilio.Supersim.V1.SimContext.SimIpAddressList#
|
|
271
|
+
*
|
|
272
|
+
* @param {string} [targetUrl] - API-generated URL for the requested results page
|
|
273
|
+
* @param {function} [callback] - Callback to handle list of records
|
|
274
|
+
*
|
|
275
|
+
* @returns {Promise} Resolves to a list of records
|
|
276
|
+
*/
|
|
277
|
+
/* jshint ignore:end */
|
|
278
|
+
SimIpAddressListInstance.getPage = function getPage(targetUrl, callback) {
|
|
279
|
+
var deferred = Q.defer();
|
|
280
|
+
|
|
281
|
+
var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl});
|
|
282
|
+
|
|
283
|
+
promise = promise.then(function(payload) {
|
|
284
|
+
deferred.resolve(new SimIpAddressPage(this._version, payload, this._solution));
|
|
285
|
+
}.bind(this));
|
|
286
|
+
|
|
287
|
+
promise.catch(function(error) {
|
|
288
|
+
deferred.reject(error);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
if (_.isFunction(callback)) {
|
|
292
|
+
deferred.promise.nodeify(callback);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return deferred.promise;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
/* jshint ignore:start */
|
|
299
|
+
/**
|
|
300
|
+
* Provide a user-friendly representation
|
|
301
|
+
*
|
|
302
|
+
* @function toJSON
|
|
303
|
+
* @memberof Twilio.Supersim.V1.SimContext.SimIpAddressList#
|
|
304
|
+
*
|
|
305
|
+
* @returns Object
|
|
306
|
+
*/
|
|
307
|
+
/* jshint ignore:end */
|
|
308
|
+
SimIpAddressListInstance.toJSON = function toJSON() {
|
|
309
|
+
return this._solution;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
SimIpAddressListInstance[util.inspect.custom] = function inspect(depth, options)
|
|
313
|
+
{
|
|
314
|
+
return util.inspect(this.toJSON(), options);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
return SimIpAddressListInstance;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
/* jshint ignore:start */
|
|
322
|
+
/**
|
|
323
|
+
* Initialize the SimIpAddressPage
|
|
324
|
+
*
|
|
325
|
+
* PLEASE NOTE that this class contains beta products that are subject to change.
|
|
326
|
+
* Use them with caution.
|
|
327
|
+
*
|
|
328
|
+
* @constructor Twilio.Supersim.V1.SimContext.SimIpAddressPage
|
|
329
|
+
*
|
|
330
|
+
* @param {V1} version - Version of the resource
|
|
331
|
+
* @param {Response<string>} response - Response from the API
|
|
332
|
+
* @param {SimIpAddressSolution} solution - Path solution
|
|
333
|
+
*
|
|
334
|
+
* @returns SimIpAddressPage
|
|
335
|
+
*/
|
|
336
|
+
/* jshint ignore:end */
|
|
337
|
+
SimIpAddressPage = function SimIpAddressPage(version, response, solution) {
|
|
338
|
+
// Path Solution
|
|
339
|
+
this._solution = solution;
|
|
340
|
+
|
|
341
|
+
Page.prototype.constructor.call(this, version, response, this._solution);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
_.extend(SimIpAddressPage.prototype, Page.prototype);
|
|
345
|
+
SimIpAddressPage.prototype.constructor = SimIpAddressPage;
|
|
346
|
+
|
|
347
|
+
/* jshint ignore:start */
|
|
348
|
+
/**
|
|
349
|
+
* Build an instance of SimIpAddressInstance
|
|
350
|
+
*
|
|
351
|
+
* @function getInstance
|
|
352
|
+
* @memberof Twilio.Supersim.V1.SimContext.SimIpAddressPage#
|
|
353
|
+
*
|
|
354
|
+
* @param {SimIpAddressPayload} payload - Payload response from the API
|
|
355
|
+
*
|
|
356
|
+
* @returns SimIpAddressInstance
|
|
357
|
+
*/
|
|
358
|
+
/* jshint ignore:end */
|
|
359
|
+
SimIpAddressPage.prototype.getInstance = function getInstance(payload) {
|
|
360
|
+
return new SimIpAddressInstance(this._version, payload, this._solution.simSid);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/* jshint ignore:start */
|
|
364
|
+
/**
|
|
365
|
+
* Provide a user-friendly representation
|
|
366
|
+
*
|
|
367
|
+
* @function toJSON
|
|
368
|
+
* @memberof Twilio.Supersim.V1.SimContext.SimIpAddressPage#
|
|
369
|
+
*
|
|
370
|
+
* @returns Object
|
|
371
|
+
*/
|
|
372
|
+
/* jshint ignore:end */
|
|
373
|
+
SimIpAddressPage.prototype.toJSON = function toJSON() {
|
|
374
|
+
let clone = {};
|
|
375
|
+
_.forOwn(this, function(value, key) {
|
|
376
|
+
if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
|
|
377
|
+
clone[key] = value;
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
return clone;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
SimIpAddressPage.prototype[util.inspect.custom] = function inspect(depth,
|
|
384
|
+
options) {
|
|
385
|
+
return util.inspect(this.toJSON(), options);
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
/* jshint ignore:start */
|
|
390
|
+
/**
|
|
391
|
+
* Initialize the SimIpAddressContext
|
|
392
|
+
*
|
|
393
|
+
* PLEASE NOTE that this class contains beta products that are subject to change.
|
|
394
|
+
* Use them with caution.
|
|
395
|
+
*
|
|
396
|
+
* @constructor Twilio.Supersim.V1.SimContext.SimIpAddressInstance
|
|
397
|
+
*
|
|
398
|
+
* @property {string} ipAddress - IP address assigned to the given Super SIM
|
|
399
|
+
* @property {sim_ip_address.ip_address_version} ipAddressVersion -
|
|
400
|
+
* IP address version
|
|
401
|
+
*
|
|
402
|
+
* @param {V1} version - Version of the resource
|
|
403
|
+
* @param {SimIpAddressPayload} payload - The instance payload
|
|
404
|
+
* @param {sid} simSid - The unique string that identifies the resource
|
|
405
|
+
*/
|
|
406
|
+
/* jshint ignore:end */
|
|
407
|
+
SimIpAddressInstance = function SimIpAddressInstance(version, payload, simSid) {
|
|
408
|
+
this._version = version;
|
|
409
|
+
|
|
410
|
+
// Marshaled Properties
|
|
411
|
+
this.ipAddress = payload.ip_address; // jshint ignore:line
|
|
412
|
+
this.ipAddressVersion = payload.ip_address_version; // jshint ignore:line
|
|
413
|
+
|
|
414
|
+
// Context
|
|
415
|
+
this._context = undefined;
|
|
416
|
+
this._solution = {simSid: simSid, };
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
/* jshint ignore:start */
|
|
420
|
+
/**
|
|
421
|
+
* Provide a user-friendly representation
|
|
422
|
+
*
|
|
423
|
+
* @function toJSON
|
|
424
|
+
* @memberof Twilio.Supersim.V1.SimContext.SimIpAddressInstance#
|
|
425
|
+
*
|
|
426
|
+
* @returns Object
|
|
427
|
+
*/
|
|
428
|
+
/* jshint ignore:end */
|
|
429
|
+
SimIpAddressInstance.prototype.toJSON = function toJSON() {
|
|
430
|
+
let clone = {};
|
|
431
|
+
_.forOwn(this, function(value, key) {
|
|
432
|
+
if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
|
|
433
|
+
clone[key] = value;
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
return clone;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
SimIpAddressInstance.prototype[util.inspect.custom] = function inspect(depth,
|
|
440
|
+
options) {
|
|
441
|
+
return util.inspect(this.toJSON(), options);
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
module.exports = {
|
|
445
|
+
SimIpAddressList: SimIpAddressList,
|
|
446
|
+
SimIpAddressPage: SimIpAddressPage,
|
|
447
|
+
SimIpAddressInstance: SimIpAddressInstance
|
|
448
|
+
};
|