From 3aa26fdea1b1512772cec8b25e534195d5da07db Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 10 Aug 2022 11:43:28 -0700 Subject: [PATCH] [Librarian] Regenerated @ 9e43c4b1c21f11427158cfc8a409854c419cd158 --- CHANGES.md | 9 + lib/rest/Microvisor.d.ts | 28 + lib/rest/Microvisor.js | 62 ++ lib/rest/Preview.d.ts | 6 - lib/rest/Preview.js | 28 - lib/rest/Routes.d.ts | 30 + lib/rest/Routes.js | 71 ++ lib/rest/Twilio.d.ts | 4 + lib/rest/Twilio.js | 28 + .../sip/ipAccessControlList/ipAddress.d.ts | 4 +- .../sip/ipAccessControlList/ipAddress.js | 8 +- lib/rest/microvisor/V1.d.ts | 28 + lib/rest/microvisor/V1.js | 57 ++ .../day.d.ts => microvisor/v1/app.d.ts} | 148 ++-- .../export/day.js => microvisor/v1/app.js} | 282 ++++---- .../v1/device.d.ts} | 220 +++--- lib/rest/microvisor/v1/device.js | 652 ++++++++++++++++++ lib/rest/preview/BulkExports.d.ts | 28 - lib/rest/preview/BulkExports.js | 59 -- lib/rest/preview/bulk_exports/export.d.ts | 153 ---- lib/rest/preview/bulk_exports/export.js | 402 ----------- .../bulk_exports/export/exportCustomJob.js | 540 --------------- lib/rest/preview/bulk_exports/export/job.d.ts | 163 ----- lib/rest/preview/bulk_exports/export/job.js | 390 ----------- .../bulk_exports/exportConfiguration.d.ts | 180 ----- .../bulk_exports/exportConfiguration.js | 411 ----------- lib/rest/routes/V2.d.ts | 31 + lib/rest/routes/V2.js | 69 ++ lib/rest/routes/v2/phoneNumber.d.ts | 193 ++++++ lib/rest/routes/v2/phoneNumber.js | 466 +++++++++++++ lib/rest/routes/v2/sipDomain.d.ts | 205 ++++++ lib/rest/routes/v2/sipDomain.js | 447 ++++++++++++ lib/rest/routes/v2/trunk.d.ts | 205 ++++++ lib/rest/routes/v2/trunk.js | 458 ++++++++++++ lib/rest/supersim/v1/fleet.d.ts | 4 +- lib/rest/supersim/v1/fleet.js | 11 +- .../api/v2010/account/application.spec.js | 21 +- .../rest/microvisor/v1/app.spec.js | 283 ++++++++ .../rest/microvisor/v1/device.spec.js | 363 ++++++++++ .../rest/preview/bulk_exports/export.spec.js | 74 -- .../preview/bulk_exports/export/day.spec.js | 243 ------- .../export/exportCustomJob.spec.js | 270 -------- .../preview/bulk_exports/export/job.spec.js | 119 ---- .../bulk_exports/exportConfiguration.spec.js | 116 ---- .../rest/routes/v2/phoneNumber.spec.js | 171 +++++ .../rest/routes/v2/sipDomain.spec.js | 167 +++++ spec/integration/rest/routes/v2/trunk.spec.js | 167 +++++ .../rest/supersim/v1/fleet.spec.js | 8 +- .../verify/v2/service/verification.spec.js | 49 ++ 49 files changed, 4653 insertions(+), 3478 deletions(-) create mode 100644 lib/rest/Microvisor.d.ts create mode 100644 lib/rest/Microvisor.js create mode 100644 lib/rest/Routes.d.ts create mode 100644 lib/rest/Routes.js create mode 100644 lib/rest/microvisor/V1.d.ts create mode 100644 lib/rest/microvisor/V1.js rename lib/rest/{preview/bulk_exports/export/day.d.ts => microvisor/v1/app.d.ts} (63%) rename lib/rest/{preview/bulk_exports/export/day.js => microvisor/v1/app.js} (62%) rename lib/rest/{preview/bulk_exports/export/exportCustomJob.d.ts => microvisor/v1/device.d.ts} (51%) create mode 100644 lib/rest/microvisor/v1/device.js delete mode 100644 lib/rest/preview/BulkExports.d.ts delete mode 100644 lib/rest/preview/BulkExports.js delete mode 100644 lib/rest/preview/bulk_exports/export.d.ts delete mode 100644 lib/rest/preview/bulk_exports/export.js delete mode 100644 lib/rest/preview/bulk_exports/export/exportCustomJob.js delete mode 100644 lib/rest/preview/bulk_exports/export/job.d.ts delete mode 100644 lib/rest/preview/bulk_exports/export/job.js delete mode 100644 lib/rest/preview/bulk_exports/exportConfiguration.d.ts delete mode 100644 lib/rest/preview/bulk_exports/exportConfiguration.js create mode 100644 lib/rest/routes/V2.d.ts create mode 100644 lib/rest/routes/V2.js create mode 100644 lib/rest/routes/v2/phoneNumber.d.ts create mode 100644 lib/rest/routes/v2/phoneNumber.js create mode 100644 lib/rest/routes/v2/sipDomain.d.ts create mode 100644 lib/rest/routes/v2/sipDomain.js create mode 100644 lib/rest/routes/v2/trunk.d.ts create mode 100644 lib/rest/routes/v2/trunk.js create mode 100644 spec/integration/rest/microvisor/v1/app.spec.js create mode 100644 spec/integration/rest/microvisor/v1/device.spec.js delete mode 100644 spec/integration/rest/preview/bulk_exports/export.spec.js delete mode 100644 spec/integration/rest/preview/bulk_exports/export/day.spec.js delete mode 100644 spec/integration/rest/preview/bulk_exports/export/exportCustomJob.spec.js delete mode 100644 spec/integration/rest/preview/bulk_exports/export/job.spec.js delete mode 100644 spec/integration/rest/preview/bulk_exports/exportConfiguration.spec.js create mode 100644 spec/integration/rest/routes/v2/phoneNumber.spec.js create mode 100644 spec/integration/rest/routes/v2/sipDomain.spec.js create mode 100644 spec/integration/rest/routes/v2/trunk.spec.js diff --git a/CHANGES.md b/CHANGES.md index dc869c3ad1..3d5230be3f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,15 @@ twilio-node changelog ===================== +[2022-08-10] Version 3.80.1 +--------------------------- +**Routes** +- Inbound Proccessing Region API - Public GA + +**Supersim** +- Allow updating `DataLimit` on a Fleet + + [2022-07-21] Version 3.80.0 --------------------------- **Library - Docs** diff --git a/lib/rest/Microvisor.d.ts b/lib/rest/Microvisor.d.ts new file mode 100644 index 0000000000..e396e37b68 --- /dev/null +++ b/lib/rest/Microvisor.d.ts @@ -0,0 +1,28 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Domain = require('../base/Domain'); +import Twilio = require('./Twilio'); +import V1 = require('./microvisor/V1'); +import { AppListInstance } from './microvisor/v1/app'; +import { DeviceListInstance } from './microvisor/v1/device'; + + +declare class Microvisor extends Domain { + /** + * Initialize microvisor domain + * + * @param twilio - The twilio client + */ + constructor(twilio: Twilio); + + readonly apps: AppListInstance; + readonly devices: DeviceListInstance; + readonly v1: V1; +} + +export = Microvisor; diff --git a/lib/rest/Microvisor.js b/lib/rest/Microvisor.js new file mode 100644 index 0000000000..f6b1ee506e --- /dev/null +++ b/lib/rest/Microvisor.js @@ -0,0 +1,62 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var _ = require('lodash'); /* jshint ignore:line */ +var Domain = require('../base/Domain'); /* jshint ignore:line */ +var V1 = require('./microvisor/V1'); /* jshint ignore:line */ + + +/* jshint ignore:start */ +/** + * Initialize microvisor domain + * + * @constructor Twilio.Microvisor + * + * @property {Twilio.Microvisor.V1} v1 - v1 version + * @property {Twilio.Microvisor.V1.AppList} apps - apps resource + * @property {Twilio.Microvisor.V1.DeviceList} devices - devices resource + * + * @param {Twilio} twilio - The twilio client + */ +/* jshint ignore:end */ +function Microvisor(twilio) { + Domain.prototype.constructor.call(this, twilio, 'https://microvisor.twilio.com'); + + // Versions + this._v1 = undefined; +} + +_.extend(Microvisor.prototype, Domain.prototype); +Microvisor.prototype.constructor = Microvisor; + +Object.defineProperty(Microvisor.prototype, + 'v1', { + get: function() { + this._v1 = this._v1 || new V1(this); + return this._v1; + } +}); + +Object.defineProperty(Microvisor.prototype, + 'apps', { + get: function() { + return this.v1.apps; + } +}); + +Object.defineProperty(Microvisor.prototype, + 'devices', { + get: function() { + return this.v1.devices; + } +}); + +module.exports = Microvisor; diff --git a/lib/rest/Preview.d.ts b/lib/rest/Preview.d.ts index 33a1520abe..3d9f38f33d 100644 --- a/lib/rest/Preview.d.ts +++ b/lib/rest/Preview.d.ts @@ -5,7 +5,6 @@ * / / */ -import BulkExports = require('./preview/BulkExports'); import DeployedDevices = require('./preview/DeployedDevices'); import Domain = require('../base/Domain'); import HostedNumbers = require('./preview/HostedNumbers'); @@ -23,8 +22,6 @@ import { BrandsInformationListInstance } from './preview/trusted_comms/brandsInf import { CommandListInstance } from './preview/wireless/command'; import { CpsListInstance } from './preview/trusted_comms/cps'; import { CurrentCallListInstance } from './preview/trusted_comms/currentCall'; -import { ExportConfigurationListInstance } from './preview/bulk_exports/exportConfiguration'; -import { ExportListInstance } from './preview/bulk_exports/export'; import { FleetListInstance } from './preview/deployed_devices/fleet'; import { HostedNumberOrderListInstance } from './preview/hosted_numbers/hostedNumberOrder'; import { InstalledAddOnListInstance } from './preview/marketplace/installedAddOn'; @@ -46,13 +43,10 @@ declare class Preview extends Domain { readonly availableAddOns: AvailableAddOnListInstance; readonly brandedChannels: BrandedChannelListInstance; readonly brandsInformation: BrandsInformationListInstance; - readonly bulk_exports: BulkExports; readonly commands: CommandListInstance; readonly cps: CpsListInstance; readonly currentCalls: CurrentCallListInstance; readonly deployed_devices: DeployedDevices; - readonly exportConfiguration: ExportConfigurationListInstance; - readonly exports: ExportListInstance; readonly fleets: FleetListInstance; readonly hostedNumberOrders: HostedNumberOrderListInstance; readonly hosted_numbers: HostedNumbers; diff --git a/lib/rest/Preview.js b/lib/rest/Preview.js index 24434ce07e..a4a320e11c 100644 --- a/lib/rest/Preview.js +++ b/lib/rest/Preview.js @@ -10,7 +10,6 @@ /* jshint ignore:end */ var _ = require('lodash'); /* jshint ignore:line */ -var BulkExports = require('./preview/BulkExports'); /* jshint ignore:line */ var DeployedDevices = require( './preview/DeployedDevices'); /* jshint ignore:line */ var Domain = require('../base/Domain'); /* jshint ignore:line */ @@ -29,7 +28,6 @@ var Wireless = require('./preview/Wireless'); /* jshint ignore:line */ * * @constructor Twilio.Preview * - * @property {Twilio.Preview.BulkExports} bulk_exports - bulk_exports version * @property {Twilio.Preview.DeployedDevices} deployed_devices - * deployed_devices version * @property {Twilio.Preview.HostedNumbers} hosted_numbers - hosted_numbers version @@ -38,9 +36,6 @@ var Wireless = require('./preview/Wireless'); /* jshint ignore:line */ * @property {Twilio.Preview.Understand} understand - understand version * @property {Twilio.Preview.Wireless} wireless - wireless version * @property {Twilio.Preview.TrustedComms} trusted_comms - trusted_comms version - * @property {Twilio.Preview.BulkExports.ExportList} exports - exports resource - * @property {Twilio.Preview.BulkExports.ExportConfigurationList} exportConfiguration - - * exportConfiguration resource * @property {Twilio.Preview.DeployedDevices.FleetList} fleets - fleets resource * @property {Twilio.Preview.HostedNumbers.AuthorizationDocumentList} authorizationDocuments - * authorizationDocuments resource @@ -71,7 +66,6 @@ function Preview(twilio) { Domain.prototype.constructor.call(this, twilio, 'https://preview.twilio.com'); // Versions - this._bulk_exports = undefined; this._deployed_devices = undefined; this._hosted_numbers = undefined; this._marketplace = undefined; @@ -84,14 +78,6 @@ function Preview(twilio) { _.extend(Preview.prototype, Domain.prototype); Preview.prototype.constructor = Preview; -Object.defineProperty(Preview.prototype, - 'bulk_exports', { - get: function() { - this._bulk_exports = this._bulk_exports || new BulkExports(this); - return this._bulk_exports; - } -}); - Object.defineProperty(Preview.prototype, 'deployed_devices', { get: function() { @@ -148,20 +134,6 @@ Object.defineProperty(Preview.prototype, } }); -Object.defineProperty(Preview.prototype, - 'exports', { - get: function() { - return this.bulk_exports.exports; - } -}); - -Object.defineProperty(Preview.prototype, - 'exportConfiguration', { - get: function() { - return this.bulk_exports.exportConfiguration; - } -}); - Object.defineProperty(Preview.prototype, 'fleets', { get: function() { diff --git a/lib/rest/Routes.d.ts b/lib/rest/Routes.d.ts new file mode 100644 index 0000000000..7feef59019 --- /dev/null +++ b/lib/rest/Routes.d.ts @@ -0,0 +1,30 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Domain = require('../base/Domain'); +import Twilio = require('./Twilio'); +import V2 = require('./routes/V2'); +import { PhoneNumberListInstance } from './routes/v2/phoneNumber'; +import { SipDomainListInstance } from './routes/v2/sipDomain'; +import { TrunkListInstance } from './routes/v2/trunk'; + + +declare class Routes extends Domain { + /** + * Initialize routes domain + * + * @param twilio - The twilio client + */ + constructor(twilio: Twilio); + + readonly phoneNumbers: PhoneNumberListInstance; + readonly sipDomains: SipDomainListInstance; + readonly trunks: TrunkListInstance; + readonly v2: V2; +} + +export = Routes; diff --git a/lib/rest/Routes.js b/lib/rest/Routes.js new file mode 100644 index 0000000000..23fd80715b --- /dev/null +++ b/lib/rest/Routes.js @@ -0,0 +1,71 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var _ = require('lodash'); /* jshint ignore:line */ +var Domain = require('../base/Domain'); /* jshint ignore:line */ +var V2 = require('./routes/V2'); /* jshint ignore:line */ + + +/* jshint ignore:start */ +/** + * Initialize routes domain + * + * @constructor Twilio.Routes + * + * @property {Twilio.Routes.V2} v2 - v2 version + * @property {Twilio.Routes.V2.PhoneNumberList} phoneNumbers - + * phoneNumbers resource + * @property {Twilio.Routes.V2.SipDomainList} sipDomains - sipDomains resource + * @property {Twilio.Routes.V2.TrunkList} trunks - trunks resource + * + * @param {Twilio} twilio - The twilio client + */ +/* jshint ignore:end */ +function Routes(twilio) { + Domain.prototype.constructor.call(this, twilio, 'https://routes.twilio.com'); + + // Versions + this._v2 = undefined; +} + +_.extend(Routes.prototype, Domain.prototype); +Routes.prototype.constructor = Routes; + +Object.defineProperty(Routes.prototype, + 'v2', { + get: function() { + this._v2 = this._v2 || new V2(this); + return this._v2; + } +}); + +Object.defineProperty(Routes.prototype, + 'phoneNumbers', { + get: function() { + return this.v2.phoneNumbers; + } +}); + +Object.defineProperty(Routes.prototype, + 'sipDomains', { + get: function() { + return this.v2.sipDomains; + } +}); + +Object.defineProperty(Routes.prototype, + 'trunks', { + get: function() { + return this.v2.trunks; + } +}); + +module.exports = Routes; diff --git a/lib/rest/Twilio.d.ts b/lib/rest/Twilio.d.ts index e5ffa3579d..affcbdb148 100644 --- a/lib/rest/Twilio.d.ts +++ b/lib/rest/Twilio.d.ts @@ -19,6 +19,7 @@ import IpMessaging = require('./IpMessaging'); import Lookups = require('./Lookups'); import Media = require('./Media'); import Messaging = require('./Messaging'); +import Microvisor = require('./Microvisor'); import Monitor = require('./Monitor'); import Notify = require('./Notify'); import Numbers = require('./Numbers'); @@ -26,6 +27,7 @@ import Preview = require('./Preview'); import Pricing = require('./Pricing'); import Proxy = require('./Proxy'); import RequestClient = require('../base/RequestClient'); +import Routes = require('./Routes'); import Serverless = require('./Serverless'); import Studio = require('./Studio'); import Supersim = require('./Supersim'); @@ -74,6 +76,7 @@ declare class Twilio { media: Media; messages: (typeof Api.prototype.account.messages); messaging: Messaging; + microvisor: Microvisor; monitor: Monitor; newKeys: (typeof Api.prototype.account.newKeys); newSigningKeys: (typeof Api.prototype.account.newSigningKeys); @@ -93,6 +96,7 @@ declare class Twilio { * @param opts - The options argument */ request(opts: Twilio.RequestOptions): Promise; + routes: Routes; serverless: Serverless; shortCodes: (typeof Api.prototype.account.shortCodes); signingKeys: (typeof Api.prototype.account.signingKeys); diff --git a/lib/rest/Twilio.js b/lib/rest/Twilio.js index c8310f3db5..c73999e5dc 100644 --- a/lib/rest/Twilio.js +++ b/lib/rest/Twilio.js @@ -41,6 +41,7 @@ var RestException = require('../base/RestException'); /* jshint ignore:line */ * @property {Twilio.Preview} preview - preview domain * @property {Twilio.Pricing} pricing - pricing domain * @property {Twilio.Proxy} proxy - proxy domain + * @property {Twilio.Routes} routes - routes domain * @property {Twilio.Serverless} serverless - serverless domain * @property {Twilio.Studio} studio - studio domain * @property {Twilio.Sync} sync - sync domain @@ -53,6 +54,7 @@ var RestException = require('../base/RestException'); /* jshint ignore:line */ * @property {Twilio.Wireless} wireless - wireless domain * @property {Twilio.Supersim} supersim - supersim domain * @property {Twilio.Bulkexports} bulkexports - bulkexports domain + * @property {Twilio.Microvisor} microvisor - microvisor domain * @property {Twilio.Api.V2010.AccountContext.AddressList} addresses - * addresses resource * @property {Twilio.Api.V2010.AccountContext.ApplicationList} applications - @@ -166,6 +168,7 @@ function Twilio(username, password, opts) { this._preview = undefined; this._pricing = undefined; this._proxy = undefined; + this._routes = undefined; this._serverless = undefined; this._studio = undefined; this._sync = undefined; @@ -178,6 +181,7 @@ function Twilio(username, password, opts) { this._wireless = undefined; this._supersim = undefined; this._bulkexports = undefined; + this._microvisor = undefined; if (opts.lazyLoading == false) { this.accounts; @@ -199,6 +203,7 @@ function Twilio(username, password, opts) { this.preview; this.pricing; this.proxy; + this.routes; this.serverless; this.studio; this.sync; @@ -211,6 +216,7 @@ function Twilio(username, password, opts) { this.wireless; this.supersim; this.bulkexports; + this.microvisor; } } @@ -568,6 +574,17 @@ Object.defineProperty(Twilio.prototype, } }); +Object.defineProperty(Twilio.prototype, + 'routes', { + get: function() { + if (!this._routes) { + var Routes = require('./Routes'); /* jshint ignore:line */ + this._routes = new Routes(this); + } + return this._routes; + } +}); + Object.defineProperty(Twilio.prototype, 'serverless', { get: function() { @@ -700,6 +717,17 @@ Object.defineProperty(Twilio.prototype, } }); +Object.defineProperty(Twilio.prototype, + 'microvisor', { + get: function() { + if (!this._microvisor) { + var Microvisor = require('./Microvisor'); /* jshint ignore:line */ + this._microvisor = new Microvisor(this); + } + return this._microvisor; + } +}); + Object.defineProperty(Twilio.prototype, 'addresses', { get: function() { diff --git a/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.d.ts b/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.d.ts index 7c0dd7fd50..b904db3926 100644 --- a/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.d.ts +++ b/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.d.ts @@ -23,7 +23,7 @@ declare function IpAddressList(version: V2010, accountSid: string, ipAccessContr * Options to pass to update * * @property cidrPrefixLength - An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. - * @property friendlyName - A human readable descriptive text for this resource, up to 64 characters long. + * @property friendlyName - A human readable descriptive text for this resource, up to 255 characters long. * @property ipAddress - An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. */ interface IpAddressInstanceUpdateOptions { @@ -156,7 +156,7 @@ interface IpAddressListInstance { * Options to pass to create * * @property cidrPrefixLength - An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. - * @property friendlyName - A human readable descriptive text for this resource, up to 64 characters long. + * @property friendlyName - A human readable descriptive text for this resource, up to 255 characters long. * @property ipAddress - An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. */ interface IpAddressListInstanceCreateOptions { diff --git a/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.js b/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.js index 41d316e9e5..ffde560d4f 100644 --- a/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.js +++ b/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.js @@ -311,7 +311,7 @@ IpAddressList = function IpAddressList(version, accountSid, * * @param {object} opts - Options for request * @param {string} opts.friendlyName - - * A human readable descriptive text for this resource, up to 64 characters long. + * A human readable descriptive text for this resource, up to 255 characters long. * @param {string} opts.ipAddress - * An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. * @param {number} [opts.cidrPrefixLength] - @@ -486,7 +486,7 @@ IpAddressPage.prototype[util.inspect.custom] = function inspect(depth, options) * @property {string} accountSid - * The unique id of the Account that is responsible for this resource. * @property {string} friendlyName - - * A human readable descriptive text for this resource, up to 64 characters long. + * A human readable descriptive text for this resource, up to 255 characters long. * @property {string} ipAddress - * An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. * @property {number} cidrPrefixLength - @@ -576,7 +576,7 @@ IpAddressInstance.prototype.fetch = function fetch(callback) { * @param {string} [opts.ipAddress] - * An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. * @param {string} [opts.friendlyName] - - * A human readable descriptive text for this resource, up to 64 characters long. + * A human readable descriptive text for this resource, up to 255 characters long. * @param {number} [opts.cidrPrefixLength] - * An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. * @param {function} [callback] - Callback to handle processed record @@ -700,7 +700,7 @@ IpAddressContext.prototype.fetch = function fetch(callback) { * @param {string} [opts.ipAddress] - * An IP address in dotted decimal notation from which you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today. * @param {string} [opts.friendlyName] - - * A human readable descriptive text for this resource, up to 64 characters long. + * A human readable descriptive text for this resource, up to 255 characters long. * @param {number} [opts.cidrPrefixLength] - * An integer representing the length of the CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used. * @param {function} [callback] - Callback to handle processed record diff --git a/lib/rest/microvisor/V1.d.ts b/lib/rest/microvisor/V1.d.ts new file mode 100644 index 0000000000..c261e2a7a7 --- /dev/null +++ b/lib/rest/microvisor/V1.d.ts @@ -0,0 +1,28 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Microvisor = require('../Microvisor'); +import Version = require('../../base/Version'); +import { AppList } from './v1/app'; +import { AppListInstance } from './v1/app'; +import { DeviceList } from './v1/device'; +import { DeviceListInstance } from './v1/device'; + + +declare class V1 extends Version { + /** + * Initialize the V1 version of Microvisor + * + * @param domain - The twilio domain + */ + constructor(domain: Microvisor); + + readonly apps: AppListInstance; + readonly devices: DeviceListInstance; +} + +export = V1; diff --git a/lib/rest/microvisor/V1.js b/lib/rest/microvisor/V1.js new file mode 100644 index 0000000000..cbca44fd23 --- /dev/null +++ b/lib/rest/microvisor/V1.js @@ -0,0 +1,57 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var _ = require('lodash'); /* jshint ignore:line */ +var AppList = require('./v1/app').AppList; +var DeviceList = require('./v1/device').DeviceList; +var Version = require('../../base/Version'); /* jshint ignore:line */ + + +/* jshint ignore:start */ +/** + * Initialize the V1 version of Microvisor + * + * @constructor Twilio.Microvisor.V1 + * + * @property {Twilio.Microvisor.V1.AppList} apps - apps resource + * @property {Twilio.Microvisor.V1.DeviceList} devices - devices resource + * + * @param {Twilio.Microvisor} domain - The twilio domain + */ +/* jshint ignore:end */ +function V1(domain) { + Version.prototype.constructor.call(this, domain, 'v1'); + + // Resources + this._apps = undefined; + this._devices = undefined; +} + +_.extend(V1.prototype, Version.prototype); +V1.prototype.constructor = V1; + +Object.defineProperty(V1.prototype, + 'apps', { + get: function() { + this._apps = this._apps || new AppList(this); + return this._apps; + } +}); + +Object.defineProperty(V1.prototype, + 'devices', { + get: function() { + this._devices = this._devices || new DeviceList(this); + return this._devices; + } +}); + +module.exports = V1; diff --git a/lib/rest/preview/bulk_exports/export/day.d.ts b/lib/rest/microvisor/v1/app.d.ts similarity index 63% rename from lib/rest/preview/bulk_exports/export/day.d.ts rename to lib/rest/microvisor/v1/app.d.ts index 4ad4259ada..9365fa2e91 100644 --- a/lib/rest/preview/bulk_exports/export/day.d.ts +++ b/lib/rest/microvisor/v1/app.d.ts @@ -5,30 +5,29 @@ * / / */ -import BulkExports = require('../../BulkExports'); -import Page = require('../../../../base/Page'); -import Response = require('../../../../http/response'); -import { SerializableClass } from '../../../../interfaces'; +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V1 = require('../V1'); +import { SerializableClass } from '../../../interfaces'; /** - * Initialize the DayList + * Initialize the AppList * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview * access, please contact help@twilio.com. * * @param version - Version of the resource - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants */ -declare function DayList(version: BulkExports, resourceType: string): DayListInstance; +declare function AppList(version: V1): AppListInstance; -interface DayListInstance { +interface AppListInstance { /** * @param sid - sid of instance */ - (sid: string): DayContext; + (sid: string): AppContext; /** - * Streams DayInstance records from the API. + * Streams AppInstance records from the API. * * This operation lazily loads records as efficiently as possible until the limit * is reached. @@ -41,9 +40,9 @@ interface DayListInstance { * * @param callback - Function to process each record */ - each(callback?: (item: DayInstance, done: (err?: Error) => void) => void): void; + each(callback?: (item: AppInstance, done: (err?: Error) => void) => void): void; /** - * Streams DayInstance records from the API. + * Streams AppInstance records from the API. * * This operation lazily loads records as efficiently as possible until the limit * is reached. @@ -57,15 +56,15 @@ interface DayListInstance { * @param opts - Options for request * @param callback - Function to process each record */ - each(opts?: DayListInstanceEachOptions, callback?: (item: DayInstance, done: (err?: Error) => void) => void): void; + each(opts?: AppListInstanceEachOptions, callback?: (item: AppInstance, done: (err?: Error) => void) => void): void; /** - * Constructs a day + * Constructs a app * - * @param day - The date of the data in the file + * @param sid - A string that uniquely identifies this App. */ - get(day: string): DayContext; + get(sid: string): AppContext; /** - * Retrieve a single target page of DayInstance records from the API. + * Retrieve a single target page of AppInstance records from the API. * * The request is executed immediately. * @@ -74,9 +73,9 @@ interface DayListInstance { * * @param callback - Callback to handle list of records */ - getPage(callback?: (error: Error | null, items: DayPage) => any): Promise; + getPage(callback?: (error: Error | null, items: AppPage) => any): Promise; /** - * Retrieve a single target page of DayInstance records from the API. + * Retrieve a single target page of AppInstance records from the API. * * The request is executed immediately. * @@ -86,18 +85,18 @@ interface DayListInstance { * @param targetUrl - API-generated URL for the requested results page * @param callback - Callback to handle list of records */ - getPage(targetUrl?: string, callback?: (error: Error | null, items: DayPage) => any): Promise; + getPage(targetUrl?: string, callback?: (error: Error | null, items: AppPage) => any): Promise; /** - * Lists DayInstance records from the API as a list. + * Lists AppInstance records from the API as a list. * * If a function is passed as the first argument, it will be used as the callback * function. * * @param callback - Callback to handle list of records */ - list(callback?: (error: Error | null, items: DayInstance[]) => any): Promise; + list(callback?: (error: Error | null, items: AppInstance[]) => any): Promise; /** - * Lists DayInstance records from the API as a list. + * Lists AppInstance records from the API as a list. * * If a function is passed as the first argument, it will be used as the callback * function. @@ -105,9 +104,9 @@ interface DayListInstance { * @param opts - Options for request * @param callback - Callback to handle list of records */ - list(opts?: DayListInstanceOptions, callback?: (error: Error | null, items: DayInstance[]) => any): Promise; + list(opts?: AppListInstanceOptions, callback?: (error: Error | null, items: AppInstance[]) => any): Promise; /** - * Retrieve a single page of DayInstance records from the API. + * Retrieve a single page of AppInstance records from the API. * * The request is executed immediately. * @@ -116,9 +115,9 @@ interface DayListInstance { * * @param callback - Callback to handle list of records */ - page(callback?: (error: Error | null, items: DayPage) => any): Promise; + page(callback?: (error: Error | null, items: AppPage) => any): Promise; /** - * Retrieve a single page of DayInstance records from the API. + * Retrieve a single page of AppInstance records from the API. * * The request is executed immediately. * @@ -128,7 +127,7 @@ interface DayListInstance { * @param opts - Options for request * @param callback - Callback to handle list of records */ - page(opts?: DayListInstancePageOptions, callback?: (error: Error | null, items: DayPage) => any): Promise; + page(opts?: AppListInstancePageOptions, callback?: (error: Error | null, items: AppPage) => any): Promise; /** * Provide a user-friendly representation */ @@ -153,8 +152,8 @@ interface DayListInstance { * each() will attempt to read the limit with the most efficient * page size, i.e. min(limit, 1000) */ -interface DayListInstanceEachOptions { - callback?: (item: DayInstance, done: (err?: Error) => void) => void; +interface AppListInstanceEachOptions { + callback?: (item: AppInstance, done: (err?: Error) => void) => void; done?: Function; limit?: number; pageSize?: number; @@ -174,7 +173,7 @@ interface DayListInstanceEachOptions { * list() will attempt to read the limit with the most * efficient page size, i.e. min(limit, 1000) */ -interface DayListInstanceOptions { +interface AppListInstanceOptions { limit?: number; pageSize?: number; } @@ -186,49 +185,54 @@ interface DayListInstanceOptions { * @property pageSize - Number of records to return, defaults to 50 * @property pageToken - PageToken provided by the API */ -interface DayListInstancePageOptions { +interface AppListInstancePageOptions { pageNumber?: number; pageSize?: number; pageToken?: string; } -interface DayPayload extends DayResource, Page.TwilioResponsePayload { +interface AppPayload extends AppResource, Page.TwilioResponsePayload { } -interface DayResource { - create_date?: string; - day?: string; - friendly_name?: string; - redirect_to?: string; - resource_type?: string; - size?: number; +interface AppResource { + account_sid: string; + date_created: Date; + date_updated: Date; + hash: string; + sid: string; + unique_name: string; + url: string; } -interface DaySolution { - resourceType?: string; +interface AppSolution { } -declare class DayContext { +declare class AppContext { /** - * Initialize the DayContext + * Initialize the AppContext * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview * access, please contact help@twilio.com. * * @param version - Version of the resource - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants - * @param day - The date of the data in the file + * @param sid - A string that uniquely identifies this App. */ - constructor(version: BulkExports, resourceType: string, day: string); + constructor(version: V1, sid: string); /** - * fetch a DayInstance + * fetch a AppInstance * * @param callback - Callback to handle processed record */ - fetch(callback?: (error: Error | null, items: DayInstance) => any): Promise; + fetch(callback?: (error: Error | null, items: AppInstance) => any): Promise; + /** + * remove a AppInstance + * + * @param callback - Callback to handle processed record + */ + remove(callback?: (error: Error | null, items: AppInstance) => any): Promise; /** * Provide a user-friendly representation */ @@ -236,9 +240,9 @@ declare class DayContext { } -declare class DayInstance extends SerializableClass { +declare class AppInstance extends SerializableClass { /** - * Initialize the DayContext + * Initialize the AppContext * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview @@ -246,34 +250,40 @@ declare class DayInstance extends SerializableClass { * * @param version - Version of the resource * @param payload - The instance payload - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants - * @param day - The date of the data in the file + * @param sid - A string that uniquely identifies this App. */ - constructor(version: BulkExports, payload: DayPayload, resourceType: string, day: string); + constructor(version: V1, payload: AppPayload, sid: string); - private _proxy: DayContext; - createDate: string; - day: string; + private _proxy: AppContext; + accountSid: string; + dateCreated: Date; + dateUpdated: Date; + /** + * fetch a AppInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: AppInstance) => any): Promise; + hash: string; /** - * fetch a DayInstance + * remove a AppInstance * * @param callback - Callback to handle processed record */ - fetch(callback?: (error: Error | null, items: DayInstance) => any): Promise; - friendlyName: string; - redirectTo: string; - resourceType: string; - size: number; + remove(callback?: (error: Error | null, items: AppInstance) => any): Promise; + sid: string; /** * Provide a user-friendly representation */ toJSON(): any; + uniqueName: string; + url: string; } -declare class DayPage extends Page { +declare class AppPage extends Page { /** - * Initialize the DayPage + * Initialize the AppPage * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview @@ -283,18 +293,18 @@ declare class DayPage extends Page, solution: DaySolution); + constructor(version: V1, response: Response, solution: AppSolution); /** - * Build an instance of DayInstance + * Build an instance of AppInstance * * @param payload - Payload response from the API */ - getInstance(payload: DayPayload): DayInstance; + getInstance(payload: AppPayload): AppInstance; /** * Provide a user-friendly representation */ toJSON(): any; } -export { DayContext, DayInstance, DayList, DayListInstance, DayListInstanceEachOptions, DayListInstanceOptions, DayListInstancePageOptions, DayPage, DayPayload, DayResource, DaySolution } +export { AppContext, AppInstance, AppList, AppListInstance, AppListInstanceEachOptions, AppListInstanceOptions, AppListInstancePageOptions, AppPage, AppPayload, AppResource, AppSolution } diff --git a/lib/rest/preview/bulk_exports/export/day.js b/lib/rest/microvisor/v1/app.js similarity index 62% rename from lib/rest/preview/bulk_exports/export/day.js rename to lib/rest/microvisor/v1/app.js index 6944935611..93358d9f02 100644 --- a/lib/rest/preview/bulk_exports/export/day.js +++ b/lib/rest/microvisor/v1/app.js @@ -12,53 +12,51 @@ var Q = require('q'); /* jshint ignore:line */ var _ = require('lodash'); /* jshint ignore:line */ var util = require('util'); /* jshint ignore:line */ -var Page = require('../../../../base/Page'); /* jshint ignore:line */ +var Page = require('../../../base/Page'); /* jshint ignore:line */ var deserialize = require( - '../../../../base/deserialize'); /* jshint ignore:line */ -var values = require('../../../../base/values'); /* jshint ignore:line */ + '../../../base/deserialize'); /* jshint ignore:line */ +var values = require('../../../base/values'); /* jshint ignore:line */ -var DayList; -var DayPage; -var DayInstance; -var DayContext; +var AppList; +var AppPage; +var AppInstance; +var AppContext; /* jshint ignore:start */ /** - * Initialize the DayList + * Initialize the AppList * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview * access, please contact help@twilio.com. * - * @constructor Twilio.Preview.BulkExports.ExportContext.DayList + * @constructor Twilio.Microvisor.V1.AppList * - * @param {Twilio.Preview.BulkExports} version - Version of the resource - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants + * @param {Twilio.Microvisor.V1} version - Version of the resource */ /* jshint ignore:end */ -DayList = function DayList(version, resourceType) { +AppList = function AppList(version) { /* jshint ignore:start */ /** - * @function days - * @memberof Twilio.Preview.BulkExports.ExportContext# + * @function apps + * @memberof Twilio.Microvisor.V1# * * @param {string} sid - sid of instance * - * @returns {Twilio.Preview.BulkExports.ExportContext.DayContext} + * @returns {Twilio.Microvisor.V1.AppContext} */ /* jshint ignore:end */ - function DayListInstance(sid) { - return DayListInstance.get(sid); + function AppListInstance(sid) { + return AppListInstance.get(sid); } - DayListInstance._version = version; + AppListInstance._version = version; // Path Solution - DayListInstance._solution = {resourceType: resourceType}; - DayListInstance._uri = `/Exports/${resourceType}/Days`; + AppListInstance._solution = {}; + AppListInstance._uri = `/Apps`; /* jshint ignore:start */ /** - * Streams DayInstance records from the API. + * Streams AppInstance records from the API. * * This operation lazily loads records as efficiently as possible until the limit * is reached. @@ -70,7 +68,7 @@ DayList = function DayList(version, resourceType) { * function. * * @function each - * @memberof Twilio.Preview.BulkExports.ExportContext.DayList# + * @memberof Twilio.Microvisor.V1.AppList# * * @param {object} [opts] - Options for request * @param {number} [opts.limit] - @@ -91,7 +89,7 @@ DayList = function DayList(version, resourceType) { * @param {Function} [callback] - Function to process each record */ /* jshint ignore:end */ - DayListInstance.each = function each(opts, callback) { + AppListInstance.each = function each(opts, callback) { if (_.isFunction(opts)) { callback = opts; opts = {}; @@ -153,13 +151,13 @@ DayList = function DayList(version, resourceType) { /* jshint ignore:start */ /** - * Lists DayInstance records from the API as a list. + * Lists AppInstance 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.Preview.BulkExports.ExportContext.DayList# + * @memberof Twilio.Microvisor.V1.AppList# * * @param {object} [opts] - Options for request * @param {number} [opts.limit] - @@ -177,7 +175,7 @@ DayList = function DayList(version, resourceType) { * @returns {Promise} Resolves to a list of records */ /* jshint ignore:end */ - DayListInstance.list = function list(opts, callback) { + AppListInstance.list = function list(opts, callback) { if (_.isFunction(opts)) { callback = opts; opts = {}; @@ -211,7 +209,7 @@ DayList = function DayList(version, resourceType) { /* jshint ignore:start */ /** - * Retrieve a single page of DayInstance records from the API. + * Retrieve a single page of AppInstance records from the API. * * The request is executed immediately. * @@ -219,7 +217,7 @@ DayList = function DayList(version, resourceType) { * function. * * @function page - * @memberof Twilio.Preview.BulkExports.ExportContext.DayList# + * @memberof Twilio.Microvisor.V1.AppList# * * @param {object} [opts] - Options for request * @param {string} [opts.pageToken] - PageToken provided by the API @@ -231,7 +229,7 @@ DayList = function DayList(version, resourceType) { * @returns {Promise} Resolves to a list of records */ /* jshint ignore:end */ - DayListInstance.page = function page(opts, callback) { + AppListInstance.page = function page(opts, callback) { if (_.isFunction(opts)) { callback = opts; opts = {}; @@ -248,7 +246,7 @@ DayList = function DayList(version, resourceType) { var promise = this._version.page({uri: this._uri, method: 'GET', params: data}); promise = promise.then(function(payload) { - deferred.resolve(new DayPage(this._version, payload, this._solution)); + deferred.resolve(new AppPage(this._version, payload, this._solution)); }.bind(this)); promise.catch(function(error) { @@ -264,7 +262,7 @@ DayList = function DayList(version, resourceType) { /* jshint ignore:start */ /** - * Retrieve a single target page of DayInstance records from the API. + * Retrieve a single target page of AppInstance records from the API. * * The request is executed immediately. * @@ -272,7 +270,7 @@ DayList = function DayList(version, resourceType) { * function. * * @function getPage - * @memberof Twilio.Preview.BulkExports.ExportContext.DayList# + * @memberof Twilio.Microvisor.V1.AppList# * * @param {string} [targetUrl] - API-generated URL for the requested results page * @param {function} [callback] - Callback to handle list of records @@ -280,13 +278,13 @@ DayList = function DayList(version, resourceType) { * @returns {Promise} Resolves to a list of records */ /* jshint ignore:end */ - DayListInstance.getPage = function getPage(targetUrl, callback) { + AppListInstance.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 DayPage(this._version, payload, this._solution)); + deferred.resolve(new AppPage(this._version, payload, this._solution)); }.bind(this)); promise.catch(function(error) { @@ -302,18 +300,18 @@ DayList = function DayList(version, resourceType) { /* jshint ignore:start */ /** - * Constructs a day + * Constructs a app * * @function get - * @memberof Twilio.Preview.BulkExports.ExportContext.DayList# + * @memberof Twilio.Microvisor.V1.AppList# * - * @param {string} day - The date of the data in the file + * @param {string} sid - A string that uniquely identifies this App. * - * @returns {Twilio.Preview.BulkExports.ExportContext.DayContext} + * @returns {Twilio.Microvisor.V1.AppContext} */ /* jshint ignore:end */ - DayListInstance.get = function get(day) { - return new DayContext(this._version, this._solution.resourceType, day); + AppListInstance.get = function get(sid) { + return new AppContext(this._version, sid); }; /* jshint ignore:start */ @@ -321,64 +319,64 @@ DayList = function DayList(version, resourceType) { * Provide a user-friendly representation * * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.DayList# + * @memberof Twilio.Microvisor.V1.AppList# * * @returns Object */ /* jshint ignore:end */ - DayListInstance.toJSON = function toJSON() { + AppListInstance.toJSON = function toJSON() { return this._solution; }; - DayListInstance[util.inspect.custom] = function inspect(depth, options) { + AppListInstance[util.inspect.custom] = function inspect(depth, options) { return util.inspect(this.toJSON(), options); }; - return DayListInstance; + return AppListInstance; }; /* jshint ignore:start */ /** - * Initialize the DayPage + * Initialize the AppPage * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview * access, please contact help@twilio.com. * - * @constructor Twilio.Preview.BulkExports.ExportContext.DayPage + * @constructor Twilio.Microvisor.V1.AppPage * - * @param {BulkExports} version - Version of the resource + * @param {V1} version - Version of the resource * @param {Response} response - Response from the API - * @param {DaySolution} solution - Path solution + * @param {AppSolution} solution - Path solution * - * @returns DayPage + * @returns AppPage */ /* jshint ignore:end */ -DayPage = function DayPage(version, response, solution) { +AppPage = function AppPage(version, response, solution) { // Path Solution this._solution = solution; Page.prototype.constructor.call(this, version, response, this._solution); }; -_.extend(DayPage.prototype, Page.prototype); -DayPage.prototype.constructor = DayPage; +_.extend(AppPage.prototype, Page.prototype); +AppPage.prototype.constructor = AppPage; /* jshint ignore:start */ /** - * Build an instance of DayInstance + * Build an instance of AppInstance * * @function getInstance - * @memberof Twilio.Preview.BulkExports.ExportContext.DayPage# + * @memberof Twilio.Microvisor.V1.AppPage# * - * @param {DayPayload} payload - Payload response from the API + * @param {AppPayload} payload - Payload response from the API * - * @returns DayInstance + * @returns AppInstance */ /* jshint ignore:end */ -DayPage.prototype.getInstance = function getInstance(payload) { - return new DayInstance(this._version, payload, this._solution.resourceType); +AppPage.prototype.getInstance = function getInstance(payload) { + return new AppInstance(this._version, payload); }; /* jshint ignore:start */ @@ -386,12 +384,12 @@ DayPage.prototype.getInstance = function getInstance(payload) { * Provide a user-friendly representation * * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.DayPage# + * @memberof Twilio.Microvisor.V1.AppPage# * * @returns Object */ /* jshint ignore:end */ -DayPage.prototype.toJSON = function toJSON() { +AppPage.prototype.toJSON = function toJSON() { let clone = {}; _.forOwn(this, function(value, key) { if (!_.startsWith(key, '_') && ! _.isFunction(value)) { @@ -401,58 +399,58 @@ DayPage.prototype.toJSON = function toJSON() { return clone; }; -DayPage.prototype[util.inspect.custom] = function inspect(depth, options) { +AppPage.prototype[util.inspect.custom] = function inspect(depth, options) { return util.inspect(this.toJSON(), options); }; /* jshint ignore:start */ /** - * Initialize the DayContext + * Initialize the AppContext * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview * access, please contact help@twilio.com. * - * @constructor Twilio.Preview.BulkExports.ExportContext.DayInstance - * - * @property {string} redirectTo - The redirect_to - * @property {string} day - The date of the data in the file - * @property {number} size - Size of the file in bytes - * @property {string} createDate - The date when resource is created - * @property {string} friendlyName - - * The friendly name specified when creating the job - * @property {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * - * @param {BulkExports} version - Version of the resource - * @param {DayPayload} payload - The instance payload - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * @param {string} day - The date of the data in the file + * @constructor Twilio.Microvisor.V1.AppInstance + * + * @property {string} sid - A string that uniquely identifies this App. + * @property {string} accountSid - The Account SID. + * @property {string} hash - + * App manifest hash represented as hash_algorithm:hash_value. + * @property {string} uniqueName - + * An developer-defined string that uniquely identifies the App. + * @property {Date} dateCreated - The date that this App was created. + * @property {Date} dateUpdated - The date that this App was last updated. + * @property {string} url - The URL of this resource. + * + * @param {V1} version - Version of the resource + * @param {AppPayload} payload - The instance payload + * @param {sid_like} sid - A string that uniquely identifies this App. */ /* jshint ignore:end */ -DayInstance = function DayInstance(version, payload, resourceType, day) { +AppInstance = function AppInstance(version, payload, sid) { this._version = version; // Marshaled Properties - this.redirectTo = payload.redirect_to; // jshint ignore:line - this.day = payload.day; // jshint ignore:line - this.size = deserialize.integer(payload.size); // jshint ignore:line - this.createDate = payload.create_date; // jshint ignore:line - this.friendlyName = payload.friendly_name; // jshint ignore:line - this.resourceType = payload.resource_type; // jshint ignore:line + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.hash = payload.hash; // jshint ignore:line + this.uniqueName = payload.unique_name; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + this.url = payload.url; // jshint ignore:line // Context this._context = undefined; - this._solution = {resourceType: resourceType, day: day || this.day, }; + this._solution = {sid: sid || this.sid, }; }; -Object.defineProperty(DayInstance.prototype, +Object.defineProperty(AppInstance.prototype, '_proxy', { get: function() { if (!this._context) { - this._context = new DayContext(this._version, this._solution.resourceType, this._solution.day); + this._context = new AppContext(this._version, this._solution.sid); } return this._context; @@ -461,31 +459,47 @@ Object.defineProperty(DayInstance.prototype, /* jshint ignore:start */ /** - * fetch a DayInstance + * fetch a AppInstance * * @function fetch - * @memberof Twilio.Preview.BulkExports.ExportContext.DayInstance# + * @memberof Twilio.Microvisor.V1.AppInstance# * * @param {function} [callback] - Callback to handle processed record * - * @returns {Promise} Resolves to processed DayInstance + * @returns {Promise} Resolves to processed AppInstance */ /* jshint ignore:end */ -DayInstance.prototype.fetch = function fetch(callback) { +AppInstance.prototype.fetch = function fetch(callback) { return this._proxy.fetch(callback); }; +/* jshint ignore:start */ +/** + * remove a AppInstance + * + * @function remove + * @memberof Twilio.Microvisor.V1.AppInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed AppInstance + */ +/* jshint ignore:end */ +AppInstance.prototype.remove = function remove(callback) { + return this._proxy.remove(callback); +}; + /* jshint ignore:start */ /** * Provide a user-friendly representation * * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.DayInstance# + * @memberof Twilio.Microvisor.V1.AppInstance# * * @returns Object */ /* jshint ignore:end */ -DayInstance.prototype.toJSON = function toJSON() { +AppInstance.prototype.toJSON = function toJSON() { let clone = {}; _.forOwn(this, function(value, key) { if (!_.startsWith(key, '_') && ! _.isFunction(value)) { @@ -495,58 +509,82 @@ DayInstance.prototype.toJSON = function toJSON() { return clone; }; -DayInstance.prototype[util.inspect.custom] = function inspect(depth, options) { +AppInstance.prototype[util.inspect.custom] = function inspect(depth, options) { return util.inspect(this.toJSON(), options); }; /* jshint ignore:start */ /** - * Initialize the DayContext + * Initialize the AppContext * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview * access, please contact help@twilio.com. * - * @constructor Twilio.Preview.BulkExports.ExportContext.DayContext + * @constructor Twilio.Microvisor.V1.AppContext * - * @param {BulkExports} version - Version of the resource - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * @param {string} day - The date of the data in the file + * @param {V1} version - Version of the resource + * @param {sid_like} sid - A string that uniquely identifies this App. */ /* jshint ignore:end */ -DayContext = function DayContext(version, resourceType, day) { +AppContext = function AppContext(version, sid) { this._version = version; // Path Solution - this._solution = {resourceType: resourceType, day: day, }; - this._uri = `/Exports/${resourceType}/Days/${day}`; + this._solution = {sid: sid, }; + this._uri = `/Apps/${sid}`; }; /* jshint ignore:start */ /** - * fetch a DayInstance + * fetch a AppInstance * * @function fetch - * @memberof Twilio.Preview.BulkExports.ExportContext.DayContext# + * @memberof Twilio.Microvisor.V1.AppContext# * * @param {function} [callback] - Callback to handle processed record * - * @returns {Promise} Resolves to processed DayInstance + * @returns {Promise} Resolves to processed AppInstance */ /* jshint ignore:end */ -DayContext.prototype.fetch = function fetch(callback) { +AppContext.prototype.fetch = function fetch(callback) { var deferred = Q.defer(); var promise = this._version.fetch({uri: this._uri, method: 'GET'}); promise = promise.then(function(payload) { - deferred.resolve(new DayInstance( - this._version, - payload, - this._solution.resourceType, - this._solution.day - )); + deferred.resolve(new AppInstance(this._version, payload, this._solution.sid)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * remove a AppInstance + * + * @function remove + * @memberof Twilio.Microvisor.V1.AppContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed AppInstance + */ +/* jshint ignore:end */ +AppContext.prototype.remove = function remove(callback) { + var deferred = Q.defer(); + var promise = this._version.remove({uri: this._uri, method: 'DELETE'}); + + promise = promise.then(function(payload) { + deferred.resolve(payload); }.bind(this)); promise.catch(function(error) { @@ -565,22 +603,22 @@ DayContext.prototype.fetch = function fetch(callback) { * Provide a user-friendly representation * * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.DayContext# + * @memberof Twilio.Microvisor.V1.AppContext# * * @returns Object */ /* jshint ignore:end */ -DayContext.prototype.toJSON = function toJSON() { +AppContext.prototype.toJSON = function toJSON() { return this._solution; }; -DayContext.prototype[util.inspect.custom] = function inspect(depth, options) { +AppContext.prototype[util.inspect.custom] = function inspect(depth, options) { return util.inspect(this.toJSON(), options); }; module.exports = { - DayList: DayList, - DayPage: DayPage, - DayInstance: DayInstance, - DayContext: DayContext + AppList: AppList, + AppPage: AppPage, + AppInstance: AppInstance, + AppContext: AppContext }; diff --git a/lib/rest/preview/bulk_exports/export/exportCustomJob.d.ts b/lib/rest/microvisor/v1/device.d.ts similarity index 51% rename from lib/rest/preview/bulk_exports/export/exportCustomJob.d.ts rename to lib/rest/microvisor/v1/device.d.ts index 3d6ee0b0b3..50133db222 100644 --- a/lib/rest/preview/bulk_exports/export/exportCustomJob.d.ts +++ b/lib/rest/microvisor/v1/device.d.ts @@ -5,33 +5,42 @@ * / / */ -import BulkExports = require('../../BulkExports'); -import Page = require('../../../../base/Page'); -import Response = require('../../../../http/response'); -import { SerializableClass } from '../../../../interfaces'; +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V1 = require('../V1'); +import { SerializableClass } from '../../../interfaces'; /** - * Initialize the ExportCustomJobList + * Initialize the DeviceList * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview * access, please contact help@twilio.com. * * @param version - Version of the resource - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants */ -declare function ExportCustomJobList(version: BulkExports, resourceType: string): ExportCustomJobListInstance; +declare function DeviceList(version: V1): DeviceListInstance; -interface ExportCustomJobListInstance { +/** + * Options to pass to update + * + * @property loggingEnabled - Whether to enable logging. + * @property targetApp - The target App SID or unique name. + * @property uniqueName - A unique, developer-assigned name for this Device. + */ +interface DeviceInstanceUpdateOptions { + loggingEnabled?: boolean; + targetApp?: string; + uniqueName?: string; +} + +interface DeviceListInstance { /** - * create a ExportCustomJobInstance - * - * @param opts - Options for request - * @param callback - Callback to handle processed record + * @param sid - sid of instance */ - create(opts: ExportCustomJobListInstanceCreateOptions, callback?: (error: Error | null, item: ExportCustomJobInstance) => any): Promise; + (sid: string): DeviceContext; /** - * Streams ExportCustomJobInstance records from the API. + * Streams DeviceInstance records from the API. * * This operation lazily loads records as efficiently as possible until the limit * is reached. @@ -44,9 +53,9 @@ interface ExportCustomJobListInstance { * * @param callback - Function to process each record */ - each(callback?: (item: ExportCustomJobInstance, done: (err?: Error) => void) => void): void; + each(callback?: (item: DeviceInstance, done: (err?: Error) => void) => void): void; /** - * Streams ExportCustomJobInstance records from the API. + * Streams DeviceInstance records from the API. * * This operation lazily loads records as efficiently as possible until the limit * is reached. @@ -60,9 +69,15 @@ interface ExportCustomJobListInstance { * @param opts - Options for request * @param callback - Function to process each record */ - each(opts?: ExportCustomJobListInstanceEachOptions, callback?: (item: ExportCustomJobInstance, done: (err?: Error) => void) => void): void; + each(opts?: DeviceListInstanceEachOptions, callback?: (item: DeviceInstance, done: (err?: Error) => void) => void): void; /** - * Retrieve a single target page of ExportCustomJobInstance records from the API. + * Constructs a device + * + * @param sid - A string that uniquely identifies this Device. + */ + get(sid: string): DeviceContext; + /** + * Retrieve a single target page of DeviceInstance records from the API. * * The request is executed immediately. * @@ -71,9 +86,9 @@ interface ExportCustomJobListInstance { * * @param callback - Callback to handle list of records */ - getPage(callback?: (error: Error | null, items: ExportCustomJobPage) => any): Promise; + getPage(callback?: (error: Error | null, items: DevicePage) => any): Promise; /** - * Retrieve a single target page of ExportCustomJobInstance records from the API. + * Retrieve a single target page of DeviceInstance records from the API. * * The request is executed immediately. * @@ -83,18 +98,18 @@ interface ExportCustomJobListInstance { * @param targetUrl - API-generated URL for the requested results page * @param callback - Callback to handle list of records */ - getPage(targetUrl?: string, callback?: (error: Error | null, items: ExportCustomJobPage) => any): Promise; + getPage(targetUrl?: string, callback?: (error: Error | null, items: DevicePage) => any): Promise; /** - * Lists ExportCustomJobInstance records from the API as a list. + * Lists DeviceInstance records from the API as a list. * * If a function is passed as the first argument, it will be used as the callback * function. * * @param callback - Callback to handle list of records */ - list(callback?: (error: Error | null, items: ExportCustomJobInstance[]) => any): Promise; + list(callback?: (error: Error | null, items: DeviceInstance[]) => any): Promise; /** - * Lists ExportCustomJobInstance records from the API as a list. + * Lists DeviceInstance records from the API as a list. * * If a function is passed as the first argument, it will be used as the callback * function. @@ -102,9 +117,9 @@ interface ExportCustomJobListInstance { * @param opts - Options for request * @param callback - Callback to handle list of records */ - list(opts?: ExportCustomJobListInstanceOptions, callback?: (error: Error | null, items: ExportCustomJobInstance[]) => any): Promise; + list(opts?: DeviceListInstanceOptions, callback?: (error: Error | null, items: DeviceInstance[]) => any): Promise; /** - * Retrieve a single page of ExportCustomJobInstance records from the API. + * Retrieve a single page of DeviceInstance records from the API. * * The request is executed immediately. * @@ -113,9 +128,9 @@ interface ExportCustomJobListInstance { * * @param callback - Callback to handle list of records */ - page(callback?: (error: Error | null, items: ExportCustomJobPage) => any): Promise; + page(callback?: (error: Error | null, items: DevicePage) => any): Promise; /** - * Retrieve a single page of ExportCustomJobInstance records from the API. + * Retrieve a single page of DeviceInstance records from the API. * * The request is executed immediately. * @@ -125,32 +140,13 @@ interface ExportCustomJobListInstance { * @param opts - Options for request * @param callback - Callback to handle list of records */ - page(opts?: ExportCustomJobListInstancePageOptions, callback?: (error: Error | null, items: ExportCustomJobPage) => any): Promise; + page(opts?: DeviceListInstancePageOptions, callback?: (error: Error | null, items: DevicePage) => any): Promise; /** * Provide a user-friendly representation */ toJSON(): any; } -/** - * Options to pass to create - * - * @property email - The optional email to send the completion notification to - * @property endDay - The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day. - * @property friendlyName - The friendly name specified when creating the job - * @property startDay - The start day for the custom export specified as a string in the format of yyyy-mm-dd - * @property webhookMethod - This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied. - * @property webhookUrl - The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. - */ -interface ExportCustomJobListInstanceCreateOptions { - email?: string; - endDay: string; - friendlyName: string; - startDay: string; - webhookMethod?: string; - webhookUrl?: string; -} - /** * Options to pass to each * @@ -169,8 +165,8 @@ interface ExportCustomJobListInstanceCreateOptions { * each() will attempt to read the limit with the most efficient * page size, i.e. min(limit, 1000) */ -interface ExportCustomJobListInstanceEachOptions { - callback?: (item: ExportCustomJobInstance, done: (err?: Error) => void) => void; +interface DeviceListInstanceEachOptions { + callback?: (item: DeviceInstance, done: (err?: Error) => void) => void; done?: Function; limit?: number; pageSize?: number; @@ -190,7 +186,7 @@ interface ExportCustomJobListInstanceEachOptions { * list() will attempt to read the limit with the most * efficient page size, i.e. min(limit, 1000) */ -interface ExportCustomJobListInstanceOptions { +interface DeviceListInstanceOptions { limit?: number; pageSize?: number; } @@ -202,35 +198,72 @@ interface ExportCustomJobListInstanceOptions { * @property pageSize - Number of records to return, defaults to 50 * @property pageToken - PageToken provided by the API */ -interface ExportCustomJobListInstancePageOptions { +interface DeviceListInstancePageOptions { pageNumber?: number; pageSize?: number; pageToken?: string; } -interface ExportCustomJobPayload extends ExportCustomJobResource, Page.TwilioResponsePayload { +interface DevicePayload extends DeviceResource, Page.TwilioResponsePayload { +} + +interface DeviceResource { + account_sid: string; + app: object; + date_created: Date; + date_updated: Date; + logging: object; + sid: string; + unique_name: string; + url: string; } -interface ExportCustomJobResource { - details: object; - email: string; - end_day: string; - friendly_name: string; - job_sid: string; - resource_type: string; - start_day: string; - webhook_method: string; - webhook_url: string; +interface DeviceSolution { } -interface ExportCustomJobSolution { - resourceType?: string; + +declare class DeviceContext { + /** + * Initialize the DeviceContext + * + * PLEASE NOTE that this class contains preview products that are subject to + * change. Use them with caution. If you currently do not have developer preview + * access, please contact help@twilio.com. + * + * @param version - Version of the resource + * @param sid - A string that uniquely identifies this Device. + */ + constructor(version: V1, sid: string); + + /** + * fetch a DeviceInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: DeviceInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a DeviceInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: DeviceInstance) => any): Promise; + /** + * update a DeviceInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: DeviceInstanceUpdateOptions, callback?: (error: Error | null, items: DeviceInstance) => any): Promise; } -declare class ExportCustomJobInstance extends SerializableClass { +declare class DeviceInstance extends SerializableClass { /** - * Initialize the ExportCustomJobContext + * Initialize the DeviceContext * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview @@ -238,29 +271,48 @@ declare class ExportCustomJobInstance extends SerializableClass { * * @param version - Version of the resource * @param payload - The instance payload - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants + * @param sid - A string that uniquely identifies this Device. */ - constructor(version: BulkExports, payload: ExportCustomJobPayload, resourceType: string); + constructor(version: V1, payload: DevicePayload, sid: string); - details: any; - email: string; - endDay: string; - friendlyName: string; - jobSid: string; - resourceType: string; - startDay: string; + private _proxy: DeviceContext; + accountSid: string; + app: any; + dateCreated: Date; + dateUpdated: Date; + /** + * fetch a DeviceInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: DeviceInstance) => any): Promise; + logging: any; + sid: string; /** * Provide a user-friendly representation */ toJSON(): any; - webhookMethod: string; - webhookUrl: string; + uniqueName: string; + /** + * update a DeviceInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: DeviceInstance) => any): Promise; + /** + * update a DeviceInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: DeviceInstanceUpdateOptions, callback?: (error: Error | null, items: DeviceInstance) => any): Promise; + url: string; } -declare class ExportCustomJobPage extends Page { +declare class DevicePage extends Page { /** - * Initialize the ExportCustomJobPage + * Initialize the DevicePage * * PLEASE NOTE that this class contains preview products that are subject to * change. Use them with caution. If you currently do not have developer preview @@ -270,18 +322,18 @@ declare class ExportCustomJobPage extends Page, solution: ExportCustomJobSolution); + constructor(version: V1, response: Response, solution: DeviceSolution); /** - * Build an instance of ExportCustomJobInstance + * Build an instance of DeviceInstance * * @param payload - Payload response from the API */ - getInstance(payload: ExportCustomJobPayload): ExportCustomJobInstance; + getInstance(payload: DevicePayload): DeviceInstance; /** * Provide a user-friendly representation */ toJSON(): any; } -export { ExportCustomJobInstance, ExportCustomJobList, ExportCustomJobListInstance, ExportCustomJobListInstanceCreateOptions, ExportCustomJobListInstanceEachOptions, ExportCustomJobListInstanceOptions, ExportCustomJobListInstancePageOptions, ExportCustomJobPage, ExportCustomJobPayload, ExportCustomJobResource, ExportCustomJobSolution } +export { DeviceContext, DeviceInstance, DeviceInstanceUpdateOptions, DeviceList, DeviceListInstance, DeviceListInstanceEachOptions, DeviceListInstanceOptions, DeviceListInstancePageOptions, DevicePage, DevicePayload, DeviceResource, DeviceSolution } diff --git a/lib/rest/microvisor/v1/device.js b/lib/rest/microvisor/v1/device.js new file mode 100644 index 0000000000..cf141547f2 --- /dev/null +++ b/lib/rest/microvisor/v1/device.js @@ -0,0 +1,652 @@ +'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 util = require('util'); /* 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 DeviceList; +var DevicePage; +var DeviceInstance; +var DeviceContext; + +/* jshint ignore:start */ +/** + * Initialize the DeviceList + * + * PLEASE NOTE that this class contains preview products that are subject to + * change. Use them with caution. If you currently do not have developer preview + * access, please contact help@twilio.com. + * + * @constructor Twilio.Microvisor.V1.DeviceList + * + * @param {Twilio.Microvisor.V1} version - Version of the resource + */ +/* jshint ignore:end */ +DeviceList = function DeviceList(version) { + /* jshint ignore:start */ + /** + * @function devices + * @memberof Twilio.Microvisor.V1# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Microvisor.V1.DeviceContext} + */ + /* jshint ignore:end */ + function DeviceListInstance(sid) { + return DeviceListInstance.get(sid); + } + + DeviceListInstance._version = version; + // Path Solution + DeviceListInstance._solution = {}; + DeviceListInstance._uri = `/Devices`; + /* jshint ignore:start */ + /** + * Streams DeviceInstance 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.Microvisor.V1.DeviceList# + * + * @param {object} [opts] - Options for request + * @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] - + * 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 */ + DeviceListInstance.each = function each(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + if (opts.callback) { + callback = opts.callback; + } + if (_.isUndefined(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++; + callback(instance, onComplete); + }); + + if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } else { + onComplete(); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists DeviceInstance 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.Microvisor.V1.DeviceList# + * + * @param {object} [opts] - Options for request + * @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 */ + DeviceListInstance.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 DeviceInstance records from the API. + * + * The 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.Microvisor.V1.DeviceList# + * + * @param {object} [opts] - Options for request + * @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 */ + DeviceListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + '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 DevicePage(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 DeviceInstance records from the API. + * + * The 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.Microvisor.V1.DeviceList# + * + * @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 */ + DeviceListInstance.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 DevicePage(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 */ + /** + * Constructs a device + * + * @function get + * @memberof Twilio.Microvisor.V1.DeviceList# + * + * @param {string} sid - A string that uniquely identifies this Device. + * + * @returns {Twilio.Microvisor.V1.DeviceContext} + */ + /* jshint ignore:end */ + DeviceListInstance.get = function get(sid) { + return new DeviceContext(this._version, sid); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Microvisor.V1.DeviceList# + * + * @returns Object + */ + /* jshint ignore:end */ + DeviceListInstance.toJSON = function toJSON() { + return this._solution; + }; + + DeviceListInstance[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return DeviceListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the DevicePage + * + * PLEASE NOTE that this class contains preview products that are subject to + * change. Use them with caution. If you currently do not have developer preview + * access, please contact help@twilio.com. + * + * @constructor Twilio.Microvisor.V1.DevicePage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {DeviceSolution} solution - Path solution + * + * @returns DevicePage + */ +/* jshint ignore:end */ +DevicePage = function DevicePage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(DevicePage.prototype, Page.prototype); +DevicePage.prototype.constructor = DevicePage; + +/* jshint ignore:start */ +/** + * Build an instance of DeviceInstance + * + * @function getInstance + * @memberof Twilio.Microvisor.V1.DevicePage# + * + * @param {DevicePayload} payload - Payload response from the API + * + * @returns DeviceInstance + */ +/* jshint ignore:end */ +DevicePage.prototype.getInstance = function getInstance(payload) { + return new DeviceInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Microvisor.V1.DevicePage# + * + * @returns Object + */ +/* jshint ignore:end */ +DevicePage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +DevicePage.prototype[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the DeviceContext + * + * PLEASE NOTE that this class contains preview products that are subject to + * change. Use them with caution. If you currently do not have developer preview + * access, please contact help@twilio.com. + * + * @constructor Twilio.Microvisor.V1.DeviceInstance + * + * @property {string} sid - A string that uniquely identifies this Device. + * @property {string} uniqueName - + * A developer-defined string that uniquely identifies the Device. + * @property {string} accountSid - Account SID. + * @property {object} app - + * Information about the target App and the App reported by this Device. + * @property {object} logging - + * Object specifying whether application logging is enabled for this Device. + * @property {Date} dateCreated - The date that this Device was created. + * @property {Date} dateUpdated - The date that this Device was last updated. + * @property {string} url - The URL of this resource. + * + * @param {V1} version - Version of the resource + * @param {DevicePayload} payload - The instance payload + * @param {sid_like} sid - A string that uniquely identifies this Device. + */ +/* jshint ignore:end */ +DeviceInstance = function DeviceInstance(version, payload, sid) { + this._version = version; + + // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line + this.uniqueName = payload.unique_name; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.app = payload.app; // jshint ignore:line + this.logging = payload.logging; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + this.url = payload.url; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {sid: sid || this.sid, }; +}; + +Object.defineProperty(DeviceInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new DeviceContext(this._version, this._solution.sid); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * fetch a DeviceInstance + * + * @function fetch + * @memberof Twilio.Microvisor.V1.DeviceInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed DeviceInstance + */ +/* jshint ignore:end */ +DeviceInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * update a DeviceInstance + * + * @function update + * @memberof Twilio.Microvisor.V1.DeviceInstance# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.uniqueName] - + * A unique, developer-assigned name for this Device. + * @param {string} [opts.targetApp] - The target App SID or unique name. + * @param {boolean} [opts.loggingEnabled] - Whether to enable logging. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed DeviceInstance + */ +/* jshint ignore:end */ +DeviceInstance.prototype.update = function update(opts, callback) { + return this._proxy.update(opts, callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Microvisor.V1.DeviceInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +DeviceInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +DeviceInstance.prototype[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the DeviceContext + * + * PLEASE NOTE that this class contains preview products that are subject to + * change. Use them with caution. If you currently do not have developer preview + * access, please contact help@twilio.com. + * + * @constructor Twilio.Microvisor.V1.DeviceContext + * + * @param {V1} version - Version of the resource + * @param {sid_like} sid - A string that uniquely identifies this Device. + */ +/* jshint ignore:end */ +DeviceContext = function DeviceContext(version, sid) { + this._version = version; + + // Path Solution + this._solution = {sid: sid, }; + this._uri = `/Devices/${sid}`; +}; + +/* jshint ignore:start */ +/** + * fetch a DeviceInstance + * + * @function fetch + * @memberof Twilio.Microvisor.V1.DeviceContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed DeviceInstance + */ +/* jshint ignore:end */ +DeviceContext.prototype.fetch = function fetch(callback) { + var deferred = Q.defer(); + var promise = this._version.fetch({uri: this._uri, method: 'GET'}); + + promise = promise.then(function(payload) { + deferred.resolve(new DeviceInstance(this._version, payload, this._solution.sid)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * update a DeviceInstance + * + * @function update + * @memberof Twilio.Microvisor.V1.DeviceContext# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.uniqueName] - + * A unique, developer-assigned name for this Device. + * @param {string} [opts.targetApp] - The target App SID or unique name. + * @param {boolean} [opts.loggingEnabled] - Whether to enable logging. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed DeviceInstance + */ +/* jshint ignore:end */ +DeviceContext.prototype.update = function update(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'UniqueName': _.get(opts, 'uniqueName'), + 'TargetApp': _.get(opts, 'targetApp'), + 'LoggingEnabled': serialize.bool(_.get(opts, 'loggingEnabled')) + }); + + var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new DeviceInstance(this._version, payload, this._solution.sid)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Microvisor.V1.DeviceContext# + * + * @returns Object + */ +/* jshint ignore:end */ +DeviceContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +DeviceContext.prototype[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + DeviceList: DeviceList, + DevicePage: DevicePage, + DeviceInstance: DeviceInstance, + DeviceContext: DeviceContext +}; diff --git a/lib/rest/preview/BulkExports.d.ts b/lib/rest/preview/BulkExports.d.ts deleted file mode 100644 index 4e96e4872d..0000000000 --- a/lib/rest/preview/BulkExports.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ - -import Preview = require('../Preview'); -import Version = require('../../base/Version'); -import { ExportConfigurationList } from './bulk_exports/exportConfiguration'; -import { ExportConfigurationListInstance } from './bulk_exports/exportConfiguration'; -import { ExportList } from './bulk_exports/export'; -import { ExportListInstance } from './bulk_exports/export'; - - -declare class BulkExports extends Version { - /** - * Initialize the BulkExports version of Preview - * - * @param domain - The twilio domain - */ - constructor(domain: Preview); - - readonly exportConfiguration: ExportConfigurationListInstance; - readonly exports: ExportListInstance; -} - -export = BulkExports; diff --git a/lib/rest/preview/BulkExports.js b/lib/rest/preview/BulkExports.js deleted file mode 100644 index 6015e2f25a..0000000000 --- a/lib/rest/preview/BulkExports.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -var _ = require('lodash'); /* jshint ignore:line */ -var ExportConfigurationList = require( - './bulk_exports/exportConfiguration').ExportConfigurationList; -var ExportList = require('./bulk_exports/export').ExportList; -var Version = require('../../base/Version'); /* jshint ignore:line */ - - -/* jshint ignore:start */ -/** - * Initialize the BulkExports version of Preview - * - * @constructor Twilio.Preview.BulkExports - * - * @property {Twilio.Preview.BulkExports.ExportList} exports - exports resource - * @property {Twilio.Preview.BulkExports.ExportConfigurationList} exportConfiguration - - * exportConfiguration resource - * - * @param {Twilio.Preview} domain - The twilio domain - */ -/* jshint ignore:end */ -function BulkExports(domain) { - Version.prototype.constructor.call(this, domain, 'BulkExports'); - - // Resources - this._exports = undefined; - this._exportConfiguration = undefined; -} - -_.extend(BulkExports.prototype, Version.prototype); -BulkExports.prototype.constructor = BulkExports; - -Object.defineProperty(BulkExports.prototype, - 'exports', { - get: function() { - this._exports = this._exports || new ExportList(this); - return this._exports; - } -}); - -Object.defineProperty(BulkExports.prototype, - 'exportConfiguration', { - get: function() { - this._exportConfiguration = this._exportConfiguration || new ExportConfigurationList(this); - return this._exportConfiguration; - } -}); - -module.exports = BulkExports; diff --git a/lib/rest/preview/bulk_exports/export.d.ts b/lib/rest/preview/bulk_exports/export.d.ts deleted file mode 100644 index 40f1c31ed3..0000000000 --- a/lib/rest/preview/bulk_exports/export.d.ts +++ /dev/null @@ -1,153 +0,0 @@ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ - -import BulkExports = require('../BulkExports'); -import Page = require('../../../base/Page'); -import Response = require('../../../http/response'); -import { DayList } from './export/day'; -import { DayListInstance } from './export/day'; -import { ExportCustomJobList } from './export/exportCustomJob'; -import { ExportCustomJobListInstance } from './export/exportCustomJob'; -import { JobListInstance } from './export/job'; -import { SerializableClass } from '../../../interfaces'; - -/** - * Initialize the ExportList - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - */ -declare function ExportList(version: BulkExports): ExportListInstance; - -interface ExportListInstance { - /** - * @param sid - sid of instance - */ - (sid: string): ExportContext; - /** - * Constructs a export - * - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants - */ - get(resourceType: string): ExportContext; - jobs?: JobListInstance; - /** - * Provide a user-friendly representation - */ - toJSON(): any; -} - -interface ExportPayload extends ExportResource, Page.TwilioResponsePayload { -} - -interface ExportResource { - links: string; - resource_type: string; - url: string; -} - -interface ExportSolution { -} - - -declare class ExportContext { - /** - * Initialize the ExportContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants - */ - constructor(version: BulkExports, resourceType: string); - - days: DayListInstance; - exportCustomJobs: ExportCustomJobListInstance; - /** - * fetch a ExportInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: ExportInstance) => any): Promise; - /** - * Provide a user-friendly representation - */ - toJSON(): any; -} - - -declare class ExportInstance extends SerializableClass { - /** - * Initialize the ExportContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param payload - The instance payload - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants - */ - constructor(version: BulkExports, payload: ExportPayload, resourceType: string); - - private _proxy: ExportContext; - /** - * Access the days - */ - days(): DayListInstance; - /** - * Access the exportCustomJobs - */ - exportCustomJobs(): ExportCustomJobListInstance; - /** - * fetch a ExportInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: ExportInstance) => any): Promise; - links: string; - resourceType: string; - /** - * Provide a user-friendly representation - */ - toJSON(): any; - url: string; -} - - -declare class ExportPage extends Page { - /** - * Initialize the ExportPage - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor(version: BulkExports, response: Response, solution: ExportSolution); - - /** - * Build an instance of ExportInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: ExportPayload): ExportInstance; - /** - * Provide a user-friendly representation - */ - toJSON(): any; -} - -export { ExportContext, ExportInstance, ExportList, ExportListInstance, ExportPage, ExportPayload, ExportResource, ExportSolution } diff --git a/lib/rest/preview/bulk_exports/export.js b/lib/rest/preview/bulk_exports/export.js deleted file mode 100644 index c89e02a16f..0000000000 --- a/lib/rest/preview/bulk_exports/export.js +++ /dev/null @@ -1,402 +0,0 @@ -'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 util = require('util'); /* jshint ignore:line */ -var DayList = require('./export/day').DayList; -var ExportCustomJobList = require( - './export/exportCustomJob').ExportCustomJobList; -var JobList = require('./export/job').JobList; -var Page = require('../../../base/Page'); /* jshint ignore:line */ -var values = require('../../../base/values'); /* jshint ignore:line */ - -var ExportList; -var ExportPage; -var ExportInstance; -var ExportContext; - -/* jshint ignore:start */ -/** - * Initialize the ExportList - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportList - * - * @param {Twilio.Preview.BulkExports} version - Version of the resource - */ -/* jshint ignore:end */ -ExportList = function ExportList(version) { - /* jshint ignore:start */ - /** - * @function exports - * @memberof Twilio.Preview.BulkExports# - * - * @param {string} sid - sid of instance - * - * @returns {Twilio.Preview.BulkExports.ExportContext} - */ - /* jshint ignore:end */ - function ExportListInstance(sid) { - return ExportListInstance.get(sid); - } - - ExportListInstance._version = version; - // Path Solution - ExportListInstance._solution = {}; - - // Components - ExportListInstance._jobs = undefined; - - /* jshint ignore:start */ - /** - * Constructs a export - * - * @function get - * @memberof Twilio.Preview.BulkExports.ExportList# - * - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * - * @returns {Twilio.Preview.BulkExports.ExportContext} - */ - /* jshint ignore:end */ - ExportListInstance.get = function get(resourceType) { - return new ExportContext(this._version, resourceType); - }; - - Object.defineProperty(ExportListInstance, - 'jobs', { - get: function jobs() { - if (!this._jobs) { - this._jobs = new JobList(this._version); - } - - return this._jobs; - } - }); - - /* jshint ignore:start */ - /** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportList# - * - * @returns Object - */ - /* jshint ignore:end */ - ExportListInstance.toJSON = function toJSON() { - return this._solution; - }; - - ExportListInstance[util.inspect.custom] = function inspect(depth, options) { - return util.inspect(this.toJSON(), options); - }; - - return ExportListInstance; -}; - - -/* jshint ignore:start */ -/** - * Initialize the ExportPage - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportPage - * - * @param {BulkExports} version - Version of the resource - * @param {Response} response - Response from the API - * @param {ExportSolution} solution - Path solution - * - * @returns ExportPage - */ -/* jshint ignore:end */ -ExportPage = function ExportPage(version, response, solution) { - // Path Solution - this._solution = solution; - - Page.prototype.constructor.call(this, version, response, this._solution); -}; - -_.extend(ExportPage.prototype, Page.prototype); -ExportPage.prototype.constructor = ExportPage; - -/* jshint ignore:start */ -/** - * Build an instance of ExportInstance - * - * @function getInstance - * @memberof Twilio.Preview.BulkExports.ExportPage# - * - * @param {ExportPayload} payload - Payload response from the API - * - * @returns ExportInstance - */ -/* jshint ignore:end */ -ExportPage.prototype.getInstance = function getInstance(payload) { - return new ExportInstance(this._version, payload); -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportPage# - * - * @returns Object - */ -/* jshint ignore:end */ -ExportPage.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - -ExportPage.prototype[util.inspect.custom] = function inspect(depth, options) { - return util.inspect(this.toJSON(), options); -}; - - -/* jshint ignore:start */ -/** - * Initialize the ExportContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportInstance - * - * @property {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * @property {string} url - The URL of this resource. - * @property {string} links - Nested resource URLs. - * - * @param {BulkExports} version - Version of the resource - * @param {ExportPayload} payload - The instance payload - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - */ -/* jshint ignore:end */ -ExportInstance = function ExportInstance(version, payload, resourceType) { - this._version = version; - - // Marshaled Properties - this.resourceType = payload.resource_type; // jshint ignore:line - this.url = payload.url; // jshint ignore:line - this.links = payload.links; // jshint ignore:line - - // Context - this._context = undefined; - this._solution = {resourceType: resourceType || this.resourceType, }; -}; - -Object.defineProperty(ExportInstance.prototype, - '_proxy', { - get: function() { - if (!this._context) { - this._context = new ExportContext(this._version, this._solution.resourceType); - } - - return this._context; - } -}); - -/* jshint ignore:start */ -/** - * fetch a ExportInstance - * - * @function fetch - * @memberof Twilio.Preview.BulkExports.ExportInstance# - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ExportInstance - */ -/* jshint ignore:end */ -ExportInstance.prototype.fetch = function fetch(callback) { - return this._proxy.fetch(callback); -}; - -/* jshint ignore:start */ -/** - * Access the days - * - * @function days - * @memberof Twilio.Preview.BulkExports.ExportInstance# - * - * @returns {Twilio.Preview.BulkExports.ExportContext.DayList} - */ -/* jshint ignore:end */ -ExportInstance.prototype.days = function days() { - return this._proxy.days; -}; - -/* jshint ignore:start */ -/** - * Access the exportCustomJobs - * - * @function exportCustomJobs - * @memberof Twilio.Preview.BulkExports.ExportInstance# - * - * @returns {Twilio.Preview.BulkExports.ExportContext.ExportCustomJobList} - */ -/* jshint ignore:end */ -ExportInstance.prototype.exportCustomJobs = function exportCustomJobs() { - return this._proxy.exportCustomJobs; -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportInstance# - * - * @returns Object - */ -/* jshint ignore:end */ -ExportInstance.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - -ExportInstance.prototype[util.inspect.custom] = function inspect(depth, options) - { - return util.inspect(this.toJSON(), options); -}; - - -/* jshint ignore:start */ -/** - * Initialize the ExportContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportContext - * - * @property {Twilio.Preview.BulkExports.ExportContext.DayList} days - - * days resource - * @property {Twilio.Preview.BulkExports.ExportContext.ExportCustomJobList} exportCustomJobs - - * exportCustomJobs resource - * - * @param {BulkExports} version - Version of the resource - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - */ -/* jshint ignore:end */ -ExportContext = function ExportContext(version, resourceType) { - this._version = version; - - // Path Solution - this._solution = {resourceType: resourceType, }; - this._uri = `/Exports/${resourceType}`; - - // Dependents - this._days = undefined; - this._exportCustomJobs = undefined; -}; - -/* jshint ignore:start */ -/** - * fetch a ExportInstance - * - * @function fetch - * @memberof Twilio.Preview.BulkExports.ExportContext# - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ExportInstance - */ -/* jshint ignore:end */ -ExportContext.prototype.fetch = function fetch(callback) { - var deferred = Q.defer(); - var promise = this._version.fetch({uri: this._uri, method: 'GET'}); - - promise = promise.then(function(payload) { - deferred.resolve(new ExportInstance(this._version, payload, this._solution.resourceType)); - }.bind(this)); - - promise.catch(function(error) { - deferred.reject(error); - }); - - if (_.isFunction(callback)) { - deferred.promise.nodeify(callback); - } - - return deferred.promise; -}; - -Object.defineProperty(ExportContext.prototype, - 'days', { - get: function() { - if (!this._days) { - this._days = new DayList(this._version, this._solution.resourceType); - } - return this._days; - } -}); - -Object.defineProperty(ExportContext.prototype, - 'exportCustomJobs', { - get: function() { - if (!this._exportCustomJobs) { - this._exportCustomJobs = new ExportCustomJobList(this._version, this._solution.resourceType); - } - return this._exportCustomJobs; - } -}); - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext# - * - * @returns Object - */ -/* jshint ignore:end */ -ExportContext.prototype.toJSON = function toJSON() { - return this._solution; -}; - -ExportContext.prototype[util.inspect.custom] = function inspect(depth, options) - { - return util.inspect(this.toJSON(), options); -}; - -module.exports = { - ExportList: ExportList, - ExportPage: ExportPage, - ExportInstance: ExportInstance, - ExportContext: ExportContext -}; diff --git a/lib/rest/preview/bulk_exports/export/exportCustomJob.js b/lib/rest/preview/bulk_exports/export/exportCustomJob.js deleted file mode 100644 index b65c923a27..0000000000 --- a/lib/rest/preview/bulk_exports/export/exportCustomJob.js +++ /dev/null @@ -1,540 +0,0 @@ -'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 util = require('util'); /* jshint ignore:line */ -var Page = require('../../../../base/Page'); /* jshint ignore:line */ -var values = require('../../../../base/values'); /* jshint ignore:line */ - -var ExportCustomJobList; -var ExportCustomJobPage; -var ExportCustomJobInstance; - -/* jshint ignore:start */ -/** - * Initialize the ExportCustomJobList - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportContext.ExportCustomJobList - * - * @param {Twilio.Preview.BulkExports} version - Version of the resource - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - */ -/* jshint ignore:end */ -ExportCustomJobList = function ExportCustomJobList(version, resourceType) { - /* jshint ignore:start */ - /** - * @function exportCustomJobs - * @memberof Twilio.Preview.BulkExports.ExportContext# - * - * @param {string} sid - sid of instance - * - * @returns {Twilio.Preview.BulkExports.ExportContext.ExportCustomJobContext} - */ - /* jshint ignore:end */ - function ExportCustomJobListInstance(sid) { - return ExportCustomJobListInstance.get(sid); - } - - ExportCustomJobListInstance._version = version; - // Path Solution - ExportCustomJobListInstance._solution = {resourceType: resourceType}; - ExportCustomJobListInstance._uri = `/Exports/${resourceType}/Jobs`; - /* jshint ignore:start */ - /** - * Streams ExportCustomJobInstance 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.Preview.BulkExports.ExportContext.ExportCustomJobList# - * - * @param {object} [opts] - Options for request - * @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] - - * 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 */ - ExportCustomJobListInstance.each = function each(opts, callback) { - if (_.isFunction(opts)) { - callback = opts; - opts = {}; - } - opts = opts || {}; - if (opts.callback) { - callback = opts.callback; - } - if (_.isUndefined(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++; - callback(instance, onComplete); - }); - - if (!done) { - currentPage++; - fetchNextPage(_.bind(page.nextPage, page)); - } else { - onComplete(); - } - }); - - promise.catch(onComplete); - } - - fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); - }; - - /* jshint ignore:start */ - /** - * Lists ExportCustomJobInstance 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.Preview.BulkExports.ExportContext.ExportCustomJobList# - * - * @param {object} [opts] - Options for request - * @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 */ - ExportCustomJobListInstance.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 ExportCustomJobInstance records from the API. - * - * The 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.Preview.BulkExports.ExportContext.ExportCustomJobList# - * - * @param {object} [opts] - Options for request - * @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 */ - ExportCustomJobListInstance.page = function page(opts, callback) { - if (_.isFunction(opts)) { - callback = opts; - opts = {}; - } - opts = opts || {}; - - var deferred = Q.defer(); - var data = values.of({ - '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 ExportCustomJobPage(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 ExportCustomJobInstance records from the API. - * - * The 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.Preview.BulkExports.ExportContext.ExportCustomJobList# - * - * @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 */ - ExportCustomJobListInstance.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 ExportCustomJobPage(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 */ - /** - * create a ExportCustomJobInstance - * - * @function create - * @memberof Twilio.Preview.BulkExports.ExportContext.ExportCustomJobList# - * - * @param {object} opts - Options for request - * @param {string} opts.startDay - - * The start day for the custom export specified as a string in the format of yyyy-mm-dd - * @param {string} opts.endDay - - * The end day for the custom export specified as a string in the format of yyyy-mm-dd. End day is inclusive and must be 2 days earlier than the current UTC day. - * @param {string} opts.friendlyName - - * The friendly name specified when creating the job - * @param {string} [opts.webhookUrl] - - * The optional webhook url called on completion of the job. If this is supplied, `WebhookMethod` must also be supplied. - * @param {string} [opts.webhookMethod] - - * This is the method used to call the webhook on completion of the job. If this is supplied, `WebhookUrl` must also be supplied. - * @param {string} [opts.email] - - * The optional email to send the completion notification to - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ExportCustomJobInstance - */ - /* jshint ignore:end */ - ExportCustomJobListInstance.create = function create(opts, callback) { - if (_.isUndefined(opts)) { - throw new Error('Required parameter "opts" missing.'); - } - if (_.isUndefined(opts['startDay'])) { - throw new Error('Required parameter "opts[\'startDay\']" missing.'); - } - if (_.isUndefined(opts['endDay'])) { - throw new Error('Required parameter "opts[\'endDay\']" missing.'); - } - if (_.isUndefined(opts['friendlyName'])) { - throw new Error('Required parameter "opts[\'friendlyName\']" missing.'); - } - - var deferred = Q.defer(); - var data = values.of({ - 'StartDay': _.get(opts, 'startDay'), - 'EndDay': _.get(opts, 'endDay'), - 'FriendlyName': _.get(opts, 'friendlyName'), - 'WebhookUrl': _.get(opts, 'webhookUrl'), - 'WebhookMethod': _.get(opts, 'webhookMethod'), - 'Email': _.get(opts, 'email') - }); - - var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); - - promise = promise.then(function(payload) { - deferred.resolve(new ExportCustomJobInstance(this._version, payload)); - }.bind(this)); - - promise.catch(function(error) { - deferred.reject(error); - }); - - if (_.isFunction(callback)) { - deferred.promise.nodeify(callback); - } - - return deferred.promise; - }; - - /* jshint ignore:start */ - /** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.ExportCustomJobList# - * - * @returns Object - */ - /* jshint ignore:end */ - ExportCustomJobListInstance.toJSON = function toJSON() { - return this._solution; - }; - - ExportCustomJobListInstance[util.inspect.custom] = function inspect(depth, - options) { - return util.inspect(this.toJSON(), options); - }; - - return ExportCustomJobListInstance; -}; - - -/* jshint ignore:start */ -/** - * Initialize the ExportCustomJobPage - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportContext.ExportCustomJobPage - * - * @param {BulkExports} version - Version of the resource - * @param {Response} response - Response from the API - * @param {ExportCustomJobSolution} solution - Path solution - * - * @returns ExportCustomJobPage - */ -/* jshint ignore:end */ -ExportCustomJobPage = function ExportCustomJobPage(version, response, solution) - { - // Path Solution - this._solution = solution; - - Page.prototype.constructor.call(this, version, response, this._solution); -}; - -_.extend(ExportCustomJobPage.prototype, Page.prototype); -ExportCustomJobPage.prototype.constructor = ExportCustomJobPage; - -/* jshint ignore:start */ -/** - * Build an instance of ExportCustomJobInstance - * - * @function getInstance - * @memberof Twilio.Preview.BulkExports.ExportContext.ExportCustomJobPage# - * - * @param {ExportCustomJobPayload} payload - Payload response from the API - * - * @returns ExportCustomJobInstance - */ -/* jshint ignore:end */ -ExportCustomJobPage.prototype.getInstance = function getInstance(payload) { - return new ExportCustomJobInstance(this._version, payload, this._solution.resourceType); -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.ExportCustomJobPage# - * - * @returns Object - */ -/* jshint ignore:end */ -ExportCustomJobPage.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - -ExportCustomJobPage.prototype[util.inspect.custom] = function inspect(depth, - options) { - return util.inspect(this.toJSON(), options); -}; - - -/* jshint ignore:start */ -/** - * Initialize the ExportCustomJobContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportContext.ExportCustomJobInstance - * - * @property {string} friendlyName - - * The friendly name specified when creating the job - * @property {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * @property {string} startDay - - * The start day for the custom export specified as a string in the format of yyyy-MM-dd - * @property {string} endDay - - * The end day for the custom export specified as a string in the format of yyyy-MM-dd - * @property {string} webhookUrl - The optional webhook url called on completion - * @property {string} webhookMethod - This is the method used to call the webhook - * @property {string} email - - * The optional email to send the completion notification to - * @property {string} jobSid - - * The unique job_sid returned when the custom export was created. This can be used to look up the status of the job. - * @property {object} details - The details - * - * @param {BulkExports} version - Version of the resource - * @param {ExportCustomJobPayload} payload - The instance payload - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - */ -/* jshint ignore:end */ -ExportCustomJobInstance = function ExportCustomJobInstance(version, payload, - resourceType) { - this._version = version; - - // Marshaled Properties - this.friendlyName = payload.friendly_name; // jshint ignore:line - this.resourceType = payload.resource_type; // jshint ignore:line - this.startDay = payload.start_day; // jshint ignore:line - this.endDay = payload.end_day; // jshint ignore:line - this.webhookUrl = payload.webhook_url; // jshint ignore:line - this.webhookMethod = payload.webhook_method; // jshint ignore:line - this.email = payload.email; // jshint ignore:line - this.jobSid = payload.job_sid; // jshint ignore:line - this.details = payload.details; // jshint ignore:line - - // Context - this._context = undefined; - this._solution = {resourceType: resourceType, }; -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.ExportCustomJobInstance# - * - * @returns Object - */ -/* jshint ignore:end */ -ExportCustomJobInstance.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - -ExportCustomJobInstance.prototype[util.inspect.custom] = function inspect(depth, - options) { - return util.inspect(this.toJSON(), options); -}; - -module.exports = { - ExportCustomJobList: ExportCustomJobList, - ExportCustomJobPage: ExportCustomJobPage, - ExportCustomJobInstance: ExportCustomJobInstance -}; diff --git a/lib/rest/preview/bulk_exports/export/job.d.ts b/lib/rest/preview/bulk_exports/export/job.d.ts deleted file mode 100644 index edec9df8f0..0000000000 --- a/lib/rest/preview/bulk_exports/export/job.d.ts +++ /dev/null @@ -1,163 +0,0 @@ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ - -import BulkExports = require('../../BulkExports'); -import Page = require('../../../../base/Page'); -import Response = require('../../../../http/response'); -import { SerializableClass } from '../../../../interfaces'; - -/** - * Initialize the JobList - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - */ -declare function JobList(version: BulkExports): JobListInstance; - -interface JobListInstance { - /** - * @param sid - sid of instance - */ - (sid: string): JobContext; - /** - * Constructs a job - * - * @param jobSid - The unique string that that we created to identify the Bulk Export job - */ - get(jobSid: string): JobContext; - /** - * Provide a user-friendly representation - */ - toJSON(): any; -} - -interface JobPayload extends JobResource, Page.TwilioResponsePayload { -} - -interface JobResource { - details: object; - email: string; - end_day: string; - friendly_name: string; - job_sid: string; - resource_type: string; - start_day: string; - url: string; - webhook_method: string; - webhook_url: string; -} - -interface JobSolution { -} - - -declare class JobContext { - /** - * Initialize the JobContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param jobSid - The unique string that that we created to identify the Bulk Export job - */ - constructor(version: BulkExports, jobSid: string); - - /** - * fetch a JobInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: JobInstance) => any): Promise; - /** - * remove a JobInstance - * - * @param callback - Callback to handle processed record - */ - remove(callback?: (error: Error | null, items: JobInstance) => any): Promise; - /** - * Provide a user-friendly representation - */ - toJSON(): any; -} - - -declare class JobInstance extends SerializableClass { - /** - * Initialize the JobContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param payload - The instance payload - * @param jobSid - The unique string that that we created to identify the Bulk Export job - */ - constructor(version: BulkExports, payload: JobPayload, jobSid: string); - - private _proxy: JobContext; - details: any; - email: string; - endDay: string; - /** - * fetch a JobInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: JobInstance) => any): Promise; - friendlyName: string; - jobSid: string; - /** - * remove a JobInstance - * - * @param callback - Callback to handle processed record - */ - remove(callback?: (error: Error | null, items: JobInstance) => any): Promise; - resourceType: string; - startDay: string; - /** - * Provide a user-friendly representation - */ - toJSON(): any; - url: string; - webhookMethod: string; - webhookUrl: string; -} - - -declare class JobPage extends Page { - /** - * Initialize the JobPage - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor(version: BulkExports, response: Response, solution: JobSolution); - - /** - * Build an instance of JobInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: JobPayload): JobInstance; - /** - * Provide a user-friendly representation - */ - toJSON(): any; -} - -export { JobContext, JobInstance, JobList, JobListInstance, JobPage, JobPayload, JobResource, JobSolution } diff --git a/lib/rest/preview/bulk_exports/export/job.js b/lib/rest/preview/bulk_exports/export/job.js deleted file mode 100644 index 2646b2e538..0000000000 --- a/lib/rest/preview/bulk_exports/export/job.js +++ /dev/null @@ -1,390 +0,0 @@ -'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 util = require('util'); /* jshint ignore:line */ -var Page = require('../../../../base/Page'); /* jshint ignore:line */ -var values = require('../../../../base/values'); /* jshint ignore:line */ - -var JobList; -var JobPage; -var JobInstance; -var JobContext; - -/* jshint ignore:start */ -/** - * Initialize the JobList - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportContext.JobList - * - * @param {Twilio.Preview.BulkExports} version - Version of the resource - */ -/* jshint ignore:end */ -JobList = function JobList(version) { - /* jshint ignore:start */ - /** - * @function jobs - * @memberof Twilio.Preview.BulkExports.ExportContext# - * - * @param {string} sid - sid of instance - * - * @returns {Twilio.Preview.BulkExports.ExportContext.JobContext} - */ - /* jshint ignore:end */ - function JobListInstance(sid) { - return JobListInstance.get(sid); - } - - JobListInstance._version = version; - // Path Solution - JobListInstance._solution = {}; - /* jshint ignore:start */ - /** - * Constructs a job - * - * @function get - * @memberof Twilio.Preview.BulkExports.ExportContext.JobList# - * - * @param {string} jobSid - - * The unique string that that we created to identify the Bulk Export job - * - * @returns {Twilio.Preview.BulkExports.ExportContext.JobContext} - */ - /* jshint ignore:end */ - JobListInstance.get = function get(jobSid) { - return new JobContext(this._version, jobSid); - }; - - /* jshint ignore:start */ - /** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.JobList# - * - * @returns Object - */ - /* jshint ignore:end */ - JobListInstance.toJSON = function toJSON() { - return this._solution; - }; - - JobListInstance[util.inspect.custom] = function inspect(depth, options) { - return util.inspect(this.toJSON(), options); - }; - - return JobListInstance; -}; - - -/* jshint ignore:start */ -/** - * Initialize the JobPage - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportContext.JobPage - * - * @param {BulkExports} version - Version of the resource - * @param {Response} response - Response from the API - * @param {JobSolution} solution - Path solution - * - * @returns JobPage - */ -/* jshint ignore:end */ -JobPage = function JobPage(version, response, solution) { - // Path Solution - this._solution = solution; - - Page.prototype.constructor.call(this, version, response, this._solution); -}; - -_.extend(JobPage.prototype, Page.prototype); -JobPage.prototype.constructor = JobPage; - -/* jshint ignore:start */ -/** - * Build an instance of JobInstance - * - * @function getInstance - * @memberof Twilio.Preview.BulkExports.ExportContext.JobPage# - * - * @param {JobPayload} payload - Payload response from the API - * - * @returns JobInstance - */ -/* jshint ignore:end */ -JobPage.prototype.getInstance = function getInstance(payload) { - return new JobInstance(this._version, payload); -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.JobPage# - * - * @returns Object - */ -/* jshint ignore:end */ -JobPage.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - -JobPage.prototype[util.inspect.custom] = function inspect(depth, options) { - return util.inspect(this.toJSON(), options); -}; - - -/* jshint ignore:start */ -/** - * Initialize the JobContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportContext.JobInstance - * - * @property {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * @property {string} friendlyName - - * The friendly name specified when creating the job - * @property {object} details - - * This is a list of the completed, pending, or errored dates within the export time range, with one entry for each status with more than one day in that status - * @property {string} startDay - - * The start time for the export specified when creating the job - * @property {string} endDay - - * The end time for the export specified when creating the job - * @property {string} jobSid - The job_sid returned when the export was created - * @property {string} webhookUrl - The optional webhook url called on completion - * @property {string} webhookMethod - This is the method used to call the webhook - * @property {string} email - - * The optional email to send the completion notification to - * @property {string} url - The url - * - * @param {BulkExports} version - Version of the resource - * @param {JobPayload} payload - The instance payload - * @param {sid} jobSid - - * The unique string that that we created to identify the Bulk Export job - */ -/* jshint ignore:end */ -JobInstance = function JobInstance(version, payload, jobSid) { - this._version = version; - - // Marshaled Properties - this.resourceType = payload.resource_type; // jshint ignore:line - this.friendlyName = payload.friendly_name; // jshint ignore:line - this.details = payload.details; // jshint ignore:line - this.startDay = payload.start_day; // jshint ignore:line - this.endDay = payload.end_day; // jshint ignore:line - this.jobSid = payload.job_sid; // jshint ignore:line - this.webhookUrl = payload.webhook_url; // jshint ignore:line - this.webhookMethod = payload.webhook_method; // jshint ignore:line - this.email = payload.email; // jshint ignore:line - this.url = payload.url; // jshint ignore:line - - // Context - this._context = undefined; - this._solution = {jobSid: jobSid || this.jobSid, }; -}; - -Object.defineProperty(JobInstance.prototype, - '_proxy', { - get: function() { - if (!this._context) { - this._context = new JobContext(this._version, this._solution.jobSid); - } - - return this._context; - } -}); - -/* jshint ignore:start */ -/** - * fetch a JobInstance - * - * @function fetch - * @memberof Twilio.Preview.BulkExports.ExportContext.JobInstance# - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed JobInstance - */ -/* jshint ignore:end */ -JobInstance.prototype.fetch = function fetch(callback) { - return this._proxy.fetch(callback); -}; - -/* jshint ignore:start */ -/** - * remove a JobInstance - * - * @function remove - * @memberof Twilio.Preview.BulkExports.ExportContext.JobInstance# - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed JobInstance - */ -/* jshint ignore:end */ -JobInstance.prototype.remove = function remove(callback) { - return this._proxy.remove(callback); -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.JobInstance# - * - * @returns Object - */ -/* jshint ignore:end */ -JobInstance.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - -JobInstance.prototype[util.inspect.custom] = function inspect(depth, options) { - return util.inspect(this.toJSON(), options); -}; - - -/* jshint ignore:start */ -/** - * Initialize the JobContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportContext.JobContext - * - * @param {BulkExports} version - Version of the resource - * @param {sid} jobSid - - * The unique string that that we created to identify the Bulk Export job - */ -/* jshint ignore:end */ -JobContext = function JobContext(version, jobSid) { - this._version = version; - - // Path Solution - this._solution = {jobSid: jobSid, }; - this._uri = `/Exports/Jobs/${jobSid}`; -}; - -/* jshint ignore:start */ -/** - * fetch a JobInstance - * - * @function fetch - * @memberof Twilio.Preview.BulkExports.ExportContext.JobContext# - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed JobInstance - */ -/* jshint ignore:end */ -JobContext.prototype.fetch = function fetch(callback) { - var deferred = Q.defer(); - var promise = this._version.fetch({uri: this._uri, method: 'GET'}); - - promise = promise.then(function(payload) { - deferred.resolve(new JobInstance(this._version, payload, this._solution.jobSid)); - }.bind(this)); - - promise.catch(function(error) { - deferred.reject(error); - }); - - if (_.isFunction(callback)) { - deferred.promise.nodeify(callback); - } - - return deferred.promise; -}; - -/* jshint ignore:start */ -/** - * remove a JobInstance - * - * @function remove - * @memberof Twilio.Preview.BulkExports.ExportContext.JobContext# - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed JobInstance - */ -/* jshint ignore:end */ -JobContext.prototype.remove = function remove(callback) { - var deferred = Q.defer(); - var promise = this._version.remove({uri: this._uri, method: 'DELETE'}); - - promise = promise.then(function(payload) { - deferred.resolve(payload); - }.bind(this)); - - promise.catch(function(error) { - deferred.reject(error); - }); - - if (_.isFunction(callback)) { - deferred.promise.nodeify(callback); - } - - return deferred.promise; -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportContext.JobContext# - * - * @returns Object - */ -/* jshint ignore:end */ -JobContext.prototype.toJSON = function toJSON() { - return this._solution; -}; - -JobContext.prototype[util.inspect.custom] = function inspect(depth, options) { - return util.inspect(this.toJSON(), options); -}; - -module.exports = { - JobList: JobList, - JobPage: JobPage, - JobInstance: JobInstance, - JobContext: JobContext -}; diff --git a/lib/rest/preview/bulk_exports/exportConfiguration.d.ts b/lib/rest/preview/bulk_exports/exportConfiguration.d.ts deleted file mode 100644 index dc53c256cc..0000000000 --- a/lib/rest/preview/bulk_exports/exportConfiguration.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ - -import BulkExports = require('../BulkExports'); -import Page = require('../../../base/Page'); -import Response = require('../../../http/response'); -import { SerializableClass } from '../../../interfaces'; - -/** - * Initialize the ExportConfigurationList - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - */ -declare function ExportConfigurationList(version: BulkExports): ExportConfigurationListInstance; - -/** - * Options to pass to update - * - * @property enabled - Whether files are automatically generated - * @property webhookMethod - Whether to GET or POST to the webhook url - * @property webhookUrl - URL targeted at export - */ -interface ExportConfigurationInstanceUpdateOptions { - enabled?: boolean; - webhookMethod?: string; - webhookUrl?: string; -} - -interface ExportConfigurationListInstance { - /** - * @param sid - sid of instance - */ - (sid: string): ExportConfigurationContext; - /** - * Constructs a export_configuration - * - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants - */ - get(resourceType: string): ExportConfigurationContext; - /** - * Provide a user-friendly representation - */ - toJSON(): any; -} - -interface ExportConfigurationPayload extends ExportConfigurationResource, Page.TwilioResponsePayload { -} - -interface ExportConfigurationResource { - enabled: boolean; - resource_type: string; - url: string; - webhook_method: string; - webhook_url: string; -} - -interface ExportConfigurationSolution { -} - - -declare class ExportConfigurationContext { - /** - * Initialize the ExportConfigurationContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants - */ - constructor(version: BulkExports, resourceType: string); - - /** - * fetch a ExportConfigurationInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: ExportConfigurationInstance) => any): Promise; - /** - * Provide a user-friendly representation - */ - toJSON(): any; - /** - * update a ExportConfigurationInstance - * - * @param callback - Callback to handle processed record - */ - update(callback?: (error: Error | null, items: ExportConfigurationInstance) => any): Promise; - /** - * update a ExportConfigurationInstance - * - * @param opts - Options for request - * @param callback - Callback to handle processed record - */ - update(opts?: ExportConfigurationInstanceUpdateOptions, callback?: (error: Error | null, items: ExportConfigurationInstance) => any): Promise; -} - - -declare class ExportConfigurationInstance extends SerializableClass { - /** - * Initialize the ExportConfigurationContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param payload - The instance payload - * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants - */ - constructor(version: BulkExports, payload: ExportConfigurationPayload, resourceType: string); - - private _proxy: ExportConfigurationContext; - enabled: boolean; - /** - * fetch a ExportConfigurationInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: ExportConfigurationInstance) => any): Promise; - resourceType: string; - /** - * Provide a user-friendly representation - */ - toJSON(): any; - /** - * update a ExportConfigurationInstance - * - * @param callback - Callback to handle processed record - */ - update(callback?: (error: Error | null, items: ExportConfigurationInstance) => any): Promise; - /** - * update a ExportConfigurationInstance - * - * @param opts - Options for request - * @param callback - Callback to handle processed record - */ - update(opts?: ExportConfigurationInstanceUpdateOptions, callback?: (error: Error | null, items: ExportConfigurationInstance) => any): Promise; - url: string; - webhookMethod: string; - webhookUrl: string; -} - - -declare class ExportConfigurationPage extends Page { - /** - * Initialize the ExportConfigurationPage - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor(version: BulkExports, response: Response, solution: ExportConfigurationSolution); - - /** - * Build an instance of ExportConfigurationInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: ExportConfigurationPayload): ExportConfigurationInstance; - /** - * Provide a user-friendly representation - */ - toJSON(): any; -} - -export { ExportConfigurationContext, ExportConfigurationInstance, ExportConfigurationInstanceUpdateOptions, ExportConfigurationList, ExportConfigurationListInstance, ExportConfigurationPage, ExportConfigurationPayload, ExportConfigurationResource, ExportConfigurationSolution } diff --git a/lib/rest/preview/bulk_exports/exportConfiguration.js b/lib/rest/preview/bulk_exports/exportConfiguration.js deleted file mode 100644 index ea8f234667..0000000000 --- a/lib/rest/preview/bulk_exports/exportConfiguration.js +++ /dev/null @@ -1,411 +0,0 @@ -'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 util = require('util'); /* jshint ignore:line */ -var Page = require('../../../base/Page'); /* jshint ignore:line */ -var serialize = require('../../../base/serialize'); /* jshint ignore:line */ -var values = require('../../../base/values'); /* jshint ignore:line */ - -var ExportConfigurationList; -var ExportConfigurationPage; -var ExportConfigurationInstance; -var ExportConfigurationContext; - -/* jshint ignore:start */ -/** - * Initialize the ExportConfigurationList - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportConfigurationList - * - * @param {Twilio.Preview.BulkExports} version - Version of the resource - */ -/* jshint ignore:end */ -ExportConfigurationList = function ExportConfigurationList(version) { - /* jshint ignore:start */ - /** - * @function exportConfiguration - * @memberof Twilio.Preview.BulkExports# - * - * @param {string} sid - sid of instance - * - * @returns {Twilio.Preview.BulkExports.ExportConfigurationContext} - */ - /* jshint ignore:end */ - function ExportConfigurationListInstance(sid) { - return ExportConfigurationListInstance.get(sid); - } - - ExportConfigurationListInstance._version = version; - // Path Solution - ExportConfigurationListInstance._solution = {}; - /* jshint ignore:start */ - /** - * Constructs a export_configuration - * - * @function get - * @memberof Twilio.Preview.BulkExports.ExportConfigurationList# - * - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * - * @returns {Twilio.Preview.BulkExports.ExportConfigurationContext} - */ - /* jshint ignore:end */ - ExportConfigurationListInstance.get = function get(resourceType) { - return new ExportConfigurationContext(this._version, resourceType); - }; - - /* jshint ignore:start */ - /** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportConfigurationList# - * - * @returns Object - */ - /* jshint ignore:end */ - ExportConfigurationListInstance.toJSON = function toJSON() { - return this._solution; - }; - - ExportConfigurationListInstance[util.inspect.custom] = function inspect(depth, - options) { - return util.inspect(this.toJSON(), options); - }; - - return ExportConfigurationListInstance; -}; - - -/* jshint ignore:start */ -/** - * Initialize the ExportConfigurationPage - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportConfigurationPage - * - * @param {BulkExports} version - Version of the resource - * @param {Response} response - Response from the API - * @param {ExportConfigurationSolution} solution - Path solution - * - * @returns ExportConfigurationPage - */ -/* jshint ignore:end */ -ExportConfigurationPage = function ExportConfigurationPage(version, response, - solution) { - // Path Solution - this._solution = solution; - - Page.prototype.constructor.call(this, version, response, this._solution); -}; - -_.extend(ExportConfigurationPage.prototype, Page.prototype); -ExportConfigurationPage.prototype.constructor = ExportConfigurationPage; - -/* jshint ignore:start */ -/** - * Build an instance of ExportConfigurationInstance - * - * @function getInstance - * @memberof Twilio.Preview.BulkExports.ExportConfigurationPage# - * - * @param {ExportConfigurationPayload} payload - Payload response from the API - * - * @returns ExportConfigurationInstance - */ -/* jshint ignore:end */ -ExportConfigurationPage.prototype.getInstance = function getInstance(payload) { - return new ExportConfigurationInstance(this._version, payload); -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportConfigurationPage# - * - * @returns Object - */ -/* jshint ignore:end */ -ExportConfigurationPage.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - -ExportConfigurationPage.prototype[util.inspect.custom] = function inspect(depth, - options) { - return util.inspect(this.toJSON(), options); -}; - - -/* jshint ignore:start */ -/** - * Initialize the ExportConfigurationContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportConfigurationInstance - * - * @property {boolean} enabled - Whether files are automatically generated - * @property {string} webhookUrl - URL targeted at export - * @property {string} webhookMethod - Whether to GET or POST to the webhook url - * @property {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - * @property {string} url - The URL of this resource. - * - * @param {BulkExports} version - Version of the resource - * @param {ExportConfigurationPayload} payload - The instance payload - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - */ -/* jshint ignore:end */ -ExportConfigurationInstance = function ExportConfigurationInstance(version, - payload, resourceType) { - this._version = version; - - // Marshaled Properties - this.enabled = payload.enabled; // jshint ignore:line - this.webhookUrl = payload.webhook_url; // jshint ignore:line - this.webhookMethod = payload.webhook_method; // jshint ignore:line - this.resourceType = payload.resource_type; // jshint ignore:line - this.url = payload.url; // jshint ignore:line - - // Context - this._context = undefined; - this._solution = {resourceType: resourceType || this.resourceType, }; -}; - -Object.defineProperty(ExportConfigurationInstance.prototype, - '_proxy', { - get: function() { - if (!this._context) { - this._context = new ExportConfigurationContext(this._version, this._solution.resourceType); - } - - return this._context; - } -}); - -/* jshint ignore:start */ -/** - * fetch a ExportConfigurationInstance - * - * @function fetch - * @memberof Twilio.Preview.BulkExports.ExportConfigurationInstance# - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ExportConfigurationInstance - */ -/* jshint ignore:end */ -ExportConfigurationInstance.prototype.fetch = function fetch(callback) { - return this._proxy.fetch(callback); -}; - -/* jshint ignore:start */ -/** - * update a ExportConfigurationInstance - * - * @function update - * @memberof Twilio.Preview.BulkExports.ExportConfigurationInstance# - * - * @param {object} [opts] - Options for request - * @param {boolean} [opts.enabled] - Whether files are automatically generated - * @param {string} [opts.webhookUrl] - URL targeted at export - * @param {string} [opts.webhookMethod] - Whether to GET or POST to the webhook url - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ExportConfigurationInstance - */ -/* jshint ignore:end */ -ExportConfigurationInstance.prototype.update = function update(opts, callback) { - return this._proxy.update(opts, callback); -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportConfigurationInstance# - * - * @returns Object - */ -/* jshint ignore:end */ -ExportConfigurationInstance.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - -ExportConfigurationInstance.prototype[util.inspect.custom] = function - inspect(depth, options) { - return util.inspect(this.toJSON(), options); -}; - - -/* jshint ignore:start */ -/** - * Initialize the ExportConfigurationContext - * - * PLEASE NOTE that this class contains preview products that are subject to - * change. Use them with caution. If you currently do not have developer preview - * access, please contact help@twilio.com. - * - * @constructor Twilio.Preview.BulkExports.ExportConfigurationContext - * - * @param {BulkExports} version - Version of the resource - * @param {string} resourceType - - * The type of communication – Messages, Calls, Conferences, and Participants - */ -/* jshint ignore:end */ -ExportConfigurationContext = function ExportConfigurationContext(version, - resourceType) { - this._version = version; - - // Path Solution - this._solution = {resourceType: resourceType, }; - this._uri = `/Exports/${resourceType}/Configuration`; -}; - -/* jshint ignore:start */ -/** - * fetch a ExportConfigurationInstance - * - * @function fetch - * @memberof Twilio.Preview.BulkExports.ExportConfigurationContext# - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ExportConfigurationInstance - */ -/* jshint ignore:end */ -ExportConfigurationContext.prototype.fetch = function fetch(callback) { - var deferred = Q.defer(); - var promise = this._version.fetch({uri: this._uri, method: 'GET'}); - - promise = promise.then(function(payload) { - deferred.resolve(new ExportConfigurationInstance( - this._version, - payload, - this._solution.resourceType - )); - }.bind(this)); - - promise.catch(function(error) { - deferred.reject(error); - }); - - if (_.isFunction(callback)) { - deferred.promise.nodeify(callback); - } - - return deferred.promise; -}; - -/* jshint ignore:start */ -/** - * update a ExportConfigurationInstance - * - * @function update - * @memberof Twilio.Preview.BulkExports.ExportConfigurationContext# - * - * @param {object} [opts] - Options for request - * @param {boolean} [opts.enabled] - Whether files are automatically generated - * @param {string} [opts.webhookUrl] - URL targeted at export - * @param {string} [opts.webhookMethod] - Whether to GET or POST to the webhook url - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ExportConfigurationInstance - */ -/* jshint ignore:end */ -ExportConfigurationContext.prototype.update = function update(opts, callback) { - if (_.isFunction(opts)) { - callback = opts; - opts = {}; - } - opts = opts || {}; - - var deferred = Q.defer(); - var data = values.of({ - 'Enabled': serialize.bool(_.get(opts, 'enabled')), - 'WebhookUrl': _.get(opts, 'webhookUrl'), - 'WebhookMethod': _.get(opts, 'webhookMethod') - }); - - var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); - - promise = promise.then(function(payload) { - deferred.resolve(new ExportConfigurationInstance( - this._version, - payload, - this._solution.resourceType - )); - }.bind(this)); - - promise.catch(function(error) { - deferred.reject(error); - }); - - if (_.isFunction(callback)) { - deferred.promise.nodeify(callback); - } - - return deferred.promise; -}; - -/* jshint ignore:start */ -/** - * Provide a user-friendly representation - * - * @function toJSON - * @memberof Twilio.Preview.BulkExports.ExportConfigurationContext# - * - * @returns Object - */ -/* jshint ignore:end */ -ExportConfigurationContext.prototype.toJSON = function toJSON() { - return this._solution; -}; - -ExportConfigurationContext.prototype[util.inspect.custom] = function - inspect(depth, options) { - return util.inspect(this.toJSON(), options); -}; - -module.exports = { - ExportConfigurationList: ExportConfigurationList, - ExportConfigurationPage: ExportConfigurationPage, - ExportConfigurationInstance: ExportConfigurationInstance, - ExportConfigurationContext: ExportConfigurationContext -}; diff --git a/lib/rest/routes/V2.d.ts b/lib/rest/routes/V2.d.ts new file mode 100644 index 0000000000..1c6044551f --- /dev/null +++ b/lib/rest/routes/V2.d.ts @@ -0,0 +1,31 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Routes = require('../Routes'); +import Version = require('../../base/Version'); +import { PhoneNumberList } from './v2/phoneNumber'; +import { PhoneNumberListInstance } from './v2/phoneNumber'; +import { SipDomainList } from './v2/sipDomain'; +import { SipDomainListInstance } from './v2/sipDomain'; +import { TrunkList } from './v2/trunk'; +import { TrunkListInstance } from './v2/trunk'; + + +declare class V2 extends Version { + /** + * Initialize the V2 version of Routes + * + * @param domain - The twilio domain + */ + constructor(domain: Routes); + + readonly phoneNumbers: PhoneNumberListInstance; + readonly sipDomains: SipDomainListInstance; + readonly trunks: TrunkListInstance; +} + +export = V2; diff --git a/lib/rest/routes/V2.js b/lib/rest/routes/V2.js new file mode 100644 index 0000000000..49b1550434 --- /dev/null +++ b/lib/rest/routes/V2.js @@ -0,0 +1,69 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var _ = require('lodash'); /* jshint ignore:line */ +var PhoneNumberList = require('./v2/phoneNumber').PhoneNumberList; +var SipDomainList = require('./v2/sipDomain').SipDomainList; +var TrunkList = require('./v2/trunk').TrunkList; +var Version = require('../../base/Version'); /* jshint ignore:line */ + + +/* jshint ignore:start */ +/** + * Initialize the V2 version of Routes + * + * @constructor Twilio.Routes.V2 + * + * @property {Twilio.Routes.V2.PhoneNumberList} phoneNumbers - + * phoneNumbers resource + * @property {Twilio.Routes.V2.SipDomainList} sipDomains - sipDomains resource + * @property {Twilio.Routes.V2.TrunkList} trunks - trunks resource + * + * @param {Twilio.Routes} domain - The twilio domain + */ +/* jshint ignore:end */ +function V2(domain) { + Version.prototype.constructor.call(this, domain, 'v2'); + + // Resources + this._phoneNumbers = undefined; + this._sipDomains = undefined; + this._trunks = undefined; +} + +_.extend(V2.prototype, Version.prototype); +V2.prototype.constructor = V2; + +Object.defineProperty(V2.prototype, + 'phoneNumbers', { + get: function() { + this._phoneNumbers = this._phoneNumbers || new PhoneNumberList(this); + return this._phoneNumbers; + } +}); + +Object.defineProperty(V2.prototype, + 'sipDomains', { + get: function() { + this._sipDomains = this._sipDomains || new SipDomainList(this); + return this._sipDomains; + } +}); + +Object.defineProperty(V2.prototype, + 'trunks', { + get: function() { + this._trunks = this._trunks || new TrunkList(this); + return this._trunks; + } +}); + +module.exports = V2; diff --git a/lib/rest/routes/v2/phoneNumber.d.ts b/lib/rest/routes/v2/phoneNumber.d.ts new file mode 100644 index 0000000000..7033d0ea10 --- /dev/null +++ b/lib/rest/routes/v2/phoneNumber.d.ts @@ -0,0 +1,193 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V2 = require('../V2'); +import { SerializableClass } from '../../../interfaces'; + +/** + * Initialize the PhoneNumberList + * + * @param version - Version of the resource + */ +declare function PhoneNumberList(version: V2): PhoneNumberListInstance; + +/** + * Options to pass to create + * + * @property friendlyName - A human readable description of this resource. + * @property voiceRegion - The Inbound Processing Region used for this phone number for voice + */ +interface PhoneNumberInstanceCreateOptions { + friendlyName?: string; + voiceRegion?: string; +} + +/** + * Options to pass to update + * + * @property friendlyName - A human readable description of this resource. + * @property voiceRegion - The Inbound Processing Region used for this phone number for voice + */ +interface PhoneNumberInstanceUpdateOptions { + friendlyName: string; + voiceRegion: string; +} + +interface PhoneNumberListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): PhoneNumberContext; + /** + * Constructs a phone_number + * + * @param phoneNumber - The phone number + */ + get(phoneNumber: string): PhoneNumberContext; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +interface PhoneNumberPayload extends PhoneNumberResource, Page.TwilioResponsePayload { +} + +interface PhoneNumberResource { + account_sid: string; + date_created: Date; + date_updated: Date; + friendly_name: string; + phone_number: string; + sid: string; + url: string; + voice_region: string; +} + +interface PhoneNumberSolution { +} + + +declare class PhoneNumberContext { + /** + * Initialize the PhoneNumberContext + * + * @param version - Version of the resource + * @param phoneNumber - The phone number + */ + constructor(version: V2, phoneNumber: string); + + /** + * create a PhoneNumberInstance + * + * @param callback - Callback to handle processed record + */ + create(callback?: (error: Error | null, item: PhoneNumberInstance) => any): Promise; + /** + * create a PhoneNumberInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts?: PhoneNumberInstanceCreateOptions, callback?: (error: Error | null, item: PhoneNumberInstance) => any): Promise; + /** + * fetch a PhoneNumberInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: PhoneNumberInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a PhoneNumberInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts: PhoneNumberInstanceUpdateOptions, callback?: (error: Error | null, items: PhoneNumberInstance) => any): Promise; +} + + +declare class PhoneNumberInstance extends SerializableClass { + /** + * Initialize the PhoneNumberContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param phoneNumber - The phone number + */ + constructor(version: V2, payload: PhoneNumberPayload, phoneNumber: string); + + private _proxy: PhoneNumberContext; + accountSid: string; + /** + * create a PhoneNumberInstance + * + * @param callback - Callback to handle processed record + */ + create(callback?: (error: Error | null, items: PhoneNumberInstance) => any): Promise; + /** + * create a PhoneNumberInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts?: PhoneNumberInstanceCreateOptions, callback?: (error: Error | null, items: PhoneNumberInstance) => any): Promise; + dateCreated: Date; + dateUpdated: Date; + /** + * fetch a PhoneNumberInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: PhoneNumberInstance) => any): Promise; + friendlyName: string; + phoneNumber: string; + sid: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a PhoneNumberInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts: PhoneNumberInstanceUpdateOptions, callback?: (error: Error | null, items: PhoneNumberInstance) => any): Promise; + url: string; + voiceRegion: string; +} + + +declare class PhoneNumberPage extends Page { + /** + * Initialize the PhoneNumberPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V2, response: Response, solution: PhoneNumberSolution); + + /** + * Build an instance of PhoneNumberInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: PhoneNumberPayload): PhoneNumberInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { PhoneNumberContext, PhoneNumberInstance, PhoneNumberInstanceCreateOptions, PhoneNumberInstanceUpdateOptions, PhoneNumberList, PhoneNumberListInstance, PhoneNumberPage, PhoneNumberPayload, PhoneNumberResource, PhoneNumberSolution } diff --git a/lib/rest/routes/v2/phoneNumber.js b/lib/rest/routes/v2/phoneNumber.js new file mode 100644 index 0000000000..467eaa0377 --- /dev/null +++ b/lib/rest/routes/v2/phoneNumber.js @@ -0,0 +1,466 @@ +'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 util = require('util'); /* jshint ignore:line */ +var Page = require('../../../base/Page'); /* jshint ignore:line */ +var deserialize = require( + '../../../base/deserialize'); /* jshint ignore:line */ +var values = require('../../../base/values'); /* jshint ignore:line */ + +var PhoneNumberList; +var PhoneNumberPage; +var PhoneNumberInstance; +var PhoneNumberContext; + +/* jshint ignore:start */ +/** + * Initialize the PhoneNumberList + * + * @constructor Twilio.Routes.V2.PhoneNumberList + * + * @param {Twilio.Routes.V2} version - Version of the resource + */ +/* jshint ignore:end */ +PhoneNumberList = function PhoneNumberList(version) { + /* jshint ignore:start */ + /** + * @function phoneNumbers + * @memberof Twilio.Routes.V2# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Routes.V2.PhoneNumberContext} + */ + /* jshint ignore:end */ + function PhoneNumberListInstance(sid) { + return PhoneNumberListInstance.get(sid); + } + + PhoneNumberListInstance._version = version; + // Path Solution + PhoneNumberListInstance._solution = {}; + /* jshint ignore:start */ + /** + * Constructs a phone_number + * + * @function get + * @memberof Twilio.Routes.V2.PhoneNumberList# + * + * @param {string} phoneNumber - The phone number + * + * @returns {Twilio.Routes.V2.PhoneNumberContext} + */ + /* jshint ignore:end */ + PhoneNumberListInstance.get = function get(phoneNumber) { + return new PhoneNumberContext(this._version, phoneNumber); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.PhoneNumberList# + * + * @returns Object + */ + /* jshint ignore:end */ + PhoneNumberListInstance.toJSON = function toJSON() { + return this._solution; + }; + + PhoneNumberListInstance[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); + }; + + return PhoneNumberListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the PhoneNumberPage + * + * @constructor Twilio.Routes.V2.PhoneNumberPage + * + * @param {V2} version - Version of the resource + * @param {Response} response - Response from the API + * @param {PhoneNumberSolution} solution - Path solution + * + * @returns PhoneNumberPage + */ +/* jshint ignore:end */ +PhoneNumberPage = function PhoneNumberPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(PhoneNumberPage.prototype, Page.prototype); +PhoneNumberPage.prototype.constructor = PhoneNumberPage; + +/* jshint ignore:start */ +/** + * Build an instance of PhoneNumberInstance + * + * @function getInstance + * @memberof Twilio.Routes.V2.PhoneNumberPage# + * + * @param {PhoneNumberPayload} payload - Payload response from the API + * + * @returns PhoneNumberInstance + */ +/* jshint ignore:end */ +PhoneNumberPage.prototype.getInstance = function getInstance(payload) { + return new PhoneNumberInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.PhoneNumberPage# + * + * @returns Object + */ +/* jshint ignore:end */ +PhoneNumberPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +PhoneNumberPage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the PhoneNumberContext + * + * @constructor Twilio.Routes.V2.PhoneNumberInstance + * + * @property {string} phoneNumber - The phone number + * @property {string} url - The absolute URL of the resource + * @property {string} sid - + * A string that uniquely identifies the Inbound Processing Region assignments for this phone number. + * @property {string} accountSid - Account Sid. + * @property {string} friendlyName - + * A human readable description of the Inbound Processing Region assignments for this phone number. + * @property {string} voiceRegion - + * The Inbound Processing Region used for this phone number for voice. + * @property {Date} dateCreated - + * The date that this phone number was assigned an Inbound Processing Region. + * @property {Date} dateUpdated - + * The date that the Inbound Processing Region was updated for this phone number. + * + * @param {V2} version - Version of the resource + * @param {PhoneNumberPayload} payload - The instance payload + * @param {string} phoneNumber - The phone number + */ +/* jshint ignore:end */ +PhoneNumberInstance = function PhoneNumberInstance(version, payload, + phoneNumber) { + this._version = version; + + // Marshaled Properties + this.phoneNumber = payload.phone_number; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.voiceRegion = payload.voice_region; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {phoneNumber: phoneNumber || this.phoneNumber, }; +}; + +Object.defineProperty(PhoneNumberInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new PhoneNumberContext(this._version, this._solution.phoneNumber); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * create a PhoneNumberInstance + * + * @function create + * @memberof Twilio.Routes.V2.PhoneNumberInstance# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - + * The Inbound Processing Region used for this phone number for voice + * @param {string} [opts.friendlyName] - + * A human readable description of this resource. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed PhoneNumberInstance + */ +/* jshint ignore:end */ +PhoneNumberInstance.prototype.create = function create(opts, callback) { + return this._proxy.create(opts, callback); +}; + +/* jshint ignore:start */ +/** + * update a PhoneNumberInstance + * + * @function update + * @memberof Twilio.Routes.V2.PhoneNumberInstance# + * + * @param {object} opts - Options for request + * @param {string} opts.voiceRegion - + * The Inbound Processing Region used for this phone number for voice + * @param {string} opts.friendlyName - + * A human readable description of this resource. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed PhoneNumberInstance + */ +/* jshint ignore:end */ +PhoneNumberInstance.prototype.update = function update(opts, callback) { + return this._proxy.update(opts, callback); +}; + +/* jshint ignore:start */ +/** + * fetch a PhoneNumberInstance + * + * @function fetch + * @memberof Twilio.Routes.V2.PhoneNumberInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed PhoneNumberInstance + */ +/* jshint ignore:end */ +PhoneNumberInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.PhoneNumberInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +PhoneNumberInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +PhoneNumberInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the PhoneNumberContext + * + * @constructor Twilio.Routes.V2.PhoneNumberContext + * + * @param {V2} version - Version of the resource + * @param {string} phoneNumber - The phone number + */ +/* jshint ignore:end */ +PhoneNumberContext = function PhoneNumberContext(version, phoneNumber) { + this._version = version; + + // Path Solution + this._solution = {phoneNumber: phoneNumber, }; + this._uri = `/PhoneNumbers/${phoneNumber}`; +}; + +/* jshint ignore:start */ +/** + * create a PhoneNumberInstance + * + * @function create + * @memberof Twilio.Routes.V2.PhoneNumberContext# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - + * The Inbound Processing Region used for this phone number for voice + * @param {string} [opts.friendlyName] - + * A human readable description of this resource. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed PhoneNumberInstance + */ +/* jshint ignore:end */ +PhoneNumberContext.prototype.create = function create(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'VoiceRegion': _.get(opts, 'voiceRegion'), + 'FriendlyName': _.get(opts, 'friendlyName') + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new PhoneNumberInstance(this._version, payload, this._solution.phoneNumber)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * update a PhoneNumberInstance + * + * @function update + * @memberof Twilio.Routes.V2.PhoneNumberContext# + * + * @param {object} opts - Options for request + * @param {string} opts.voiceRegion - + * The Inbound Processing Region used for this phone number for voice + * @param {string} opts.friendlyName - + * A human readable description of this resource. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed PhoneNumberInstance + */ +/* jshint ignore:end */ +PhoneNumberContext.prototype.update = function update(opts, callback) { + if (_.isUndefined(opts)) { + throw new Error('Required parameter "opts" missing.'); + } + if (_.isUndefined(opts['voiceRegion'])) { + throw new Error('Required parameter "opts[\'voiceRegion\']" missing.'); + } + if (_.isUndefined(opts['friendlyName'])) { + throw new Error('Required parameter "opts[\'friendlyName\']" missing.'); + } + + var deferred = Q.defer(); + var data = values.of({ + 'VoiceRegion': _.get(opts, 'voiceRegion'), + 'FriendlyName': _.get(opts, 'friendlyName') + }); + + var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new PhoneNumberInstance(this._version, payload, this._solution.phoneNumber)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * fetch a PhoneNumberInstance + * + * @function fetch + * @memberof Twilio.Routes.V2.PhoneNumberContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed PhoneNumberInstance + */ +/* jshint ignore:end */ +PhoneNumberContext.prototype.fetch = function fetch(callback) { + var deferred = Q.defer(); + var promise = this._version.fetch({uri: this._uri, method: 'GET'}); + + promise = promise.then(function(payload) { + deferred.resolve(new PhoneNumberInstance(this._version, payload, this._solution.phoneNumber)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.PhoneNumberContext# + * + * @returns Object + */ +/* jshint ignore:end */ +PhoneNumberContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +PhoneNumberContext.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + PhoneNumberList: PhoneNumberList, + PhoneNumberPage: PhoneNumberPage, + PhoneNumberInstance: PhoneNumberInstance, + PhoneNumberContext: PhoneNumberContext +}; diff --git a/lib/rest/routes/v2/sipDomain.d.ts b/lib/rest/routes/v2/sipDomain.d.ts new file mode 100644 index 0000000000..28915b25d5 --- /dev/null +++ b/lib/rest/routes/v2/sipDomain.d.ts @@ -0,0 +1,205 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V2 = require('../V2'); +import { SerializableClass } from '../../../interfaces'; + +/** + * Initialize the SipDomainList + * + * @param version - Version of the resource + */ +declare function SipDomainList(version: V2): SipDomainListInstance; + +/** + * Options to pass to create + * + * @property friendlyName - The friendly_name + * @property voiceRegion - The voice_region + */ +interface SipDomainInstanceCreateOptions { + friendlyName?: string; + voiceRegion?: string; +} + +/** + * Options to pass to update + * + * @property friendlyName - The friendly_name + * @property voiceRegion - The voice_region + */ +interface SipDomainInstanceUpdateOptions { + friendlyName?: string; + voiceRegion?: string; +} + +interface SipDomainListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): SipDomainContext; + /** + * Constructs a sip_domain + * + * @param sipDomain - The sip_domain + */ + get(sipDomain: string): SipDomainContext; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +interface SipDomainPayload extends SipDomainResource, Page.TwilioResponsePayload { +} + +interface SipDomainResource { + account_sid: string; + date_created: Date; + date_updated: Date; + friendly_name: string; + sid: string; + sip_domain: string; + url: string; + voice_region: string; +} + +interface SipDomainSolution { +} + + +declare class SipDomainContext { + /** + * Initialize the SipDomainContext + * + * @param version - Version of the resource + * @param sipDomain - The sip_domain + */ + constructor(version: V2, sipDomain: string); + + /** + * create a SipDomainInstance + * + * @param callback - Callback to handle processed record + */ + create(callback?: (error: Error | null, item: SipDomainInstance) => any): Promise; + /** + * create a SipDomainInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts?: SipDomainInstanceCreateOptions, callback?: (error: Error | null, item: SipDomainInstance) => any): Promise; + /** + * fetch a SipDomainInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: SipDomainInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a SipDomainInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: SipDomainInstance) => any): Promise; + /** + * update a SipDomainInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: SipDomainInstanceUpdateOptions, callback?: (error: Error | null, items: SipDomainInstance) => any): Promise; +} + + +declare class SipDomainInstance extends SerializableClass { + /** + * Initialize the SipDomainContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param sipDomain - The sip_domain + */ + constructor(version: V2, payload: SipDomainPayload, sipDomain: string); + + private _proxy: SipDomainContext; + accountSid: string; + /** + * create a SipDomainInstance + * + * @param callback - Callback to handle processed record + */ + create(callback?: (error: Error | null, items: SipDomainInstance) => any): Promise; + /** + * create a SipDomainInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts?: SipDomainInstanceCreateOptions, callback?: (error: Error | null, items: SipDomainInstance) => any): Promise; + dateCreated: Date; + dateUpdated: Date; + /** + * fetch a SipDomainInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: SipDomainInstance) => any): Promise; + friendlyName: string; + sid: string; + sipDomain: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a SipDomainInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: SipDomainInstance) => any): Promise; + /** + * update a SipDomainInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: SipDomainInstanceUpdateOptions, callback?: (error: Error | null, items: SipDomainInstance) => any): Promise; + url: string; + voiceRegion: string; +} + + +declare class SipDomainPage extends Page { + /** + * Initialize the SipDomainPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V2, response: Response, solution: SipDomainSolution); + + /** + * Build an instance of SipDomainInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: SipDomainPayload): SipDomainInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { SipDomainContext, SipDomainInstance, SipDomainInstanceCreateOptions, SipDomainInstanceUpdateOptions, SipDomainList, SipDomainListInstance, SipDomainPage, SipDomainPayload, SipDomainResource, SipDomainSolution } diff --git a/lib/rest/routes/v2/sipDomain.js b/lib/rest/routes/v2/sipDomain.js new file mode 100644 index 0000000000..84e90cbd8b --- /dev/null +++ b/lib/rest/routes/v2/sipDomain.js @@ -0,0 +1,447 @@ +'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 util = require('util'); /* jshint ignore:line */ +var Page = require('../../../base/Page'); /* jshint ignore:line */ +var deserialize = require( + '../../../base/deserialize'); /* jshint ignore:line */ +var values = require('../../../base/values'); /* jshint ignore:line */ + +var SipDomainList; +var SipDomainPage; +var SipDomainInstance; +var SipDomainContext; + +/* jshint ignore:start */ +/** + * Initialize the SipDomainList + * + * @constructor Twilio.Routes.V2.SipDomainList + * + * @param {Twilio.Routes.V2} version - Version of the resource + */ +/* jshint ignore:end */ +SipDomainList = function SipDomainList(version) { + /* jshint ignore:start */ + /** + * @function sipDomains + * @memberof Twilio.Routes.V2# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Routes.V2.SipDomainContext} + */ + /* jshint ignore:end */ + function SipDomainListInstance(sid) { + return SipDomainListInstance.get(sid); + } + + SipDomainListInstance._version = version; + // Path Solution + SipDomainListInstance._solution = {}; + /* jshint ignore:start */ + /** + * Constructs a sip_domain + * + * @function get + * @memberof Twilio.Routes.V2.SipDomainList# + * + * @param {string} sipDomain - The sip_domain + * + * @returns {Twilio.Routes.V2.SipDomainContext} + */ + /* jshint ignore:end */ + SipDomainListInstance.get = function get(sipDomain) { + return new SipDomainContext(this._version, sipDomain); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.SipDomainList# + * + * @returns Object + */ + /* jshint ignore:end */ + SipDomainListInstance.toJSON = function toJSON() { + return this._solution; + }; + + SipDomainListInstance[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return SipDomainListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the SipDomainPage + * + * @constructor Twilio.Routes.V2.SipDomainPage + * + * @param {V2} version - Version of the resource + * @param {Response} response - Response from the API + * @param {SipDomainSolution} solution - Path solution + * + * @returns SipDomainPage + */ +/* jshint ignore:end */ +SipDomainPage = function SipDomainPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(SipDomainPage.prototype, Page.prototype); +SipDomainPage.prototype.constructor = SipDomainPage; + +/* jshint ignore:start */ +/** + * Build an instance of SipDomainInstance + * + * @function getInstance + * @memberof Twilio.Routes.V2.SipDomainPage# + * + * @param {SipDomainPayload} payload - Payload response from the API + * + * @returns SipDomainInstance + */ +/* jshint ignore:end */ +SipDomainPage.prototype.getInstance = function getInstance(payload) { + return new SipDomainInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.SipDomainPage# + * + * @returns Object + */ +/* jshint ignore:end */ +SipDomainPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +SipDomainPage.prototype[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the SipDomainContext + * + * @constructor Twilio.Routes.V2.SipDomainInstance + * + * @property {string} sipDomain - The sip_domain + * @property {string} url - The url + * @property {string} sid - The sid + * @property {string} accountSid - The account_sid + * @property {string} friendlyName - The friendly_name + * @property {string} voiceRegion - The voice_region + * @property {Date} dateCreated - The date_created + * @property {Date} dateUpdated - The date_updated + * + * @param {V2} version - Version of the resource + * @param {SipDomainPayload} payload - The instance payload + * @param {string} sipDomain - The sip_domain + */ +/* jshint ignore:end */ +SipDomainInstance = function SipDomainInstance(version, payload, sipDomain) { + this._version = version; + + // Marshaled Properties + this.sipDomain = payload.sip_domain; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.voiceRegion = payload.voice_region; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {sipDomain: sipDomain || this.sipDomain, }; +}; + +Object.defineProperty(SipDomainInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new SipDomainContext(this._version, this._solution.sipDomain); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * create a SipDomainInstance + * + * @function create + * @memberof Twilio.Routes.V2.SipDomainInstance# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - The voice_region + * @param {string} [opts.friendlyName] - The friendly_name + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SipDomainInstance + */ +/* jshint ignore:end */ +SipDomainInstance.prototype.create = function create(opts, callback) { + return this._proxy.create(opts, callback); +}; + +/* jshint ignore:start */ +/** + * update a SipDomainInstance + * + * @function update + * @memberof Twilio.Routes.V2.SipDomainInstance# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - The voice_region + * @param {string} [opts.friendlyName] - The friendly_name + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SipDomainInstance + */ +/* jshint ignore:end */ +SipDomainInstance.prototype.update = function update(opts, callback) { + return this._proxy.update(opts, callback); +}; + +/* jshint ignore:start */ +/** + * fetch a SipDomainInstance + * + * @function fetch + * @memberof Twilio.Routes.V2.SipDomainInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SipDomainInstance + */ +/* jshint ignore:end */ +SipDomainInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.SipDomainInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +SipDomainInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +SipDomainInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the SipDomainContext + * + * @constructor Twilio.Routes.V2.SipDomainContext + * + * @param {V2} version - Version of the resource + * @param {string} sipDomain - The sip_domain + */ +/* jshint ignore:end */ +SipDomainContext = function SipDomainContext(version, sipDomain) { + this._version = version; + + // Path Solution + this._solution = {sipDomain: sipDomain, }; + this._uri = `/SipDomains/${sipDomain}`; +}; + +/* jshint ignore:start */ +/** + * create a SipDomainInstance + * + * @function create + * @memberof Twilio.Routes.V2.SipDomainContext# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - The voice_region + * @param {string} [opts.friendlyName] - The friendly_name + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SipDomainInstance + */ +/* jshint ignore:end */ +SipDomainContext.prototype.create = function create(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'VoiceRegion': _.get(opts, 'voiceRegion'), + 'FriendlyName': _.get(opts, 'friendlyName') + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new SipDomainInstance(this._version, payload, this._solution.sipDomain)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * update a SipDomainInstance + * + * @function update + * @memberof Twilio.Routes.V2.SipDomainContext# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - The voice_region + * @param {string} [opts.friendlyName] - The friendly_name + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SipDomainInstance + */ +/* jshint ignore:end */ +SipDomainContext.prototype.update = function update(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'VoiceRegion': _.get(opts, 'voiceRegion'), + 'FriendlyName': _.get(opts, 'friendlyName') + }); + + var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new SipDomainInstance(this._version, payload, this._solution.sipDomain)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * fetch a SipDomainInstance + * + * @function fetch + * @memberof Twilio.Routes.V2.SipDomainContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SipDomainInstance + */ +/* jshint ignore:end */ +SipDomainContext.prototype.fetch = function fetch(callback) { + var deferred = Q.defer(); + var promise = this._version.fetch({uri: this._uri, method: 'GET'}); + + promise = promise.then(function(payload) { + deferred.resolve(new SipDomainInstance(this._version, payload, this._solution.sipDomain)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.SipDomainContext# + * + * @returns Object + */ +/* jshint ignore:end */ +SipDomainContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +SipDomainContext.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + SipDomainList: SipDomainList, + SipDomainPage: SipDomainPage, + SipDomainInstance: SipDomainInstance, + SipDomainContext: SipDomainContext +}; diff --git a/lib/rest/routes/v2/trunk.d.ts b/lib/rest/routes/v2/trunk.d.ts new file mode 100644 index 0000000000..ce4ff7407c --- /dev/null +++ b/lib/rest/routes/v2/trunk.d.ts @@ -0,0 +1,205 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V2 = require('../V2'); +import { SerializableClass } from '../../../interfaces'; + +/** + * Initialize the TrunkList + * + * @param version - Version of the resource + */ +declare function TrunkList(version: V2): TrunkListInstance; + +/** + * Options to pass to create + * + * @property friendlyName - A human readable description of this resource. + * @property voiceRegion - The Inbound Processing Region used for this SIP Trunk for voice + */ +interface TrunkInstanceCreateOptions { + friendlyName?: string; + voiceRegion?: string; +} + +/** + * Options to pass to update + * + * @property friendlyName - A human readable description of this resource. + * @property voiceRegion - The Inbound Processing Region used for this SIP Trunk for voice + */ +interface TrunkInstanceUpdateOptions { + friendlyName?: string; + voiceRegion?: string; +} + +interface TrunkListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): TrunkContext; + /** + * Constructs a trunk + * + * @param sipTrunkDomain - The SIP Trunk + */ + get(sipTrunkDomain: string): TrunkContext; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +interface TrunkPayload extends TrunkResource, Page.TwilioResponsePayload { +} + +interface TrunkResource { + account_sid: string; + date_created: Date; + date_updated: Date; + friendly_name: string; + sid: string; + sip_trunk_domain: string; + url: string; + voice_region: string; +} + +interface TrunkSolution { +} + + +declare class TrunkContext { + /** + * Initialize the TrunkContext + * + * @param version - Version of the resource + * @param sipTrunkDomain - The SIP Trunk + */ + constructor(version: V2, sipTrunkDomain: string); + + /** + * create a TrunkInstance + * + * @param callback - Callback to handle processed record + */ + create(callback?: (error: Error | null, item: TrunkInstance) => any): Promise; + /** + * create a TrunkInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts?: TrunkInstanceCreateOptions, callback?: (error: Error | null, item: TrunkInstance) => any): Promise; + /** + * fetch a TrunkInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: TrunkInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a TrunkInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: TrunkInstance) => any): Promise; + /** + * update a TrunkInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: TrunkInstanceUpdateOptions, callback?: (error: Error | null, items: TrunkInstance) => any): Promise; +} + + +declare class TrunkInstance extends SerializableClass { + /** + * Initialize the TrunkContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param sipTrunkDomain - The SIP Trunk + */ + constructor(version: V2, payload: TrunkPayload, sipTrunkDomain: string); + + private _proxy: TrunkContext; + accountSid: string; + /** + * create a TrunkInstance + * + * @param callback - Callback to handle processed record + */ + create(callback?: (error: Error | null, items: TrunkInstance) => any): Promise; + /** + * create a TrunkInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts?: TrunkInstanceCreateOptions, callback?: (error: Error | null, items: TrunkInstance) => any): Promise; + dateCreated: Date; + dateUpdated: Date; + /** + * fetch a TrunkInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: TrunkInstance) => any): Promise; + friendlyName: string; + sid: string; + sipTrunkDomain: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a TrunkInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: TrunkInstance) => any): Promise; + /** + * update a TrunkInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: TrunkInstanceUpdateOptions, callback?: (error: Error | null, items: TrunkInstance) => any): Promise; + url: string; + voiceRegion: string; +} + + +declare class TrunkPage extends Page { + /** + * Initialize the TrunkPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V2, response: Response, solution: TrunkSolution); + + /** + * Build an instance of TrunkInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: TrunkPayload): TrunkInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { TrunkContext, TrunkInstance, TrunkInstanceCreateOptions, TrunkInstanceUpdateOptions, TrunkList, TrunkListInstance, TrunkPage, TrunkPayload, TrunkResource, TrunkSolution } diff --git a/lib/rest/routes/v2/trunk.js b/lib/rest/routes/v2/trunk.js new file mode 100644 index 0000000000..5b5bdba856 --- /dev/null +++ b/lib/rest/routes/v2/trunk.js @@ -0,0 +1,458 @@ +'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 util = require('util'); /* jshint ignore:line */ +var Page = require('../../../base/Page'); /* jshint ignore:line */ +var deserialize = require( + '../../../base/deserialize'); /* jshint ignore:line */ +var values = require('../../../base/values'); /* jshint ignore:line */ + +var TrunkList; +var TrunkPage; +var TrunkInstance; +var TrunkContext; + +/* jshint ignore:start */ +/** + * Initialize the TrunkList + * + * @constructor Twilio.Routes.V2.TrunkList + * + * @param {Twilio.Routes.V2} version - Version of the resource + */ +/* jshint ignore:end */ +TrunkList = function TrunkList(version) { + /* jshint ignore:start */ + /** + * @function trunks + * @memberof Twilio.Routes.V2# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Routes.V2.TrunkContext} + */ + /* jshint ignore:end */ + function TrunkListInstance(sid) { + return TrunkListInstance.get(sid); + } + + TrunkListInstance._version = version; + // Path Solution + TrunkListInstance._solution = {}; + /* jshint ignore:start */ + /** + * Constructs a trunk + * + * @function get + * @memberof Twilio.Routes.V2.TrunkList# + * + * @param {string} sipTrunkDomain - The SIP Trunk + * + * @returns {Twilio.Routes.V2.TrunkContext} + */ + /* jshint ignore:end */ + TrunkListInstance.get = function get(sipTrunkDomain) { + return new TrunkContext(this._version, sipTrunkDomain); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.TrunkList# + * + * @returns Object + */ + /* jshint ignore:end */ + TrunkListInstance.toJSON = function toJSON() { + return this._solution; + }; + + TrunkListInstance[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return TrunkListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the TrunkPage + * + * @constructor Twilio.Routes.V2.TrunkPage + * + * @param {V2} version - Version of the resource + * @param {Response} response - Response from the API + * @param {TrunkSolution} solution - Path solution + * + * @returns TrunkPage + */ +/* jshint ignore:end */ +TrunkPage = function TrunkPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(TrunkPage.prototype, Page.prototype); +TrunkPage.prototype.constructor = TrunkPage; + +/* jshint ignore:start */ +/** + * Build an instance of TrunkInstance + * + * @function getInstance + * @memberof Twilio.Routes.V2.TrunkPage# + * + * @param {TrunkPayload} payload - Payload response from the API + * + * @returns TrunkInstance + */ +/* jshint ignore:end */ +TrunkPage.prototype.getInstance = function getInstance(payload) { + return new TrunkInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.TrunkPage# + * + * @returns Object + */ +/* jshint ignore:end */ +TrunkPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +TrunkPage.prototype[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the TrunkContext + * + * @constructor Twilio.Routes.V2.TrunkInstance + * + * @property {string} sipTrunkDomain - The SIP Trunk + * @property {string} url - The absolute URL of the resource + * @property {string} sid - + * A string that uniquely identifies the Inbound Processing Region assignments for this SIP Trunk. + * @property {string} accountSid - Account Sid. + * @property {string} friendlyName - + * A human readable description of the Inbound Processing Region assignments for this SIP Trunk. + * @property {string} voiceRegion - + * The Inbound Processing Region used for this SIP Trunk for voice. + * @property {Date} dateCreated - + * The date that this SIP Trunk was assigned an Inbound Processing Region. + * @property {Date} dateUpdated - + * The date that the Inbound Processing Region was updated for this SIP Trunk. + * + * @param {V2} version - Version of the resource + * @param {TrunkPayload} payload - The instance payload + * @param {string} sipTrunkDomain - The SIP Trunk + */ +/* jshint ignore:end */ +TrunkInstance = function TrunkInstance(version, payload, sipTrunkDomain) { + this._version = version; + + // Marshaled Properties + this.sipTrunkDomain = payload.sip_trunk_domain; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.voiceRegion = payload.voice_region; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {sipTrunkDomain: sipTrunkDomain || this.sipTrunkDomain, }; +}; + +Object.defineProperty(TrunkInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new TrunkContext(this._version, this._solution.sipTrunkDomain); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * create a TrunkInstance + * + * @function create + * @memberof Twilio.Routes.V2.TrunkInstance# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - + * The Inbound Processing Region used for this SIP Trunk for voice + * @param {string} [opts.friendlyName] - + * A human readable description of this resource. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed TrunkInstance + */ +/* jshint ignore:end */ +TrunkInstance.prototype.create = function create(opts, callback) { + return this._proxy.create(opts, callback); +}; + +/* jshint ignore:start */ +/** + * update a TrunkInstance + * + * @function update + * @memberof Twilio.Routes.V2.TrunkInstance# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - + * The Inbound Processing Region used for this SIP Trunk for voice + * @param {string} [opts.friendlyName] - + * A human readable description of this resource. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed TrunkInstance + */ +/* jshint ignore:end */ +TrunkInstance.prototype.update = function update(opts, callback) { + return this._proxy.update(opts, callback); +}; + +/* jshint ignore:start */ +/** + * fetch a TrunkInstance + * + * @function fetch + * @memberof Twilio.Routes.V2.TrunkInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed TrunkInstance + */ +/* jshint ignore:end */ +TrunkInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.TrunkInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +TrunkInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +TrunkInstance.prototype[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the TrunkContext + * + * @constructor Twilio.Routes.V2.TrunkContext + * + * @param {V2} version - Version of the resource + * @param {string} sipTrunkDomain - The SIP Trunk + */ +/* jshint ignore:end */ +TrunkContext = function TrunkContext(version, sipTrunkDomain) { + this._version = version; + + // Path Solution + this._solution = {sipTrunkDomain: sipTrunkDomain, }; + this._uri = `/Trunks/${sipTrunkDomain}`; +}; + +/* jshint ignore:start */ +/** + * create a TrunkInstance + * + * @function create + * @memberof Twilio.Routes.V2.TrunkContext# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - + * The Inbound Processing Region used for this SIP Trunk for voice + * @param {string} [opts.friendlyName] - + * A human readable description of this resource. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed TrunkInstance + */ +/* jshint ignore:end */ +TrunkContext.prototype.create = function create(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'VoiceRegion': _.get(opts, 'voiceRegion'), + 'FriendlyName': _.get(opts, 'friendlyName') + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new TrunkInstance(this._version, payload, this._solution.sipTrunkDomain)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * update a TrunkInstance + * + * @function update + * @memberof Twilio.Routes.V2.TrunkContext# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.voiceRegion] - + * The Inbound Processing Region used for this SIP Trunk for voice + * @param {string} [opts.friendlyName] - + * A human readable description of this resource. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed TrunkInstance + */ +/* jshint ignore:end */ +TrunkContext.prototype.update = function update(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'VoiceRegion': _.get(opts, 'voiceRegion'), + 'FriendlyName': _.get(opts, 'friendlyName') + }); + + var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new TrunkInstance(this._version, payload, this._solution.sipTrunkDomain)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * fetch a TrunkInstance + * + * @function fetch + * @memberof Twilio.Routes.V2.TrunkContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed TrunkInstance + */ +/* jshint ignore:end */ +TrunkContext.prototype.fetch = function fetch(callback) { + var deferred = Q.defer(); + var promise = this._version.fetch({uri: this._uri, method: 'GET'}); + + promise = promise.then(function(payload) { + deferred.resolve(new TrunkInstance(this._version, payload, this._solution.sipTrunkDomain)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Routes.V2.TrunkContext# + * + * @returns Object + */ +/* jshint ignore:end */ +TrunkContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +TrunkContext.prototype[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + TrunkList: TrunkList, + TrunkPage: TrunkPage, + TrunkInstance: TrunkInstance, + TrunkContext: TrunkContext +}; diff --git a/lib/rest/supersim/v1/fleet.d.ts b/lib/rest/supersim/v1/fleet.d.ts index 18a8824096..9329d317f9 100644 --- a/lib/rest/supersim/v1/fleet.d.ts +++ b/lib/rest/supersim/v1/fleet.d.ts @@ -25,6 +25,7 @@ declare function FleetList(version: V1): FleetListInstance; /** * Options to pass to update * + * @property dataLimit - The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume * @property ipCommandsMethod - A string representing the HTTP method to use when making a request to `ip_commands_url` * @property ipCommandsUrl - The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device * @property networkAccessProfile - The SID or unique name of the Network Access Profile of the Fleet @@ -33,6 +34,7 @@ declare function FleetList(version: V1): FleetListInstance; * @property uniqueName - An application-defined string that uniquely identifies the resource */ interface FleetInstanceUpdateOptions { + dataLimit?: number; ipCommandsMethod?: string; ipCommandsUrl?: string; networkAccessProfile?: string; @@ -165,7 +167,7 @@ interface FleetListInstance { * Options to pass to create * * @property dataEnabled - Defines whether SIMs in the Fleet are capable of using data connectivity - * @property dataLimit - The total data usage (download and upload combined) in Megabytes that each Sim resource assigned to the Fleet resource can consume + * @property dataLimit - The total data usage (download and upload combined) in Megabytes that each Super SIM resource assigned to the Fleet can consume * @property ipCommandsMethod - A string representing the HTTP method to use when making a request to `ip_commands_url` * @property ipCommandsUrl - The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device * @property networkAccessProfile - The SID or unique name of the Network Access Profile of the Fleet diff --git a/lib/rest/supersim/v1/fleet.js b/lib/rest/supersim/v1/fleet.js index 67fd94a69f..92f88e24e7 100644 --- a/lib/rest/supersim/v1/fleet.js +++ b/lib/rest/supersim/v1/fleet.js @@ -69,7 +69,7 @@ FleetList = function FleetList(version) { * @param {boolean} [opts.dataEnabled] - * Defines whether SIMs in the Fleet are capable of using data connectivity * @param {number} [opts.dataLimit] - - * The total data usage (download and upload combined) in Megabytes that each Sim resource assigned to the Fleet resource can consume + * The total data usage (download and upload combined) in Megabytes that each Super SIM resource assigned to the Fleet can consume * @param {string} [opts.ipCommandsUrl] - * The URL that will receive a webhook when a Super SIM in the Fleet is used to send an IP Command from your device * @param {string} [opts.ipCommandsMethod] - @@ -500,7 +500,7 @@ FleetPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {boolean} dataEnabled - * Defines whether SIMs in the Fleet are capable of using data connectivity * @property {number} dataLimit - - * The total data usage (download and upload combined) in Megabytes that each Sim resource assigned to the Fleet resource can consume + * The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume * @property {fleet.data_metering} dataMetering - * The model by which a SIM is metered and billed * @property {boolean} smsCommandsEnabled - @@ -593,6 +593,8 @@ FleetInstance.prototype.fetch = function fetch(callback) { * The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number * @param {string} [opts.smsCommandsMethod] - * A string representing the HTTP method to use when making a request to `sms_commands_url` + * @param {number} [opts.dataLimit] - + * The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FleetInstance @@ -700,6 +702,8 @@ FleetContext.prototype.fetch = function fetch(callback) { * The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number * @param {string} [opts.smsCommandsMethod] - * A string representing the HTTP method to use when making a request to `sms_commands_url` + * @param {number} [opts.dataLimit] - + * The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FleetInstance @@ -719,7 +723,8 @@ FleetContext.prototype.update = function update(opts, callback) { 'IpCommandsUrl': _.get(opts, 'ipCommandsUrl'), 'IpCommandsMethod': _.get(opts, 'ipCommandsMethod'), 'SmsCommandsUrl': _.get(opts, 'smsCommandsUrl'), - 'SmsCommandsMethod': _.get(opts, 'smsCommandsMethod') + 'SmsCommandsMethod': _.get(opts, 'smsCommandsMethod'), + 'DataLimit': _.get(opts, 'dataLimit') }); var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); diff --git a/spec/integration/rest/api/v2010/account/application.spec.js b/spec/integration/rest/api/v2010/account/application.spec.js index 89e20d83b6..9704fff421 100644 --- a/spec/integration/rest/api/v2010/account/application.spec.js +++ b/spec/integration/rest/api/v2010/account/application.spec.js @@ -73,7 +73,8 @@ describe('Application', function() { 'voice_fallback_method': 'GET', 'voice_fallback_url': 'http://www.example.com/voice-callback', 'voice_method': 'GET', - 'voice_url': 'http://example.com' + 'voice_url': 'http://example.com', + 'public_application_connect_enabled': true }; holodeck.mock(new Response(201, body)); @@ -172,7 +173,8 @@ describe('Application', function() { 'voice_fallback_method': 'GET', 'voice_fallback_url': 'http://www.example.com/voice-callback', 'voice_method': 'GET', - 'voice_url': 'http://example.com' + 'voice_url': 'http://example.com', + 'public_application_connect_enabled': false }; holodeck.mock(new Response(200, body)); @@ -211,7 +213,8 @@ describe('Application', function() { 'voice_fallback_method': 'POST', 'voice_fallback_url': null, 'voice_method': 'POST', - 'voice_url': null + 'voice_url': null, + 'public_application_connect_enabled': false } ], 'end': 0, @@ -252,7 +255,8 @@ describe('Application', function() { 'voice_fallback_method': 'POST', 'voice_fallback_url': null, 'voice_method': 'POST', - 'voice_url': null + 'voice_url': null, + 'public_application_connect_enabled': false } ], 'end': 0, @@ -298,7 +302,8 @@ describe('Application', function() { 'voice_fallback_method': 'POST', 'voice_fallback_url': null, 'voice_method': 'POST', - 'voice_url': null + 'voice_url': null, + 'public_application_connect_enabled': false } ], 'end': 0, @@ -361,7 +366,8 @@ describe('Application', function() { 'voice_fallback_method': 'POST', 'voice_fallback_url': null, 'voice_method': 'POST', - 'voice_url': null + 'voice_url': null, + 'public_application_connect_enabled': false } ], 'end': 0, @@ -457,7 +463,8 @@ describe('Application', function() { 'voice_fallback_method': 'GET', 'voice_fallback_url': 'http://www.example.com/voice-callback', 'voice_method': 'GET', - 'voice_url': 'http://example.com' + 'voice_url': 'http://example.com', + 'public_application_connect_enabled': true }; holodeck.mock(new Response(200, body)); diff --git a/spec/integration/rest/microvisor/v1/app.spec.js b/spec/integration/rest/microvisor/v1/app.spec.js new file mode 100644 index 0000000000..86298cd899 --- /dev/null +++ b/spec/integration/rest/microvisor/v1/app.spec.js @@ -0,0 +1,283 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +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('App', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should treat the first each arg as a callback', + function(done) { + var body = { + 'apps': [ + { + 'sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'hash': 'hash', + 'unique_name': 'unique name', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'url': 'https://microvisor.twilio.com/v1/Apps/KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'apps' + } + }; + holodeck.mock(new Response(200, body)); + client.microvisor.v1.apps.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'apps': [ + { + 'sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'hash': 'hash', + 'unique_name': 'unique name', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'url': 'https://microvisor.twilio.com/v1/Apps/KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'apps' + } + }; + holodeck.mock(new Response(200, body)); + client.microvisor.v1.apps.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://microvisor.twilio.com/v1/Apps', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'apps': [ + { + 'sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'hash': 'hash', + 'unique_name': 'unique name', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'url': 'https://microvisor.twilio.com/v1/Apps/KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'apps' + } + }; + holodeck.mock(new Response(200, body)); + client.microvisor.v1.apps.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.microvisor.v1.apps.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://microvisor.twilio.com/v1/Apps'; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_empty response', + function(done) { + var body = { + 'apps': [], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'apps' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.microvisor.v1.apps.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full response', + function(done) { + var body = { + 'apps': [ + { + 'sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'hash': 'hash', + 'unique_name': 'unique name', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'url': 'https://microvisor.twilio.com/v1/Apps/KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Apps?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'apps' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.microvisor.v1.apps.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.microvisor.v1.apps('KAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sid = 'KAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://microvisor.twilio.com/v1/Apps/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'hash': 'hash', + 'unique_name': 'look at this crazy app', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'url': 'https://microvisor.twilio.com/v1/Apps/KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.microvisor.v1.apps('KAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid remove request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.microvisor.v1.apps('KAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sid = 'KAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://microvisor.twilio.com/v1/Apps/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'DELETE', + url: url + })); + } + ); + it('should generate valid delete response', + function(done) { + var body = null; + + holodeck.mock(new Response(204, body)); + + var promise = client.microvisor.v1.apps('KAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); + promise.then(function(response) { + expect(response).toBe(true); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/microvisor/v1/device.spec.js b/spec/integration/rest/microvisor/v1/device.spec.js new file mode 100644 index 0000000000..e4995c8a11 --- /dev/null +++ b/spec/integration/rest/microvisor/v1/device.spec.js @@ -0,0 +1,363 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +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('Device', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should treat the first each arg as a callback', + function(done) { + var body = { + 'devices': [ + { + 'sid': 'UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unique_name': 'This is my device; there are many like it.', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'app': { + 'target_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'target_hash': null, + 'date_targeted': '2021-01-01T12:34:56Z', + 'update_status': 'up-to-date', + 'update_error_code': 0, + 'reported_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_reported': '2021-01-01T12:34:56Z' + }, + 'logging': { + 'enabled': true, + 'date_expires': '2021-01-01T12:34:56Z' + }, + 'date_created': '2021-01-01T12:34:56Z', + 'date_updated': '2021-01-01T12:34:56Z', + 'url': 'https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'devices' + } + }; + holodeck.mock(new Response(200, body)); + client.microvisor.v1.devices.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'devices': [ + { + 'sid': 'UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unique_name': 'This is my device; there are many like it.', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'app': { + 'target_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'target_hash': null, + 'date_targeted': '2021-01-01T12:34:56Z', + 'update_status': 'up-to-date', + 'update_error_code': 0, + 'reported_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_reported': '2021-01-01T12:34:56Z' + }, + 'logging': { + 'enabled': true, + 'date_expires': '2021-01-01T12:34:56Z' + }, + 'date_created': '2021-01-01T12:34:56Z', + 'date_updated': '2021-01-01T12:34:56Z', + 'url': 'https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'devices' + } + }; + holodeck.mock(new Response(200, body)); + client.microvisor.v1.devices.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://microvisor.twilio.com/v1/Devices', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'devices': [ + { + 'sid': 'UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unique_name': 'This is my device; there are many like it.', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'app': { + 'target_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'target_hash': null, + 'date_targeted': '2021-01-01T12:34:56Z', + 'update_status': 'up-to-date', + 'update_error_code': 0, + 'reported_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_reported': '2021-01-01T12:34:56Z' + }, + 'logging': { + 'enabled': true, + 'date_expires': '2021-01-01T12:34:56Z' + }, + 'date_created': '2021-01-01T12:34:56Z', + 'date_updated': '2021-01-01T12:34:56Z', + 'url': 'https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'devices' + } + }; + holodeck.mock(new Response(200, body)); + client.microvisor.v1.devices.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.microvisor.v1.devices.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://microvisor.twilio.com/v1/Devices'; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_empty response', + function(done) { + var body = { + 'devices': [], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'devices' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.microvisor.v1.devices.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full response', + function(done) { + var body = { + 'devices': [ + { + 'sid': 'UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unique_name': 'This is my device; there are many like it.', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'app': { + 'target_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'target_hash': null, + 'date_targeted': '2021-01-01T12:34:56Z', + 'update_status': 'up-to-date', + 'update_error_code': 0, + 'reported_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_reported': '2021-01-01T12:34:56Z' + }, + 'logging': { + 'enabled': true, + 'date_expires': '2021-01-01T12:34:56Z' + }, + 'date_created': '2021-01-01T12:34:56Z', + 'date_updated': '2021-01-01T12:34:56Z', + 'url': 'https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://microvisor.twilio.com/v1/Devices?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'devices' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.microvisor.v1.devices.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.microvisor.v1.devices('UVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sid = 'UVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://microvisor.twilio.com/v1/Devices/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'sid': 'UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unique_name': 'This is my device; there are many like it.', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'app': { + 'target_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'target_hash': null, + 'date_targeted': '2021-01-01T12:34:56Z', + 'update_status': 'up-to-date', + 'update_error_code': 0, + 'reported_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_reported': '2021-01-01T12:34:56Z' + }, + 'logging': { + 'enabled': true, + 'date_expires': '2021-01-01T12:34:56Z' + }, + 'date_created': '2021-01-01T12:34:56Z', + 'date_updated': '2021-01-01T12:34:56Z', + 'url': 'https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.microvisor.v1.devices('UVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid update request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.microvisor.v1.devices('UVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sid = 'UVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://microvisor.twilio.com/v1/Devices/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid update response', + function(done) { + var body = { + 'sid': 'UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unique_name': 'UniqueName', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'app': { + 'target_sid': 'KAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'target_hash': null, + 'date_targeted': '2021-01-01T12:34:56Z', + 'update_status': 'pending', + 'update_error_code': 0, + 'reported_sid': null, + 'date_reported': '2021-01-01T12:34:56Z' + }, + 'logging': { + 'enabled': false, + 'date_expires': null + }, + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'url': 'https://microvisor.twilio.com/v1/Devices/UVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.microvisor.v1.devices('UVXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/preview/bulk_exports/export.spec.js b/spec/integration/rest/preview/bulk_exports/export.spec.js deleted file mode 100644 index 6e2510076a..0000000000 --- a/spec/integration/rest/preview/bulk_exports/export.spec.js +++ /dev/null @@ -1,74 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -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('Export', function() { - beforeEach(function() { - holodeck = new Holodeck(); - client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { - httpClient: holodeck - }); - }); - it('should generate valid fetch request', - function(done) { - holodeck.mock(new Response(500, {})); - - var promise = client.preview.bulk_exports.exports('resource_type').fetch(); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var resourceType = 'resource_type'; - var url = `https://preview.twilio.com/BulkExports/Exports/${resourceType}`; - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid fetch response', - function(done) { - var body = { - 'resource_type': 'Calls', - 'url': 'https://preview.twilio.com/BulkExports/Exports/Calls', - 'links': { - 'days': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days' - } - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exports('resource_type').fetch(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); -}); diff --git a/spec/integration/rest/preview/bulk_exports/export/day.spec.js b/spec/integration/rest/preview/bulk_exports/export/day.spec.js deleted file mode 100644 index ef2d431425..0000000000 --- a/spec/integration/rest/preview/bulk_exports/export/day.spec.js +++ /dev/null @@ -1,243 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -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('Day', function() { - beforeEach(function() { - holodeck = new Holodeck(); - client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { - httpClient: holodeck - }); - }); - it('should generate valid fetch request', - function(done) { - holodeck.mock(new Response(500, {})); - - var promise = client.preview.bulk_exports.exports('resource_type') - .days('day').fetch(); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var resourceType = 'resource_type'; - var day = 'day'; - var url = `https://preview.twilio.com/BulkExports/Exports/${resourceType}/Days/${day}`; - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid fetch response', - function(done) { - var body = { - 'redirect_to': 'https://www.twilio.com' - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exports('resource_type') - .days('day').fetch(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); - it('should treat the first each arg as a callback', - function(done) { - var body = { - 'days': [ - { - 'day': '2017-04-01', - 'size': 100, - 'resource_type': 'Calls', - 'create_date': '2017-04-02', - 'friendly_name': 'friendly_name' - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'days' - } - }; - holodeck.mock(new Response(200, body)); - client.preview.bulk_exports.exports('resource_type') - .days.each(() => done()); - } - ); - it('should treat the second arg as a callback', - function(done) { - var body = { - 'days': [ - { - 'day': '2017-04-01', - 'size': 100, - 'resource_type': 'Calls', - 'create_date': '2017-04-02', - 'friendly_name': 'friendly_name' - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'days' - } - }; - holodeck.mock(new Response(200, body)); - client.preview.bulk_exports.exports('resource_type') - .days.each({pageSize: 20}, () => done()); - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: 'https://preview.twilio.com/BulkExports/Exports/${resourceType}/Days', - params: {PageSize: 20}, - })); - } - ); - it('should find the callback in the opts object', - function(done) { - var body = { - 'days': [ - { - 'day': '2017-04-01', - 'size': 100, - 'resource_type': 'Calls', - 'create_date': '2017-04-02', - 'friendly_name': 'friendly_name' - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'days' - } - }; - holodeck.mock(new Response(200, body)); - client.preview.bulk_exports.exports('resource_type') - .days.each({callback: () => done()}, () => fail('wrong callback!')); - } - ); - it('should generate valid list request', - function(done) { - holodeck.mock(new Response(500, {})); - - var promise = client.preview.bulk_exports.exports('resource_type') - .days.list(); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var resourceType = 'resource_type'; - var url = `https://preview.twilio.com/BulkExports/Exports/${resourceType}/Days`; - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid read_empty response', - function(done) { - var body = { - 'days': [], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'days' - } - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exports('resource_type') - .days.list(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); - it('should generate valid read_full response', - function(done) { - var body = { - 'days': [ - { - 'day': '2017-04-01', - 'size': 100, - 'resource_type': 'Calls', - 'create_date': '2017-04-02', - 'friendly_name': 'friendly_name' - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'days' - } - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exports('resource_type') - .days.list(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); -}); diff --git a/spec/integration/rest/preview/bulk_exports/export/exportCustomJob.spec.js b/spec/integration/rest/preview/bulk_exports/export/exportCustomJob.spec.js deleted file mode 100644 index d3adc117d3..0000000000 --- a/spec/integration/rest/preview/bulk_exports/export/exportCustomJob.spec.js +++ /dev/null @@ -1,270 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -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('ExportCustomJob', function() { - beforeEach(function() { - holodeck = new Holodeck(); - client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { - httpClient: holodeck - }); - }); - it('should treat the first each arg as a callback', - function(done) { - var body = { - 'meta': { - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'page_size': 50, - 'key': 'jobs', - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'next_page_url': null, - 'page': 0 - }, - 'jobs': [ - { - 'start_day': 'start_day', - 'job_sid': 'JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'webhook_method': 'webhook_method', - 'details': {}, - 'end_day': 'end_day', - 'webhook_url': 'webhook_url', - 'email': 'email', - 'resource_type': 'resource_type' - } - ] - }; - holodeck.mock(new Response(200, body)); - client.preview.bulk_exports.exports('resource_type') - .exportCustomJobs.each(() => done()); - } - ); - it('should treat the second arg as a callback', - function(done) { - var body = { - 'meta': { - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'page_size': 50, - 'key': 'jobs', - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'next_page_url': null, - 'page': 0 - }, - 'jobs': [ - { - 'start_day': 'start_day', - 'job_sid': 'JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'webhook_method': 'webhook_method', - 'details': {}, - 'end_day': 'end_day', - 'webhook_url': 'webhook_url', - 'email': 'email', - 'resource_type': 'resource_type' - } - ] - }; - holodeck.mock(new Response(200, body)); - client.preview.bulk_exports.exports('resource_type') - .exportCustomJobs.each({pageSize: 20}, () => done()); - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: 'https://preview.twilio.com/BulkExports/Exports/${resourceType}/Jobs', - params: {PageSize: 20}, - })); - } - ); - it('should find the callback in the opts object', - function(done) { - var body = { - 'meta': { - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'page_size': 50, - 'key': 'jobs', - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'next_page_url': null, - 'page': 0 - }, - 'jobs': [ - { - 'start_day': 'start_day', - 'job_sid': 'JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'webhook_method': 'webhook_method', - 'details': {}, - 'end_day': 'end_day', - 'webhook_url': 'webhook_url', - 'email': 'email', - 'resource_type': 'resource_type' - } - ] - }; - holodeck.mock(new Response(200, body)); - client.preview.bulk_exports.exports('resource_type') - .exportCustomJobs.each({callback: () => done()}, () => fail('wrong callback!')); - } - ); - it('should generate valid list request', - function(done) { - holodeck.mock(new Response(500, {})); - - var promise = client.preview.bulk_exports.exports('resource_type') - .exportCustomJobs.list(); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var resourceType = 'resource_type'; - var url = `https://preview.twilio.com/BulkExports/Exports/${resourceType}/Jobs`; - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid read_empty response', - function(done) { - var body = { - 'meta': { - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'page_size': 50, - 'key': 'jobs', - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'next_page_url': null, - 'page': 0 - }, - 'jobs': [] - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exports('resource_type') - .exportCustomJobs.list(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); - it('should generate valid read_full response', - function(done) { - var body = { - 'meta': { - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'page_size': 50, - 'key': 'jobs', - 'first_page_url': 'https://preview.twilio.com/BulkExports/Exports/Messages/Jobs?PageSize=50&Page=0', - 'next_page_url': null, - 'page': 0 - }, - 'jobs': [ - { - 'start_day': 'start_day', - 'job_sid': 'JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'webhook_method': 'webhook_method', - 'details': {}, - 'end_day': 'end_day', - 'webhook_url': 'webhook_url', - 'email': 'email', - 'resource_type': 'resource_type' - } - ] - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exports('resource_type') - .exportCustomJobs.list(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); - it('should generate valid create request', - function(done) { - holodeck.mock(new Response(500, {})); - - var opts = {'startDay': 'start_day', 'endDay': 'end_day', 'friendlyName': 'friendly_name'}; - var promise = client.preview.bulk_exports.exports('resource_type') - .exportCustomJobs.create(opts); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var resourceType = 'resource_type'; - var url = `https://preview.twilio.com/BulkExports/Exports/${resourceType}/Jobs`; - - var values = {'StartDay': 'start_day', 'EndDay': 'end_day', 'FriendlyName': 'friendly_name', }; - holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url, - data: values - })); - } - ); - it('should generate valid create response', - function(done) { - var body = { - 'start_day': 'start_day', - 'job_sid': 'JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'webhook_method': 'webhook_method', - 'details': {}, - 'end_day': 'end_day', - 'webhook_url': 'webhook_url', - 'email': 'email', - 'resource_type': 'resource_type' - }; - - holodeck.mock(new Response(201, body)); - - var opts = {'startDay': 'start_day', 'endDay': 'end_day', 'friendlyName': 'friendly_name'}; - var promise = client.preview.bulk_exports.exports('resource_type') - .exportCustomJobs.create(opts); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); -}); diff --git a/spec/integration/rest/preview/bulk_exports/export/job.spec.js b/spec/integration/rest/preview/bulk_exports/export/job.spec.js deleted file mode 100644 index 6df828434c..0000000000 --- a/spec/integration/rest/preview/bulk_exports/export/job.spec.js +++ /dev/null @@ -1,119 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -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('Job', function() { - beforeEach(function() { - holodeck = new Holodeck(); - client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { - httpClient: holodeck - }); - }); - it('should generate valid fetch request', - function(done) { - holodeck.mock(new Response(500, {})); - - var promise = client.preview.bulk_exports.exports - .jobs('JSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var jobSid = 'JSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; - var url = `https://preview.twilio.com/BulkExports/Exports/Jobs/${jobSid}`; - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid fetch response', - function(done) { - var body = { - 'start_day': 'start_day', - 'job_sid': 'JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://preview.twilio.com/BulkExports/Exports/Jobs/JSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'end_day': 'end_day', - 'details': {}, - 'webhook_url': 'webhook_url', - 'webhook_method': 'webhook_method', - 'email': 'email', - 'resource_type': 'resource_type' - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exports - .jobs('JSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); - it('should generate valid remove request', - function(done) { - holodeck.mock(new Response(500, {})); - - var promise = client.preview.bulk_exports.exports - .jobs('JSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var jobSid = 'JSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; - var url = `https://preview.twilio.com/BulkExports/Exports/Jobs/${jobSid}`; - - holodeck.assertHasRequest(new Request({ - method: 'DELETE', - url: url - })); - } - ); - it('should generate valid delete response', - function(done) { - var body = null; - - holodeck.mock(new Response(204, body)); - - var promise = client.preview.bulk_exports.exports - .jobs('JSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); - promise.then(function(response) { - expect(response).toBe(true); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); -}); diff --git a/spec/integration/rest/preview/bulk_exports/exportConfiguration.spec.js b/spec/integration/rest/preview/bulk_exports/exportConfiguration.spec.js deleted file mode 100644 index 8e636e1b6a..0000000000 --- a/spec/integration/rest/preview/bulk_exports/exportConfiguration.spec.js +++ /dev/null @@ -1,116 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -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('ExportConfiguration', function() { - beforeEach(function() { - holodeck = new Holodeck(); - client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { - httpClient: holodeck - }); - }); - it('should generate valid fetch request', - function(done) { - holodeck.mock(new Response(500, {})); - - var promise = client.preview.bulk_exports.exportConfiguration('resource_type').fetch(); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var resourceType = 'resource_type'; - var url = `https://preview.twilio.com/BulkExports/Exports/${resourceType}/Configuration`; - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid fetch response', - function(done) { - var body = { - 'url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Configuration', - 'enabled': true, - 'webhook_url': '', - 'webhook_method': '', - 'resource_type': 'Calls' - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exportConfiguration('resource_type').fetch(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); - it('should generate valid update request', - function(done) { - holodeck.mock(new Response(500, {})); - - var promise = client.preview.bulk_exports.exportConfiguration('resource_type').update(); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var resourceType = 'resource_type'; - var url = `https://preview.twilio.com/BulkExports/Exports/${resourceType}/Configuration`; - - holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url - })); - } - ); - it('should generate valid update response', - function(done) { - var body = { - 'url': 'https://preview.twilio.com/BulkExports/Exports/Calls/Configuration', - 'enabled': true, - 'webhook_url': '', - 'resource_type': 'Calls', - 'webhook_method': '' - }; - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.bulk_exports.exportConfiguration('resource_type').update(); - promise.then(function(response) { - expect(response).toBeDefined(); - done(); - }, function() { - throw new Error('failed'); - }).done(); - } - ); -}); diff --git a/spec/integration/rest/routes/v2/phoneNumber.spec.js b/spec/integration/rest/routes/v2/phoneNumber.spec.js new file mode 100644 index 0000000000..6cf0af886f --- /dev/null +++ b/spec/integration/rest/routes/v2/phoneNumber.spec.js @@ -0,0 +1,171 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +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('PhoneNumber', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid create request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.routes.v2.phoneNumbers('phone_number').create(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var phoneNumber = 'phone_number'; + var url = `https://routes.twilio.com/v2/PhoneNumbers/${phoneNumber}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid create response', + function(done) { + var body = { + 'phone_number': '+18001234567', + 'url': 'https://routes.twilio.com/v2/PhoneNumbers/+18001234567', + 'sid': 'QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'voice_region': 'au1', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z' + }; + + holodeck.mock(new Response(201, body)); + + var promise = client.routes.v2.phoneNumbers('phone_number').create(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid update request', + function(done) { + holodeck.mock(new Response(500, {})); + + var opts = {'voiceRegion': 'voice_region', 'friendlyName': 'friendly_name'}; + var promise = client.routes.v2.phoneNumbers('phone_number').update(opts); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var phoneNumber = 'phone_number'; + var url = `https://routes.twilio.com/v2/PhoneNumbers/${phoneNumber}`; + + var values = {'VoiceRegion': 'voice_region', 'FriendlyName': 'friendly_name', }; + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url, + data: values + })); + } + ); + it('should generate valid update response', + function(done) { + var body = { + 'phone_number': '+18001234567', + 'url': 'https://routes.twilio.com/v2/PhoneNumbers/+18001234567', + 'sid': 'QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'voice_region': 'au1', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z' + }; + + holodeck.mock(new Response(200, body)); + + var opts = {'voiceRegion': 'voice_region', 'friendlyName': 'friendly_name'}; + var promise = client.routes.v2.phoneNumbers('phone_number').update(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.routes.v2.phoneNumbers('phone_number').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var phoneNumber = 'phone_number'; + var url = `https://routes.twilio.com/v2/PhoneNumbers/${phoneNumber}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'phone_number': '+18001234567', + 'url': 'https://routes.twilio.com/v2/PhoneNumbers/+18001234567', + 'sid': 'QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'voice_region': 'au1', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.routes.v2.phoneNumbers('phone_number').fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/routes/v2/sipDomain.spec.js b/spec/integration/rest/routes/v2/sipDomain.spec.js new file mode 100644 index 0000000000..11fe78ac23 --- /dev/null +++ b/spec/integration/rest/routes/v2/sipDomain.spec.js @@ -0,0 +1,167 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +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('SipDomain', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid create request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.routes.v2.sipDomains('sip_domain').create(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sipDomain = 'sip_domain'; + var url = `https://routes.twilio.com/v2/SipDomains/${sipDomain}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid create response', + function(done) { + var body = { + 'url': 'https://routes.twilio.com/v2/SipDomains/test.sip.twilio.com', + 'sip_domain': 'test.sip.twilio.com', + 'sid': 'QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'voice_region': 'au1', + 'date_created': '2020-08-07T22:29:24Z', + 'date_updated': '2020-08-07T22:29:24Z' + }; + + holodeck.mock(new Response(201, body)); + + var promise = client.routes.v2.sipDomains('sip_domain').create(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid update request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.routes.v2.sipDomains('sip_domain').update(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sipDomain = 'sip_domain'; + var url = `https://routes.twilio.com/v2/SipDomains/${sipDomain}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid update response', + function(done) { + var body = { + 'url': 'https://routes.twilio.com/v2/SipDomains/test.sip.twilio.com', + 'sip_domain': 'test.sip.twilio.com', + 'sid': 'QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'voice_region': 'au1', + 'date_created': '2020-08-07T22:29:24Z', + 'date_updated': '2020-08-07T22:29:24Z' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.routes.v2.sipDomains('sip_domain').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.routes.v2.sipDomains('sip_domain').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sipDomain = 'sip_domain'; + var url = `https://routes.twilio.com/v2/SipDomains/${sipDomain}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'url': 'https://routes.twilio.com/v2/SipDomains/test.sip.twilio.com', + 'account_sid': 'AC00000000000000000000000000000000', + 'sid': 'QQ00000000000000000000000000000000', + 'sip_domain': 'test.sip.twilio.com', + 'friendly_name': 'string', + 'voice_region': 'string', + 'date_created': '2022-06-02T22:33:47Z', + 'date_updated': '2022-06-02T22:33:47Z' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.routes.v2.sipDomains('sip_domain').fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/routes/v2/trunk.spec.js b/spec/integration/rest/routes/v2/trunk.spec.js new file mode 100644 index 0000000000..f0ce76c5e9 --- /dev/null +++ b/spec/integration/rest/routes/v2/trunk.spec.js @@ -0,0 +1,167 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +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('Trunk', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid create request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.routes.v2.trunks('sip_trunk_domain').create(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sipTrunkDomain = 'sip_trunk_domain'; + var url = `https://routes.twilio.com/v2/Trunks/${sipTrunkDomain}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid create response', + function(done) { + var body = { + 'sip_trunk_domain': 'test.pstn.twilio.com', + 'url': 'https://routes.twilio.com/v2/Trunks/test.pstn.twilio.com', + 'sid': 'QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'voice_region': 'au1', + 'date_created': '2020-08-07T22:29:24Z', + 'date_updated': '2020-08-07T22:29:24Z' + }; + + holodeck.mock(new Response(201, body)); + + var promise = client.routes.v2.trunks('sip_trunk_domain').create(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid update request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.routes.v2.trunks('sip_trunk_domain').update(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sipTrunkDomain = 'sip_trunk_domain'; + var url = `https://routes.twilio.com/v2/Trunks/${sipTrunkDomain}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid update response', + function(done) { + var body = { + 'sip_trunk_domain': 'test.pstn.twilio.com', + 'url': 'https://routes.twilio.com/v2/Trunks/test.pstn.twilio.com', + 'sid': 'QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'voice_region': 'au1', + 'date_created': '2020-08-07T22:29:24Z', + 'date_updated': '2020-08-07T22:29:24Z' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.routes.v2.trunks('sip_trunk_domain').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.routes.v2.trunks('sip_trunk_domain').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sipTrunkDomain = 'sip_trunk_domain'; + var url = `https://routes.twilio.com/v2/Trunks/${sipTrunkDomain}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'sip_trunk_domain': 'test.pstn.twilio.com', + 'url': 'https://routes.twilio.com/v2/Trunks/test.pstn.twilio.com', + 'account_sid': 'AC00000000000000000000000000000000', + 'sid': 'QQ00000000000000000000000000000000', + 'friendly_name': 'string', + 'voice_region': 'string', + 'date_created': '2022-06-02T22:33:47Z', + 'date_updated': '2022-06-02T22:33:47Z' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.routes.v2.trunks('sip_trunk_domain').fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/supersim/v1/fleet.spec.js b/spec/integration/rest/supersim/v1/fleet.spec.js index 5bd30bb864..65958945d0 100644 --- a/spec/integration/rest/supersim/v1/fleet.spec.js +++ b/spec/integration/rest/supersim/v1/fleet.spec.js @@ -58,7 +58,7 @@ describe('Fleet', function() { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'unique_name': 'unique_name', 'data_enabled': true, - 'data_limit': 1000, + 'data_limit': 500, 'data_metering': 'payg', 'date_created': '2019-07-30T20:00:00Z', 'date_updated': '2019-07-30T20:00:00Z', @@ -360,13 +360,13 @@ describe('Fleet', function() { })); } ); - it('should generate valid update_unique_name response', + it('should generate valid update_unique_name_and_data_limit response', function(done) { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'unique_name': 'unique_name', + 'unique_name': 'GPS Trackers Fleet 5GB', 'data_enabled': true, - 'data_limit': 1000, + 'data_limit': 5000, 'data_metering': 'payg', 'date_created': '2019-10-15T20:00:00Z', 'date_updated': '2019-10-15T20:00:00Z', diff --git a/spec/integration/rest/verify/v2/service/verification.spec.js b/spec/integration/rest/verify/v2/service/verification.spec.js index dbde1f65f5..2d643e5430 100644 --- a/spec/integration/rest/verify/v2/service/verification.spec.js +++ b/spec/integration/rest/verify/v2/service/verification.spec.js @@ -210,6 +210,55 @@ describe('Verification', function() { }).done(); } ); + it('should generate valid create_verification_sna response', + function(done) { + var body = { + 'sid': 'VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'to': '+15017122661', + 'channel': 'sna', + 'status': 'pending', + 'valid': false, + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'lookup': { + 'carrier': { + 'mobile_country_code': '311', + 'type': 'mobile', + 'error_code': null, + 'mobile_network_code': '180', + 'name': 'T-Mobile USA, Inc.' + } + }, + 'amount': null, + 'payee': null, + 'send_code_attempts': [ + { + 'time': '2015-07-30T20:00:00Z', + 'channel': 'sna', + 'attempt_sid': 'VLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'sna': { + 'url': 'https://mi.dnlsrv.com/m/id/ANBByzx7?data=AAAglRRdNn02iTFWfDWwdTjOzM8o%2F6JB86fH%2Bt%2FFftUPj0pFA0u8%2FibWuYwzmMeMOtdTwYlsO8V%2FXF%2BJmngMhbeGKYhHeTOF2H9VrGEYKcEEklPxHgb5GgL3XtYa33j3lIU%2By6InvoV%2FowWHBzA0QeFPBh6vmJ8LoUPJqGE7q0PRz618Z4ym1AGq%2BaomSq9PlP4rCduv9Cmtxu%2FrvPSBwocs0GCWDE8seK8t9epmPQW7gwODxkAiKr9UxhJd9KvmBVuAQPf%2BoFQVo86USXkhXqTvUzB2bNUYY9FCy3CWgZFTOa1D3H1CVxf1eHzYIswNA7SmOzP%2FBX8g6%2B0hkzwMRkcit3gBNs4evAVJiqAgYvUlrtGwwv9bFx4X7jWSHY4%3D&cipherSalt=yANeDq09bwM38SJs' + }, + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications/VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {'to': 'to', 'channel': 'channel'}; + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .verifications.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); it('should generate valid update request', function(done) { holodeck.mock(new Response(500, {}));