Skip to content

Commit 1bd5ed6

Browse files
authored
Regenerate with structured params/properties (twilio#361)
* regenerate with structured params/properties * add callback tests * added new test cases * better test case for opts + callback * update "second arg as a callback" test cases to show that opts are not stomped
1 parent 0a269db commit 1bd5ed6

File tree

440 files changed

+27309
-3741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

440 files changed

+27309
-3741
lines changed

lib/rest/Api.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var V2010 = require('./api/V2010'); /* jshint ignore:line */
2121
* @constructor Twilio.Api
2222
*
2323
* @property {Twilio.Api.V2010} v2010 - v2010 version
24+
* @property {Twilio.Api.V2010.AccountContext} account - Main account resource
2425
* @property {Twilio.Api.V2010.AccountList} accounts - accounts resource
2526
* @property {Twilio.Api.V2010.AccountContext.AddressList} addresses -
2627
* addresses resource

lib/rest/Preview.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ var Wireless = require('./preview/Wireless'); /* jshint ignore:line */
5050
* authorizationDocuments resource
5151
* @property {Twilio.Preview.HostedNumbers.HostedNumberOrderList} hostedNumberOrders -
5252
* hostedNumberOrders resource
53-
* @property {Twilio.Preview.Marketplace.AvailableAddOnList} availableAddOns -
54-
* availableAddOns resource
5553
* @property {Twilio.Preview.Marketplace.InstalledAddOnList} installedAddOns -
5654
* installedAddOns resource
55+
* @property {Twilio.Preview.Marketplace.AvailableAddOnList} availableAddOns -
56+
* availableAddOns resource
5757
* @property {Twilio.Preview.Sync.ServiceList} services - services resource
5858
* @property {Twilio.Preview.Studio.FlowList} flows - flows resource
5959
* @property {Twilio.Preview.Understand.AssistantList} assistants -
@@ -200,16 +200,16 @@ Object.defineProperty(Preview.prototype,
200200
});
201201

