From acbbca1a1e382317c23efa869ad4a244a7c2c1b7 Mon Sep 17 00:00:00 2001 From: Jeremy McEntire Date: Fri, 15 Dec 2017 17:43:00 -0800 Subject: [PATCH] [Librarian] Regenerated @ 9e369cf9a8faca3a4590250f768d8ce69a65d0e8 --- CHANGES.md | 18 + .../api/v2010/account/availablePhoneNumber.js | 132 +++++ .../availablePhoneNumber/machineToMachine.js | 503 ++++++++++++++++++ .../account/availablePhoneNumber/national.js | 501 +++++++++++++++++ .../availablePhoneNumber/sharedCost.js | 501 +++++++++++++++++ .../account/availablePhoneNumber/voip.js | 496 +++++++++++++++++ lib/rest/api/v2010/account/call.js | 5 +- lib/rest/api/v2010/account/call/recording.js | 12 +- .../v2010/account/conference/participant.js | 8 +- lib/rest/api/v2010/account/recording.js | 23 +- .../hosted_numbers/hostedNumberOrder.js | 22 +- lib/twiml/FaxResponse.js | 4 +- lib/twiml/MessagingResponse.js | 7 +- lib/twiml/VoiceResponse.js | 166 +++--- .../machineToMachine.spec.js | 138 +++++ .../availablePhoneNumber/national.spec.js | 138 +++++ .../availablePhoneNumber/sharedCost.spec.js | 138 +++++ .../account/availablePhoneNumber/voip.spec.js | 138 +++++ .../api/v2010/account/call/recording.spec.js | 56 +- .../rest/api/v2010/account/conference.spec.js | 9 +- .../rest/api/v2010/account/recording.spec.js | 56 +- .../rest/notify/v1/service.spec.js | 4 + .../hosted_numbers/hostedNumberOrder.spec.js | 59 +- .../rest/proxy/v1/service/session.spec.js | 6 +- 24 files changed, 2972 insertions(+), 168 deletions(-) create mode 100644 lib/rest/api/v2010/account/availablePhoneNumber/machineToMachine.js create mode 100644 lib/rest/api/v2010/account/availablePhoneNumber/national.js create mode 100644 lib/rest/api/v2010/account/availablePhoneNumber/sharedCost.js create mode 100644 lib/rest/api/v2010/account/availablePhoneNumber/voip.js create mode 100644 spec/integration/rest/api/v2010/account/availablePhoneNumber/machineToMachine.spec.js create mode 100644 spec/integration/rest/api/v2010/account/availablePhoneNumber/national.spec.js create mode 100644 spec/integration/rest/api/v2010/account/availablePhoneNumber/sharedCost.spec.js create mode 100644 spec/integration/rest/api/v2010/account/availablePhoneNumber/voip.spec.js diff --git a/CHANGES.md b/CHANGES.md index 6b96b885d8..ad3d004a1a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,24 @@ twilio-node changelog ===================== +[2017-12-15] Version 3.11.0 +---------------------------- +**Api** +- Add `voip`, `national`, `shared_cost`, and `machine_to_machine` sub-resources to `/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers/{IsoCountryCode}/` +- Add programmable video keys + +**Preview** +- Add `verification_type` and `verification_document_sid` to HostedNumberOrders. + +**Proxy** +- Fixed typo in session status enum value + +**Twiml** +- Fix Dial record property incorrectly typed as accepting TrimEnum values when it actually has its own enum of values. *(breaking change)* +- Add `priority` and `timeout` properties to Task TwiML. +- Add support for `recording_status_callback_event` for Dial verb and for Conference + + [2017-12-01] Version 3.10.1 ---------------------------- **Api** diff --git a/lib/rest/api/v2010/account/availablePhoneNumber.js b/lib/rest/api/v2010/account/availablePhoneNumber.js index 7c7ac7d133..03e439b4e4 100644 --- a/lib/rest/api/v2010/account/availablePhoneNumber.js +++ b/lib/rest/api/v2010/account/availablePhoneNumber.js @@ -12,9 +12,15 @@ var Q = require('q'); /* jshint ignore:line */ var _ = require('lodash'); /* jshint ignore:line */ var LocalList = require('./availablePhoneNumber/local').LocalList; +var MachineToMachineList = require( + './availablePhoneNumber/machineToMachine').MachineToMachineList; var MobileList = require('./availablePhoneNumber/mobile').MobileList; +var NationalList = require('./availablePhoneNumber/national').NationalList; var Page = require('../../../../base/Page'); /* jshint ignore:line */ +var SharedCostList = require( + './availablePhoneNumber/sharedCost').SharedCostList; var TollFreeList = require('./availablePhoneNumber/tollFree').TollFreeList; +var VoipList = require('./availablePhoneNumber/voip').VoipList; var values = require('../../../../base/values'); /* jshint ignore:line */ var AvailablePhoneNumberCountryList; @@ -468,6 +474,68 @@ AvailablePhoneNumberCountryInstance.prototype.mobile = function mobile() { return this._proxy.mobile; }; +/* jshint ignore:start */ +/** + * Access the national + * + * @function national + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryInstance + * @instance + * + * @returns {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalList} + */ +/* jshint ignore:end */ +AvailablePhoneNumberCountryInstance.prototype.national = function national() { + return this._proxy.national; +}; + +/* jshint ignore:start */ +/** + * Access the voip + * + * @function voip + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryInstance + * @instance + * + * @returns {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipList} + */ +/* jshint ignore:end */ +AvailablePhoneNumberCountryInstance.prototype.voip = function voip() { + return this._proxy.voip; +}; + +/* jshint ignore:start */ +/** + * Access the sharedCost + * + * @function sharedCost + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryInstance + * @instance + * + * @returns {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostList} + */ +/* jshint ignore:end */ +AvailablePhoneNumberCountryInstance.prototype.sharedCost = function sharedCost() + { + return this._proxy.sharedCost; +}; + +/* jshint ignore:start */ +/** + * Access the machineToMachine + * + * @function machineToMachine + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryInstance + * @instance + * + * @returns {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineList} + */ +/* jshint ignore:end */ +AvailablePhoneNumberCountryInstance.prototype.machineToMachine = function + machineToMachine() { + return this._proxy.machineToMachine; +}; + /* jshint ignore:start */ /** @@ -480,6 +548,14 @@ AvailablePhoneNumberCountryInstance.prototype.mobile = function mobile() { * tollFree resource * @property {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MobileList} mobile - * mobile resource + * @property {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalList} national - + * national resource + * @property {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipList} voip - + * voip resource + * @property {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostList} sharedCost - + * sharedCost resource + * @property {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineList} machineToMachine - + * machineToMachine resource * * @param {Twilio.Api.V2010} version - Version of the resource * @param {sid} accountSid - The account_sid @@ -500,6 +576,10 @@ AvailablePhoneNumberCountryContext = function this._local = undefined; this._tollFree = undefined; this._mobile = undefined; + this._national = undefined; + this._voip = undefined; + this._sharedCost = undefined; + this._machineToMachine = undefined; }; /* jshint ignore:start */ @@ -573,6 +653,58 @@ Object.defineProperty(AvailablePhoneNumberCountryContext.prototype, } }); +Object.defineProperty(AvailablePhoneNumberCountryContext.prototype, + 'national', { + get: function() { + if (!this._national) { + this._national = new NationalList( + this._version, + this._solution.accountSid, + this._solution.countryCode + ); + } + return this._national; + } +}); + +Object.defineProperty(AvailablePhoneNumberCountryContext.prototype, + 'voip', { + get: function() { + if (!this._voip) { + this._voip = new VoipList(this._version, this._solution.accountSid, this._solution.countryCode); + } + return this._voip; + } +}); + +Object.defineProperty(AvailablePhoneNumberCountryContext.prototype, + 'sharedCost', { + get: function() { + if (!this._sharedCost) { + this._sharedCost = new SharedCostList( + this._version, + this._solution.accountSid, + this._solution.countryCode + ); + } + return this._sharedCost; + } +}); + +Object.defineProperty(AvailablePhoneNumberCountryContext.prototype, + 'machineToMachine', { + get: function() { + if (!this._machineToMachine) { + this._machineToMachine = new MachineToMachineList( + this._version, + this._solution.accountSid, + this._solution.countryCode + ); + } + return this._machineToMachine; + } +}); + module.exports = { AvailablePhoneNumberCountryList: AvailablePhoneNumberCountryList, AvailablePhoneNumberCountryPage: AvailablePhoneNumberCountryPage, diff --git a/lib/rest/api/v2010/account/availablePhoneNumber/machineToMachine.js b/lib/rest/api/v2010/account/availablePhoneNumber/machineToMachine.js new file mode 100644 index 0000000000..1d00b896b4 --- /dev/null +++ b/lib/rest/api/v2010/account/availablePhoneNumber/machineToMachine.js @@ -0,0 +1,503 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var Q = require('q'); /* jshint ignore:line */ +var _ = require('lodash'); /* jshint ignore:line */ +var Page = require('../../../../../base/Page'); /* jshint ignore:line */ +var deserialize = require( + '../../../../../base/deserialize'); /* jshint ignore:line */ +var serialize = require( + '../../../../../base/serialize'); /* jshint ignore:line */ +var values = require('../../../../../base/values'); /* jshint ignore:line */ + +var MachineToMachineList; +var MachineToMachinePage; +var MachineToMachineInstance; + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineList + * @description Initialize the MachineToMachineList + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {string} accountSid - + * The 34 character string that uniquely identifies your account. + * @param {string} countryCode - The ISO Country code to lookup phone numbers for. + */ +/* jshint ignore:end */ +MachineToMachineList = function MachineToMachineList(version, accountSid, + countryCode) { + /* jshint ignore:start */ + /** + * @function machineToMachine + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext + * @instance + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineContext} + */ + /* jshint ignore:end */ + function MachineToMachineListInstance(sid) { + return MachineToMachineListInstance.get(sid); + } + + MachineToMachineListInstance._version = version; + // Path Solution + MachineToMachineListInstance._solution = {accountSid: accountSid, countryCode: countryCode}; + MachineToMachineListInstance._uri = _.template( + '/Accounts/<%= accountSid %>/AvailablePhoneNumbers/<%= countryCode %>/MachineToMachine.json' // jshint ignore:line + )(MachineToMachineListInstance._solution); + /* jshint ignore:start */ + /** + * Streams MachineToMachineInstance records from the API. + * + * This operation lazily loads records as efficiently as possible until the limit + * is reached. + * + * The results are passed into the callback function, so this operation is memory efficient. + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function each + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize=50] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no pageSize is defined but a limit is defined, + * each() will attempt to read the limit with the most efficient + * page size, i.e. min(limit, 1000) + * @param {Function} [opts.callback] - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @param {Function} [opts.done] - + * Function to be called upon completion of streaming + * @param {Function} [callback] - Function to process each record + */ + /* jshint ignore:end */ + MachineToMachineListInstance.each = function each(opts, callback) { + opts = opts || {}; + if (_.isFunction(opts)) { + opts = { callback: opts }; + } else if (_.isFunction(callback) && !_.isFunction(opts.callback)) { + opts.callback = callback; + } + + if (_.isUndefined(opts.callback)) { + throw new Error('Callback function must be provided'); + } + + var done = false; + var currentPage = 1; + var currentResource = 0; + var limits = this._version.readLimits({ + limit: opts.limit, + pageSize: opts.pageSize + }); + + function onComplete(error) { + done = true; + if (_.isFunction(opts.done)) { + opts.done(error); + } + } + + function fetchNextPage(fn) { + var promise = fn(); + if (_.isUndefined(promise)) { + onComplete(); + return; + } + + promise.then(function(page) { + _.each(page.instances, function(instance) { + if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) { + done = true; + return false; + } + + currentResource++; + opts.callback(instance, onComplete); + }); + + if ((limits.pageLimit && limits.pageLimit <= currentPage)) { + onComplete(); + } else if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * @description Lists MachineToMachineInstance records from the API as a list. + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function list + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no page_size is defined but a limit is defined, + * list() will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + MachineToMachineListInstance.list = function list(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + var deferred = Q.defer(); + var allResources = []; + opts.callback = function(resource, done) { + allResources.push(resource); + + if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) { + done(); + } + }; + + opts.done = function(error) { + if (_.isUndefined(error)) { + deferred.resolve(allResources); + } else { + deferred.reject(error); + } + }; + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + this.each(opts); + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single page of MachineToMachineInstance records from the API. + * Request is executed immediately + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function page + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {string} [opts.pageToken] - PageToken provided by the API + * @param {number} [opts.pageNumber] - + * Page Number, this value is simply for client state + * @param {number} [opts.pageSize] - Number of records to return, defaults to 50 + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + MachineToMachineListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'AreaCode': _.get(opts, 'areaCode'), + 'Contains': _.get(opts, 'contains'), + 'SmsEnabled': serialize.bool(_.get(opts, 'smsEnabled')), + 'MmsEnabled': serialize.bool(_.get(opts, 'mmsEnabled')), + 'VoiceEnabled': serialize.bool(_.get(opts, 'voiceEnabled')), + 'ExcludeAllAddressRequired': serialize.bool(_.get(opts, 'excludeAllAddressRequired')), + 'ExcludeLocalAddressRequired': serialize.bool(_.get(opts, 'excludeLocalAddressRequired')), + 'ExcludeForeignAddressRequired': serialize.bool(_.get(opts, 'excludeForeignAddressRequired')), + 'Beta': serialize.bool(_.get(opts, 'beta')), + 'NearNumber': _.get(opts, 'nearNumber'), + 'NearLatLong': _.get(opts, 'nearLatLong'), + 'Distance': _.get(opts, 'distance'), + 'InPostalCode': _.get(opts, 'inPostalCode'), + 'InRegion': _.get(opts, 'inRegion'), + 'InRateCenter': _.get(opts, 'inRateCenter'), + 'InLata': _.get(opts, 'inLata'), + 'InLocality': _.get(opts, 'inLocality'), + 'FaxEnabled': serialize.bool(_.get(opts, 'faxEnabled')), + 'PageToken': opts.pageToken, + 'Page': opts.pageNumber, + 'PageSize': opts.pageSize + }); + + var promise = this._version.page({uri: this._uri, method: 'GET', params: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new MachineToMachinePage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single target page of MachineToMachineInstance records from the API. + * Request is executed immediately + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function getPage + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineList + * @instance + * + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {string} [targetUrl] - API-generated URL for the requested results page + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + MachineToMachineListInstance.getPage = function getPage(targetUrl, callback) { + var deferred = Q.defer(); + + var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl}); + + promise = promise.then(function(payload) { + deferred.resolve(new MachineToMachinePage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + return MachineToMachineListInstance; +}; + + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachinePage + * @augments Page + * @description Initialize the MachineToMachinePage + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {object} response - Response from the API + * @param {object} solution - Path solution + * + * @returns MachineToMachinePage + */ +/* jshint ignore:end */ +MachineToMachinePage = function MachineToMachinePage(version, response, + solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(MachineToMachinePage.prototype, Page.prototype); +MachineToMachinePage.prototype.constructor = MachineToMachinePage; + +/* jshint ignore:start */ +/** + * Build an instance of MachineToMachineInstance + * + * @function getInstance + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachinePage + * @instance + * + * @param {object} payload - Payload response from the API + * + * @returns MachineToMachineInstance + */ +/* jshint ignore:end */ +MachineToMachinePage.prototype.getInstance = function getInstance(payload) { + return new MachineToMachineInstance( + this._version, + payload, + this._solution.accountSid, + this._solution.countryCode + ); +}; + + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.MachineToMachineInstance + * @description Initialize the MachineToMachineContext + * + * @property {string} friendlyName - The friendly_name + * @property {string} phoneNumber - The phone_number + * @property {string} lata - The lata + * @property {string} locality - The locality + * @property {string} rateCenter - The rate_center + * @property {number} latitude - The latitude + * @property {number} longitude - The longitude + * @property {string} region - The region + * @property {string} postalCode - The postal_code + * @property {string} isoCountry - The iso_country + * @property {string} addressRequirements - The address_requirements + * @property {boolean} beta - The beta + * @property {string} capabilities - The capabilities + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {object} payload - The instance payload + */ +/* jshint ignore:end */ +MachineToMachineInstance = function MachineToMachineInstance(version, payload, + accountSid, countryCode) { + this._version = version; + + // Marshaled Properties + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.phoneNumber = payload.phone_number; // jshint ignore:line + this.lata = payload.lata; // jshint ignore:line + this.locality = payload.locality; // jshint ignore:line + this.rateCenter = payload.rate_center; // jshint ignore:line + this.latitude = deserialize.decimal(payload.latitude); // jshint ignore:line + this.longitude = deserialize.decimal(payload.longitude); // jshint ignore:line + this.region = payload.region; // jshint ignore:line + this.postalCode = payload.postal_code; // jshint ignore:line + this.isoCountry = payload.iso_country; // jshint ignore:line + this.addressRequirements = payload.address_requirements; // jshint ignore:line + this.beta = payload.beta; // jshint ignore:line + this.capabilities = payload.capabilities; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {accountSid: accountSid, countryCode: countryCode}; +}; + +module.exports = { + MachineToMachineList: MachineToMachineList, + MachineToMachinePage: MachineToMachinePage, + MachineToMachineInstance: MachineToMachineInstance +}; diff --git a/lib/rest/api/v2010/account/availablePhoneNumber/national.js b/lib/rest/api/v2010/account/availablePhoneNumber/national.js new file mode 100644 index 0000000000..095ad1c6c2 --- /dev/null +++ b/lib/rest/api/v2010/account/availablePhoneNumber/national.js @@ -0,0 +1,501 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var Q = require('q'); /* jshint ignore:line */ +var _ = require('lodash'); /* jshint ignore:line */ +var Page = require('../../../../../base/Page'); /* jshint ignore:line */ +var deserialize = require( + '../../../../../base/deserialize'); /* jshint ignore:line */ +var serialize = require( + '../../../../../base/serialize'); /* jshint ignore:line */ +var values = require('../../../../../base/values'); /* jshint ignore:line */ + +var NationalList; +var NationalPage; +var NationalInstance; + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalList + * @description Initialize the NationalList + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {string} accountSid - + * The 34 character string that uniquely identifies your account. + * @param {string} countryCode - The ISO Country code to lookup phone numbers for. + */ +/* jshint ignore:end */ +NationalList = function NationalList(version, accountSid, countryCode) { + /* jshint ignore:start */ + /** + * @function national + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext + * @instance + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalContext} + */ + /* jshint ignore:end */ + function NationalListInstance(sid) { + return NationalListInstance.get(sid); + } + + NationalListInstance._version = version; + // Path Solution + NationalListInstance._solution = {accountSid: accountSid, countryCode: countryCode}; + NationalListInstance._uri = _.template( + '/Accounts/<%= accountSid %>/AvailablePhoneNumbers/<%= countryCode %>/National.json' // jshint ignore:line + )(NationalListInstance._solution); + /* jshint ignore:start */ + /** + * Streams NationalInstance records from the API. + * + * This operation lazily loads records as efficiently as possible until the limit + * is reached. + * + * The results are passed into the callback function, so this operation is memory efficient. + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function each + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize=50] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no pageSize is defined but a limit is defined, + * each() will attempt to read the limit with the most efficient + * page size, i.e. min(limit, 1000) + * @param {Function} [opts.callback] - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @param {Function} [opts.done] - + * Function to be called upon completion of streaming + * @param {Function} [callback] - Function to process each record + */ + /* jshint ignore:end */ + NationalListInstance.each = function each(opts, callback) { + opts = opts || {}; + if (_.isFunction(opts)) { + opts = { callback: opts }; + } else if (_.isFunction(callback) && !_.isFunction(opts.callback)) { + opts.callback = callback; + } + + if (_.isUndefined(opts.callback)) { + throw new Error('Callback function must be provided'); + } + + var done = false; + var currentPage = 1; + var currentResource = 0; + var limits = this._version.readLimits({ + limit: opts.limit, + pageSize: opts.pageSize + }); + + function onComplete(error) { + done = true; + if (_.isFunction(opts.done)) { + opts.done(error); + } + } + + function fetchNextPage(fn) { + var promise = fn(); + if (_.isUndefined(promise)) { + onComplete(); + return; + } + + promise.then(function(page) { + _.each(page.instances, function(instance) { + if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) { + done = true; + return false; + } + + currentResource++; + opts.callback(instance, onComplete); + }); + + if ((limits.pageLimit && limits.pageLimit <= currentPage)) { + onComplete(); + } else if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * @description Lists NationalInstance records from the API as a list. + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function list + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no page_size is defined but a limit is defined, + * list() will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + NationalListInstance.list = function list(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + var deferred = Q.defer(); + var allResources = []; + opts.callback = function(resource, done) { + allResources.push(resource); + + if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) { + done(); + } + }; + + opts.done = function(error) { + if (_.isUndefined(error)) { + deferred.resolve(allResources); + } else { + deferred.reject(error); + } + }; + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + this.each(opts); + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single page of NationalInstance records from the API. + * Request is executed immediately + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function page + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {string} [opts.pageToken] - PageToken provided by the API + * @param {number} [opts.pageNumber] - + * Page Number, this value is simply for client state + * @param {number} [opts.pageSize] - Number of records to return, defaults to 50 + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + NationalListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'AreaCode': _.get(opts, 'areaCode'), + 'Contains': _.get(opts, 'contains'), + 'SmsEnabled': serialize.bool(_.get(opts, 'smsEnabled')), + 'MmsEnabled': serialize.bool(_.get(opts, 'mmsEnabled')), + 'VoiceEnabled': serialize.bool(_.get(opts, 'voiceEnabled')), + 'ExcludeAllAddressRequired': serialize.bool(_.get(opts, 'excludeAllAddressRequired')), + 'ExcludeLocalAddressRequired': serialize.bool(_.get(opts, 'excludeLocalAddressRequired')), + 'ExcludeForeignAddressRequired': serialize.bool(_.get(opts, 'excludeForeignAddressRequired')), + 'Beta': serialize.bool(_.get(opts, 'beta')), + 'NearNumber': _.get(opts, 'nearNumber'), + 'NearLatLong': _.get(opts, 'nearLatLong'), + 'Distance': _.get(opts, 'distance'), + 'InPostalCode': _.get(opts, 'inPostalCode'), + 'InRegion': _.get(opts, 'inRegion'), + 'InRateCenter': _.get(opts, 'inRateCenter'), + 'InLata': _.get(opts, 'inLata'), + 'InLocality': _.get(opts, 'inLocality'), + 'FaxEnabled': serialize.bool(_.get(opts, 'faxEnabled')), + 'PageToken': opts.pageToken, + 'Page': opts.pageNumber, + 'PageSize': opts.pageSize + }); + + var promise = this._version.page({uri: this._uri, method: 'GET', params: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new NationalPage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single target page of NationalInstance records from the API. + * Request is executed immediately + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function getPage + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalList + * @instance + * + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {string} [targetUrl] - API-generated URL for the requested results page + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + NationalListInstance.getPage = function getPage(targetUrl, callback) { + var deferred = Q.defer(); + + var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl}); + + promise = promise.then(function(payload) { + deferred.resolve(new NationalPage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + return NationalListInstance; +}; + + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalPage + * @augments Page + * @description Initialize the NationalPage + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {object} response - Response from the API + * @param {object} solution - Path solution + * + * @returns NationalPage + */ +/* jshint ignore:end */ +NationalPage = function NationalPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(NationalPage.prototype, Page.prototype); +NationalPage.prototype.constructor = NationalPage; + +/* jshint ignore:start */ +/** + * Build an instance of NationalInstance + * + * @function getInstance + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalPage + * @instance + * + * @param {object} payload - Payload response from the API + * + * @returns NationalInstance + */ +/* jshint ignore:end */ +NationalPage.prototype.getInstance = function getInstance(payload) { + return new NationalInstance( + this._version, + payload, + this._solution.accountSid, + this._solution.countryCode + ); +}; + + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.NationalInstance + * @description Initialize the NationalContext + * + * @property {string} friendlyName - The friendly_name + * @property {string} phoneNumber - The phone_number + * @property {string} lata - The lata + * @property {string} locality - The locality + * @property {string} rateCenter - The rate_center + * @property {number} latitude - The latitude + * @property {number} longitude - The longitude + * @property {string} region - The region + * @property {string} postalCode - The postal_code + * @property {string} isoCountry - The iso_country + * @property {string} addressRequirements - The address_requirements + * @property {boolean} beta - The beta + * @property {string} capabilities - The capabilities + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {object} payload - The instance payload + */ +/* jshint ignore:end */ +NationalInstance = function NationalInstance(version, payload, accountSid, + countryCode) { + this._version = version; + + // Marshaled Properties + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.phoneNumber = payload.phone_number; // jshint ignore:line + this.lata = payload.lata; // jshint ignore:line + this.locality = payload.locality; // jshint ignore:line + this.rateCenter = payload.rate_center; // jshint ignore:line + this.latitude = deserialize.decimal(payload.latitude); // jshint ignore:line + this.longitude = deserialize.decimal(payload.longitude); // jshint ignore:line + this.region = payload.region; // jshint ignore:line + this.postalCode = payload.postal_code; // jshint ignore:line + this.isoCountry = payload.iso_country; // jshint ignore:line + this.addressRequirements = payload.address_requirements; // jshint ignore:line + this.beta = payload.beta; // jshint ignore:line + this.capabilities = payload.capabilities; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {accountSid: accountSid, countryCode: countryCode}; +}; + +module.exports = { + NationalList: NationalList, + NationalPage: NationalPage, + NationalInstance: NationalInstance +}; diff --git a/lib/rest/api/v2010/account/availablePhoneNumber/sharedCost.js b/lib/rest/api/v2010/account/availablePhoneNumber/sharedCost.js new file mode 100644 index 0000000000..6b0fa23046 --- /dev/null +++ b/lib/rest/api/v2010/account/availablePhoneNumber/sharedCost.js @@ -0,0 +1,501 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var Q = require('q'); /* jshint ignore:line */ +var _ = require('lodash'); /* jshint ignore:line */ +var Page = require('../../../../../base/Page'); /* jshint ignore:line */ +var deserialize = require( + '../../../../../base/deserialize'); /* jshint ignore:line */ +var serialize = require( + '../../../../../base/serialize'); /* jshint ignore:line */ +var values = require('../../../../../base/values'); /* jshint ignore:line */ + +var SharedCostList; +var SharedCostPage; +var SharedCostInstance; + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostList + * @description Initialize the SharedCostList + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {string} accountSid - + * The 34 character string that uniquely identifies your account. + * @param {string} countryCode - The ISO Country code to lookup phone numbers for. + */ +/* jshint ignore:end */ +SharedCostList = function SharedCostList(version, accountSid, countryCode) { + /* jshint ignore:start */ + /** + * @function sharedCost + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext + * @instance + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostContext} + */ + /* jshint ignore:end */ + function SharedCostListInstance(sid) { + return SharedCostListInstance.get(sid); + } + + SharedCostListInstance._version = version; + // Path Solution + SharedCostListInstance._solution = {accountSid: accountSid, countryCode: countryCode}; + SharedCostListInstance._uri = _.template( + '/Accounts/<%= accountSid %>/AvailablePhoneNumbers/<%= countryCode %>/SharedCost.json' // jshint ignore:line + )(SharedCostListInstance._solution); + /* jshint ignore:start */ + /** + * Streams SharedCostInstance records from the API. + * + * This operation lazily loads records as efficiently as possible until the limit + * is reached. + * + * The results are passed into the callback function, so this operation is memory efficient. + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function each + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize=50] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no pageSize is defined but a limit is defined, + * each() will attempt to read the limit with the most efficient + * page size, i.e. min(limit, 1000) + * @param {Function} [opts.callback] - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @param {Function} [opts.done] - + * Function to be called upon completion of streaming + * @param {Function} [callback] - Function to process each record + */ + /* jshint ignore:end */ + SharedCostListInstance.each = function each(opts, callback) { + opts = opts || {}; + if (_.isFunction(opts)) { + opts = { callback: opts }; + } else if (_.isFunction(callback) && !_.isFunction(opts.callback)) { + opts.callback = callback; + } + + if (_.isUndefined(opts.callback)) { + throw new Error('Callback function must be provided'); + } + + var done = false; + var currentPage = 1; + var currentResource = 0; + var limits = this._version.readLimits({ + limit: opts.limit, + pageSize: opts.pageSize + }); + + function onComplete(error) { + done = true; + if (_.isFunction(opts.done)) { + opts.done(error); + } + } + + function fetchNextPage(fn) { + var promise = fn(); + if (_.isUndefined(promise)) { + onComplete(); + return; + } + + promise.then(function(page) { + _.each(page.instances, function(instance) { + if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) { + done = true; + return false; + } + + currentResource++; + opts.callback(instance, onComplete); + }); + + if ((limits.pageLimit && limits.pageLimit <= currentPage)) { + onComplete(); + } else if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * @description Lists SharedCostInstance records from the API as a list. + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function list + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no page_size is defined but a limit is defined, + * list() will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + SharedCostListInstance.list = function list(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + var deferred = Q.defer(); + var allResources = []; + opts.callback = function(resource, done) { + allResources.push(resource); + + if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) { + done(); + } + }; + + opts.done = function(error) { + if (_.isUndefined(error)) { + deferred.resolve(allResources); + } else { + deferred.reject(error); + } + }; + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + this.each(opts); + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single page of SharedCostInstance records from the API. + * Request is executed immediately + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function page + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {string} [opts.pageToken] - PageToken provided by the API + * @param {number} [opts.pageNumber] - + * Page Number, this value is simply for client state + * @param {number} [opts.pageSize] - Number of records to return, defaults to 50 + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + SharedCostListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'AreaCode': _.get(opts, 'areaCode'), + 'Contains': _.get(opts, 'contains'), + 'SmsEnabled': serialize.bool(_.get(opts, 'smsEnabled')), + 'MmsEnabled': serialize.bool(_.get(opts, 'mmsEnabled')), + 'VoiceEnabled': serialize.bool(_.get(opts, 'voiceEnabled')), + 'ExcludeAllAddressRequired': serialize.bool(_.get(opts, 'excludeAllAddressRequired')), + 'ExcludeLocalAddressRequired': serialize.bool(_.get(opts, 'excludeLocalAddressRequired')), + 'ExcludeForeignAddressRequired': serialize.bool(_.get(opts, 'excludeForeignAddressRequired')), + 'Beta': serialize.bool(_.get(opts, 'beta')), + 'NearNumber': _.get(opts, 'nearNumber'), + 'NearLatLong': _.get(opts, 'nearLatLong'), + 'Distance': _.get(opts, 'distance'), + 'InPostalCode': _.get(opts, 'inPostalCode'), + 'InRegion': _.get(opts, 'inRegion'), + 'InRateCenter': _.get(opts, 'inRateCenter'), + 'InLata': _.get(opts, 'inLata'), + 'InLocality': _.get(opts, 'inLocality'), + 'FaxEnabled': serialize.bool(_.get(opts, 'faxEnabled')), + 'PageToken': opts.pageToken, + 'Page': opts.pageNumber, + 'PageSize': opts.pageSize + }); + + var promise = this._version.page({uri: this._uri, method: 'GET', params: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new SharedCostPage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single target page of SharedCostInstance records from the API. + * Request is executed immediately + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function getPage + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostList + * @instance + * + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {string} [targetUrl] - API-generated URL for the requested results page + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + SharedCostListInstance.getPage = function getPage(targetUrl, callback) { + var deferred = Q.defer(); + + var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl}); + + promise = promise.then(function(payload) { + deferred.resolve(new SharedCostPage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + return SharedCostListInstance; +}; + + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostPage + * @augments Page + * @description Initialize the SharedCostPage + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {object} response - Response from the API + * @param {object} solution - Path solution + * + * @returns SharedCostPage + */ +/* jshint ignore:end */ +SharedCostPage = function SharedCostPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(SharedCostPage.prototype, Page.prototype); +SharedCostPage.prototype.constructor = SharedCostPage; + +/* jshint ignore:start */ +/** + * Build an instance of SharedCostInstance + * + * @function getInstance + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostPage + * @instance + * + * @param {object} payload - Payload response from the API + * + * @returns SharedCostInstance + */ +/* jshint ignore:end */ +SharedCostPage.prototype.getInstance = function getInstance(payload) { + return new SharedCostInstance( + this._version, + payload, + this._solution.accountSid, + this._solution.countryCode + ); +}; + + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.SharedCostInstance + * @description Initialize the SharedCostContext + * + * @property {string} friendlyName - The friendly_name + * @property {string} phoneNumber - The phone_number + * @property {string} lata - The lata + * @property {string} locality - The locality + * @property {string} rateCenter - The rate_center + * @property {number} latitude - The latitude + * @property {number} longitude - The longitude + * @property {string} region - The region + * @property {string} postalCode - The postal_code + * @property {string} isoCountry - The iso_country + * @property {string} addressRequirements - The address_requirements + * @property {boolean} beta - The beta + * @property {string} capabilities - The capabilities + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {object} payload - The instance payload + */ +/* jshint ignore:end */ +SharedCostInstance = function SharedCostInstance(version, payload, accountSid, + countryCode) { + this._version = version; + + // Marshaled Properties + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.phoneNumber = payload.phone_number; // jshint ignore:line + this.lata = payload.lata; // jshint ignore:line + this.locality = payload.locality; // jshint ignore:line + this.rateCenter = payload.rate_center; // jshint ignore:line + this.latitude = deserialize.decimal(payload.latitude); // jshint ignore:line + this.longitude = deserialize.decimal(payload.longitude); // jshint ignore:line + this.region = payload.region; // jshint ignore:line + this.postalCode = payload.postal_code; // jshint ignore:line + this.isoCountry = payload.iso_country; // jshint ignore:line + this.addressRequirements = payload.address_requirements; // jshint ignore:line + this.beta = payload.beta; // jshint ignore:line + this.capabilities = payload.capabilities; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {accountSid: accountSid, countryCode: countryCode}; +}; + +module.exports = { + SharedCostList: SharedCostList, + SharedCostPage: SharedCostPage, + SharedCostInstance: SharedCostInstance +}; diff --git a/lib/rest/api/v2010/account/availablePhoneNumber/voip.js b/lib/rest/api/v2010/account/availablePhoneNumber/voip.js new file mode 100644 index 0000000000..9c3c5befe2 --- /dev/null +++ b/lib/rest/api/v2010/account/availablePhoneNumber/voip.js @@ -0,0 +1,496 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var Q = require('q'); /* jshint ignore:line */ +var _ = require('lodash'); /* jshint ignore:line */ +var Page = require('../../../../../base/Page'); /* jshint ignore:line */ +var deserialize = require( + '../../../../../base/deserialize'); /* jshint ignore:line */ +var serialize = require( + '../../../../../base/serialize'); /* jshint ignore:line */ +var values = require('../../../../../base/values'); /* jshint ignore:line */ + +var VoipList; +var VoipPage; +var VoipInstance; + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipList + * @description Initialize the VoipList + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {string} accountSid - + * The 34 character string that uniquely identifies your account. + * @param {string} countryCode - The ISO Country code to lookup phone numbers for. + */ +/* jshint ignore:end */ +VoipList = function VoipList(version, accountSid, countryCode) { + /* jshint ignore:start */ + /** + * @function voip + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext + * @instance + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipContext} + */ + /* jshint ignore:end */ + function VoipListInstance(sid) { + return VoipListInstance.get(sid); + } + + VoipListInstance._version = version; + // Path Solution + VoipListInstance._solution = {accountSid: accountSid, countryCode: countryCode}; + VoipListInstance._uri = _.template( + '/Accounts/<%= accountSid %>/AvailablePhoneNumbers/<%= countryCode %>/Voip.json' // jshint ignore:line + )(VoipListInstance._solution); + /* jshint ignore:start */ + /** + * Streams VoipInstance records from the API. + * + * This operation lazily loads records as efficiently as possible until the limit + * is reached. + * + * The results are passed into the callback function, so this operation is memory efficient. + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function each + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize=50] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no pageSize is defined but a limit is defined, + * each() will attempt to read the limit with the most efficient + * page size, i.e. min(limit, 1000) + * @param {Function} [opts.callback] - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @param {Function} [opts.done] - + * Function to be called upon completion of streaming + * @param {Function} [callback] - Function to process each record + */ + /* jshint ignore:end */ + VoipListInstance.each = function each(opts, callback) { + opts = opts || {}; + if (_.isFunction(opts)) { + opts = { callback: opts }; + } else if (_.isFunction(callback) && !_.isFunction(opts.callback)) { + opts.callback = callback; + } + + if (_.isUndefined(opts.callback)) { + throw new Error('Callback function must be provided'); + } + + var done = false; + var currentPage = 1; + var currentResource = 0; + var limits = this._version.readLimits({ + limit: opts.limit, + pageSize: opts.pageSize + }); + + function onComplete(error) { + done = true; + if (_.isFunction(opts.done)) { + opts.done(error); + } + } + + function fetchNextPage(fn) { + var promise = fn(); + if (_.isUndefined(promise)) { + onComplete(); + return; + } + + promise.then(function(page) { + _.each(page.instances, function(instance) { + if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) { + done = true; + return false; + } + + currentResource++; + opts.callback(instance, onComplete); + }); + + if ((limits.pageLimit && limits.pageLimit <= currentPage)) { + onComplete(); + } else if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * @description Lists VoipInstance records from the API as a list. + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function list + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no page_size is defined but a limit is defined, + * list() will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + VoipListInstance.list = function list(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + var deferred = Q.defer(); + var allResources = []; + opts.callback = function(resource, done) { + allResources.push(resource); + + if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) { + done(); + } + }; + + opts.done = function(error) { + if (_.isUndefined(error)) { + deferred.resolve(allResources); + } else { + deferred.reject(error); + } + }; + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + this.each(opts); + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single page of VoipInstance records from the API. + * Request is executed immediately + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function page + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipList + * @instance + * + * @param {object|function} opts - ... + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {string} [opts.pageToken] - PageToken provided by the API + * @param {number} [opts.pageNumber] - + * Page Number, this value is simply for client state + * @param {number} [opts.pageSize] - Number of records to return, defaults to 50 + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + VoipListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'AreaCode': _.get(opts, 'areaCode'), + 'Contains': _.get(opts, 'contains'), + 'SmsEnabled': serialize.bool(_.get(opts, 'smsEnabled')), + 'MmsEnabled': serialize.bool(_.get(opts, 'mmsEnabled')), + 'VoiceEnabled': serialize.bool(_.get(opts, 'voiceEnabled')), + 'ExcludeAllAddressRequired': serialize.bool(_.get(opts, 'excludeAllAddressRequired')), + 'ExcludeLocalAddressRequired': serialize.bool(_.get(opts, 'excludeLocalAddressRequired')), + 'ExcludeForeignAddressRequired': serialize.bool(_.get(opts, 'excludeForeignAddressRequired')), + 'Beta': serialize.bool(_.get(opts, 'beta')), + 'NearNumber': _.get(opts, 'nearNumber'), + 'NearLatLong': _.get(opts, 'nearLatLong'), + 'Distance': _.get(opts, 'distance'), + 'InPostalCode': _.get(opts, 'inPostalCode'), + 'InRegion': _.get(opts, 'inRegion'), + 'InRateCenter': _.get(opts, 'inRateCenter'), + 'InLata': _.get(opts, 'inLata'), + 'InLocality': _.get(opts, 'inLocality'), + 'FaxEnabled': serialize.bool(_.get(opts, 'faxEnabled')), + 'PageToken': opts.pageToken, + 'Page': opts.pageNumber, + 'PageSize': opts.pageSize + }); + + var promise = this._version.page({uri: this._uri, method: 'GET', params: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new VoipPage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single target page of VoipInstance records from the API. + * Request is executed immediately + * + * If a function is passed as the first argument, it will be used as the callback function. + * + * @function getPage + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipList + * @instance + * + * @param {number} [opts.areaCode] - The area_code + * @param {string} [opts.contains] - The contains + * @param {boolean} [opts.smsEnabled] - The sms_enabled + * @param {boolean} [opts.mmsEnabled] - The mms_enabled + * @param {boolean} [opts.voiceEnabled] - The voice_enabled + * @param {boolean} [opts.excludeAllAddressRequired] - + * The exclude_all_address_required + * @param {boolean} [opts.excludeLocalAddressRequired] - + * The exclude_local_address_required + * @param {boolean} [opts.excludeForeignAddressRequired] - + * The exclude_foreign_address_required + * @param {boolean} [opts.beta] - The beta + * @param {string} [opts.nearNumber] - The near_number + * @param {string} [opts.nearLatLong] - The near_lat_long + * @param {number} [opts.distance] - The distance + * @param {string} [opts.inPostalCode] - The in_postal_code + * @param {string} [opts.inRegion] - The in_region + * @param {string} [opts.inRateCenter] - The in_rate_center + * @param {string} [opts.inLata] - The in_lata + * @param {string} [opts.inLocality] - The in_locality + * @param {boolean} [opts.faxEnabled] - The fax_enabled + * @param {string} [targetUrl] - API-generated URL for the requested results page + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + VoipListInstance.getPage = function getPage(targetUrl, callback) { + var deferred = Q.defer(); + + var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl}); + + promise = promise.then(function(payload) { + deferred.resolve(new VoipPage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + return VoipListInstance; +}; + + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipPage + * @augments Page + * @description Initialize the VoipPage + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {object} response - Response from the API + * @param {object} solution - Path solution + * + * @returns VoipPage + */ +/* jshint ignore:end */ +VoipPage = function VoipPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(VoipPage.prototype, Page.prototype); +VoipPage.prototype.constructor = VoipPage; + +/* jshint ignore:start */ +/** + * Build an instance of VoipInstance + * + * @function getInstance + * @memberof Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipPage + * @instance + * + * @param {object} payload - Payload response from the API + * + * @returns VoipInstance + */ +/* jshint ignore:end */ +VoipPage.prototype.getInstance = function getInstance(payload) { + return new VoipInstance(this._version, payload, this._solution.accountSid, this._solution.countryCode); +}; + + +/* jshint ignore:start */ +/** + * @constructor Twilio.Api.V2010.AccountContext.AvailablePhoneNumberCountryContext.VoipInstance + * @description Initialize the VoipContext + * + * @property {string} friendlyName - The friendly_name + * @property {string} phoneNumber - The phone_number + * @property {string} lata - The lata + * @property {string} locality - The locality + * @property {string} rateCenter - The rate_center + * @property {number} latitude - The latitude + * @property {number} longitude - The longitude + * @property {string} region - The region + * @property {string} postalCode - The postal_code + * @property {string} isoCountry - The iso_country + * @property {string} addressRequirements - The address_requirements + * @property {boolean} beta - The beta + * @property {string} capabilities - The capabilities + * + * @param {Twilio.Api.V2010} version - Version of the resource + * @param {object} payload - The instance payload + */ +/* jshint ignore:end */ +VoipInstance = function VoipInstance(version, payload, accountSid, countryCode) + { + this._version = version; + + // Marshaled Properties + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.phoneNumber = payload.phone_number; // jshint ignore:line + this.lata = payload.lata; // jshint ignore:line + this.locality = payload.locality; // jshint ignore:line + this.rateCenter = payload.rate_center; // jshint ignore:line + this.latitude = deserialize.decimal(payload.latitude); // jshint ignore:line + this.longitude = deserialize.decimal(payload.longitude); // jshint ignore:line + this.region = payload.region; // jshint ignore:line + this.postalCode = payload.postal_code; // jshint ignore:line + this.isoCountry = payload.iso_country; // jshint ignore:line + this.addressRequirements = payload.address_requirements; // jshint ignore:line + this.beta = payload.beta; // jshint ignore:line + this.capabilities = payload.capabilities; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {accountSid: accountSid, countryCode: countryCode}; +}; + +module.exports = { + VoipList: VoipList, + VoipPage: VoipPage, + VoipInstance: VoipInstance +}; diff --git a/lib/rest/api/v2010/account/call.js b/lib/rest/api/v2010/account/call.js index 0dc0c70fde..b863e17633 100644 --- a/lib/rest/api/v2010/account/call.js +++ b/lib/rest/api/v2010/account/call.js @@ -95,6 +95,8 @@ CallList = function CallList(version, accountSid) { * Enable machine detection or end of greeting detection * @param {number} [opts.machineDetectionTimeout] - * Number of miliseconds to wait for machine detection + * @param {string|list} [opts.recordingStatusCallbackEvent] - + * The recording_status_callback_event * @param {string} [opts.url] - Url from which to fetch TwiML * @param {string} [opts.applicationSid] - * ApplicationSid that configures from where to fetch TwiML @@ -136,7 +138,8 @@ CallList = function CallList(version, accountSid) { 'SipAuthUsername': _.get(opts, 'sipAuthUsername'), 'SipAuthPassword': _.get(opts, 'sipAuthPassword'), 'MachineDetection': _.get(opts, 'machineDetection'), - 'MachineDetectionTimeout': _.get(opts, 'machineDetectionTimeout') + 'MachineDetectionTimeout': _.get(opts, 'machineDetectionTimeout'), + 'RecordingStatusCallbackEvent': serialize.map(_.get(opts, 'recordingStatusCallbackEvent'), function(e) { return e; }) }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/api/v2010/account/call/recording.js b/lib/rest/api/v2010/account/call/recording.js index 779dec92af..d0532d743d 100644 --- a/lib/rest/api/v2010/account/call/recording.js +++ b/lib/rest/api/v2010/account/call/recording.js @@ -392,11 +392,11 @@ RecordingPage.prototype.getInstance = function getInstance(payload) { * @property {number} price - The price * @property {string} uri - The uri * @property {string} encryptionDetails - The encryption_details - * @property {number} errorCode - The error_code + * @property {string} priceUnit - The price_unit * @property {recording.status} status - The status - * @property {recording.source} source - The source * @property {number} channels - The channels - * @property {string} priceUnit - The price_unit + * @property {recording.source} source - The source + * @property {number} errorCode - The error_code * * @param {Twilio.Api.V2010} version - Version of the resource * @param {object} payload - The instance payload @@ -420,11 +420,11 @@ RecordingInstance = function RecordingInstance(version, payload, accountSid, this.price = deserialize.decimal(payload.price); // jshint ignore:line this.uri = payload.uri; // jshint ignore:line this.encryptionDetails = payload.encryption_details; // jshint ignore:line - this.errorCode = deserialize.integer(payload.error_code); // jshint ignore:line + this.priceUnit = payload.price_unit; // jshint ignore:line this.status = payload.status; // jshint ignore:line - this.source = payload.source; // jshint ignore:line this.channels = deserialize.integer(payload.channels); // jshint ignore:line - this.priceUnit = payload.price_unit; // jshint ignore:line + this.source = payload.source; // jshint ignore:line + this.errorCode = deserialize.integer(payload.error_code); // jshint ignore:line // Context this._context = undefined; diff --git a/lib/rest/api/v2010/account/conference/participant.js b/lib/rest/api/v2010/account/conference/participant.js index 16740018ba..ae4ac5a40a 100644 --- a/lib/rest/api/v2010/account/conference/participant.js +++ b/lib/rest/api/v2010/account/conference/participant.js @@ -98,6 +98,10 @@ ParticipantList = function ParticipantList(version, accountSid, conferenceSid) { * The conference_recording_status_callback * @param {string} [opts.conferenceRecordingStatusCallbackMethod] - * The conference_recording_status_callback_method + * @param {string|list} [opts.recordingStatusCallbackEvent] - + * The recording_status_callback_event + * @param {string|list} [opts.conferenceRecordingStatusCallbackEvent] - + * The conference_recording_status_callback_event * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed ParticipantInstance @@ -143,7 +147,9 @@ ParticipantList = function ParticipantList(version, accountSid, conferenceSid) { 'SipAuthPassword': _.get(opts, 'sipAuthPassword'), 'Region': _.get(opts, 'region'), 'ConferenceRecordingStatusCallback': _.get(opts, 'conferenceRecordingStatusCallback'), - 'ConferenceRecordingStatusCallbackMethod': _.get(opts, 'conferenceRecordingStatusCallbackMethod') + 'ConferenceRecordingStatusCallbackMethod': _.get(opts, 'conferenceRecordingStatusCallbackMethod'), + 'RecordingStatusCallbackEvent': serialize.map(_.get(opts, 'recordingStatusCallbackEvent'), function(e) { return e; }), + 'ConferenceRecordingStatusCallbackEvent': serialize.map(_.get(opts, 'conferenceRecordingStatusCallbackEvent'), function(e) { return e; }) }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/api/v2010/account/recording.js b/lib/rest/api/v2010/account/recording.js index 1567cfa75c..9a23589d04 100644 --- a/lib/rest/api/v2010/account/recording.js +++ b/lib/rest/api/v2010/account/recording.js @@ -385,20 +385,24 @@ RecordingPage.prototype.getInstance = function getInstance(payload) { * @property {string} accountSid - The unique sid that identifies this account * @property {string} apiVersion - * The version of the API in use during the recording. - * @property {string} callSid - The call during which the recording was made. + * @property {string} callSid - + * The unique id for the call leg that corresponds to the recording. * @property {Date} dateCreated - The date this resource was created * @property {Date} dateUpdated - The date this resource was last updated * @property {string} duration - The length of the recording, in seconds. * @property {string} sid - A string that uniquely identifies this recording - * @property {string} price - The price - * @property {string} priceUnit - The price_unit - * @property {recording.status} status - The status - * @property {number} channels - The channels - * @property {recording.source} source - The source - * @property {string} uri - The URI for this resource - * @property {string} encryptionDetails - The encryption_details + * @property {string} price - The one-time cost of creating this recording. + * @property {string} priceUnit - The currency used in the Price property. + * @property {recording.status} status - The status of the recording. + * @property {number} channels - + * The number of channels in the final recording file as an integer. + * @property {recording.source} source - + * The way in which this recording was created. * @property {number} errorCode - * More information about the recording failure, if Status is failed. + * @property {string} uri - The URI for this resource + * @property {string} encryptionDetails - The encryption_details + * @property {string} subresourceUris - The subresource_uris * * @param {Twilio.Api.V2010} version - Version of the resource * @param {object} payload - The instance payload @@ -423,9 +427,10 @@ RecordingInstance = function RecordingInstance(version, payload, accountSid, this.status = payload.status; // jshint ignore:line this.channels = deserialize.integer(payload.channels); // jshint ignore:line this.source = payload.source; // jshint ignore:line + this.errorCode = deserialize.integer(payload.error_code); // jshint ignore:line this.uri = payload.uri; // jshint ignore:line this.encryptionDetails = payload.encryption_details; // jshint ignore:line - this.errorCode = deserialize.integer(payload.error_code); // jshint ignore:line + this.subresourceUris = payload.subresource_uris; // jshint ignore:line // Context this._context = undefined; diff --git a/lib/rest/preview/hosted_numbers/hostedNumberOrder.js b/lib/rest/preview/hosted_numbers/hostedNumberOrder.js index 11e46a01e8..b5978313fc 100644 --- a/lib/rest/preview/hosted_numbers/hostedNumberOrder.js +++ b/lib/rest/preview/hosted_numbers/hostedNumberOrder.js @@ -356,6 +356,9 @@ HostedNumberOrderList = function HostedNumberOrderList(version) { * @param {string} [opts.smsApplicationSid] - SMS Application Sid. * @param {string} [opts.addressSid] - Address sid. * @param {string} [opts.email] - Email. + * @param {hosted_number_order.verification_type} [opts.verificationType] - + * Verification Type. + * @param {string} [opts.verificationDocumentSid] - Verification Document Sid * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed HostedNumberOrderInstance @@ -388,7 +391,9 @@ HostedNumberOrderList = function HostedNumberOrderList(version) { 'StatusCallbackMethod': _.get(opts, 'statusCallbackMethod'), 'SmsApplicationSid': _.get(opts, 'smsApplicationSid'), 'AddressSid': _.get(opts, 'addressSid'), - 'Email': _.get(opts, 'email') + 'Email': _.get(opts, 'email'), + 'VerificationType': _.get(opts, 'verificationType'), + 'VerificationDocumentSid': _.get(opts, 'verificationDocumentSid') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); @@ -497,6 +502,9 @@ HostedNumberOrderPage.prototype.getInstance = function getInstance(payload) { * @property {string} email - Email. * @property {string} ccEmails - A list of emails. * @property {string} url - The URL of this HostedNumberOrder. + * @property {hosted_number_order.verification_type} verificationType - + * The method used for verifying ownership of the number to be hosted. + * @property {string} verificationDocumentSid - Verification Document Sid. * * @param {Twilio.Preview.HostedNumbers} version - Version of the resource * @param {object} payload - The instance payload @@ -524,6 +532,8 @@ HostedNumberOrderInstance = function HostedNumberOrderInstance(version, payload, this.email = payload.email; // jshint ignore:line this.ccEmails = payload.cc_emails; // jshint ignore:line this.url = payload.url; // jshint ignore:line + this.verificationType = payload.verification_type; // jshint ignore:line + this.verificationDocumentSid = payload.verification_document_sid; // jshint ignore:line // Context this._context = undefined; @@ -593,6 +603,9 @@ HostedNumberOrderInstance.prototype.remove = function remove(callback) { * @param {hosted_number_order.status} [opts.status] - * The Status of this HostedNumberOrder. * @param {string} [opts.verificationCode] - A verification code. + * @param {hosted_number_order.verification_type} [opts.verificationType] - + * Verification Type. + * @param {string} [opts.verificationDocumentSid] - Verification Document Sid * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed HostedNumberOrderInstance @@ -705,6 +718,9 @@ HostedNumberOrderContext.prototype.remove = function remove(callback) { * @param {hosted_number_order.status} [opts.status] - * The Status of this HostedNumberOrder. * @param {string} [opts.verificationCode] - A verification code. + * @param {hosted_number_order.verification_type} [opts.verificationType] - + * Verification Type. + * @param {string} [opts.verificationDocumentSid] - Verification Document Sid * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed HostedNumberOrderInstance @@ -724,7 +740,9 @@ HostedNumberOrderContext.prototype.update = function update(opts, callback) { 'Email': _.get(opts, 'email'), 'CcEmails': serialize.map(_.get(opts, 'ccEmails'), function(e) { return e; }), 'Status': _.get(opts, 'status'), - 'VerificationCode': _.get(opts, 'verificationCode') + 'VerificationCode': _.get(opts, 'verificationCode'), + 'VerificationType': _.get(opts, 'verificationType'), + 'VerificationDocumentSid': _.get(opts, 'verificationDocumentSid') }); var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/twiml/FaxResponse.js b/lib/twiml/FaxResponse.js index f12198c19d..8707a12ae0 100644 --- a/lib/twiml/FaxResponse.js +++ b/lib/twiml/FaxResponse.js @@ -26,8 +26,8 @@ function FaxResponse() { * TwiML Verb * * @param {object} attributes - ... - * @param {url} [attributes.action] Receive action URL - * @param {http_method} [attributes.method] Receive action URL method + * @param {string} [attributes.action] Receive action URL + * @param {string} [attributes.method] Receive action URL method */ /* jshint ignore:end */ FaxResponse.prototype.receive = function receive(attributes) { diff --git a/lib/twiml/MessagingResponse.js b/lib/twiml/MessagingResponse.js index d88ceb3a63..d426441d20 100644 --- a/lib/twiml/MessagingResponse.js +++ b/lib/twiml/MessagingResponse.js @@ -28,8 +28,9 @@ function MessagingResponse() { * @param {object} attributes - ... * @param {string} [attributes.to] Phone Number to send Message to * @param {string} [attributes.from] Phone Number to send Message from - * @param {url} [attributes.action] Action URL - * @param {http_method} [attributes.method] Action URL Method + * @param {string} [attributes.action] Action URL + * @param {string} [attributes.method] Action URL Method + * @param {string} [attributes.statusCallback] Status callback URL. Deprecated in favor of action. * @param {string} [body] Message Body * * @returns Message @@ -44,7 +45,7 @@ MessagingResponse.prototype.message = function message(attributes, body) { * TwiML Verb * * @param {object} attributes - ... - * @param {http_method} [attributes.method] Redirect URL method + * @param {string} [attributes.method] Redirect URL method * @param {url} url Redirect URL */ /* jshint ignore:end */ diff --git a/lib/twiml/VoiceResponse.js b/lib/twiml/VoiceResponse.js index 8fb6c96909..bcaa6971b6 100644 --- a/lib/twiml/VoiceResponse.js +++ b/lib/twiml/VoiceResponse.js @@ -26,18 +26,19 @@ function VoiceResponse() { * TwiML Verb * * @param {object} attributes - ... - * @param {url} [attributes.action] Action URL - * @param {http_method} [attributes.method] Action URL method - * @param {integer} [attributes.timeout] Time to wait for answer + * @param {string} [attributes.action] Action URL + * @param {string} [attributes.method] Action URL method + * @param {number} [attributes.timeout] Time to wait for answer * @param {boolean} [attributes.hangupOnStar] Hangup call on star press - * @param {integer} [attributes.timeLimit] Max time length + * @param {number} [attributes.timeLimit] Max time length * @param {string} [attributes.callerId] Caller ID to display - * @param {record.trim} [attributes.record] Record the call - * @param {record.trim} [attributes.trim] Trim the recording - * @param {url} [attributes.recordingStatusCallback] Recording status callback URL - * @param {http_method} [attributes.recordingStatusCallbackMethod] Recording status callback URL method + * @param {record} [attributes.record] Record the call + * @param {trim} [attributes.trim] Trim the recording + * @param {string} [attributes.recordingStatusCallback] Recording status callback URL + * @param {string} [attributes.recordingStatusCallbackMethod] Recording status callback URL method + * @param {recording_event} [attributes.recordingStatusCallbackEvent] Recording status callback events * @param {boolean} [attributes.answerOnBridge] Preserve the ringing behavior of the inbound call until the Dialed call picks up - * @param {dial.ring_tone} [attributes.ringTone] Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial + * @param {ring_tone} [attributes.ringTone] Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial * @param {string} [number] Phone number to dial * * @returns Dial @@ -63,10 +64,10 @@ VoiceResponse.prototype.echo = function echo(attributes) { * TwiML Noun * * @param {object} attributes - ... - * @param {url} [attributes.action] Action URL - * @param {http_method} [attributes.method] Action URL method - * @param {url} [attributes.waitUrl] Wait URL - * @param {http_method} [attributes.waitUrlMethod] Wait URL method + * @param {string} [attributes.action] Action URL + * @param {string} [attributes.method] Action URL method + * @param {string} [attributes.waitUrl] Wait URL + * @param {string} [attributes.waitUrlMethod] Wait URL method * @param {string} [attributes.workflowSid] TaskRouter Workflow SID * @param {string} [name] Friendly name * @@ -82,18 +83,18 @@ VoiceResponse.prototype.enqueue = function enqueue(attributes, name) { * TwiML Verb * * @param {object} attributes - ... - * @param {gather.input} [attributes.input] Input type Twilio should accept - * @param {url} [attributes.action] Action URL - * @param {http_method} [attributes.method] Action URL method - * @param {integer} [attributes.timeout] Time to wait to gather input + * @param {input} [attributes.input] Input type Twilio should accept + * @param {string} [attributes.action] Action URL + * @param {string} [attributes.method] Action URL method + * @param {number} [attributes.timeout] Time to wait to gather input * @param {string} [attributes.speechTimeout] Time to wait to gather speech input and it should be either auto or a positive integer. - * @param {integer} [attributes.maxSpeechTime] Max allowed time for speech input + * @param {number} [attributes.maxSpeechTime] Max allowed time for speech input * @param {boolean} [attributes.profanityFilter] Profanity Filter on speech * @param {string} [attributes.finishOnKey] Finish gather on key - * @param {integer} [attributes.numDigits] Number of digits to collect - * @param {url} [attributes.partialResultCallback] Partial result callback URL - * @param {http_method} [attributes.partialResultCallbackMethod] Partial result callback URL method - * @param {say.language} [attributes.language] Language to use + * @param {number} [attributes.numDigits] Number of digits to collect + * @param {string} [attributes.partialResultCallback] Partial result callback URL + * @param {string} [attributes.partialResultCallbackMethod] Partial result callback URL method + * @param {language} [attributes.language] Language to use * @param {string} [attributes.hints] Speech recognition hints * @param {boolean} [attributes.bargeIn] Stop playing media upon speech * @@ -131,7 +132,7 @@ VoiceResponse.prototype.leave = function leave(attributes) { * TwiML Verb * * @param {object} attributes - ... - * @param {integer} [attributes.length] Length in seconds to pause + * @param {number} [attributes.length] Length in seconds to pause */ /* jshint ignore:end */ VoiceResponse.prototype.pause = function pause(attributes) { @@ -143,7 +144,7 @@ VoiceResponse.prototype.pause = function pause(attributes) { * TwiML Verb * * @param {object} attributes - ... - * @param {integer} [attributes.loop] Times to loop media + * @param {number} [attributes.loop] Times to loop media * @param {string} [attributes.digits] Play DTMF tones for digits * @param {url} [url] Media URL */ @@ -157,8 +158,8 @@ VoiceResponse.prototype.play = function play(attributes, url) { * TwiML Noun * * @param {object} attributes - ... - * @param {url} [attributes.url] Action URL - * @param {http_method} [attributes.method] Action URL method + * @param {string} [attributes.url] Action URL + * @param {string} [attributes.method] Action URL method * @param {string} [attributes.reservationSid] TaskRouter Reservation SID * @param {string} [attributes.postWorkActivitySid] TaskRouter Activity SID * @param {string} name Queue name @@ -173,17 +174,17 @@ VoiceResponse.prototype.queue = function queue(attributes, name) { * TwiML Verb * * @param {object} attributes - ... - * @param {url} [attributes.action] Action URL - * @param {http_method} [attributes.method] Action URL method - * @param {integer} [attributes.timeout] Timeout to begin recording + * @param {string} [attributes.action] Action URL + * @param {string} [attributes.method] Action URL method + * @param {number} [attributes.timeout] Timeout to begin recording * @param {string} [attributes.finishOnKey] Finish recording on key - * @param {integer} [attributes.maxLength] Max time to record in seconds + * @param {number} [attributes.maxLength] Max time to record in seconds * @param {boolean} [attributes.playBeep] Play beep - * @param {conference.trim} [attributes.trim] Trim the recording - * @param {url} [attributes.recordingStatusCallback] Status callback URL - * @param {http_method} [attributes.recordingStatusCallbackMethod] Status callback URL method + * @param {trim} [attributes.trim] Trim the recording + * @param {string} [attributes.recordingStatusCallback] Status callback URL + * @param {string} [attributes.recordingStatusCallbackMethod] Status callback URL method * @param {boolean} [attributes.transcribe] Transcribe the recording - * @param {url} [attributes.transcribeCallback] Transcribe callback URL + * @param {string} [attributes.transcribeCallback] Transcribe callback URL */ /* jshint ignore:end */ VoiceResponse.prototype.record = function record(attributes) { @@ -195,7 +196,7 @@ VoiceResponse.prototype.record = function record(attributes) { * TwiML Verb * * @param {object} attributes - ... - * @param {http_method} [attributes.method] Redirect URL method + * @param {string} [attributes.method] Redirect URL method * @param {url} url Redirect URL */ /* jshint ignore:end */ @@ -208,7 +209,7 @@ VoiceResponse.prototype.redirect = function redirect(attributes, url) { * TwiML Verb * * @param {object} attributes - ... - * @param {reject.reason} [attributes.reason] Rejection reason + * @param {reason} [attributes.reason] Rejection reason */ /* jshint ignore:end */ VoiceResponse.prototype.reject = function reject(attributes) { @@ -220,9 +221,9 @@ VoiceResponse.prototype.reject = function reject(attributes) { * TwiML Verb * * @param {object} attributes - ... - * @param {say.voice} [attributes.voice] Voice to use - * @param {integer} [attributes.loop] Times to loop message - * @param {say.language} [attributes.language] Message langauge + * @param {voice} [attributes.voice] Voice to use + * @param {number} [attributes.loop] Times to loop message + * @param {language} [attributes.language] Message langauge * @param {string} message Message to say */ /* jshint ignore:end */ @@ -235,11 +236,11 @@ VoiceResponse.prototype.say = function say(attributes, message) { * TwiML Noun * * @param {object} attributes - ... - * @param {phone_number} [attributes.to] Number to send message to - * @param {phone_number} [attributes.from] Number to send message from - * @param {url} [attributes.action] Action URL - * @param {http_method} [attributes.method] Action URL method - * @param {url} [attributes.statusCallback] Status callback URL + * @param {string} [attributes.to] Number to send message to + * @param {string} [attributes.from] Number to send message from + * @param {string} [attributes.action] Action URL + * @param {string} [attributes.method] Action URL method + * @param {string} [attributes.statusCallback] Status callback URL * @param {string} message Message body */ /* jshint ignore:end */ @@ -275,9 +276,9 @@ function Gather(gather) { * TwiML Verb * * @param {object} attributes - ... - * @param {say.voice} [attributes.voice] Voice to use - * @param {integer} [attributes.loop] Times to loop message - * @param {say.language} [attributes.language] Message langauge + * @param {voice} [attributes.voice] Voice to use + * @param {number} [attributes.loop] Times to loop message + * @param {language} [attributes.language] Message langauge * @param {string} message Message to say */ /* jshint ignore:end */ @@ -290,7 +291,7 @@ Gather.prototype.say = function say(attributes, message) { * TwiML Verb * * @param {object} attributes - ... - * @param {integer} [attributes.length] Length in seconds to pause + * @param {number} [attributes.length] Length in seconds to pause */ /* jshint ignore:end */ Gather.prototype.pause = function pause(attributes) { @@ -302,7 +303,7 @@ Gather.prototype.pause = function pause(attributes) { * TwiML Verb * * @param {object} attributes - ... - * @param {integer} [attributes.loop] Times to loop media + * @param {number} [attributes.loop] Times to loop media * @param {string} [attributes.digits] Play DTMF tones for digits * @param {url} [url] Media URL */ @@ -327,7 +328,9 @@ function Enqueue(enqueue) { /** * TwiML Noun * - * @param {object} attributes - TwiML attributes + * @param {object} attributes - ... + * @param {number} [attributes.priority] Task priority + * @param {number} [attributes.timeout] Timeout associated with task * @param {string} body TaskRouter task attributes */ /* jshint ignore:end */ @@ -352,11 +355,11 @@ function Dial(dial) { * TwiML Noun * * @param {object} attributes - ... - * @param {url} [attributes.url] Client URL - * @param {http_method} [attributes.method] Client URL Method - * @param {sip.event} [attributes.statusCallbackEvent] Events to trigger status callback - * @param {url} [attributes.statusCallback] Status Callback URL - * @param {http_method} [attributes.statusCallbackMethod] Status Callback URL Method + * @param {string} [attributes.url] Client URL + * @param {string} [attributes.method] Client URL Method + * @param {event} [attributes.statusCallbackEvent] Events to trigger status callback + * @param {string} [attributes.statusCallback] Status Callback URL + * @param {string} [attributes.statusCallbackMethod] Status Callback URL Method * @param {string} name Client name */ /* jshint ignore:end */ @@ -370,22 +373,23 @@ Dial.prototype.client = function client(attributes, name) { * * @param {object} attributes - ... * @param {boolean} [attributes.muted] Join the conference muted - * @param {conference.beep} [attributes.beep] Play beep when joining + * @param {beep} [attributes.beep] Play beep when joining * @param {boolean} [attributes.startConferenceOnEnter] Start the conference on enter * @param {boolean} [attributes.endConferenceOnExit] End the conferenceon exit - * @param {url} [attributes.waitUrl] Wait URL - * @param {http_method} [attributes.waitMethod] Wait URL method - * @param {integer} [attributes.maxParticipants] Maximum number of participants - * @param {conference.record} [attributes.record] Record the conference - * @param {conference.region} [attributes.region] Conference region - * @param {sid} [attributes.whisper] Call whisper - * @param {conference.trim} [attributes.trim] Trim the conference recording - * @param {sip.event} [attributes.statusCallbackEvent] Events to call status callback URL - * @param {url} [attributes.statusCallback] Status callback URL - * @param {http_method} [attributes.statusCallbackMethod] Status callback URL method - * @param {url} [attributes.recordingStatusCallback] Recording status callback URL - * @param {http_method} [attributes.recordingStatusCallbackMethod] Recording status callback URL method - * @param {url} [attributes.eventCallbackUrl] Event callback URL + * @param {string} [attributes.waitUrl] Wait URL + * @param {string} [attributes.waitMethod] Wait URL method + * @param {number} [attributes.maxParticipants] Maximum number of participants + * @param {record} [attributes.record] Record the conference + * @param {region} [attributes.region] Conference region + * @param {string} [attributes.whisper] Call whisper + * @param {trim} [attributes.trim] Trim the conference recording + * @param {event} [attributes.statusCallbackEvent] Events to call status callback URL + * @param {string} [attributes.statusCallback] Status callback URL + * @param {string} [attributes.statusCallbackMethod] Status callback URL method + * @param {string} [attributes.recordingStatusCallback] Recording status callback URL + * @param {string} [attributes.recordingStatusCallbackMethod] Recording status callback URL method + * @param {recording_event} [attributes.recordingStatusCallbackEvent] Recording status callback events + * @param {string} [attributes.eventCallbackUrl] Event callback URL * @param {string} name Conference name */ /* jshint ignore:end */ @@ -399,11 +403,11 @@ Dial.prototype.conference = function conference(attributes, name) { * * @param {object} attributes - ... * @param {string} [attributes.sendDigits] DTMF tones to play when the call is answered - * @param {url} [attributes.url] TwiML URL - * @param {http_method} [attributes.method] TwiML URL method - * @param {sip.event} [attributes.statusCallbackEvent] Events to call status callback - * @param {url} [attributes.statusCallback] Status callback URL - * @param {http_method} [attributes.statusCallbackMethod] Status callback URL method + * @param {string} [attributes.url] TwiML URL + * @param {string} [attributes.method] TwiML URL method + * @param {event} [attributes.statusCallbackEvent] Events to call status callback + * @param {string} [attributes.statusCallback] Status callback URL + * @param {string} [attributes.statusCallbackMethod] Status callback URL method * @param {phone_number} phoneNumber Phone Number to dial */ /* jshint ignore:end */ @@ -416,8 +420,8 @@ Dial.prototype.number = function number(attributes, phoneNumber) { * TwiML Noun * * @param {object} attributes - ... - * @param {url} [attributes.url] Action URL - * @param {http_method} [attributes.method] Action URL method + * @param {string} [attributes.url] Action URL + * @param {string} [attributes.method] Action URL method * @param {string} [attributes.reservationSid] TaskRouter Reservation SID * @param {string} [attributes.postWorkActivitySid] TaskRouter Activity SID * @param {string} name Queue name @@ -446,11 +450,11 @@ Dial.prototype.sim = function sim(attributes, simSid) { * @param {object} attributes - ... * @param {string} [attributes.username] SIP Username * @param {string} [attributes.password] SIP Password - * @param {url} [attributes.url] Action URL - * @param {http_method} [attributes.method] Action URL method - * @param {sip.event} [attributes.statusCallbackEvent] Status callback events - * @param {url} [attributes.statusCallback] Status callback URL - * @param {http_method} [attributes.statusCallbackMethod] Status callback URL method + * @param {string} [attributes.url] Action URL + * @param {string} [attributes.method] Action URL method + * @param {event} [attributes.statusCallbackEvent] Status callback events + * @param {string} [attributes.statusCallback] Status callback URL + * @param {string} [attributes.statusCallbackMethod] Status callback URL method * @param {url} sipUrl SIP URL */ /* jshint ignore:end */ diff --git a/spec/integration/rest/api/v2010/account/availablePhoneNumber/machineToMachine.spec.js b/spec/integration/rest/api/v2010/account/availablePhoneNumber/machineToMachine.spec.js new file mode 100644 index 0000000000..a60e5b8d6d --- /dev/null +++ b/spec/integration/rest/api/v2010/account/availablePhoneNumber/machineToMachine.spec.js @@ -0,0 +1,138 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var _ = require('lodash'); /* jshint ignore:line */ +var Holodeck = require('../../../../../holodeck'); /* jshint ignore:line */ +var Request = require( + '../../../../../../../lib/http/request'); /* jshint ignore:line */ +var Response = require( + '../../../../../../../lib/http/response'); /* jshint ignore:line */ +var RestException = require( + '../../../../../../../lib/base/RestException'); /* jshint ignore:line */ +var Twilio = require('../../../../../../../lib'); /* jshint ignore:line */ + + +var client; +var holodeck; + +describe('MachineToMachine', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid list request', + function() { + holodeck.mock(new Response(500, '{}')); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .machineToMachine.list(); + promise = promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + }); + promise.done(); + + var solution = {accountSid: 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', countryCode: 'US'}; + var url = _.template('https://api.twilio.com/2010-04-01/Accounts/<%= accountSid %>/AvailablePhoneNumbers/<%= countryCode %>/MachineToMachine.json')(solution); + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_full response', + function() { + var body = JSON.stringify({ + 'available_phone_numbers': [ + { + 'address_requirements': 'none', + 'beta': false, + 'capabilities': { + 'mms': false, + 'sms': true, + 'voice': false + }, + 'friendly_name': '+4759440374', + 'iso_country': 'NO', + 'lata': null, + 'latitude': null, + 'locality': null, + 'longitude': null, + 'phone_number': '+4759440374', + 'postal_code': null, + 'rate_center': null, + 'region': null + } + ], + 'end': 1, + 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/MachineToMachine.json?PageSize=50&Page=0', + 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/MachineToMachine.json?PageSize=50&Page=0', + 'next_page_uri': null, + 'num_pages': 1, + 'page': 0, + 'page_size': 50, + 'previous_page_uri': null, + 'start': 0, + 'total': 1, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/MachineToMachine.json?PageSize=1' + }); + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .machineToMachine.list(); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); + it('should generate valid read_empty response', + function() { + var body = JSON.stringify({ + 'available_phone_numbers': [], + 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/MachineToMachine.json?PageSize=50&Page=0', + 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/MachineToMachine.json?PageSize=50&Page=0', + 'next_page_uri': null, + 'num_pages': 1, + 'page': 0, + 'page_size': 50, + 'previous_page_uri': null, + 'start': 0, + 'total': 1, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/MachineToMachine.json?PageSize=1' + }); + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .machineToMachine.list(); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); +}); + diff --git a/spec/integration/rest/api/v2010/account/availablePhoneNumber/national.spec.js b/spec/integration/rest/api/v2010/account/availablePhoneNumber/national.spec.js new file mode 100644 index 0000000000..2040659221 --- /dev/null +++ b/spec/integration/rest/api/v2010/account/availablePhoneNumber/national.spec.js @@ -0,0 +1,138 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var _ = require('lodash'); /* jshint ignore:line */ +var Holodeck = require('../../../../../holodeck'); /* jshint ignore:line */ +var Request = require( + '../../../../../../../lib/http/request'); /* jshint ignore:line */ +var Response = require( + '../../../../../../../lib/http/response'); /* jshint ignore:line */ +var RestException = require( + '../../../../../../../lib/base/RestException'); /* jshint ignore:line */ +var Twilio = require('../../../../../../../lib'); /* jshint ignore:line */ + + +var client; +var holodeck; + +describe('National', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid list request', + function() { + holodeck.mock(new Response(500, '{}')); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .national.list(); + promise = promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + }); + promise.done(); + + var solution = {accountSid: 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', countryCode: 'US'}; + var url = _.template('https://api.twilio.com/2010-04-01/Accounts/<%= accountSid %>/AvailablePhoneNumbers/<%= countryCode %>/National.json')(solution); + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_full response', + function() { + var body = JSON.stringify({ + 'available_phone_numbers': [ + { + 'address_requirements': 'none', + 'beta': false, + 'capabilities': { + 'mms': false, + 'sms': true, + 'voice': false + }, + 'friendly_name': '+4759440374', + 'iso_country': 'NO', + 'lata': null, + 'latitude': null, + 'locality': null, + 'longitude': null, + 'phone_number': '+4759440374', + 'postal_code': null, + 'rate_center': null, + 'region': null + } + ], + 'end': 1, + 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/National.json?PageSize=50&Page=0', + 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/National.json?PageSize=50&Page=0', + 'next_page_uri': null, + 'num_pages': 1, + 'page': 0, + 'page_size': 50, + 'previous_page_uri': null, + 'start': 0, + 'total': 1, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/National.json?PageSize=1' + }); + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .national.list(); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); + it('should generate valid read_empty response', + function() { + var body = JSON.stringify({ + 'available_phone_numbers': [], + 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/National.json?PageSize=50&Page=0', + 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/National.json?PageSize=50&Page=0', + 'next_page_uri': null, + 'num_pages': 1, + 'page': 0, + 'page_size': 50, + 'previous_page_uri': null, + 'start': 0, + 'total': 1, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/National.json?PageSize=1' + }); + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .national.list(); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); +}); + diff --git a/spec/integration/rest/api/v2010/account/availablePhoneNumber/sharedCost.spec.js b/spec/integration/rest/api/v2010/account/availablePhoneNumber/sharedCost.spec.js new file mode 100644 index 0000000000..f644639afb --- /dev/null +++ b/spec/integration/rest/api/v2010/account/availablePhoneNumber/sharedCost.spec.js @@ -0,0 +1,138 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var _ = require('lodash'); /* jshint ignore:line */ +var Holodeck = require('../../../../../holodeck'); /* jshint ignore:line */ +var Request = require( + '../../../../../../../lib/http/request'); /* jshint ignore:line */ +var Response = require( + '../../../../../../../lib/http/response'); /* jshint ignore:line */ +var RestException = require( + '../../../../../../../lib/base/RestException'); /* jshint ignore:line */ +var Twilio = require('../../../../../../../lib'); /* jshint ignore:line */ + + +var client; +var holodeck; + +describe('SharedCost', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid list request', + function() { + holodeck.mock(new Response(500, '{}')); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .sharedCost.list(); + promise = promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + }); + promise.done(); + + var solution = {accountSid: 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', countryCode: 'US'}; + var url = _.template('https://api.twilio.com/2010-04-01/Accounts/<%= accountSid %>/AvailablePhoneNumbers/<%= countryCode %>/SharedCost.json')(solution); + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_full response', + function() { + var body = JSON.stringify({ + 'available_phone_numbers': [ + { + 'address_requirements': 'none', + 'beta': false, + 'capabilities': { + 'mms': false, + 'sms': true, + 'voice': false + }, + 'friendly_name': '+4759440374', + 'iso_country': 'NO', + 'lata': null, + 'latitude': null, + 'locality': null, + 'longitude': null, + 'phone_number': '+4759440374', + 'postal_code': null, + 'rate_center': null, + 'region': null + } + ], + 'end': 1, + 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/SharedCost.json?PageSize=50&Page=0', + 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/SharedCost.json?PageSize=50&Page=0', + 'next_page_uri': null, + 'num_pages': 1, + 'page': 0, + 'page_size': 50, + 'previous_page_uri': null, + 'start': 0, + 'total': 1, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/SharedCost.json?PageSize=1' + }); + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .sharedCost.list(); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); + it('should generate valid read_empty response', + function() { + var body = JSON.stringify({ + 'available_phone_numbers': [], + 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/SharedCost.json?PageSize=50&Page=0', + 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/SharedCost.json?PageSize=50&Page=0', + 'next_page_uri': null, + 'num_pages': 1, + 'page': 0, + 'page_size': 50, + 'previous_page_uri': null, + 'start': 0, + 'total': 1, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/SharedCost.json?PageSize=1' + }); + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .sharedCost.list(); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); +}); + diff --git a/spec/integration/rest/api/v2010/account/availablePhoneNumber/voip.spec.js b/spec/integration/rest/api/v2010/account/availablePhoneNumber/voip.spec.js new file mode 100644 index 0000000000..ac76bc01fb --- /dev/null +++ b/spec/integration/rest/api/v2010/account/availablePhoneNumber/voip.spec.js @@ -0,0 +1,138 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var _ = require('lodash'); /* jshint ignore:line */ +var Holodeck = require('../../../../../holodeck'); /* jshint ignore:line */ +var Request = require( + '../../../../../../../lib/http/request'); /* jshint ignore:line */ +var Response = require( + '../../../../../../../lib/http/response'); /* jshint ignore:line */ +var RestException = require( + '../../../../../../../lib/base/RestException'); /* jshint ignore:line */ +var Twilio = require('../../../../../../../lib'); /* jshint ignore:line */ + + +var client; +var holodeck; + +describe('Voip', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid list request', + function() { + holodeck.mock(new Response(500, '{}')); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .voip.list(); + promise = promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + }); + promise.done(); + + var solution = {accountSid: 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', countryCode: 'US'}; + var url = _.template('https://api.twilio.com/2010-04-01/Accounts/<%= accountSid %>/AvailablePhoneNumbers/<%= countryCode %>/Voip.json')(solution); + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_full response', + function() { + var body = JSON.stringify({ + 'available_phone_numbers': [ + { + 'address_requirements': 'none', + 'beta': false, + 'capabilities': { + 'mms': false, + 'sms': true, + 'voice': false + }, + 'friendly_name': '+4759440374', + 'iso_country': 'NO', + 'lata': null, + 'latitude': null, + 'locality': null, + 'longitude': null, + 'phone_number': '+4759440374', + 'postal_code': null, + 'rate_center': null, + 'region': null + } + ], + 'end': 1, + 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Voip.json?PageSize=50&Page=0', + 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Voip.json?PageSize=50&Page=0', + 'next_page_uri': null, + 'num_pages': 1, + 'page': 0, + 'page_size': 50, + 'previous_page_uri': null, + 'start': 0, + 'total': 1, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Voip.json?PageSize=1' + }); + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .voip.list(); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); + it('should generate valid read_empty response', + function() { + var body = JSON.stringify({ + 'available_phone_numbers': [], + 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Voip.json?PageSize=50&Page=0', + 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Voip.json?PageSize=50&Page=0', + 'next_page_uri': null, + 'num_pages': 1, + 'page': 0, + 'page_size': 50, + 'previous_page_uri': null, + 'start': 0, + 'total': 1, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Voip.json?PageSize=1' + }); + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + .availablePhoneNumbers('US') + .voip.list(); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); +}); + diff --git a/spec/integration/rest/api/v2010/account/call/recording.spec.js b/spec/integration/rest/api/v2010/account/call/recording.spec.js index 64bbb62f8a..ab63ae0319 100644 --- a/spec/integration/rest/api/v2010/account/call/recording.spec.js +++ b/spec/integration/rest/api/v2010/account/call/recording.spec.js @@ -61,24 +61,27 @@ describe('Recording', function() { function() { var body = JSON.stringify({ 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'api_version': '2008-08-01', + 'api_version': '2010-04-01', 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': 'Mon, 22 Aug 2011 20:58:45 +0000', - 'date_updated': 'Mon, 22 Aug 2011 20:58:45 +0000', - 'duration': '6', - 'sid': 'REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'price': '0.04', + 'conference_sid': null, + 'channels': 2, + 'date_created': 'Fri, 14 Oct 2016 21:56:34 +0000', + 'date_updated': 'Fri, 14 Oct 2016 21:56:38 +0000', + 'start_time': 'Fri, 14 Oct 2016 21:56:34 +0000', + 'end_time': 'Fri, 14 Oct 2016 21:56:38 +0000', + 'price': '-0.0025', 'price_unit': 'USD', - 'status': 'completed', - 'channels': 1, - 'source': 'Trunking', - 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', + 'duration': '4', + 'sid': 'REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'encryption_details': { 'encryption_public_key_sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'encryption_cek': 'OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==', 'encryption_iv': '8I2hhNIYNTrwxfHk' }, - 'error_code': null + 'source': 'StartCallRecordingAPI', + 'status': 'completed', + 'error_code': null, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json' }); holodeck.mock(new Response(200, body)); @@ -171,37 +174,37 @@ describe('Recording', function() { var body = JSON.stringify({ 'end': 0, 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0', - 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0', 'next_page_uri': null, - 'num_pages': 1, 'page': 0, 'page_size': 50, 'previous_page_uri': null, 'recordings': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'api_version': '2008-08-01', + 'api_version': '2010-04-01', 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': 'Mon, 22 Aug 2011 20:58:45 +0000', - 'date_updated': 'Mon, 22 Aug 2011 20:58:45 +0000', - 'duration': '6', - 'sid': 'REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'price': '0.04', + 'conference_sid': null, + 'channels': 2, + 'date_created': 'Fri, 14 Oct 2016 21:56:34 +0000', + 'date_updated': 'Fri, 14 Oct 2016 21:56:38 +0000', + 'start_time': 'Fri, 14 Oct 2016 21:56:34 +0000', + 'end_time': 'Fri, 14 Oct 2016 21:56:38 +0000', + 'price': '-0.0025', 'price_unit': 'USD', - 'status': 'completed', - 'channels': 1, - 'source': 'Trunking', - 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', + 'duration': '4', + 'sid': 'REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'encryption_details': { 'encryption_public_key_sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'encryption_cek': 'OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==', 'encryption_iv': '8I2hhNIYNTrwxfHk' }, - 'error_code': null + 'source': 'StartCallRecordingAPI', + 'status': 'completed', + 'error_code': null, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json' } ], 'start': 0, - 'total': 1, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0' }); @@ -224,15 +227,12 @@ describe('Recording', function() { var body = JSON.stringify({ 'end': 0, 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0', - 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0', 'next_page_uri': null, - 'num_pages': 1, 'page': 0, 'page_size': 50, 'previous_page_uri': null, 'recordings': [], 'start': 0, - 'total': 1, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0' }); diff --git a/spec/integration/rest/api/v2010/account/conference.spec.js b/spec/integration/rest/api/v2010/account/conference.spec.js index 51cd181568..79189f42e9 100644 --- a/spec/integration/rest/api/v2010/account/conference.spec.js +++ b/spec/integration/rest/api/v2010/account/conference.spec.js @@ -67,7 +67,8 @@ describe('Conference', function() { 'region': 'us1', 'status': 'completed', 'subresource_uris': { - 'participants': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json' + 'participants': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json', + 'recordings': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json' }, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json' }); @@ -121,7 +122,8 @@ describe('Conference', function() { 'sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'status': 'in-progress', 'subresource_uris': { - 'participants': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json' + 'participants': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json', + 'recordings': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json' }, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json' } @@ -213,7 +215,8 @@ describe('Conference', function() { 'sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'status': 'completed', 'subresource_uris': { - 'participants': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json' + 'participants': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json', + 'recordings': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json' }, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json' }); diff --git a/spec/integration/rest/api/v2010/account/recording.spec.js b/spec/integration/rest/api/v2010/account/recording.spec.js index e1732600b2..4ace859681 100644 --- a/spec/integration/rest/api/v2010/account/recording.spec.js +++ b/spec/integration/rest/api/v2010/account/recording.spec.js @@ -61,22 +61,29 @@ describe('Recording', function() { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'api_version': '2010-04-01', 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': 'Wed, 01 Sep 2010 15:15:41 +0000', - 'date_updated': 'Wed, 01 Sep 2010 15:15:41 +0000', - 'duration': '6', - 'sid': 'REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'price': '0.04', + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'channels': 1, + 'date_created': 'Fri, 14 Oct 2016 21:56:34 +0000', + 'date_updated': 'Fri, 14 Oct 2016 21:56:38 +0000', + 'start_time': 'Fri, 14 Oct 2016 21:56:34 +0000', + 'end_time': 'Fri, 14 Oct 2016 21:56:38 +0000', + 'price': '-0.00250', 'price_unit': 'USD', + 'duration': '4', + 'sid': 'REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'source': 'StartConferenceRecordingAPI', 'status': 'completed', - 'channels': 1, - 'source': 'Trunking', + 'error_code': null, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', + 'subresource_uris': { + 'add_on_results': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json', + 'transcriptions': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json' + }, 'encryption_details': { 'encryption_public_key_sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'encryption_cek': 'OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==', 'encryption_iv': '8I2hhNIYNTrwxfHk' - }, - 'error_code': null + } }); holodeck.mock(new Response(200, body)); @@ -161,37 +168,41 @@ describe('Recording', function() { var body = JSON.stringify({ 'end': 0, 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0', - 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=4', 'next_page_uri': null, - 'num_pages': 5, 'page': 0, 'page_size': 1, 'previous_page_uri': null, 'recordings': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'api_version': '2008-08-01', + 'api_version': '2010-04-01', 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': 'Wed, 22 Aug 2012 20:58:45 +0000', - 'date_updated': 'Wed, 22 Aug 2012 20:58:45 +0000', - 'duration': null, - 'sid': 'REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'channels': 1, + 'date_created': 'Fri, 14 Oct 2016 21:56:34 +0000', + 'date_updated': 'Fri, 14 Oct 2016 21:56:38 +0000', + 'start_time': 'Fri, 14 Oct 2016 21:56:34 +0000', + 'end_time': 'Fri, 14 Oct 2016 21:56:38 +0000', 'price': '0.04', 'price_unit': 'USD', + 'duration': '4', + 'sid': 'REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'source': 'StartConferenceRecordingAPI', 'status': 'completed', - 'channels': 1, - 'source': 'Trunking', + 'error_code': null, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', + 'subresource_uris': { + 'add_on_results': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json', + 'transcriptions': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json' + }, 'encryption_details': { 'encryption_public_key_sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'encryption_cek': 'OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==', 'encryption_iv': '8I2hhNIYNTrwxfHk' - }, - 'error_code': null + } } ], 'start': 0, - 'total': 5, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0' }); @@ -213,15 +224,12 @@ describe('Recording', function() { var body = JSON.stringify({ 'end': 0, 'first_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0', - 'last_page_uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=4', 'next_page_uri': null, - 'num_pages': 5, 'page': 0, 'page_size': 1, 'previous_page_uri': null, 'recordings': [], 'start': 0, - 'total': 5, 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0' }); diff --git a/spec/integration/rest/notify/v1/service.spec.js b/spec/integration/rest/notify/v1/service.spec.js index 46d5b15986..e2eaed51ec 100644 --- a/spec/integration/rest/notify/v1/service.spec.js +++ b/spec/integration/rest/notify/v1/service.spec.js @@ -69,6 +69,7 @@ describe('Service', function() { 'default_fcm_notification_protocol_version': '3', 'default_alexa_notification_protocol_version': '3', 'log_enabled': true, + 'type': 'S', 'url': 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'bindings': 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', @@ -167,6 +168,7 @@ describe('Service', function() { 'default_fcm_notification_protocol_version': '3', 'default_alexa_notification_protocol_version': '3', 'log_enabled': true, + 'type': 'S', 'url': 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'bindings': 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', @@ -238,6 +240,7 @@ describe('Service', function() { 'default_fcm_notification_protocol_version': '3', 'default_alexa_notification_protocol_version': '3', 'log_enabled': true, + 'type': 'S', 'url': 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'bindings': 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', @@ -328,6 +331,7 @@ describe('Service', function() { 'alexa_skill_id': null, 'facebook_messenger_page_id': '4', 'log_enabled': true, + 'type': 'S', 'url': 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'bindings': 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', diff --git a/spec/integration/rest/preview/hosted_numbers/hostedNumberOrder.spec.js b/spec/integration/rest/preview/hosted_numbers/hostedNumberOrder.spec.js index d21756c73e..78c6b13b1b 100644 --- a/spec/integration/rest/preview/hosted_numbers/hostedNumberOrder.spec.js +++ b/spec/integration/rest/preview/hosted_numbers/hostedNumberOrder.spec.js @@ -77,7 +77,9 @@ describe('HostedNumberOrder', function() { 'status': 'received', 'unique_name': 'foobar', 'url': 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'verification_attempts': 0 + 'verification_attempts': 0, + 'verification_type': 'phone-call', + 'verification_document_sid': null }); holodeck.mock(new Response(200, body)); @@ -174,7 +176,9 @@ describe('HostedNumberOrder', function() { 'status': 'pending-loa', 'unique_name': 'new unique name', 'url': 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'verification_attempts': 1 + 'verification_attempts': 1, + 'verification_type': 'phone-call', + 'verification_document_sid': null }); holodeck.mock(new Response(200, body)); @@ -271,7 +275,9 @@ describe('HostedNumberOrder', function() { 'status': 'received', 'unique_name': 'foobar', 'url': 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'verification_attempts': 0 + 'verification_attempts': 0, + 'verification_type': 'phone-call', + 'verification_document_sid': null } ] }); @@ -332,7 +338,9 @@ describe('HostedNumberOrder', function() { 'status': 'received', 'unique_name': null, 'url': 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'verification_attempts': 0 + 'verification_attempts': 0, + 'verification_type': 'phone-call', + 'verification_document_sid': null }); holodeck.mock(new Response(201, body)); @@ -369,7 +377,48 @@ describe('HostedNumberOrder', function() { 'status': 'received', 'unique_name': null, 'url': 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'verification_attempts': 0 + 'verification_attempts': 0, + 'verification_type': 'phone-call', + 'verification_document_sid': null + }); + + holodeck.mock(new Response(201, body)); + + var opts = {phoneNumber: '+987654321', smsCapability: true}; + var promise = client.preview.hosted_numbers.hostedNumberOrders.create(opts); + promise = promise.then(function(response) { + expect(response).toBeDefined(); + }, function() { + throw new Error('failed'); + }); + + promise.done(); + } + ); + it('should generate valid create_with_phone_bill_verification response', + function() { + var body = JSON.stringify({ + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'address_sid': null, + 'capabilities': { + 'sms': true, + 'voice': false + }, + 'cc_emails': [], + 'date_created': '2017-03-28T20:06:39Z', + 'date_updated': '2017-03-28T20:06:39Z', + 'email': null, + 'friendly_name': null, + 'incoming_phone_number_sid': 'PN11111111111111111111111111111111', + 'phone_number': '+14153608311', + 'sid': 'HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'signing_document_sid': null, + 'status': 'received', + 'unique_name': null, + 'url': 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'verification_attempts': 0, + 'verification_type': 'phone-bill', + 'verification_document_sid': 'RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }); holodeck.mock(new Response(201, body)); diff --git a/spec/integration/rest/proxy/v1/service/session.spec.js b/spec/integration/rest/proxy/v1/service/session.spec.js index 86cf544466..96c7f9378f 100644 --- a/spec/integration/rest/proxy/v1/service/session.spec.js +++ b/spec/integration/rest/proxy/v1/service/session.spec.js @@ -59,7 +59,7 @@ describe('Session', function() { function() { var body = JSON.stringify({ 'service_sid': 'KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'status': 'in-progess', + 'status': 'in-progress', 'unique_name': 'unique_name', 'date_started': '2015-07-30T20:00:00Z', 'date_ended': '2015-07-30T20:00:00Z', @@ -168,7 +168,7 @@ describe('Session', function() { function() { var body = JSON.stringify({ 'service_sid': 'KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'status': 'in-progess', + 'status': 'in-progress', 'unique_name': 'unique_name', 'date_started': '2015-07-30T20:00:00Z', 'date_ended': '2015-07-30T20:00:00Z', @@ -272,7 +272,7 @@ describe('Session', function() { function() { var body = JSON.stringify({ 'service_sid': 'KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'status': 'in-progess', + 'status': 'in-progress', 'unique_name': 'unique_name', 'date_started': '2015-07-30T20:00:00Z', 'date_ended': '2015-07-30T20:00:00Z',