202202
Object.defineProperty(Preview.prototype,
203-
'availableAddOns', {
203+
'installedAddOns', {
204204
get: function() {
205-
return this.marketplace.availableAddOns;
205+
return this.marketplace.installedAddOns;
206206
}
207207
});
208208

209209
Object.defineProperty(Preview.prototype,
210-
'installedAddOns', {
210+
'availableAddOns', {
211211
get: function() {
212-
return this.marketplace.installedAddOns;
212+
return this.marketplace.availableAddOns;
213213
}
214214
});
215215

lib/rest/Twilio.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var Wireless = require('./Wireless'); /* jshint ignore:line */
4343
* @property {Twilio.Api} api - api domain
4444
* @property {Twilio.Chat} chat - chat domain
4545
* @property {Twilio.Fax} fax - fax domain
46-
* @property {Twilio.IpMessaging} ip_messaging - ip_messaging domain
46+
* @property {Twilio.IpMessaging} ipMessaging - ip_messaging domain
4747
* @property {Twilio.Lookups} lookups - lookups domain
4848
* @property {Twilio.Monitor} monitor - monitor domain
4949
* @property {Twilio.Notify} notify - notify domain
@@ -102,7 +102,7 @@ var Wireless = require('./Wireless'); /* jshint ignore:line */
102102
* The username used for authentication. This is normally account sid, but if using key/secret auth will be the api key sid.
103103
* @param {string} password -
104104
* The password used for authentication. This is normally auth token, but if using key/secret auth will be the secret.
105-
* @param {object} opts - ...
105+
* @param {object} [opts] - ...
106106
* @param {HttpClient} [opts.httpClient] -
107107
* The client used for http requests. Defaults to RequestClient
108108
* @param {string} [opts.accountSid] -

lib/rest/Video.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ var V1 = require('./video/V1'); /* jshint ignore:line */
2121
* @constructor Twilio.Video
2222
*
2323
* @property {Twilio.Video.V1} v1 - v1 version
24-
* @property {Twilio.Video.V1.CompositionList} compositions - compositions resource
2524
* @property {Twilio.Video.V1.RecordingList} recordings - recordings resource
25+
* @property {Twilio.Video.V1.CompositionList} compositions - compositions resource
2626
* @property {Twilio.Video.V1.RoomList} rooms - rooms resource
2727
*
2828
* @param {Twilio} twilio - The twilio client
@@ -47,16 +47,16 @@ Object.defineProperty(Video.prototype,
4747
});
4848

4949
Object.defineProperty(Video.prototype,
50-
'compositions', {
50+
'recordings', {
5151
get: function() {
52-
return this.v1.compositions;
52+
return this.v1.recordings;
5353
}
5454
});
5555

5656
Object.defineProperty(Video.prototype,
57-
'recordings', {
57+
'compositions', {
5858
get: function() {
59-
return this.v1.recordings;
59+
return this.v1.compositions;
6060
}
6161
});
6262

lib/rest/accounts/v1/credential/aws.js

+19-14
Original file line numberDiff line numberDiff line change
@@ -66,34 +66,35 @@ AwsList = function AwsList(version) {
6666
* @memberof Twilio.Accounts.V1.CredentialContext.AwsList
6767
* @instance
6868
*
69-
* @param {object|function} opts - ...
69+
* @param {object} [opts] - ...
7070
* @param {number} [opts.limit] -
7171
* Upper limit for the number of records to return.
7272
* each() guarantees never to return more than limit.
7373
* Default is no limit
74-
* @param {number} [opts.pageSize=50] -
74+
* @param {number} [opts.pageSize] -
7575
* Number of records to fetch per request,
7676
* when not set will use the default value of 50 records.
7777
* If no pageSize is defined but a limit is defined,
7878
* each() will attempt to read the limit with the most efficient
7979
* page size, i.e. min(limit, 1000)
8080
* @param {Function} [opts.callback] -
8181
* Function to process each record. If this and a positional
82-
* callback are passed, this one will be used
82+
* callback are passed, this one will be used
8383
* @param {Function} [opts.done] -
8484
* Function to be called upon completion of streaming
8585
* @param {Function} [callback] - Function to process each record
8686
*/
8787
/* jshint ignore:end */
8888
AwsListInstance.each = function each(opts, callback) {
89-
opts = opts || {};
9089
if (_.isFunction(opts)) {
91-
opts = { callback: opts };
92-
} else if (_.isFunction(callback) && !_.isFunction(opts.callback)) {
93-
opts.callback = callback;
90+
callback = opts;
91+
opts = {};
9492
}
95-
96-
if (_.isUndefined(opts.callback)) {
93+
opts = opts || {};
94+
if (opts.callback) {
95+
callback = opts.callback;
96+
}
97+
if (_.isUndefined(callback)) {
9798
throw new Error('Callback function must be provided');
9899
}
99100

@@ -127,7 +128,7 @@ AwsList = function AwsList(version) {
127128
}
128129

129130
currentResource++;
130-
opts.callback(instance, onComplete);
131+
callback(instance, onComplete);
131132
});
132133

133134
if ((limits.pageLimit && limits.pageLimit <= currentPage)) {
@@ -154,7 +155,7 @@ AwsList = function AwsList(version) {
154155
* @memberof Twilio.Accounts.V1.CredentialContext.AwsList
155156
* @instance
156157
*
157-
* @param {object|function} opts - ...
158+
* @param {object} [opts] - ...
158159
* @param {number} [opts.limit] -
159160
* Upper limit for the number of records to return.
160161
* list() guarantees never to return more than limit.
@@ -213,7 +214,7 @@ AwsList = function AwsList(version) {
213214
* @memberof Twilio.Accounts.V1.CredentialContext.AwsList
214215
* @instance
215216
*
216-
* @param {object|function} opts - ...
217+
* @param {object} [opts] - ...
217218
* @param {string} [opts.pageToken] - PageToken provided by the API
218219
* @param {number} [opts.pageNumber] -
219220
* Page Number, this value is simply for client state
@@ -224,6 +225,10 @@ AwsList = function AwsList(version) {
224225
*/
225226
/* jshint ignore:end */
226227
AwsListInstance.page = function page(opts, callback) {
228+
if (_.isFunction(opts)) {
229+
callback = opts;
230+
opts = {};
231+
}
227232
opts = opts || {};
228233

229234
var deferred = Q.defer();
@@ -467,7 +472,7 @@ AwsInstance.prototype.fetch = function fetch(callback) {
467472
* @memberof Twilio.Accounts.V1.CredentialContext.AwsInstance
468473
* @instance
469474
*
470-
* @param {object|function} opts - ...
475+
* @param {object} [opts] - ...
471476
* @param {string} [opts.friendlyName] - The friendly_name
472477
* @param {function} [callback] - Callback to handle processed record
473478
*
@@ -577,7 +582,7 @@ AwsContext.prototype.fetch = function fetch(callback) {
577582
* @memberof Twilio.Accounts.V1.CredentialContext.AwsContext
578583
* @instance
579584
*
580-
* @param {object|function} opts - ...
585+
* @param {object} [opts] - ...
581586
* @param {string} [opts.friendlyName] - The friendly_name
582587
* @param {function} [callback] - Callback to handle processed record
583588
*

lib/rest/accounts/v1/credential/publicKey.js

+19-14
Original file line numberDiff line numberDiff line change
@@ -66,34 +66,35 @@ PublicKeyList = function PublicKeyList(version) {
6666
* @memberof Twilio.Accounts.V1.CredentialContext.PublicKeyList
6767
* @instance
6868
*
69-
* @param {object|function} opts - ...
69+
* @param {object} [opts] - ...
7070
* @param {number} [opts.limit] -
7171
* Upper limit for the number of records to return.
7272
* each() guarantees never to return more than limit.
7373
* Default is no limit
74-
* @param {number} [opts.pageSize=50] -
74+
* @param {number} [opts.pageSize] -
7575
* Number of records to fetch per request,
7676
* when not set will use the default value of 50 records.
7777
* If no pageSize is defined but a limit is defined,
7878
* each() will attempt to read the limit with the most efficient
7979
* page size, i.e. min(limit, 1000)
8080
* @param {Function} [opts.callback] -
8181
* Function to process each record. If this and a positional
82-
* callback are passed, this one will be used
82+
* callback are passed, this one will be used
8383
* @param {Function} [opts.done] -
8484
* Function to be called upon completion of streaming
8585
* @param {Function} [callback] - Function to process each record
8686
*/
8787
/* jshint ignore:end */
8888
PublicKeyListInstance.each = function each(opts, callback) {
89-
opts = opts || {};
9089
if (_.isFunction(opts)) {
91-
opts = { callback: opts };
92-
} else if (_.isFunction(callback) && !_.isFunction(opts.callback)) {
93-
opts.callback = callback;
90+
callback = opts;
91+
opts = {};
9492
}
95-
96-
if (_.isUndefined(opts.callback)) {
93+
opts = opts || {};
94+
if (opts.callback) {
95+
callback = opts.callback;
96+
}
97+
if (_.isUndefined(callback)) {
9798
throw new Error('Callback function must be provided');
9899
}
99100

@@ -127,7 +128,7 @@ PublicKeyList = function PublicKeyList(version) {
127128
}
128129

129130
currentResource++;
130-
opts.callback(instance, onComplete);
131+
callback(instance, onComplete);
131132
});
132133

133134
if ((limits.pageLimit && limits.pageLimit <= currentPage)) {
@@ -154,7 +155,7 @@ PublicKeyList = function PublicKeyList(version) {
154155
* @memberof Twilio.Accounts.V1.CredentialContext.PublicKeyList
155156
* @instance
156157
*
157-
* @param {object|function} opts - ...
158+
* @param {object} [opts] - ...
158159
* @param {number} [opts.limit] -
159160
* Upper limit for the number of records to return.
160161
* list() guarantees never to return more than limit.
@@ -213,7 +214,7 @@ PublicKeyList = function PublicKeyList(version) {
213214
* @memberof Twilio.Accounts.V1.CredentialContext.PublicKeyList
214215
* @instance
215216
*
216-
* @param {object|function} opts - ...
217+
* @param {object} [opts] - ...
217218
* @param {string} [opts.pageToken] - PageToken provided by the API
218219
* @param {number} [opts.pageNumber] -
219220
* Page Number, this value is simply for client state
@@ -224,6 +225,10 @@ PublicKeyList = function PublicKeyList(version) {
224225
*/
225226
/* jshint ignore:end */
226227
PublicKeyListInstance.page = function page(opts, callback) {
228+
if (_.isFunction(opts)) {
229+
callback = opts;
230+
opts = {};
231+
}
227232
opts = opts || {};
228233

229234
var deferred = Q.defer();
@@ -471,7 +476,7 @@ PublicKeyInstance.prototype.fetch = function fetch(callback) {
471476
* @memberof Twilio.Accounts.V1.CredentialContext.PublicKeyInstance
472477
* @instance
473478
*
474-
* @param {object|function} opts - ...
479+
* @param {object} [opts] - ...
475480
* @param {string} [opts.friendlyName] -
476481
* A human readable description of this resource
477482
* @param {function} [callback] - Callback to handle processed record
@@ -582,7 +587,7 @@ PublicKeyContext.prototype.fetch = function fetch(callback) {
582587
* @memberof Twilio.Accounts.V1.CredentialContext.PublicKeyContext
583588
* @instance
584589
*
585-
* @param {object|function} opts - ...
590+
* @param {object} [opts] - ...
586591
* @param {string} [opts.friendlyName] -
587592
* A human readable description of this resource
588593
* @param {function} [callback] - Callback to handle processed record

0 commit comments

Comments
 (0)