From 04f9e9153f68c346516383698a9cf526b73ae9da Mon Sep 17 00:00:00 2001 From: Shawn Stern Date: Wed, 31 Mar 2021 07:32:12 -0700 Subject: [PATCH 01/30] chore: expose internal RequestClient to users at top level (#668) --- index.d.ts | 2 ++ lib/index.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/index.d.ts b/index.d.ts index ade6a8737a..920376d1b4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -8,6 +8,7 @@ import TwilioClient = require('./lib/rest/Twilio'); import AccessToken = require('./lib/jwt/AccessToken'); import ClientCapability = require('./lib/jwt/ClientCapability'); import TaskRouterCapability = require('./lib/jwt/taskrouter/TaskRouterCapability'); +import RequestClient = require('./lib/base/RequestClient'); interface TwimlConstructor { new (): T; @@ -36,6 +37,7 @@ declare namespace twilio { } export const jwt: JwtInterface; export const twiml: TwimlInterface; + export const RequestClient: RequestClient; export const validateRequest: typeof webhookTools.validateRequest; export const validateRequestWithBody: typeof webhookTools.validateRequestWithBody; export const validateExpressRequest: typeof webhookTools.validateExpressRequest; diff --git a/lib/index.js b/lib/index.js index 0084157694..c2275398cb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,6 +3,7 @@ var Twilio = require('./rest/Twilio'); var webhooks = require('./webhooks/webhooks'); var obsolete = require('./base/obsolete'); +var RequestClient = require('./base/RequestClient'); // Shorthand to automatically create a RestClient var initializer = function(accountSid, authToken, opts) { @@ -13,6 +14,7 @@ var initializer = function(accountSid, authToken, opts) { initializer.Twilio = Twilio; initializer.jwt = { }; initializer.twiml = { }; +initializer.RequestClient = RequestClient; var AccessToken; Object.defineProperty(initializer.jwt, From 4edadffbd31147e1d9723ea56845902ac642fe43 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 7 Apr 2021 18:37:22 +0000 Subject: [PATCH 02/30] [Librarian] Regenerated @ 6d6bd4543b2ef60947eac37b35d6a7454a9686c7 --- CHANGES.md | 32 ++ lib/rest/Messaging.d.ts | 4 + lib/rest/Messaging.js | 17 + lib/rest/api/v2010/account/call.d.ts | 2 - lib/rest/api/v2010/account/call.js | 4 +- lib/rest/messaging/V1.d.ts | 6 + lib/rest/messaging/V1.js | 24 ++ lib/rest/messaging/v1/externalCampaign.d.ts | 110 +++++ lib/rest/messaging/v1/externalCampaign.js | 260 ++++++++++++ lib/rest/messaging/v1/service.d.ts | 14 + lib/rest/messaging/v1/service.js | 58 +++ .../messaging/v1/service/usAppToPerson.d.ts | 155 +++++++ .../messaging/v1/service/usAppToPerson.js | 385 ++++++++++++++++++ .../v1/service/usAppToPersonUsecase.d.ts | 95 +++++ .../v1/service/usAppToPersonUsecase.js | 241 +++++++++++ lib/rest/messaging/v1/usecase.d.ts | 92 +++++ lib/rest/messaging/v1/usecase.js | 228 +++++++++++ lib/rest/supersim/v1/sim.d.ts | 20 +- lib/rest/supersim/v1/sim.js | 51 +++ lib/rest/verify/v2/service/entity.d.ts | 7 + lib/rest/verify/v2/service/entity.js | 32 ++ lib/rest/verify/v2/service/entity/factor.d.ts | 46 +-- lib/rest/verify/v2/service/entity/factor.js | 86 ---- .../verify/v2/service/entity/newFactor.d.ts | 168 ++++++++ .../verify/v2/service/entity/newFactor.js | 314 ++++++++++++++ lib/twiml/VoiceResponse.d.ts | 2 +- .../rest/api/v2010/account/call.spec.js | 51 +++ .../messaging/v1/externalCampaign.spec.js | 76 ++++ .../rest/messaging/v1/service.spec.js | 42 +- .../v1/service/usAppToPerson.spec.js | 227 +++++++++++ .../v1/service/usAppToPersonUsecase.spec.js | 83 ++++ .../rest/messaging/v1/usecase.spec.js | 80 ++++ spec/integration/rest/supersim/v1/sim.spec.js | 49 +++ .../rest/verify/v2/service/entity.spec.js | 6 + .../verify/v2/service/entity/factor.spec.js | 183 ++++++--- .../v2/service/entity/newFactor.spec.js | 139 +++++++ spec/integration/rest/video/v1/room.spec.js | 90 +++- 37 files changed, 3266 insertions(+), 213 deletions(-) create mode 100644 lib/rest/messaging/v1/externalCampaign.d.ts create mode 100644 lib/rest/messaging/v1/externalCampaign.js create mode 100644 lib/rest/messaging/v1/service/usAppToPerson.d.ts create mode 100644 lib/rest/messaging/v1/service/usAppToPerson.js create mode 100644 lib/rest/messaging/v1/service/usAppToPersonUsecase.d.ts create mode 100644 lib/rest/messaging/v1/service/usAppToPersonUsecase.js create mode 100644 lib/rest/messaging/v1/usecase.d.ts create mode 100644 lib/rest/messaging/v1/usecase.js create mode 100644 lib/rest/verify/v2/service/entity/newFactor.d.ts create mode 100644 lib/rest/verify/v2/service/entity/newFactor.js create mode 100644 spec/integration/rest/messaging/v1/externalCampaign.spec.js create mode 100644 spec/integration/rest/messaging/v1/service/usAppToPerson.spec.js create mode 100644 spec/integration/rest/messaging/v1/service/usAppToPersonUsecase.spec.js create mode 100644 spec/integration/rest/messaging/v1/usecase.spec.js create mode 100644 spec/integration/rest/verify/v2/service/entity/newFactor.spec.js diff --git a/CHANGES.md b/CHANGES.md index 675cc8e1c8..85c968bf8b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,38 @@ twilio-node changelog ===================== +[2021-04-07] Version 3.60.0 +--------------------------- +**Library - Chore** +- [PR #668](https://github.com/twilio/twilio-node/pull/668): expose internal RequestClient to users at top level. Thanks to [@stern-shawn](https://github.com/stern-shawn)! + +**Api** +- Added `announcement` event to conference status callback events +- Removed optional property `time_limit` in the call create request. **(breaking change)** + +**Messaging** +- Add rate_limits field to Messaging Services US App To Person API +- Add usecase field in Service API for fetch, create, update, read +- Add us app to person api and us app to person usecase api as dependents in service +- Add us_app_to_person_registered field in service api for fetch, read, create, update +- Add us app to person api +- Add us app to person usecase api +- Add A2P external campaign api +- Add Usecases API + +**Supersim** +- Add Create endpoint to Sims resource + +**Verify** +- The `Binding` field is now returned when creating a `Factor`. This value won't be returned for other endpoints. + +**Video** +- [Rooms] max_concurrent_published_tracks has got GA maturity + +**Twiml** +- Add `announcement` event to `statusCallbackEvent` for ``. + + [2021-03-24] Version 3.59.0 --------------------------- **Api** diff --git a/lib/rest/Messaging.d.ts b/lib/rest/Messaging.d.ts index 823064afb0..667a9f618b 100644 --- a/lib/rest/Messaging.d.ts +++ b/lib/rest/Messaging.d.ts @@ -10,7 +10,9 @@ import Twilio = require('./Twilio'); import V1 = require('./messaging/V1'); import { BrandRegistrationListInstance } from './messaging/v1/brandRegistration'; import { DeactivationsListInstance } from './messaging/v1/deactivation'; +import { ExternalCampaignListInstance } from './messaging/v1/externalCampaign'; import { ServiceListInstance } from './messaging/v1/service'; +import { UsecaseListInstance } from './messaging/v1/usecase'; declare class Messaging extends Domain { @@ -23,7 +25,9 @@ declare class Messaging extends Domain { readonly brandRegistrations: BrandRegistrationListInstance; readonly deactivations: DeactivationsListInstance; + readonly externalCampaign: ExternalCampaignListInstance; readonly services: ServiceListInstance; + readonly usecases: UsecaseListInstance; readonly v1: V1; } diff --git a/lib/rest/Messaging.js b/lib/rest/Messaging.js index 7de67d3e50..034939c9e1 100644 --- a/lib/rest/Messaging.js +++ b/lib/rest/Messaging.js @@ -25,7 +25,10 @@ var V1 = require('./messaging/V1'); /* jshint ignore:line */ * brandRegistrations resource * @property {Twilio.Messaging.V1.DeactivationsList} deactivations - * deactivations resource + * @property {Twilio.Messaging.V1.ExternalCampaignList} externalCampaign - + * externalCampaign resource * @property {Twilio.Messaging.V1.ServiceList} services - services resource + * @property {Twilio.Messaging.V1.UsecaseList} usecases - usecases resource * * @param {Twilio} twilio - The twilio client */ @@ -62,6 +65,13 @@ Object.defineProperty(Messaging.prototype, } }); +Object.defineProperty(Messaging.prototype, + 'externalCampaign', { + get: function() { + return this.v1.externalCampaign; + } +}); + Object.defineProperty(Messaging.prototype, 'services', { get: function() { @@ -69,4 +79,11 @@ Object.defineProperty(Messaging.prototype, } }); +Object.defineProperty(Messaging.prototype, + 'usecases', { + get: function() { + return this.v1.usecases; + } +}); + module.exports = Messaging; diff --git a/lib/rest/api/v2010/account/call.d.ts b/lib/rest/api/v2010/account/call.d.ts index cb69468ed4..ca97808426 100644 --- a/lib/rest/api/v2010/account/call.d.ts +++ b/lib/rest/api/v2010/account/call.d.ts @@ -211,7 +211,6 @@ interface CallListInstance { * @property statusCallback - The URL we should call to send status information to your application * @property statusCallbackEvent - The call progress events that we send to the `status_callback` URL. * @property statusCallbackMethod - HTTP Method to use with status_callback - * @property timeLimit - The maximum duration of the call in seconds. * @property timeout - Number of seconds to wait for an answer * @property to - Phone number, SIP address, or client identifier to call * @property trim - Set this parameter to control trimming of silence on the recording. @@ -248,7 +247,6 @@ interface CallListInstanceCreateOptions { statusCallback?: string; statusCallbackEvent?: string | string[]; statusCallbackMethod?: string; - timeLimit?: number; timeout?: number; to: string; trim?: string; diff --git a/lib/rest/api/v2010/account/call.js b/lib/rest/api/v2010/account/call.js index c5d77fac26..0215c75197 100644 --- a/lib/rest/api/v2010/account/call.js +++ b/lib/rest/api/v2010/account/call.js @@ -122,7 +122,6 @@ CallList = function CallList(version, accountSid) { * @param {string} [opts.callToken] - * A token string needed to invoke a forwarded call with a caller-id recieved on a previous incoming call * @param {string} [opts.recordingTrack] - Which track(s) to record - * @param {number} [opts.timeLimit] - The maximum duration of the call in seconds. * @param {string} [opts.url] - The absolute URL that returns TwiML for this call * @param {string} [opts.twiml] - TwiML instructions for the call * @param {string} [opts.applicationSid] - @@ -178,8 +177,7 @@ CallList = function CallList(version, accountSid) { 'Byoc': _.get(opts, 'byoc'), 'CallReason': _.get(opts, 'callReason'), 'CallToken': _.get(opts, 'callToken'), - 'RecordingTrack': _.get(opts, 'recordingTrack'), - 'TimeLimit': _.get(opts, 'timeLimit') + 'RecordingTrack': _.get(opts, 'recordingTrack') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/messaging/V1.d.ts b/lib/rest/messaging/V1.d.ts index d3ed43bc89..85a06fb180 100644 --- a/lib/rest/messaging/V1.d.ts +++ b/lib/rest/messaging/V1.d.ts @@ -11,8 +11,12 @@ import { BrandRegistrationList } from './v1/brandRegistration'; import { BrandRegistrationListInstance } from './v1/brandRegistration'; import { DeactivationsList } from './v1/deactivation'; import { DeactivationsListInstance } from './v1/deactivation'; +import { ExternalCampaignList } from './v1/externalCampaign'; +import { ExternalCampaignListInstance } from './v1/externalCampaign'; import { ServiceList } from './v1/service'; import { ServiceListInstance } from './v1/service'; +import { UsecaseList } from './v1/usecase'; +import { UsecaseListInstance } from './v1/usecase'; declare class V1 extends Version { @@ -25,7 +29,9 @@ declare class V1 extends Version { readonly brandRegistrations: BrandRegistrationListInstance; readonly deactivations: DeactivationsListInstance; + readonly externalCampaign: ExternalCampaignListInstance; readonly services: ServiceListInstance; + readonly usecases: UsecaseListInstance; } export = V1; diff --git a/lib/rest/messaging/V1.js b/lib/rest/messaging/V1.js index a738496f48..f17d1ce3af 100644 --- a/lib/rest/messaging/V1.js +++ b/lib/rest/messaging/V1.js @@ -13,7 +13,10 @@ var _ = require('lodash'); /* jshint ignore:line */ var BrandRegistrationList = require( './v1/brandRegistration').BrandRegistrationList; var DeactivationsList = require('./v1/deactivation').DeactivationsList; +var ExternalCampaignList = require( + './v1/externalCampaign').ExternalCampaignList; var ServiceList = require('./v1/service').ServiceList; +var UsecaseList = require('./v1/usecase').UsecaseList; var Version = require('../../base/Version'); /* jshint ignore:line */ @@ -27,7 +30,10 @@ var Version = require('../../base/Version'); /* jshint ignore:line */ * brandRegistrations resource * @property {Twilio.Messaging.V1.DeactivationsList} deactivations - * deactivations resource + * @property {Twilio.Messaging.V1.ExternalCampaignList} externalCampaign - + * externalCampaign resource * @property {Twilio.Messaging.V1.ServiceList} services - services resource + * @property {Twilio.Messaging.V1.UsecaseList} usecases - usecases resource * * @param {Twilio.Messaging} domain - The twilio domain */ @@ -38,7 +44,9 @@ function V1(domain) { // Resources this._brandRegistrations = undefined; this._deactivations = undefined; + this._externalCampaign = undefined; this._services = undefined; + this._usecases = undefined; } _.extend(V1.prototype, Version.prototype); @@ -60,6 +68,14 @@ Object.defineProperty(V1.prototype, } }); +Object.defineProperty(V1.prototype, + 'externalCampaign', { + get: function() { + this._externalCampaign = this._externalCampaign || new ExternalCampaignList(this); + return this._externalCampaign; + } +}); + Object.defineProperty(V1.prototype, 'services', { get: function() { @@ -68,4 +84,12 @@ Object.defineProperty(V1.prototype, } }); +Object.defineProperty(V1.prototype, + 'usecases', { + get: function() { + this._usecases = this._usecases || new UsecaseList(this); + return this._usecases; + } +}); + module.exports = V1; diff --git a/lib/rest/messaging/v1/externalCampaign.d.ts b/lib/rest/messaging/v1/externalCampaign.d.ts new file mode 100644 index 0000000000..7dbb440e39 --- /dev/null +++ b/lib/rest/messaging/v1/externalCampaign.d.ts @@ -0,0 +1,110 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V1 = require('../V1'); +import { SerializableClass } from '../../../interfaces'; + +/** + * Initialize the ExternalCampaignList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + */ +declare function ExternalCampaignList(version: V1): ExternalCampaignListInstance; + +interface ExternalCampaignListInstance { + /** + * create a ExternalCampaignInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts: ExternalCampaignListInstanceCreateOptions, callback?: (error: Error | null, item: ExternalCampaignInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to create + * + * @property campaignId - ID of the preregistered campaign. + * @property messagingServiceSid - The SID of the Messaging Service the resource is associated with + */ +interface ExternalCampaignListInstanceCreateOptions { + campaignId: string; + messagingServiceSid: string; +} + +interface ExternalCampaignPayload extends ExternalCampaignResource, Page.TwilioResponsePayload { +} + +interface ExternalCampaignResource { + account_sid: string; + campaign_id: string; + date_created: Date; + messaging_service_sid: string; +} + +interface ExternalCampaignSolution { +} + + +declare class ExternalCampaignInstance extends SerializableClass { + /** + * Initialize the ExternalCampaignContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param payload - The instance payload + */ + constructor(version: V1, payload: ExternalCampaignPayload); + + accountSid: string; + campaignId: string; + dateCreated: Date; + messagingServiceSid: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + +declare class ExternalCampaignPage extends Page { + /** + * Initialize the ExternalCampaignPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: ExternalCampaignSolution); + + /** + * Build an instance of ExternalCampaignInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: ExternalCampaignPayload): ExternalCampaignInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { ExternalCampaignInstance, ExternalCampaignList, ExternalCampaignListInstance, ExternalCampaignListInstanceCreateOptions, ExternalCampaignPage, ExternalCampaignPayload, ExternalCampaignResource, ExternalCampaignSolution } diff --git a/lib/rest/messaging/v1/externalCampaign.js b/lib/rest/messaging/v1/externalCampaign.js new file mode 100644 index 0000000000..3780e00b1d --- /dev/null +++ b/lib/rest/messaging/v1/externalCampaign.js @@ -0,0 +1,260 @@ +'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 ExternalCampaignList; +var ExternalCampaignPage; +var ExternalCampaignInstance; + +/* jshint ignore:start */ +/** + * Initialize the ExternalCampaignList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ExternalCampaignList + * + * @param {Twilio.Messaging.V1} version - Version of the resource + */ +/* jshint ignore:end */ +ExternalCampaignList = function ExternalCampaignList(version) { + /* jshint ignore:start */ + /** + * @function externalCampaign + * @memberof Twilio.Messaging.V1# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Messaging.V1.ExternalCampaignContext} + */ + /* jshint ignore:end */ + function ExternalCampaignListInstance(sid) { + return ExternalCampaignListInstance.get(sid); + } + + ExternalCampaignListInstance._version = version; + // Path Solution + ExternalCampaignListInstance._solution = {}; + ExternalCampaignListInstance._uri = `/Services/PreregisteredUsa2p`; + /* jshint ignore:start */ + /** + * create a ExternalCampaignInstance + * + * @function create + * @memberof Twilio.Messaging.V1.ExternalCampaignList# + * + * @param {object} opts - Options for request + * @param {string} opts.campaignId - ID of the preregistered campaign. + * @param {string} opts.messagingServiceSid - + * The SID of the Messaging Service the resource is associated with + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed ExternalCampaignInstance + */ + /* jshint ignore:end */ + ExternalCampaignListInstance.create = function create(opts, callback) { + if (_.isUndefined(opts)) { + throw new Error('Required parameter "opts" missing.'); + } + if (_.isUndefined(opts.campaignId)) { + throw new Error('Required parameter "opts.campaignId" missing.'); + } + if (_.isUndefined(opts.messagingServiceSid)) { + throw new Error('Required parameter "opts.messagingServiceSid" missing.'); + } + + var deferred = Q.defer(); + var data = values.of({ + 'CampaignId': _.get(opts, 'campaignId'), + 'MessagingServiceSid': _.get(opts, 'messagingServiceSid') + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new ExternalCampaignInstance(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.Messaging.V1.ExternalCampaignList# + * + * @returns Object + */ + /* jshint ignore:end */ + ExternalCampaignListInstance.toJSON = function toJSON() { + return this._solution; + }; + + ExternalCampaignListInstance[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); + }; + + return ExternalCampaignListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the ExternalCampaignPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ExternalCampaignPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {ExternalCampaignSolution} solution - Path solution + * + * @returns ExternalCampaignPage + */ +/* jshint ignore:end */ +ExternalCampaignPage = function ExternalCampaignPage(version, response, + solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(ExternalCampaignPage.prototype, Page.prototype); +ExternalCampaignPage.prototype.constructor = ExternalCampaignPage; + +/* jshint ignore:start */ +/** + * Build an instance of ExternalCampaignInstance + * + * @function getInstance + * @memberof Twilio.Messaging.V1.ExternalCampaignPage# + * + * @param {ExternalCampaignPayload} payload - Payload response from the API + * + * @returns ExternalCampaignInstance + */ +/* jshint ignore:end */ +ExternalCampaignPage.prototype.getInstance = function getInstance(payload) { + return new ExternalCampaignInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Messaging.V1.ExternalCampaignPage# + * + * @returns Object + */ +/* jshint ignore:end */ +ExternalCampaignPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ExternalCampaignPage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the ExternalCampaignContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ExternalCampaignInstance + * + * @property {string} accountSid - The SID of the Account that created the resource + * @property {string} campaignId - ID of the preregistered campaign. + * @property {string} messagingServiceSid - + * The SID of the Messaging Service the resource is associated with + * @property {Date} dateCreated - + * The ISO 8601 date and time in GMT when the resource was created + * + * @param {V1} version - Version of the resource + * @param {ExternalCampaignPayload} payload - The instance payload + */ +/* jshint ignore:end */ +ExternalCampaignInstance = function ExternalCampaignInstance(version, payload) { + this._version = version; + + // Marshaled Properties + this.accountSid = payload.account_sid; // jshint ignore:line + this.campaignId = payload.campaign_id; // jshint ignore:line + this.messagingServiceSid = payload.messaging_service_sid; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {}; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Messaging.V1.ExternalCampaignInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +ExternalCampaignInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ExternalCampaignInstance.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + ExternalCampaignList: ExternalCampaignList, + ExternalCampaignPage: ExternalCampaignPage, + ExternalCampaignInstance: ExternalCampaignInstance +}; diff --git a/lib/rest/messaging/v1/service.d.ts b/lib/rest/messaging/v1/service.d.ts index 7a46aa76eb..f842fad8ef 100644 --- a/lib/rest/messaging/v1/service.d.ts +++ b/lib/rest/messaging/v1/service.d.ts @@ -15,6 +15,10 @@ import { PhoneNumberListInstance } from './service/phoneNumber'; import { SerializableClass } from '../../../interfaces'; import { ShortCodeList } from './service/shortCode'; import { ShortCodeListInstance } from './service/shortCode'; +import { UsAppToPersonList } from './service/usAppToPerson'; +import { UsAppToPersonListInstance } from './service/usAppToPerson'; +import { UsAppToPersonUsecaseList } from './service/usAppToPersonUsecase'; +import { UsAppToPersonUsecaseListInstance } from './service/usAppToPersonUsecase'; type ServiceScanMessageContent = 'inherit'|'enable'|'disable'; @@ -349,6 +353,8 @@ declare class ServiceContext { * @param callback - Callback to handle processed record */ update(opts?: ServiceInstanceUpdateOptions, callback?: (error: Error | null, items: ServiceInstance) => any): Promise; + usAppToPerson: UsAppToPersonListInstance; + usAppToPersonUsecases: UsAppToPersonUsecaseListInstance; } @@ -426,6 +432,14 @@ declare class ServiceInstance extends SerializableClass { */ update(opts?: ServiceInstanceUpdateOptions, callback?: (error: Error | null, items: ServiceInstance) => any): Promise; url: string; + /** + * Access the usAppToPerson + */ + usAppToPerson(): UsAppToPersonListInstance; + /** + * Access the usAppToPersonUsecases + */ + usAppToPersonUsecases(): UsAppToPersonUsecaseListInstance; validityPeriod: number; } diff --git a/lib/rest/messaging/v1/service.js b/lib/rest/messaging/v1/service.js index c55a8032f1..07f1f30c3f 100644 --- a/lib/rest/messaging/v1/service.js +++ b/lib/rest/messaging/v1/service.js @@ -16,6 +16,9 @@ var AlphaSenderList = require('./service/alphaSender').AlphaSenderList; var Page = require('../../../base/Page'); /* jshint ignore:line */ var PhoneNumberList = require('./service/phoneNumber').PhoneNumberList; var ShortCodeList = require('./service/shortCode').ShortCodeList; +var UsAppToPersonList = require('./service/usAppToPerson').UsAppToPersonList; +var UsAppToPersonUsecaseList = require( + './service/usAppToPersonUsecase').UsAppToPersonUsecaseList; var deserialize = require( '../../../base/deserialize'); /* jshint ignore:line */ var serialize = require('../../../base/serialize'); /* jshint ignore:line */ @@ -690,6 +693,35 @@ ServiceInstance.prototype.alphaSenders = function alphaSenders() { return this._proxy.alphaSenders; }; +/* jshint ignore:start */ +/** + * Access the usAppToPerson + * + * @function usAppToPerson + * @memberof Twilio.Messaging.V1.ServiceInstance# + * + * @returns {Twilio.Messaging.V1.ServiceContext.UsAppToPersonList} + */ +/* jshint ignore:end */ +ServiceInstance.prototype.usAppToPerson = function usAppToPerson() { + return this._proxy.usAppToPerson; +}; + +/* jshint ignore:start */ +/** + * Access the usAppToPersonUsecases + * + * @function usAppToPersonUsecases + * @memberof Twilio.Messaging.V1.ServiceInstance# + * + * @returns {Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecaseList} + */ +/* jshint ignore:end */ +ServiceInstance.prototype.usAppToPersonUsecases = function + usAppToPersonUsecases() { + return this._proxy.usAppToPersonUsecases; +}; + /* jshint ignore:start */ /** * Provide a user-friendly representation @@ -731,6 +763,10 @@ ServiceInstance.prototype[util.inspect.custom] = function inspect(depth, * shortCodes resource * @property {Twilio.Messaging.V1.ServiceContext.AlphaSenderList} alphaSenders - * alphaSenders resource + * @property {Twilio.Messaging.V1.ServiceContext.UsAppToPersonList} usAppToPerson - + * usAppToPerson resource + * @property {Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecaseList} usAppToPersonUsecases - + * usAppToPersonUsecases resource * * @param {V1} version - Version of the resource * @param {sid} sid - The SID that identifies the resource to fetch @@ -747,6 +783,8 @@ ServiceContext = function ServiceContext(version, sid) { this._phoneNumbers = undefined; this._shortCodes = undefined; this._alphaSenders = undefined; + this._usAppToPerson = undefined; + this._usAppToPersonUsecases = undefined; }; /* jshint ignore:start */ @@ -921,6 +959,26 @@ Object.defineProperty(ServiceContext.prototype, } }); +Object.defineProperty(ServiceContext.prototype, + 'usAppToPerson', { + get: function() { + if (!this._usAppToPerson) { + this._usAppToPerson = new UsAppToPersonList(this._version, this._solution.sid); + } + return this._usAppToPerson; + } +}); + +Object.defineProperty(ServiceContext.prototype, + 'usAppToPersonUsecases', { + get: function() { + if (!this._usAppToPersonUsecases) { + this._usAppToPersonUsecases = new UsAppToPersonUsecaseList(this._version, this._solution.sid); + } + return this._usAppToPersonUsecases; + } +}); + /* jshint ignore:start */ /** * Provide a user-friendly representation diff --git a/lib/rest/messaging/v1/service/usAppToPerson.d.ts b/lib/rest/messaging/v1/service/usAppToPerson.d.ts new file mode 100644 index 0000000000..074bd4ad1d --- /dev/null +++ b/lib/rest/messaging/v1/service/usAppToPerson.d.ts @@ -0,0 +1,155 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../../base/Page'); +import Response = require('../../../../http/response'); +import V1 = require('../../V1'); +import { SerializableClass } from '../../../../interfaces'; + +/** + * Initialize the UsAppToPersonList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param messagingServiceSid - The SID of the Messaging Service the resource is associated with + */ +declare function UsAppToPersonList(version: V1, messagingServiceSid: string): UsAppToPersonListInstance; + +interface UsAppToPersonListInstance { + /** + * create a UsAppToPersonInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts: UsAppToPersonListInstanceCreateOptions, callback?: (error: Error | null, item: UsAppToPersonInstance) => any): Promise; + /** + * fetch a UsAppToPersonInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UsAppToPersonListInstance) => any): Promise; + /** + * remove a UsAppToPersonInstance + * + * @param callback - Callback to handle processed record + */ + remove(callback?: (error: Error | null, items: UsAppToPersonListInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to create + * + * @property brandRegistrationSid - A2P Brand Registration SID + * @property description - A short description of what this SMS campaign does + * @property hasEmbeddedLinks - Indicates that this SMS campaign will send messages that contain links + * @property hasEmbeddedPhone - Indicates that this SMS campaign will send messages that contain phone numbers + * @property messageSamples - Message samples + * @property usAppToPersonUsecase - A2P Campaign Use Case. + */ +interface UsAppToPersonListInstanceCreateOptions { + brandRegistrationSid: string; + description: string; + hasEmbeddedLinks: boolean; + hasEmbeddedPhone: boolean; + messageSamples: string | string[]; + usAppToPersonUsecase: string; +} + +interface UsAppToPersonPayload extends UsAppToPersonResource, Page.TwilioResponsePayload { +} + +interface UsAppToPersonResource { + account_sid: string; + brand_registration_sid: string; + campaign_id: string; + date_created: Date; + date_updated: Date; + description: string; + has_embedded_links: boolean; + has_embedded_phone: boolean; + is_externally_registered: boolean; + message_samples: string[]; + messaging_service_sid: string; + rate_limits: object; + status: string; + url: string; + us_app_to_person_usecase: string; +} + +interface UsAppToPersonSolution { + messagingServiceSid?: string; +} + + +declare class UsAppToPersonInstance extends SerializableClass { + /** + * Initialize the UsAppToPersonContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param messagingServiceSid - The SID of the Messaging Service the resource is associated with + */ + constructor(version: V1, payload: UsAppToPersonPayload, messagingServiceSid: string); + + accountSid: string; + brandRegistrationSid: string; + campaignId: string; + dateCreated: Date; + dateUpdated: Date; + description: string; + hasEmbeddedLinks: boolean; + hasEmbeddedPhone: boolean; + isExternallyRegistered: boolean; + messageSamples: string[]; + messagingServiceSid: string; + rateLimits: any; + status: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + url: string; + usAppToPersonUsecase: string; +} + + +declare class UsAppToPersonPage extends Page { + /** + * Initialize the UsAppToPersonPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: UsAppToPersonSolution); + + /** + * Build an instance of UsAppToPersonInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: UsAppToPersonPayload): UsAppToPersonInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { UsAppToPersonInstance, UsAppToPersonList, UsAppToPersonListInstance, UsAppToPersonListInstanceCreateOptions, UsAppToPersonPage, UsAppToPersonPayload, UsAppToPersonResource, UsAppToPersonSolution } diff --git a/lib/rest/messaging/v1/service/usAppToPerson.js b/lib/rest/messaging/v1/service/usAppToPerson.js new file mode 100644 index 0000000000..8923ca7da0 --- /dev/null +++ b/lib/rest/messaging/v1/service/usAppToPerson.js @@ -0,0 +1,385 @@ +'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 UsAppToPersonList; +var UsAppToPersonPage; +var UsAppToPersonInstance; + +/* jshint ignore:start */ +/** + * Initialize the UsAppToPersonList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ServiceContext.UsAppToPersonList + * + * @param {Twilio.Messaging.V1} version - Version of the resource + * @param {string} messagingServiceSid - + * The SID of the Messaging Service the resource is associated with + */ +/* jshint ignore:end */ +UsAppToPersonList = function UsAppToPersonList(version, messagingServiceSid) { + /* jshint ignore:start */ + /** + * @function usAppToPerson + * @memberof Twilio.Messaging.V1.ServiceContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Messaging.V1.ServiceContext.UsAppToPersonContext} + */ + /* jshint ignore:end */ + function UsAppToPersonListInstance(sid) { + return UsAppToPersonListInstance.get(sid); + } + + UsAppToPersonListInstance._version = version; + // Path Solution + UsAppToPersonListInstance._solution = {messagingServiceSid: messagingServiceSid}; + UsAppToPersonListInstance._uri = `/Services/${messagingServiceSid}/Compliance/Usa2p`; + /* jshint ignore:start */ + /** + * create a UsAppToPersonInstance + * + * @function create + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonList# + * + * @param {object} opts - Options for request + * @param {string} opts.brandRegistrationSid - A2P Brand Registration SID + * @param {string} opts.description - + * A short description of what this SMS campaign does + * @param {string|list} opts.messageSamples - Message samples + * @param {string} opts.usAppToPersonUsecase - A2P Campaign Use Case. + * @param {boolean} opts.hasEmbeddedLinks - + * Indicates that this SMS campaign will send messages that contain links + * @param {boolean} opts.hasEmbeddedPhone - + * Indicates that this SMS campaign will send messages that contain phone numbers + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsAppToPersonInstance + */ + /* jshint ignore:end */ + UsAppToPersonListInstance.create = function create(opts, callback) { + if (_.isUndefined(opts)) { + throw new Error('Required parameter "opts" missing.'); + } + if (_.isUndefined(opts.brandRegistrationSid)) { + throw new Error('Required parameter "opts.brandRegistrationSid" missing.'); + } + if (_.isUndefined(opts.description)) { + throw new Error('Required parameter "opts.description" missing.'); + } + if (_.isUndefined(opts.messageSamples)) { + throw new Error('Required parameter "opts.messageSamples" missing.'); + } + if (_.isUndefined(opts.usAppToPersonUsecase)) { + throw new Error('Required parameter "opts.usAppToPersonUsecase" missing.'); + } + if (_.isUndefined(opts.hasEmbeddedLinks)) { + throw new Error('Required parameter "opts.hasEmbeddedLinks" missing.'); + } + if (_.isUndefined(opts.hasEmbeddedPhone)) { + throw new Error('Required parameter "opts.hasEmbeddedPhone" missing.'); + } + + var deferred = Q.defer(); + var data = values.of({ + 'BrandRegistrationSid': _.get(opts, 'brandRegistrationSid'), + 'Description': _.get(opts, 'description'), + 'MessageSamples': serialize.map(_.get(opts, 'messageSamples'), function(e) { return e; }), + 'UsAppToPersonUsecase': _.get(opts, 'usAppToPersonUsecase'), + 'HasEmbeddedLinks': serialize.bool(_.get(opts, 'hasEmbeddedLinks')), + 'HasEmbeddedPhone': serialize.bool(_.get(opts, 'hasEmbeddedPhone')) + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new UsAppToPersonInstance( + this._version, + payload, + this._solution.messagingServiceSid + )); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * remove a UsAppToPersonInstance + * + * @function remove + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonList# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsAppToPersonInstance + */ + /* jshint ignore:end */ + UsAppToPersonListInstance.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 */ + /** + * fetch a UsAppToPersonInstance + * + * @function fetch + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonList# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsAppToPersonInstance + */ + /* jshint ignore:end */ + UsAppToPersonListInstance.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 UsAppToPersonInstance( + this._version, + payload, + this._solution.messagingServiceSid + )); + }.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.Messaging.V1.ServiceContext.UsAppToPersonList# + * + * @returns Object + */ + /* jshint ignore:end */ + UsAppToPersonListInstance.toJSON = function toJSON() { + return this._solution; + }; + + UsAppToPersonListInstance[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); + }; + + return UsAppToPersonListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the UsAppToPersonPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ServiceContext.UsAppToPersonPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {UsAppToPersonSolution} solution - Path solution + * + * @returns UsAppToPersonPage + */ +/* jshint ignore:end */ +UsAppToPersonPage = function UsAppToPersonPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(UsAppToPersonPage.prototype, Page.prototype); +UsAppToPersonPage.prototype.constructor = UsAppToPersonPage; + +/* jshint ignore:start */ +/** + * Build an instance of UsAppToPersonInstance + * + * @function getInstance + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonPage# + * + * @param {UsAppToPersonPayload} payload - Payload response from the API + * + * @returns UsAppToPersonInstance + */ +/* jshint ignore:end */ +UsAppToPersonPage.prototype.getInstance = function getInstance(payload) { + return new UsAppToPersonInstance(this._version, payload, this._solution.messagingServiceSid); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonPage# + * + * @returns Object + */ +/* jshint ignore:end */ +UsAppToPersonPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UsAppToPersonPage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UsAppToPersonContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ServiceContext.UsAppToPersonInstance + * + * @property {string} accountSid - The SID of the Account that created the resource + * @property {string} brandRegistrationSid - A2P Brand Registration SID + * @property {string} messagingServiceSid - + * The SID of the Messaging Service the resource is associated with + * @property {string} description - + * A short description of what this SMS campaign does + * @property {string} messageSamples - Message samples + * @property {string} usAppToPersonUsecase - A2P Campaign Use Case. + * @property {boolean} hasEmbeddedLinks - + * Indicate that this SMS campaign will send messages that contain links + * @property {boolean} hasEmbeddedPhone - + * Indicates that this SMS campaign will send messages that contain phone numbers + * @property {string} status - Campaign status + * @property {string} campaignId - The Campaign Registry (TCR) Campaign ID. + * @property {boolean} isExternallyRegistered - + * Indicates whether the campaign was registered externally or not + * @property {object} rateLimits - + * Rate limit and/or classification set by each carrier + * @property {Date} dateCreated - + * The ISO 8601 date and time in GMT when the resource was created + * @property {Date} dateUpdated - + * The ISO 8601 date and time in GMT when the resource was last updated + * @property {string} url - The absolute URL of the US App to Person resource + * + * @param {V1} version - Version of the resource + * @param {UsAppToPersonPayload} payload - The instance payload + * @param {sid} messagingServiceSid - + * The SID of the Messaging Service the resource is associated with + */ +/* jshint ignore:end */ +UsAppToPersonInstance = function UsAppToPersonInstance(version, payload, + messagingServiceSid) { + this._version = version; + + // Marshaled Properties + this.accountSid = payload.account_sid; // jshint ignore:line + this.brandRegistrationSid = payload.brand_registration_sid; // jshint ignore:line + this.messagingServiceSid = payload.messaging_service_sid; // jshint ignore:line + this.description = payload.description; // jshint ignore:line + this.messageSamples = payload.message_samples; // jshint ignore:line + this.usAppToPersonUsecase = payload.us_app_to_person_usecase; // jshint ignore:line + this.hasEmbeddedLinks = payload.has_embedded_links; // jshint ignore:line + this.hasEmbeddedPhone = payload.has_embedded_phone; // jshint ignore:line + this.status = payload.status; // jshint ignore:line + this.campaignId = payload.campaign_id; // jshint ignore:line + this.isExternallyRegistered = payload.is_externally_registered; // jshint ignore:line + this.rateLimits = payload.rate_limits; // 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 = {messagingServiceSid: messagingServiceSid, }; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +UsAppToPersonInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UsAppToPersonInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + UsAppToPersonList: UsAppToPersonList, + UsAppToPersonPage: UsAppToPersonPage, + UsAppToPersonInstance: UsAppToPersonInstance +}; diff --git a/lib/rest/messaging/v1/service/usAppToPersonUsecase.d.ts b/lib/rest/messaging/v1/service/usAppToPersonUsecase.d.ts new file mode 100644 index 0000000000..318bd624e6 --- /dev/null +++ b/lib/rest/messaging/v1/service/usAppToPersonUsecase.d.ts @@ -0,0 +1,95 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../../base/Page'); +import Response = require('../../../../http/response'); +import V1 = require('../../V1'); +import { SerializableClass } from '../../../../interfaces'; + +/** + * Initialize the UsAppToPersonUsecaseList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param messagingServiceSid - The unique string that identifies the resource + */ +declare function UsAppToPersonUsecaseList(version: V1, messagingServiceSid: string): UsAppToPersonUsecaseListInstance; + +interface UsAppToPersonUsecaseListInstance { + /** + * fetch a UsAppToPersonUsecaseInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UsAppToPersonUsecaseListInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +interface UsAppToPersonUsecasePayload extends UsAppToPersonUsecaseResource, Page.TwilioResponsePayload { +} + +interface UsAppToPersonUsecaseResource { + us_app_to_person_usecases: object[]; +} + +interface UsAppToPersonUsecaseSolution { + messagingServiceSid?: string; +} + + +declare class UsAppToPersonUsecaseInstance extends SerializableClass { + /** + * Initialize the UsAppToPersonUsecaseContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param messagingServiceSid - The unique string that identifies the resource + */ + constructor(version: V1, payload: UsAppToPersonUsecasePayload, messagingServiceSid: string); + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + usAppToPersonUsecases: object[]; +} + + +declare class UsAppToPersonUsecasePage extends Page { + /** + * Initialize the UsAppToPersonUsecasePage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: UsAppToPersonUsecaseSolution); + + /** + * Build an instance of UsAppToPersonUsecaseInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: UsAppToPersonUsecasePayload): UsAppToPersonUsecaseInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { UsAppToPersonUsecaseInstance, UsAppToPersonUsecaseList, UsAppToPersonUsecaseListInstance, UsAppToPersonUsecasePage, UsAppToPersonUsecasePayload, UsAppToPersonUsecaseResource, UsAppToPersonUsecaseSolution } diff --git a/lib/rest/messaging/v1/service/usAppToPersonUsecase.js b/lib/rest/messaging/v1/service/usAppToPersonUsecase.js new file mode 100644 index 0000000000..6511edf2ee --- /dev/null +++ b/lib/rest/messaging/v1/service/usAppToPersonUsecase.js @@ -0,0 +1,241 @@ +'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 UsAppToPersonUsecaseList; +var UsAppToPersonUsecasePage; +var UsAppToPersonUsecaseInstance; + +/* jshint ignore:start */ +/** + * Initialize the UsAppToPersonUsecaseList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecaseList + * + * @param {Twilio.Messaging.V1} version - Version of the resource + * @param {string} messagingServiceSid - + * The unique string that identifies the resource + */ +/* jshint ignore:end */ +UsAppToPersonUsecaseList = function UsAppToPersonUsecaseList(version, + messagingServiceSid) { + /* jshint ignore:start */ + /** + * @function usAppToPersonUsecases + * @memberof Twilio.Messaging.V1.ServiceContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecaseContext} + */ + /* jshint ignore:end */ + function UsAppToPersonUsecaseListInstance(sid) { + return UsAppToPersonUsecaseListInstance.get(sid); + } + + UsAppToPersonUsecaseListInstance._version = version; + // Path Solution + UsAppToPersonUsecaseListInstance._solution = {messagingServiceSid: messagingServiceSid}; + UsAppToPersonUsecaseListInstance._uri = `/Services/${messagingServiceSid}/Compliance/Usa2p/Usecases`; + /* jshint ignore:start */ + /** + * fetch a UsAppToPersonUsecaseInstance + * + * @function fetch + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecaseList# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsAppToPersonUsecaseInstance + */ + /* jshint ignore:end */ + UsAppToPersonUsecaseListInstance.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 UsAppToPersonUsecaseInstance( + this._version, + payload, + this._solution.messagingServiceSid + )); + }.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.Messaging.V1.ServiceContext.UsAppToPersonUsecaseList# + * + * @returns Object + */ + /* jshint ignore:end */ + UsAppToPersonUsecaseListInstance.toJSON = function toJSON() { + return this._solution; + }; + + UsAppToPersonUsecaseListInstance[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); + }; + + return UsAppToPersonUsecaseListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the UsAppToPersonUsecasePage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecasePage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {UsAppToPersonUsecaseSolution} solution - Path solution + * + * @returns UsAppToPersonUsecasePage + */ +/* jshint ignore:end */ +UsAppToPersonUsecasePage = function UsAppToPersonUsecasePage(version, response, + solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(UsAppToPersonUsecasePage.prototype, Page.prototype); +UsAppToPersonUsecasePage.prototype.constructor = UsAppToPersonUsecasePage; + +/* jshint ignore:start */ +/** + * Build an instance of UsAppToPersonUsecaseInstance + * + * @function getInstance + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecasePage# + * + * @param {UsAppToPersonUsecasePayload} payload - Payload response from the API + * + * @returns UsAppToPersonUsecaseInstance + */ +/* jshint ignore:end */ +UsAppToPersonUsecasePage.prototype.getInstance = function getInstance(payload) { + return new UsAppToPersonUsecaseInstance(this._version, payload, this._solution.messagingServiceSid); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecasePage# + * + * @returns Object + */ +/* jshint ignore:end */ +UsAppToPersonUsecasePage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UsAppToPersonUsecasePage.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UsAppToPersonUsecaseContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecaseInstance + * + * @property {object} usAppToPersonUsecases - Human readable A2P Use Case details + * + * @param {V1} version - Version of the resource + * @param {UsAppToPersonUsecasePayload} payload - The instance payload + * @param {sid} messagingServiceSid - + * The unique string that identifies the resource + */ +/* jshint ignore:end */ +UsAppToPersonUsecaseInstance = function UsAppToPersonUsecaseInstance(version, + payload, messagingServiceSid) { + this._version = version; + + // Marshaled Properties + this.usAppToPersonUsecases = payload.us_app_to_person_usecases; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {messagingServiceSid: messagingServiceSid, }; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonUsecaseInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +UsAppToPersonUsecaseInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UsAppToPersonUsecaseInstance.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + UsAppToPersonUsecaseList: UsAppToPersonUsecaseList, + UsAppToPersonUsecasePage: UsAppToPersonUsecasePage, + UsAppToPersonUsecaseInstance: UsAppToPersonUsecaseInstance +}; diff --git a/lib/rest/messaging/v1/usecase.d.ts b/lib/rest/messaging/v1/usecase.d.ts new file mode 100644 index 0000000000..bf2c2665c4 --- /dev/null +++ b/lib/rest/messaging/v1/usecase.d.ts @@ -0,0 +1,92 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V1 = require('../V1'); +import { SerializableClass } from '../../../interfaces'; + +/** + * Initialize the UsecaseList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + */ +declare function UsecaseList(version: V1): UsecaseListInstance; + +interface UsecaseListInstance { + /** + * fetch a UsecaseInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UsecaseListInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +interface UsecasePayload extends UsecaseResource, Page.TwilioResponsePayload { +} + +interface UsecaseResource { + usecases: object[]; +} + +interface UsecaseSolution { +} + + +declare class UsecaseInstance extends SerializableClass { + /** + * Initialize the UsecaseContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param payload - The instance payload + */ + constructor(version: V1, payload: UsecasePayload); + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + usecases: object[]; +} + + +declare class UsecasePage extends Page { + /** + * Initialize the UsecasePage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: UsecaseSolution); + + /** + * Build an instance of UsecaseInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: UsecasePayload): UsecaseInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { UsecaseInstance, UsecaseList, UsecaseListInstance, UsecasePage, UsecasePayload, UsecaseResource, UsecaseSolution } diff --git a/lib/rest/messaging/v1/usecase.js b/lib/rest/messaging/v1/usecase.js new file mode 100644 index 0000000000..4c277970d3 --- /dev/null +++ b/lib/rest/messaging/v1/usecase.js @@ -0,0 +1,228 @@ +'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 UsecaseList; +var UsecasePage; +var UsecaseInstance; + +/* jshint ignore:start */ +/** + * Initialize the UsecaseList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.UsecaseList + * + * @param {Twilio.Messaging.V1} version - Version of the resource + */ +/* jshint ignore:end */ +UsecaseList = function UsecaseList(version) { + /* jshint ignore:start */ + /** + * @function usecases + * @memberof Twilio.Messaging.V1# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Messaging.V1.UsecaseContext} + */ + /* jshint ignore:end */ + function UsecaseListInstance(sid) { + return UsecaseListInstance.get(sid); + } + + UsecaseListInstance._version = version; + // Path Solution + UsecaseListInstance._solution = {}; + UsecaseListInstance._uri = `/Services/Usecases`; + /* jshint ignore:start */ + /** + * fetch a UsecaseInstance + * + * @function fetch + * @memberof Twilio.Messaging.V1.UsecaseList# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsecaseInstance + */ + /* jshint ignore:end */ + UsecaseListInstance.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 UsecaseInstance(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.Messaging.V1.UsecaseList# + * + * @returns Object + */ + /* jshint ignore:end */ + UsecaseListInstance.toJSON = function toJSON() { + return this._solution; + }; + + UsecaseListInstance[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return UsecaseListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the UsecasePage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.UsecasePage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {UsecaseSolution} solution - Path solution + * + * @returns UsecasePage + */ +/* jshint ignore:end */ +UsecasePage = function UsecasePage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(UsecasePage.prototype, Page.prototype); +UsecasePage.prototype.constructor = UsecasePage; + +/* jshint ignore:start */ +/** + * Build an instance of UsecaseInstance + * + * @function getInstance + * @memberof Twilio.Messaging.V1.UsecasePage# + * + * @param {UsecasePayload} payload - Payload response from the API + * + * @returns UsecaseInstance + */ +/* jshint ignore:end */ +UsecasePage.prototype.getInstance = function getInstance(payload) { + return new UsecaseInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Messaging.V1.UsecasePage# + * + * @returns Object + */ +/* jshint ignore:end */ +UsecasePage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UsecasePage.prototype[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UsecaseContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.UsecaseInstance + * + * @property {object} usecases - Human readable Messaging Service Use Case details + * + * @param {V1} version - Version of the resource + * @param {UsecasePayload} payload - The instance payload + */ +/* jshint ignore:end */ +UsecaseInstance = function UsecaseInstance(version, payload) { + this._version = version; + + // Marshaled Properties + this.usecases = payload.usecases; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {}; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Messaging.V1.UsecaseInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +UsecaseInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UsecaseInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + UsecaseList: UsecaseList, + UsecasePage: UsecasePage, + UsecaseInstance: UsecaseInstance +}; diff --git a/lib/rest/supersim/v1/sim.d.ts b/lib/rest/supersim/v1/sim.d.ts index 4cd96ec9a6..764517498c 100644 --- a/lib/rest/supersim/v1/sim.d.ts +++ b/lib/rest/supersim/v1/sim.d.ts @@ -48,6 +48,13 @@ interface SimListInstance { * @param sid - sid of instance */ (sid: string): SimContext; + /** + * create a SimInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts: SimListInstanceCreateOptions, callback?: (error: Error | null, item: SimInstance) => any): Promise; /** * Streams SimInstance records from the API. * @@ -156,6 +163,17 @@ interface SimListInstance { toJSON(): any; } +/** + * Options to pass to create + * + * @property iccid - The {@link https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID|ICCID} of the Super SIM to be added to your Account + * @property registrationCode - The 10 digit code required to claim the Super SIM for your Account + */ +interface SimListInstanceCreateOptions { + iccid: string; + registrationCode: string; +} + /** * Options to pass to each * @@ -362,4 +380,4 @@ declare class SimPage extends Page { toJSON(): any; } -export { SimContext, SimInstance, SimInstanceUpdateOptions, SimList, SimListInstance, SimListInstanceEachOptions, SimListInstanceOptions, SimListInstancePageOptions, SimPage, SimPayload, SimResource, SimSolution, SimStatus, SimStatusUpdate } +export { SimContext, SimInstance, SimInstanceUpdateOptions, SimList, SimListInstance, SimListInstanceCreateOptions, SimListInstanceEachOptions, SimListInstanceOptions, SimListInstancePageOptions, SimPage, SimPayload, SimResource, SimSolution, SimStatus, SimStatusUpdate } diff --git a/lib/rest/supersim/v1/sim.js b/lib/rest/supersim/v1/sim.js index 3295ae3261..3d48308e62 100644 --- a/lib/rest/supersim/v1/sim.js +++ b/lib/rest/supersim/v1/sim.js @@ -53,6 +53,57 @@ SimList = function SimList(version) { // Path Solution SimListInstance._solution = {}; SimListInstance._uri = `/Sims`; + /* jshint ignore:start */ + /** + * create a SimInstance + * + * @function create + * @memberof Twilio.Supersim.V1.SimList# + * + * @param {object} opts - Options for request + * @param {string} opts.iccid - + * The {@link https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID|ICCID} of the Super SIM to be added to your Account + * @param {string} opts.registrationCode - + * The 10 digit code required to claim the Super SIM for your Account + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SimInstance + */ + /* jshint ignore:end */ + SimListInstance.create = function create(opts, callback) { + if (_.isUndefined(opts)) { + throw new Error('Required parameter "opts" missing.'); + } + if (_.isUndefined(opts.iccid)) { + throw new Error('Required parameter "opts.iccid" missing.'); + } + if (_.isUndefined(opts.registrationCode)) { + throw new Error('Required parameter "opts.registrationCode" missing.'); + } + + var deferred = Q.defer(); + var data = values.of({ + 'Iccid': _.get(opts, 'iccid'), + 'RegistrationCode': _.get(opts, 'registrationCode') + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new SimInstance(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 */ /** * Streams SimInstance records from the API. diff --git a/lib/rest/verify/v2/service/entity.d.ts b/lib/rest/verify/v2/service/entity.d.ts index e7f0caf822..ce5742b499 100644 --- a/lib/rest/verify/v2/service/entity.d.ts +++ b/lib/rest/verify/v2/service/entity.d.ts @@ -12,6 +12,8 @@ import { ChallengeList } from './entity/challenge'; import { ChallengeListInstance } from './entity/challenge'; import { FactorList } from './entity/factor'; import { FactorListInstance } from './entity/factor'; +import { NewFactorList } from './entity/newFactor'; +import { NewFactorListInstance } from './entity/newFactor'; import { SerializableClass } from '../../../../interfaces'; /** @@ -251,6 +253,7 @@ declare class EntityContext { * @param callback - Callback to handle processed record */ fetch(callback?: (error: Error | null, items: EntityInstance) => any): Promise; + newFactors: NewFactorListInstance; /** * remove a EntityInstance * @@ -298,6 +301,10 @@ declare class EntityInstance extends SerializableClass { fetch(callback?: (error: Error | null, items: EntityInstance) => any): Promise; identity: string; links: string; + /** + * Access the newFactors + */ + newFactors(): NewFactorListInstance; /** * remove a EntityInstance * diff --git a/lib/rest/verify/v2/service/entity.js b/lib/rest/verify/v2/service/entity.js index 46bc2f19a4..377e42411d 100644 --- a/lib/rest/verify/v2/service/entity.js +++ b/lib/rest/verify/v2/service/entity.js @@ -14,6 +14,7 @@ var _ = require('lodash'); /* jshint ignore:line */ var util = require('util'); /* jshint ignore:line */ var ChallengeList = require('./entity/challenge').ChallengeList; var FactorList = require('./entity/factor').FactorList; +var NewFactorList = require('./entity/newFactor').NewFactorList; var Page = require('../../../../base/Page'); /* jshint ignore:line */ var deserialize = require( '../../../../base/deserialize'); /* jshint ignore:line */ @@ -554,6 +555,20 @@ EntityInstance.prototype.factors = function factors() { return this._proxy.factors; }; +/* jshint ignore:start */ +/** + * Access the newFactors + * + * @function newFactors + * @memberof Twilio.Verify.V2.ServiceContext.EntityInstance# + * + * @returns {Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorList} + */ +/* jshint ignore:end */ +EntityInstance.prototype.newFactors = function newFactors() { + return this._proxy.newFactors; +}; + /* jshint ignore:start */ /** * Access the challenges @@ -605,6 +620,8 @@ EntityInstance.prototype[util.inspect.custom] = function inspect(depth, options) * * @property {Twilio.Verify.V2.ServiceContext.EntityContext.FactorList} factors - * factors resource + * @property {Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorList} newFactors - + * newFactors resource * @property {Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeList} challenges - * challenges resource * @@ -622,6 +639,7 @@ EntityContext = function EntityContext(version, serviceSid, identity) { // Dependents this._factors = undefined; + this._newFactors = undefined; this._challenges = undefined; }; @@ -702,6 +720,20 @@ Object.defineProperty(EntityContext.prototype, } }); +Object.defineProperty(EntityContext.prototype, + 'newFactors', { + get: function() { + if (!this._newFactors) { + this._newFactors = new NewFactorList( + this._version, + this._solution.serviceSid, + this._solution.identity + ); + } + return this._newFactors; + } +}); + Object.defineProperty(EntityContext.prototype, 'challenges', { get: function() { diff --git a/lib/rest/verify/v2/service/entity/factor.d.ts b/lib/rest/verify/v2/service/entity/factor.d.ts index e19b6e810d..5e974fa988 100644 --- a/lib/rest/verify/v2/service/entity/factor.d.ts +++ b/lib/rest/verify/v2/service/entity/factor.d.ts @@ -60,13 +60,6 @@ interface FactorListInstance { * @param sid - sid of instance */ (sid: string): FactorContext; - /** - * create a FactorInstance - * - * @param opts - Options for request - * @param callback - Callback to handle processed record - */ - create(opts: FactorListInstanceCreateOptions, callback?: (error: Error | null, item: FactorInstance) => any): Promise; /** * Streams FactorInstance records from the API. * @@ -175,43 +168,6 @@ interface FactorListInstance { toJSON(): any; } -/** - * Options to pass to create - * - * @property binding.alg - The algorithm used when `factor_type` is `push` - * @property binding.publicKey - The public key encoded in Base64 - * @property binding.secret - The shared secret in Base32 - * @property config.alg - The algorithm used to derive the TOTP codes - * @property config.appId - The ID that uniquely identifies your app in the Google or Apple store - * @property config.codeLength - Number of digits for generated TOTP codes - * @property config.notificationPlatform - The transport technology used to generate the Notification Token - * @property config.notificationToken - For APN, the device token. For FCM the registration token - * @property config.sdkVersion - The Verify Push SDK version used to configure the factor - * @property config.skew - The number of past and future time-steps valid at a given time - * @property config.timeStep - How often, in seconds, are TOTP codes generated - * @property factorType - The Type of this Factor - * @property friendlyName - The friendly name of this Factor - */ -interface FactorListInstanceCreateOptions { - binding?: { - alg?: string; - publicKey?: string; - secret?: string; - }; - config?: { - appId?: string; - notificationPlatform?: FactorNotificationPlatforms; - notificationToken?: string; - sdkVersion?: string; - timeStep?: number; - skew?: number; - codeLength?: number; - alg?: FactorTotpAlgorithms; - }; - factorType: FactorFactorTypes; - friendlyName: string; -} - /** * Options to pass to each * @@ -424,4 +380,4 @@ declare class FactorPage extends Page any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to create + * + * @property binding.alg - The algorithm used when `factor_type` is `push` + * @property binding.publicKey - The public key encoded in Base64 + * @property binding.secret - The shared secret in Base32 + * @property config.alg - The algorithm used to derive the TOTP codes + * @property config.appId - The ID that uniquely identifies your app in the Google or Apple store + * @property config.codeLength - Number of digits for generated TOTP codes + * @property config.notificationPlatform - The transport technology used to generate the Notification Token + * @property config.notificationToken - For APN, the device token. For FCM the registration token + * @property config.sdkVersion - The Verify Push SDK version used to configure the factor + * @property config.skew - The number of past and future time-steps valid at a given time + * @property config.timeStep - How often, in seconds, are TOTP codes generated + * @property factorType - The Type of this Factor + * @property friendlyName - The friendly name of this Factor + */ +interface NewFactorListInstanceCreateOptions { + binding?: { + alg?: string; + publicKey?: string; + secret?: string; + }; + config?: { + appId?: string; + notificationPlatform?: NewFactorNotificationPlatforms; + notificationToken?: string; + sdkVersion?: string; + timeStep?: number; + skew?: number; + codeLength?: number; + alg?: NewFactorTotpAlgorithms; + }; + factorType: NewFactorFactorTypes; + friendlyName: string; +} + +interface NewFactorPayload extends NewFactorResource, Page.TwilioResponsePayload { +} + +interface NewFactorResource { + account_sid: string; + binding: object; + config: object; + date_created: Date; + date_updated: Date; + entity_sid: string; + factor_type: NewFactorFactorTypes; + friendly_name: string; + identity: string; + service_sid: string; + sid: string; + status: NewFactorFactorStatuses; + url: string; +} + +interface NewFactorSolution { + identity?: string; + serviceSid?: string; +} + + +declare class NewFactorInstance extends SerializableClass { + /** + * Initialize the NewFactorContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param serviceSid - Service Sid. + * @param identity - Unique external identifier of the Entity + */ + constructor(version: V2, payload: NewFactorPayload, serviceSid: string, identity: string); + + accountSid: string; + binding: any; + config: any; + dateCreated: Date; + dateUpdated: Date; + entitySid: string; + factorType: NewFactorFactorTypes; + friendlyName: string; + identity: string; + serviceSid: string; + sid: string; + status: NewFactorFactorStatuses; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + url: string; +} + + +declare class NewFactorPage extends Page { + /** + * Initialize the NewFactorPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V2, response: Response, solution: NewFactorSolution); + + /** + * Build an instance of NewFactorInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: NewFactorPayload): NewFactorInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { NewFactorFactorStatuses, NewFactorFactorTypes, NewFactorInstance, NewFactorList, NewFactorListInstance, NewFactorListInstanceCreateOptions, NewFactorNotificationPlatforms, NewFactorPage, NewFactorPayload, NewFactorResource, NewFactorSolution, NewFactorTotpAlgorithms } diff --git a/lib/rest/verify/v2/service/entity/newFactor.js b/lib/rest/verify/v2/service/entity/newFactor.js new file mode 100644 index 0000000000..2530589621 --- /dev/null +++ b/lib/rest/verify/v2/service/entity/newFactor.js @@ -0,0 +1,314 @@ +'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 NewFactorList; +var NewFactorPage; +var NewFactorInstance; + +/* jshint ignore:start */ +/** + * Initialize the NewFactorList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorList + * + * @param {Twilio.Verify.V2} version - Version of the resource + * @param {string} serviceSid - Service Sid. + * @param {string} identity - Unique external identifier of the Entity + */ +/* jshint ignore:end */ +NewFactorList = function NewFactorList(version, serviceSid, identity) { + /* jshint ignore:start */ + /** + * @function newFactors + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorContext} + */ + /* jshint ignore:end */ + function NewFactorListInstance(sid) { + return NewFactorListInstance.get(sid); + } + + NewFactorListInstance._version = version; + // Path Solution + NewFactorListInstance._solution = {serviceSid: serviceSid, identity: identity}; + NewFactorListInstance._uri = `/Services/${serviceSid}/Entities/${identity}/Factors`; + /* jshint ignore:start */ + /** + * create a NewFactorInstance + * + * @function create + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorList# + * + * @param {object} opts - Options for request + * @param {string} opts.friendlyName - The friendly name of this Factor + * @param {new_factor.factor_types} opts.factorType - The Type of this Factor + * @param {string} [opts.binding.alg] - + * The algorithm used when `factor_type` is `push` + * @param {string} [opts.binding.publicKey] - The public key encoded in Base64 + * @param {string} [opts.config.appId] - + * The ID that uniquely identifies your app in the Google or Apple store + * @param {new_factor.notification_platforms} [opts.config.notificationPlatform] - + * The transport technology used to generate the Notification Token + * @param {string} [opts.config.notificationToken] - + * For APN, the device token. For FCM the registration token + * @param {string} [opts.config.sdkVersion] - + * The Verify Push SDK version used to configure the factor + * @param {string} [opts.binding.secret] - The shared secret in Base32 + * @param {number} [opts.config.timeStep] - + * How often, in seconds, are TOTP codes generated + * @param {number} [opts.config.skew] - + * The number of past and future time-steps valid at a given time + * @param {number} [opts.config.codeLength] - + * Number of digits for generated TOTP codes + * @param {new_factor.totp_algorithms} [opts.config.alg] - + * The algorithm used to derive the TOTP codes + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed NewFactorInstance + */ + /* jshint ignore:end */ + NewFactorListInstance.create = function create(opts, callback) { + if (_.isUndefined(opts)) { + throw new Error('Required parameter "opts" missing.'); + } + if (_.isUndefined(opts.friendlyName)) { + throw new Error('Required parameter "opts.friendlyName" missing.'); + } + if (_.isUndefined(opts.factorType)) { + throw new Error('Required parameter "opts.factorType" missing.'); + } + + var deferred = Q.defer(); + var data = values.of({ + 'FriendlyName': _.get(opts, 'friendlyName'), + 'FactorType': _.get(opts, 'factorType'), + 'Binding.Alg': _.get(opts, 'binding.alg'), + 'Binding.PublicKey': _.get(opts, 'binding.publicKey'), + 'Config.AppId': _.get(opts, 'config.appId'), + 'Config.NotificationPlatform': _.get(opts, 'config.notificationPlatform'), + 'Config.NotificationToken': _.get(opts, 'config.notificationToken'), + 'Config.SdkVersion': _.get(opts, 'config.sdkVersion'), + 'Binding.Secret': _.get(opts, 'binding.secret'), + 'Config.TimeStep': _.get(opts, 'config.timeStep'), + 'Config.Skew': _.get(opts, 'config.skew'), + 'Config.CodeLength': _.get(opts, 'config.codeLength'), + 'Config.Alg': _.get(opts, 'config.alg') + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new NewFactorInstance(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.Verify.V2.ServiceContext.EntityContext.NewFactorList# + * + * @returns Object + */ + /* jshint ignore:end */ + NewFactorListInstance.toJSON = function toJSON() { + return this._solution; + }; + + NewFactorListInstance[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return NewFactorListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the NewFactorPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorPage + * + * @param {V2} version - Version of the resource + * @param {Response} response - Response from the API + * @param {NewFactorSolution} solution - Path solution + * + * @returns NewFactorPage + */ +/* jshint ignore:end */ +NewFactorPage = function NewFactorPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(NewFactorPage.prototype, Page.prototype); +NewFactorPage.prototype.constructor = NewFactorPage; + +/* jshint ignore:start */ +/** + * Build an instance of NewFactorInstance + * + * @function getInstance + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorPage# + * + * @param {NewFactorPayload} payload - Payload response from the API + * + * @returns NewFactorInstance + */ +/* jshint ignore:end */ +NewFactorPage.prototype.getInstance = function getInstance(payload) { + return new NewFactorInstance( + this._version, + payload, + this._solution.serviceSid, + this._solution.identity + ); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorPage# + * + * @returns Object + */ +/* jshint ignore:end */ +NewFactorPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +NewFactorPage.prototype[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the NewFactorContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorInstance + * + * @property {string} sid - A string that uniquely identifies this Factor. + * @property {string} accountSid - Account Sid. + * @property {string} serviceSid - Service Sid. + * @property {string} entitySid - Entity Sid. + * @property {string} identity - Unique external identifier of the Entity + * @property {object} binding - Unique external identifier of the Entity + * @property {Date} dateCreated - The date this Factor was created + * @property {Date} dateUpdated - The date this Factor was updated + * @property {string} friendlyName - A human readable description of this resource. + * @property {new_factor.factor_statuses} status - The Status of this Factor + * @property {new_factor.factor_types} factorType - The Type of this Factor + * @property {object} config - Binding for a `factor_type`. + * @property {string} url - The URL of this resource. + * + * @param {V2} version - Version of the resource + * @param {NewFactorPayload} payload - The instance payload + * @param {sid} serviceSid - Service Sid. + * @param {string} identity - Unique external identifier of the Entity + */ +/* jshint ignore:end */ +NewFactorInstance = function NewFactorInstance(version, payload, serviceSid, + identity) { + this._version = version; + + // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.serviceSid = payload.service_sid; // jshint ignore:line + this.entitySid = payload.entity_sid; // jshint ignore:line + this.identity = payload.identity; // jshint ignore:line + this.binding = payload.binding; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.status = payload.status; // jshint ignore:line + this.factorType = payload.factor_type; // jshint ignore:line + this.config = payload.config; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {serviceSid: serviceSid, identity: identity, }; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.NewFactorInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +NewFactorInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +NewFactorInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + NewFactorList: NewFactorList, + NewFactorPage: NewFactorPage, + NewFactorInstance: NewFactorInstance +}; diff --git a/lib/twiml/VoiceResponse.d.ts b/lib/twiml/VoiceResponse.d.ts index d6c25e32dc..cb039be369 100644 --- a/lib/twiml/VoiceResponse.d.ts +++ b/lib/twiml/VoiceResponse.d.ts @@ -193,7 +193,7 @@ declare namespace VoiceResponse { type ConferenceBeep = 'true'|'false'|'onEnter'|'onExit'; - type ConferenceEvent = 'start'|'end'|'join'|'leave'|'mute'|'hold'|'speaker'; + type ConferenceEvent = 'start'|'end'|'join'|'leave'|'mute'|'hold'|'speaker'|'announcement'; type ConferenceJitterBufferSize = 'large'|'medium'|'small'|'off'; diff --git a/spec/integration/rest/api/v2010/account/call.spec.js b/spec/integration/rest/api/v2010/account/call.spec.js index 1db9d1c03d..5c63e35b10 100644 --- a/spec/integration/rest/api/v2010/account/call.spec.js +++ b/spec/integration/rest/api/v2010/account/call.spec.js @@ -1023,4 +1023,55 @@ describe('Call', function() { }).done(); } ); + it('should generate valid updatetimelimit response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'annotation': null, + 'answered_by': null, + 'api_version': '2010-04-01', + 'caller_name': null, + 'date_created': 'Tue, 31 Aug 2010 20:36:28 +0000', + 'date_updated': 'Tue, 31 Aug 2010 20:36:44 +0000', + 'direction': 'inbound', + 'duration': '15', + 'end_time': 'Tue, 31 Aug 2010 20:36:44 +0000', + 'forwarded_from': '+141586753093', + 'from': '+14158675308', + 'from_formatted': '(415) 867-5308', + 'group_sid': null, + 'parent_call_sid': null, + 'phone_number_sid': 'PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'price': '-0.03000', + 'price_unit': 'USD', + 'sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'start_time': 'Tue, 31 Aug 2010 20:36:29 +0000', + 'status': 'canceled', + 'subresource_uris': { + 'notifications': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json', + 'recordings': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json', + 'feedback': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Feedback.json', + 'feedback_summaries': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json', + 'payments': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json', + 'events': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json' + }, + 'to': '+14158675309', + 'to_formatted': '(415) 867-5309', + 'trunk_sid': null, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', + 'queue_time': '1000' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); }); diff --git a/spec/integration/rest/messaging/v1/externalCampaign.spec.js b/spec/integration/rest/messaging/v1/externalCampaign.spec.js new file mode 100644 index 0000000000..157e74841b --- /dev/null +++ b/spec/integration/rest/messaging/v1/externalCampaign.spec.js @@ -0,0 +1,76 @@ +'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('ExternalCampaign', 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 opts = {campaignId: 'campaign_id', messagingServiceSid: 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; + var promise = client.messaging.v1.externalCampaign.create(opts); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://messaging.twilio.com/v1/Services/PreregisteredUsa2p'; + + var values = {CampaignId: 'campaign_id', MessagingServiceSid: 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', }; + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url, + data: values + })); + } + ); + it('should generate valid create response', + function(done) { + var body = { + 'messaging_service_sid': 'MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'campaign_id': 'CMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2021-03-21T21:31:00Z' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {campaignId: 'campaign_id', messagingServiceSid: 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; + var promise = client.messaging.v1.externalCampaign.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/messaging/v1/service.spec.js b/spec/integration/rest/messaging/v1/service.spec.js index ecc057fbaa..211f379239 100644 --- a/spec/integration/rest/messaging/v1/service.spec.js +++ b/spec/integration/rest/messaging/v1/service.spec.js @@ -73,12 +73,16 @@ describe('Service', function() { 'area_code_geomatch': true, 'validity_period': 600, 'synchronous_validation': true, + 'usecase': 'marketing', + 'us_app_to_person_registered': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', 'alpha_senders': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', 'messages': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', - 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts' + 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts', + 'us_app_to_person': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p', + 'us_app_to_person_usecases': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases' }, 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; @@ -137,12 +141,16 @@ describe('Service', function() { 'fallback_url': null, 'fallback_method': 'POST', 'status_callback': 'https://www.example.com', + 'usecase': 'marketing', + 'us_app_to_person_registered': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', 'alpha_senders': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', 'messages': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', - 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts' + 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts', + 'us_app_to_person': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p', + 'us_app_to_person_usecases': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases' }, 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; @@ -190,12 +198,16 @@ describe('Service', function() { 'fallback_url': null, 'fallback_method': 'POST', 'status_callback': 'https://www.example.com', + 'usecase': 'marketing', + 'us_app_to_person_registered': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', 'alpha_senders': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', 'messages': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', - 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts' + 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts', + 'us_app_to_person': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p', + 'us_app_to_person_usecases': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases' }, 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -237,12 +249,16 @@ describe('Service', function() { 'fallback_url': null, 'fallback_method': 'POST', 'status_callback': 'https://www.example.com', + 'usecase': 'marketing', + 'us_app_to_person_registered': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', 'alpha_senders': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', 'messages': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', - 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts' + 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts', + 'us_app_to_person': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p', + 'us_app_to_person_usecases': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases' }, 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -289,12 +305,16 @@ describe('Service', function() { 'fallback_url': null, 'fallback_method': 'POST', 'status_callback': 'https://www.example.com', + 'usecase': 'marketing', + 'us_app_to_person_registered': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', 'alpha_senders': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', 'messages': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', - 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts' + 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts', + 'us_app_to_person': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p', + 'us_app_to_person_usecases': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases' }, 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -356,12 +376,16 @@ describe('Service', function() { 'fallback_url': null, 'fallback_method': 'POST', 'status_callback': 'https://www.example.com', + 'usecase': 'marketing', + 'us_app_to_person_registered': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', 'alpha_senders': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', 'messages': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', - 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts' + 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts', + 'us_app_to_person': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p', + 'us_app_to_person_usecases': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases' }, 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -421,12 +445,16 @@ describe('Service', function() { 'validity_period': 600, 'scan_message_content': 'inherit', 'synchronous_validation': true, + 'usecase': 'marketing', + 'us_app_to_person_registered': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', 'alpha_senders': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', 'messages': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', - 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts' + 'broadcasts': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Broadcasts', + 'us_app_to_person': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p', + 'us_app_to_person_usecases': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases' }, 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; diff --git a/spec/integration/rest/messaging/v1/service/usAppToPerson.spec.js b/spec/integration/rest/messaging/v1/service/usAppToPerson.spec.js new file mode 100644 index 0000000000..fae0770187 --- /dev/null +++ b/spec/integration/rest/messaging/v1/service/usAppToPerson.spec.js @@ -0,0 +1,227 @@ +'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 serialize = require( + '../../../../../../lib/base/serialize'); /* jshint ignore:line */ + + +var client; +var holodeck; + +describe('UsAppToPerson', 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 opts = { + brandRegistrationSid: 'BNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + description: 'description', + messageSamples: ['message_samples'], + usAppToPersonUsecase: 'us_app_to_person_usecase', + hasEmbeddedLinks: true, + hasEmbeddedPhone: true + }; + var promise = client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.create(opts); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var messagingServiceSid = 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://messaging.twilio.com/v1/Services/${messagingServiceSid}/Compliance/Usa2p`; + + var values = { + BrandRegistrationSid: 'BNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + Description: 'description', + MessageSamples: serialize.map(['message_samples'], function(e) { return e; }), + UsAppToPersonUsecase: 'us_app_to_person_usecase', + HasEmbeddedLinks: serialize.bool(true), + HasEmbeddedPhone: serialize.bool(true), + }; + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url, + data: values + })); + } + ); + it('should generate valid create response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'brand_registration_sid': 'BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'messaging_service_sid': 'MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'description': 'Send marketing messages about sales and offers to opted in customers.', + 'message_samples': [ + 'EXPRESS: Denim Days Event is ON', + 'LAST CHANCE: Book your next flight for just 1 (ONE) EUR' + ], + 'us_app_to_person_usecase': 'MARKETING', + 'has_embedded_links': true, + 'has_embedded_phone': false, + 'status': 'PENDING', + 'campaign_id': 'CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'is_externally_registered': false, + 'rate_limits': { + 'att': { + 'mps': 600, + 'msg_class': 'A' + }, + 'tmobile': { + 'brand_tier': 'TOP' + } + }, + 'date_created': '2021-02-18T14:48:52Z', + 'date_updated': '2021-02-18T14:48:52Z', + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p' + }; + + holodeck.mock(new Response(201, body)); + + var opts = { + brandRegistrationSid: 'BNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + description: 'description', + messageSamples: ['message_samples'], + usAppToPersonUsecase: 'us_app_to_person_usecase', + hasEmbeddedLinks: true, + hasEmbeddedPhone: true + }; + var promise = client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.create(opts); + 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.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.remove(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var messagingServiceSid = 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://messaging.twilio.com/v1/Services/${messagingServiceSid}/Compliance/Usa2p`; + + 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.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.remove(); + promise.then(function(response) { + expect(response).toBe(true); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var messagingServiceSid = 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://messaging.twilio.com/v1/Services/${messagingServiceSid}/Compliance/Usa2p`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'brand_registration_sid': 'BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'messaging_service_sid': 'MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'description': 'Send marketing messages about sales and offers to opted in customers.', + 'message_samples': [ + 'EXPRESS: Denim Days Event is ON', + 'LAST CHANCE: Book your next flight for just 1 (ONE) EUR' + ], + 'us_app_to_person_usecase': 'MARKETING', + 'has_embedded_links': true, + 'has_embedded_phone': false, + 'status': 'PENDING', + 'campaign_id': 'CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'is_externally_registered': false, + 'rate_limits': { + 'att': { + 'mps': 600, + 'msg_class': 'A' + }, + 'tmobile': { + 'brand_tier': 'TOP' + } + }, + 'date_created': '2021-02-18T14:48:52Z', + 'date_updated': '2021-02-18T14:48:52Z', + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/messaging/v1/service/usAppToPersonUsecase.spec.js b/spec/integration/rest/messaging/v1/service/usAppToPersonUsecase.spec.js new file mode 100644 index 0000000000..24ec9182e7 --- /dev/null +++ b/spec/integration/rest/messaging/v1/service/usAppToPersonUsecase.spec.js @@ -0,0 +1,83 @@ +'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('UsAppToPersonUsecase', 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.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPersonUsecases.fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var messagingServiceSid = 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://messaging.twilio.com/v1/Services/${messagingServiceSid}/Compliance/Usa2p/Usecases`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'us_app_to_person_usecases': [ + { + 'code': 'MARKETING', + 'name': 'Marketing', + 'description': 'Send marketing messages about sales and offers to opted in customers.' + }, + { + 'code': 'DELIVERY_NOTIFICATION', + 'name': 'Delivery Notification', + 'description': 'Information about the status of the delivery of a product or service.' + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPersonUsecases.fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/messaging/v1/usecase.spec.js b/spec/integration/rest/messaging/v1/usecase.spec.js new file mode 100644 index 0000000000..b45487d64b --- /dev/null +++ b/spec/integration/rest/messaging/v1/usecase.spec.js @@ -0,0 +1,80 @@ +'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('Usecase', 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.messaging.v1.usecases.fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://messaging.twilio.com/v1/Services/Usecases'; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'usecases': [ + { + 'usecase': 'notifications', + 'description': 'Transactional notifications and Alerts for any Delivery, Account, Reminder, Order, Fraud, Security, Public Service, or Emergency announcements.', + 'purpose': 'Notify my users.' + }, + { + 'usecase': 'marketing', + 'description': 'Marketing messages may contain product information, offers, and calls to action to engage with your organization.', + 'purpose': 'Market my services.' + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.messaging.v1.usecases.fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/supersim/v1/sim.spec.js b/spec/integration/rest/supersim/v1/sim.spec.js index 2ba018ca4f..e8f3d3f324 100644 --- a/spec/integration/rest/supersim/v1/sim.spec.js +++ b/spec/integration/rest/supersim/v1/sim.spec.js @@ -29,6 +29,55 @@ describe('Sim', function() { httpClient: holodeck }); }); + it('should generate valid create request', + function(done) { + holodeck.mock(new Response(500, {})); + + var opts = {iccid: 'iccid', registrationCode: 'registration_code'}; + var promise = client.supersim.v1.sims.create(opts); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://supersim.twilio.com/v1/Sims'; + + var values = {Iccid: 'iccid', RegistrationCode: 'registration_code', }; + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url, + data: values + })); + } + ); + it('should generate valid create response', + function(done) { + var body = { + 'sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unique_name': 'MySIM', + 'status': 'new', + 'fleet_sid': null, + 'iccid': 'iccid', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {iccid: 'iccid', registrationCode: 'registration_code'}; + var promise = client.supersim.v1.sims.create(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, {})); diff --git a/spec/integration/rest/verify/v2/service/entity.spec.js b/spec/integration/rest/verify/v2/service/entity.spec.js index 0a76e6c437..de10015c19 100644 --- a/spec/integration/rest/verify/v2/service/entity.spec.js +++ b/spec/integration/rest/verify/v2/service/entity.spec.js @@ -66,6 +66,7 @@ describe('Entity', function() { 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', 'links': { 'factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', + 'new_factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', 'challenges': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges' } }; @@ -157,6 +158,7 @@ describe('Entity', function() { 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', 'links': { 'factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', + 'new_factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', 'challenges': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges' } }; @@ -187,6 +189,7 @@ describe('Entity', function() { 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', 'links': { 'factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', + 'new_factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', 'challenges': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges' } } @@ -220,6 +223,7 @@ describe('Entity', function() { 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', 'links': { 'factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', + 'new_factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', 'challenges': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges' } } @@ -258,6 +262,7 @@ describe('Entity', function() { 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', 'links': { 'factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', + 'new_factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', 'challenges': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges' } } @@ -340,6 +345,7 @@ describe('Entity', function() { 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', 'links': { 'factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', + 'new_factors': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors', 'challenges': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges' } } diff --git a/spec/integration/rest/verify/v2/service/entity/factor.spec.js b/spec/integration/rest/verify/v2/service/entity/factor.spec.js index e3b436f4ed..4811c29bd9 100644 --- a/spec/integration/rest/verify/v2/service/entity/factor.spec.js +++ b/spec/integration/rest/verify/v2/service/entity/factor.spec.js @@ -29,69 +29,6 @@ describe('Factor', function() { httpClient: holodeck }); }); - it('should generate valid create request', - function(done) { - holodeck.mock(new Response(500, {})); - - var opts = {friendlyName: 'friendly_name', factorType: 'push'}; - var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities('identity') - .factors.create(opts); - promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - done(); - }).done(); - - var serviceSid = 'VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; - var identity = 'identity'; - var url = `https://verify.twilio.com/v2/Services/${serviceSid}/Entities/${identity}/Factors`; - - var values = {FriendlyName: 'friendly_name', FactorType: 'push', }; - holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url, - data: values - })); - } - ); - it('should generate valid create_push response', - function(done) { - var body = { - 'sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'friendly_name': 'friendly_name', - 'status': 'unverified', - 'factor_type': 'push', - 'config': { - 'sdk_version': '1.0', - 'app_id': 'com.example.myapp', - 'notification_platform': 'fcm', - 'notification_token': 'test_token' - }, - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' - }; - - holodeck.mock(new Response(201, body)); - - var opts = {friendlyName: 'friendly_name', factorType: 'push'}; - var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities('identity') - .factors.create(opts); - 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, {})); @@ -194,6 +131,41 @@ describe('Factor', function() { }).done(); } ); + it('should generate valid fetch_totp response', + function(done) { + var body = { + 'sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'friendly_name': 'friendly_name', + 'status': 'unverified', + 'factor_type': 'totp', + 'config': { + 'alg': 'sha1', + 'skew': 1, + 'code_length': 6, + 'time_step': 30 + }, + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .factors('YFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').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 = { @@ -371,7 +343,7 @@ describe('Factor', function() { }).done(); } ); - it('should generate valid read_full response', + it('should generate valid read_full_push response', function(done) { var body = { 'factors': [ @@ -419,6 +391,54 @@ describe('Factor', function() { }).done(); } ); + it('should generate valid read_full_totp response', + function(done) { + var body = { + 'factors': [ + { + 'sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'friendly_name': 'friendly_name', + 'status': 'unverified', + 'factor_type': 'totp', + 'config': { + 'alg': 'sha1', + 'skew': 1, + 'code_length': 6, + 'time_step': 30 + }, + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'factors' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .factors.list(); + 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, {})); @@ -468,6 +488,41 @@ describe('Factor', function() { holodeck.mock(new Response(200, body)); + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .factors('YFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid verify_totp response', + function(done) { + var body = { + 'sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'friendly_name': 'friendly_name', + 'status': 'verified', + 'factor_type': 'totp', + 'config': { + 'alg': 'sha1', + 'skew': 1, + 'code_length': 6, + 'time_step': 30 + }, + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .entities('identity') .factors('YFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); diff --git a/spec/integration/rest/verify/v2/service/entity/newFactor.spec.js b/spec/integration/rest/verify/v2/service/entity/newFactor.spec.js new file mode 100644 index 0000000000..32799ce401 --- /dev/null +++ b/spec/integration/rest/verify/v2/service/entity/newFactor.spec.js @@ -0,0 +1,139 @@ +'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('NewFactor', 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 opts = {friendlyName: 'friendly_name', factorType: 'push'}; + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .newFactors.create(opts); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var serviceSid = 'VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var identity = 'identity'; + var url = `https://verify.twilio.com/v2/Services/${serviceSid}/Entities/${identity}/Factors`; + + var values = {FriendlyName: 'friendly_name', FactorType: 'push', }; + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url, + data: values + })); + } + ); + it('should generate valid create_push response', + function(done) { + var body = { + 'sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'binding': { + 'alg': 'ES256', + 'public_key': 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE8GdwtibWe0kpgsFl6xPQBwhtwUEyeJkeozFmi2jiJDzxFSMwVy3kVR1h/dPVYOfgkC0EkfBRJ0J/6xW47FD5vA==' + }, + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'friendly_name': 'friendly_name', + 'status': 'unverified', + 'factor_type': 'push', + 'config': { + 'sdk_version': '1.0', + 'app_id': 'com.example.myapp', + 'notification_platform': 'fcm', + 'notification_token': 'test_token' + }, + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {friendlyName: 'friendly_name', factorType: 'push'}; + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .newFactors.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid create_totp response', + function(done) { + var body = { + 'sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'binding': { + 'secret': 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ', + 'uri': 'otpauth://totp/The%20Issuer:My%20Account?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=The%20Issuer&algorithm=SHA1&digits=4&period=40' + }, + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'friendly_name': 'friendly_name', + 'status': 'unverified', + 'factor_type': 'totp', + 'config': { + 'alg': 'sha1', + 'skew': 1, + 'code_length': 6, + 'time_step': 30 + }, + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors/YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {friendlyName: 'friendly_name', factorType: 'push'}; + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .newFactors.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/video/v1/room.spec.js b/spec/integration/rest/video/v1/room.spec.js index 67f42f4712..dc4a9a9908 100644 --- a/spec/integration/rest/video/v1/room.spec.js +++ b/spec/integration/rest/video/v1/room.spec.js @@ -62,7 +62,7 @@ describe('Room', function() { 'enable_turn': true, 'unique_name': 'unique_name', 'max_participants': 10, - 'max_concurrent_published_tracks': 10, + 'max_concurrent_published_tracks': 0, 'duration': 0, 'status_callback_method': 'POST', 'status_callback': '', @@ -122,7 +122,7 @@ describe('Room', function() { 'sid': 'RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'enable_turn': true, 'unique_name': 'RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'max_concurrent_published_tracks': 10, + 'max_concurrent_published_tracks': 0, 'max_participants': 10, 'duration': 0, 'status_callback_method': 'POST', @@ -164,7 +164,7 @@ describe('Room', function() { 'enable_turn': true, 'unique_name': 'room1', 'max_participants': 10, - 'max_concurrent_published_tracks': 10, + 'max_concurrent_published_tracks': 0, 'duration': 0, 'status_callback_method': 'POST', 'status_callback': '', @@ -205,7 +205,89 @@ describe('Room', function() { 'enable_turn': true, 'unique_name': 'grouproom', 'max_participants': 50, - 'max_concurrent_published_tracks': 10, + 'max_concurrent_published_tracks': 170, + 'duration': 0, + 'status_callback_method': 'POST', + 'status_callback': '', + 'record_participants_on_connect': false, + 'video_codecs': [ + 'VP8' + ], + 'media_region': 'us1', + 'end_time': '2015-07-30T20:00:00Z', + 'url': 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participants': 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', + 'recordings': 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings', + 'recording_rules': 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RecordingRules' + } + }; + + holodeck.mock(new Response(201, body)); + + var promise = client.video.v1.rooms.create(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid create_small_group_rooms response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'status': 'in-progress', + 'type': 'group-small', + 'sid': 'RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'enable_turn': true, + 'unique_name': 'SmallDailyStandup', + 'max_participants': 4, + 'max_concurrent_published_tracks': 170, + 'duration': 0, + 'status_callback_method': 'POST', + 'status_callback': '', + 'record_participants_on_connect': false, + 'video_codecs': [ + 'VP8' + ], + 'media_region': 'us1', + 'end_time': '2015-07-30T20:00:00Z', + 'url': 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participants': 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', + 'recordings': 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings', + 'recording_rules': 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RecordingRules' + } + }; + + holodeck.mock(new Response(201, body)); + + var promise = client.video.v1.rooms.create(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid create_large_group_rooms response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'status': 'in-progress', + 'type': 'group', + 'sid': 'RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'enable_turn': true, + 'unique_name': 'MyWebinar', + 'max_participants': 50, + 'max_concurrent_published_tracks': 16, 'duration': 0, 'status_callback_method': 'POST', 'status_callback': '', From 6ce8d3ce16056b85269d2e41f9c985b9700c98b6 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 7 Apr 2021 19:04:44 +0000 Subject: [PATCH 03/30] Release 3.60.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 02d783305f..a1e79e0156 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.59.0", + "version": "3.60.0", "author": "API Team ", "contributors": [ { From 0018eca40e914d9149b49a3e6b198f4704dc82b2 Mon Sep 17 00:00:00 2001 From: Kousha Talebian Date: Wed, 14 Apr 2021 14:31:43 -0700 Subject: [PATCH 04/30] fix: remove type definition from peerDeps (#667) --- package.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/package.json b/package.json index a1e79e0156..9ec15bcef5 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,6 @@ "type": "git", "url": "https://github.com/twilio/twilio-node.git" }, - "peerDependencies": { - "@types/express": "^4.17.7", - "@types/qs": "6.9.4" - }, "dependencies": { "axios": "^0.21.1", "dayjs": "^1.8.29", From a642d8cd34b0439c78ac6ae2a87f0721fa2a556a Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 21 Apr 2021 18:57:15 +0000 Subject: [PATCH 05/30] [Librarian] Regenerated @ 13a590a5017846bb40a46a0722d90a15ca591b2d --- CHANGES.md | 30 ++ .../v1/export/exportCustomJob.d.ts | 4 +- .../bulkexports/v1/export/exportCustomJob.js | 2 +- lib/rest/bulkexports/v1/export/job.d.ts | 4 +- lib/rest/bulkexports/v1/export/job.js | 2 +- lib/rest/events/v1/schema.d.ts | 16 +- lib/rest/events/v1/schema.js | 18 +- .../{schemaVersion.d.ts => version.d.ts} | 90 +++--- .../schema/{schemaVersion.js => version.js} | 171 +++++------ .../v1/subscription/subscribedEvent.d.ts | 12 +- .../events/v1/subscription/subscribedEvent.js | 14 +- lib/rest/messaging/v1/service.d.ts | 14 +- lib/rest/messaging/v1/service.js | 31 +- lib/rest/supersim/v1/smsCommand.d.ts | 6 +- lib/rest/supersim/v1/smsCommand.js | 6 +- lib/rest/taskrouter/v1/workspace/task.d.ts | 25 +- lib/rest/taskrouter/v1/workspace/task.js | 20 +- lib/rest/verify/v2/service.d.ts | 22 ++ lib/rest/verify/v2/service.js | 35 ++- .../verify/v2/service/entity/challenge.d.ts | 11 + .../verify/v2/service/entity/challenge.js | 42 ++- .../entity/challenge/notification.d.ts | 133 +++++++++ .../service/entity/challenge/notification.js | 277 ++++++++++++++++++ lib/twiml/VoiceResponse.d.ts | 2 +- .../rest/events/v1/eventType.spec.js | 126 ++++---- .../integration/rest/events/v1/schema.spec.js | 10 +- ...{schemaVersion.spec.js => version.spec.js} | 76 ++--- .../v1/subscription/subscribedEvent.spec.js | 66 ++--- .../rest/messaging/v1/service.spec.js | 7 + spec/integration/rest/supersim/v1/sim.spec.js | 32 +- .../rest/supersim/v1/smsCommand.spec.js | 28 +- .../rest/taskrouter/v1/workspace/task.spec.js | 7 +- .../rest/verify/v2/service.spec.js | 42 +++ .../v2/service/entity/challenge.spec.js | 86 +++++- .../entity/challenge/notification.spec.js | 114 +++++++ 35 files changed, 1212 insertions(+), 369 deletions(-) rename lib/rest/events/v1/schema/{schemaVersion.d.ts => version.d.ts} (66%) rename lib/rest/events/v1/schema/{schemaVersion.js => version.js} (70%) create mode 100644 lib/rest/verify/v2/service/entity/challenge/notification.d.ts create mode 100644 lib/rest/verify/v2/service/entity/challenge/notification.js rename spec/integration/rest/events/v1/schema/{schemaVersion.spec.js => version.spec.js} (69%) create mode 100644 spec/integration/rest/verify/v2/service/entity/challenge/notification.spec.js diff --git a/CHANGES.md b/CHANGES.md index 85c968bf8b..4313978c2e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,36 @@ twilio-node changelog ===================== +[2021-04-21] Version 3.61.0 +--------------------------- +**Library - Fix** +- [PR #667](https://github.com/twilio/twilio-node/pull/667): remove type definition from peerDeps. Thanks to [@ktalebian](https://github.com/ktalebian)! + +**Api** +- Revert Update the conference participant create `from` and `to` param to be endpoint type for supporting client identifier and sip address +- Update the conference participant create `from` and `to` param to be endpoint type for supporting client identifier and sip address + +**Bulkexports** +- moving enum to doc root for auto generating documentation +- adding status enum and default output properties + +**Events** +- Change schema_versions prop and key to versions **(breaking change)** + +**Messaging** +- Add `use_inbound_webhook_on_number` field in Service API for fetch, create, update, read + +**Taskrouter** +- Add `If-Match` Header based on ETag for Task Delete + +**Verify** +- Add `AuthPayload` parameter to support verifying a `Challenge` upon creation. This is only supported for `totp` factors. +- Add support to resend the notifications of a `Challenge`. This is only supported for `push` factors. + +**Twiml** +- Add Polly Neural voices. + + [2021-04-07] Version 3.60.0 --------------------------- **Library - Chore** diff --git a/lib/rest/bulkexports/v1/export/exportCustomJob.d.ts b/lib/rest/bulkexports/v1/export/exportCustomJob.d.ts index d651ddbd42..a98caa8c89 100644 --- a/lib/rest/bulkexports/v1/export/exportCustomJob.d.ts +++ b/lib/rest/bulkexports/v1/export/exportCustomJob.d.ts @@ -10,6 +10,8 @@ import Response = require('../../../../http/response'); import V1 = require('../../V1'); import { SerializableClass } from '../../../../interfaces'; +type ExportCustomJobStatus = 'ErrorDuringRun'|'Submitted'|'Running'|'CompletedEmptyRecords'|'Completed'|'Failed'|'RunningToBeDeleted'|'DeletedByUserRequest'; + /** * Initialize the ExportCustomJobList * @@ -285,4 +287,4 @@ declare class ExportCustomJobPage extends Page { toJSON(): any; } -export { JobContext, JobInstance, JobList, JobListInstance, JobPage, JobPayload, JobResource, JobSolution } +export { JobContext, JobInstance, JobList, JobListInstance, JobPage, JobPayload, JobResource, JobSolution, JobStatus } diff --git a/lib/rest/bulkexports/v1/export/job.js b/lib/rest/bulkexports/v1/export/job.js index 9201178873..e727b90d79 100644 --- a/lib/rest/bulkexports/v1/export/job.js +++ b/lib/rest/bulkexports/v1/export/job.js @@ -170,7 +170,7 @@ JobPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @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 + * The details of a job state which is an object that contains a `status` string, a day count integer, and list of days in the job * @property {string} startDay - * The start time for the export specified when creating the job * @property {string} endDay - diff --git a/lib/rest/events/v1/schema.d.ts b/lib/rest/events/v1/schema.d.ts index 0e15a9ca7e..75b7840888 100644 --- a/lib/rest/events/v1/schema.d.ts +++ b/lib/rest/events/v1/schema.d.ts @@ -8,9 +8,9 @@ import Page = require('../../../base/Page'); import Response = require('../../../http/response'); import V1 = require('../V1'); +import { SchemaVersionList } from './schema/version'; +import { SchemaVersionListInstance } from './schema/version'; import { SerializableClass } from '../../../interfaces'; -import { VersionList } from './schema/schemaVersion'; -import { VersionListInstance } from './schema/schemaVersion'; /** * Initialize the SchemaList @@ -44,8 +44,8 @@ interface SchemaPayload extends SchemaResource, Page.TwilioResponsePayload { interface SchemaResource { id: string; - last_created: Date; - last_version: number; + latest_version: number; + latest_version_date_created: Date; links: string; url: string; } @@ -76,7 +76,7 @@ declare class SchemaContext { * Provide a user-friendly representation */ toJSON(): any; - versions: VersionListInstance; + versions: SchemaVersionListInstance; } @@ -101,8 +101,8 @@ declare class SchemaInstance extends SerializableClass { */ fetch(callback?: (error: Error | null, items: SchemaInstance) => any): Promise; id: string; - lastCreated: Date; - lastVersion: number; + latestVersion: number; + latestVersionDateCreated: Date; links: string; /** * Provide a user-friendly representation @@ -112,7 +112,7 @@ declare class SchemaInstance extends SerializableClass { /** * Access the versions */ - versions(): VersionListInstance; + versions(): SchemaVersionListInstance; } diff --git a/lib/rest/events/v1/schema.js b/lib/rest/events/v1/schema.js index 95bb330108..6a07a09c15 100644 --- a/lib/rest/events/v1/schema.js +++ b/lib/rest/events/v1/schema.js @@ -13,7 +13,7 @@ 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 VersionList = require('./schema/schemaVersion').VersionList; +var SchemaVersionList = require('./schema/version').SchemaVersionList; var deserialize = require( '../../../base/deserialize'); /* jshint ignore:line */ var values = require('../../../base/values'); /* jshint ignore:line */ @@ -170,9 +170,9 @@ SchemaPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {string} id - Schema Identifier. * @property {string} url - The URL of this resource. * @property {string} links - Nested resource URLs. - * @property {Date} lastCreated - - * The date that the last schema version was created. - * @property {number} lastVersion - Last schema version. + * @property {Date} latestVersionDateCreated - + * The date that the latest schema version was created. + * @property {number} latestVersion - Latest schema version. * * @param {V1} version - Version of the resource * @param {SchemaPayload} payload - The instance payload @@ -186,8 +186,8 @@ SchemaInstance = function SchemaInstance(version, payload, id) { this.id = payload.id; // jshint ignore:line this.url = payload.url; // jshint ignore:line this.links = payload.links; // jshint ignore:line - this.lastCreated = deserialize.iso8601DateTime(payload.last_created); // jshint ignore:line - this.lastVersion = deserialize.integer(payload.last_version); // jshint ignore:line + this.latestVersionDateCreated = deserialize.iso8601DateTime(payload.latest_version_date_created); // jshint ignore:line + this.latestVersion = deserialize.integer(payload.latest_version); // jshint ignore:line // Context this._context = undefined; @@ -228,7 +228,7 @@ SchemaInstance.prototype.fetch = function fetch(callback) { * @function versions * @memberof Twilio.Events.V1.SchemaInstance# * - * @returns {Twilio.Events.V1.SchemaContext.VersionList} + * @returns {Twilio.Events.V1.SchemaContext.SchemaVersionList} */ /* jshint ignore:end */ SchemaInstance.prototype.versions = function versions() { @@ -270,7 +270,7 @@ SchemaInstance.prototype[util.inspect.custom] = function inspect(depth, options) * * @constructor Twilio.Events.V1.SchemaContext * - * @property {Twilio.Events.V1.SchemaContext.VersionList} versions - + * @property {Twilio.Events.V1.SchemaContext.SchemaVersionList} versions - * versions resource * * @param {V1} version - Version of the resource @@ -323,7 +323,7 @@ Object.defineProperty(SchemaContext.prototype, 'versions', { get: function() { if (!this._versions) { - this._versions = new VersionList(this._version, this._solution.id); + this._versions = new SchemaVersionList(this._version, this._solution.id); } return this._versions; } diff --git a/lib/rest/events/v1/schema/schemaVersion.d.ts b/lib/rest/events/v1/schema/version.d.ts similarity index 66% rename from lib/rest/events/v1/schema/schemaVersion.d.ts rename to lib/rest/events/v1/schema/version.d.ts index 812c21a46c..d8d2571f4e 100644 --- a/lib/rest/events/v1/schema/schemaVersion.d.ts +++ b/lib/rest/events/v1/schema/version.d.ts @@ -11,7 +11,7 @@ import V1 = require('../../V1'); import { SerializableClass } from '../../../../interfaces'; /** - * Initialize the VersionList + * Initialize the SchemaVersionList * * PLEASE NOTE that this class contains beta products that are subject to change. * Use them with caution. @@ -19,15 +19,15 @@ import { SerializableClass } from '../../../../interfaces'; * @param version - Version of the resource * @param id - The unique identifier of the schema. */ -declare function VersionList(version: V1, id: string): VersionListInstance; +declare function SchemaVersionList(version: V1, id: string): SchemaVersionListInstance; -interface VersionListInstance { +interface SchemaVersionListInstance { /** * @param sid - sid of instance */ - (sid: string): VersionContext; + (sid: string): SchemaVersionContext; /** - * Streams VersionInstance records from the API. + * Streams SchemaVersionInstance records from the API. * * This operation lazily loads records as efficiently as possible until the limit * is reached. @@ -40,9 +40,9 @@ interface VersionListInstance { * * @param callback - Function to process each record */ - each(callback?: (item: VersionInstance, done: (err?: Error) => void) => void): void; + each(callback?: (item: SchemaVersionInstance, done: (err?: Error) => void) => void): void; /** - * Streams VersionInstance records from the API. + * Streams SchemaVersionInstance records from the API. * * This operation lazily loads records as efficiently as possible until the limit * is reached. @@ -56,15 +56,15 @@ interface VersionListInstance { * @param opts - Options for request * @param callback - Function to process each record */ - each(opts?: VersionListInstanceEachOptions, callback?: (item: VersionInstance, done: (err?: Error) => void) => void): void; + each(opts?: SchemaVersionListInstanceEachOptions, callback?: (item: SchemaVersionInstance, done: (err?: Error) => void) => void): void; /** - * Constructs a version + * Constructs a schema_version * * @param schemaVersion - The version of the schema */ - get(schemaVersion: string): VersionContext; + get(schemaVersion: string): SchemaVersionContext; /** - * Retrieve a single target page of VersionInstance records from the API. + * Retrieve a single target page of SchemaVersionInstance records from the API. * * The request is executed immediately. * @@ -73,9 +73,9 @@ interface VersionListInstance { * * @param callback - Callback to handle list of records */ - getPage(callback?: (error: Error | null, items: VersionPage) => any): Promise; + getPage(callback?: (error: Error | null, items: SchemaVersionPage) => any): Promise; /** - * Retrieve a single target page of VersionInstance records from the API. + * Retrieve a single target page of SchemaVersionInstance records from the API. * * The request is executed immediately. * @@ -85,18 +85,18 @@ interface VersionListInstance { * @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: VersionPage) => any): Promise; + getPage(targetUrl?: string, callback?: (error: Error | null, items: SchemaVersionPage) => any): Promise; /** - * Lists VersionInstance records from the API as a list. + * Lists SchemaVersionInstance 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: VersionInstance[]) => any): Promise; + list(callback?: (error: Error | null, items: SchemaVersionInstance[]) => any): Promise; /** - * Lists VersionInstance records from the API as a list. + * Lists SchemaVersionInstance records from the API as a list. * * If a function is passed as the first argument, it will be used as the callback * function. @@ -104,9 +104,9 @@ interface VersionListInstance { * @param opts - Options for request * @param callback - Callback to handle list of records */ - list(opts?: VersionListInstanceOptions, callback?: (error: Error | null, items: VersionInstance[]) => any): Promise; + list(opts?: SchemaVersionListInstanceOptions, callback?: (error: Error | null, items: SchemaVersionInstance[]) => any): Promise; /** - * Retrieve a single page of VersionInstance records from the API. + * Retrieve a single page of SchemaVersionInstance records from the API. * * The request is executed immediately. * @@ -115,9 +115,9 @@ interface VersionListInstance { * * @param callback - Callback to handle list of records */ - page(callback?: (error: Error | null, items: VersionPage) => any): Promise; + page(callback?: (error: Error | null, items: SchemaVersionPage) => any): Promise; /** - * Retrieve a single page of VersionInstance records from the API. + * Retrieve a single page of SchemaVersionInstance records from the API. * * The request is executed immediately. * @@ -127,7 +127,7 @@ interface VersionListInstance { * @param opts - Options for request * @param callback - Callback to handle list of records */ - page(opts?: VersionListInstancePageOptions, callback?: (error: Error | null, items: VersionPage) => any): Promise; + page(opts?: SchemaVersionListInstancePageOptions, callback?: (error: Error | null, items: SchemaVersionPage) => any): Promise; /** * Provide a user-friendly representation */ @@ -152,8 +152,8 @@ interface VersionListInstance { * each() will attempt to read the limit with the most efficient * page size, i.e. min(limit, 1000) */ -interface VersionListInstanceEachOptions { - callback?: (item: VersionInstance, done: (err?: Error) => void) => void; +interface SchemaVersionListInstanceEachOptions { + callback?: (item: SchemaVersionInstance, done: (err?: Error) => void) => void; done?: Function; limit?: number; pageSize?: number; @@ -173,7 +173,7 @@ interface VersionListInstanceEachOptions { * list() will attempt to read the limit with the most * efficient page size, i.e. min(limit, 1000) */ -interface VersionListInstanceOptions { +interface SchemaVersionListInstanceOptions { limit?: number; pageSize?: number; } @@ -185,16 +185,16 @@ interface VersionListInstanceOptions { * @property pageSize - Number of records to return, defaults to 50 * @property pageToken - PageToken provided by the API */ -interface VersionListInstancePageOptions { +interface SchemaVersionListInstancePageOptions { pageNumber?: number; pageSize?: number; pageToken?: string; } -interface VersionPayload extends VersionResource, Page.TwilioResponsePayload { +interface SchemaVersionPayload extends SchemaVersionResource, Page.TwilioResponsePayload { } -interface VersionResource { +interface SchemaVersionResource { date_created: Date; id: string; raw: string; @@ -202,14 +202,14 @@ interface VersionResource { url: string; } -interface VersionSolution { +interface SchemaVersionSolution { id?: string; } -declare class VersionContext { +declare class SchemaVersionContext { /** - * Initialize the VersionContext + * Initialize the SchemaVersionContext * * PLEASE NOTE that this class contains beta products that are subject to change. * Use them with caution. @@ -221,11 +221,11 @@ declare class VersionContext { constructor(version: V1, id: string, schemaVersion: number); /** - * fetch a VersionInstance + * fetch a SchemaVersionInstance * * @param callback - Callback to handle processed record */ - fetch(callback?: (error: Error | null, items: VersionInstance) => any): Promise; + fetch(callback?: (error: Error | null, items: SchemaVersionInstance) => any): Promise; /** * Provide a user-friendly representation */ @@ -233,9 +233,9 @@ declare class VersionContext { } -declare class VersionInstance extends SerializableClass { +declare class SchemaVersionInstance extends SerializableClass { /** - * Initialize the VersionContext + * Initialize the SchemaVersionContext * * PLEASE NOTE that this class contains beta products that are subject to change. * Use them with caution. @@ -245,16 +245,16 @@ declare class VersionInstance extends SerializableClass { * @param id - The unique identifier of the schema. * @param schemaVersion - The version of the schema */ - constructor(version: V1, payload: VersionPayload, id: string, schemaVersion: number); + constructor(version: V1, payload: SchemaVersionPayload, id: string, schemaVersion: number); - private _proxy: VersionContext; + private _proxy: SchemaVersionContext; dateCreated: Date; /** - * fetch a VersionInstance + * fetch a SchemaVersionInstance * * @param callback - Callback to handle processed record */ - fetch(callback?: (error: Error | null, items: VersionInstance) => any): Promise; + fetch(callback?: (error: Error | null, items: SchemaVersionInstance) => any): Promise; id: string; raw: string; schemaVersion: number; @@ -266,9 +266,9 @@ declare class VersionInstance extends SerializableClass { } -declare class VersionPage extends Page { +declare class SchemaVersionPage extends Page { /** - * Initialize the VersionPage + * Initialize the SchemaVersionPage * * PLEASE NOTE that this class contains beta products that are subject to change. * Use them with caution. @@ -277,18 +277,18 @@ declare class VersionPage extends Page, solution: VersionSolution); + constructor(version: V1, response: Response, solution: SchemaVersionSolution); /** - * Build an instance of VersionInstance + * Build an instance of SchemaVersionInstance * * @param payload - Payload response from the API */ - getInstance(payload: VersionPayload): VersionInstance; + getInstance(payload: SchemaVersionPayload): SchemaVersionInstance; /** * Provide a user-friendly representation */ toJSON(): any; } -export { VersionContext, VersionInstance, VersionList, VersionListInstance, VersionListInstanceEachOptions, VersionListInstanceOptions, VersionListInstancePageOptions, VersionPage, VersionPayload, VersionResource, VersionSolution } +export { SchemaVersionContext, SchemaVersionInstance, SchemaVersionList, SchemaVersionListInstance, SchemaVersionListInstanceEachOptions, SchemaVersionListInstanceOptions, SchemaVersionListInstancePageOptions, SchemaVersionPage, SchemaVersionPayload, SchemaVersionResource, SchemaVersionSolution } diff --git a/lib/rest/events/v1/schema/schemaVersion.js b/lib/rest/events/v1/schema/version.js similarity index 70% rename from lib/rest/events/v1/schema/schemaVersion.js rename to lib/rest/events/v1/schema/version.js index 40dfddb803..36b9e7cef0 100644 --- a/lib/rest/events/v1/schema/schemaVersion.js +++ b/lib/rest/events/v1/schema/version.js @@ -17,25 +17,25 @@ var deserialize = require( '../../../../base/deserialize'); /* jshint ignore:line */ var values = require('../../../../base/values'); /* jshint ignore:line */ -var VersionList; -var VersionPage; -var VersionInstance; -var VersionContext; +var SchemaVersionList; +var SchemaVersionPage; +var SchemaVersionInstance; +var SchemaVersionContext; /* jshint ignore:start */ /** - * Initialize the VersionList + * Initialize the SchemaVersionList * * PLEASE NOTE that this class contains beta products that are subject to change. * Use them with caution. * - * @constructor Twilio.Events.V1.SchemaContext.VersionList + * @constructor Twilio.Events.V1.SchemaContext.SchemaVersionList * * @param {Twilio.Events.V1} version - Version of the resource * @param {string} id - The unique identifier of the schema. */ /* jshint ignore:end */ -VersionList = function VersionList(version, id) { +SchemaVersionList = function SchemaVersionList(version, id) { /* jshint ignore:start */ /** * @function versions @@ -43,20 +43,20 @@ VersionList = function VersionList(version, id) { * * @param {string} sid - sid of instance * - * @returns {Twilio.Events.V1.SchemaContext.VersionContext} + * @returns {Twilio.Events.V1.SchemaContext.SchemaVersionContext} */ /* jshint ignore:end */ - function VersionListInstance(sid) { - return VersionListInstance.get(sid); + function SchemaVersionListInstance(sid) { + return SchemaVersionListInstance.get(sid); } - VersionListInstance._version = version; + SchemaVersionListInstance._version = version; // Path Solution - VersionListInstance._solution = {id: id}; - VersionListInstance._uri = `/Schemas/${id}/Versions`; + SchemaVersionListInstance._solution = {id: id}; + SchemaVersionListInstance._uri = `/Schemas/${id}/Versions`; /* jshint ignore:start */ /** - * Streams VersionInstance records from the API. + * Streams SchemaVersionInstance records from the API. * * This operation lazily loads records as efficiently as possible until the limit * is reached. @@ -68,7 +68,7 @@ VersionList = function VersionList(version, id) { * function. * * @function each - * @memberof Twilio.Events.V1.SchemaContext.VersionList# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionList# * * @param {object} [opts] - Options for request * @param {number} [opts.limit] - @@ -89,7 +89,7 @@ VersionList = function VersionList(version, id) { * @param {Function} [callback] - Function to process each record */ /* jshint ignore:end */ - VersionListInstance.each = function each(opts, callback) { + SchemaVersionListInstance.each = function each(opts, callback) { if (_.isFunction(opts)) { callback = opts; opts = {}; @@ -149,13 +149,13 @@ VersionList = function VersionList(version, id) { /* jshint ignore:start */ /** - * Lists VersionInstance records from the API as a list. + * Lists SchemaVersionInstance 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.Events.V1.SchemaContext.VersionList# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionList# * * @param {object} [opts] - Options for request * @param {number} [opts.limit] - @@ -173,7 +173,7 @@ VersionList = function VersionList(version, id) { * @returns {Promise} Resolves to a list of records */ /* jshint ignore:end */ - VersionListInstance.list = function list(opts, callback) { + SchemaVersionListInstance.list = function list(opts, callback) { if (_.isFunction(opts)) { callback = opts; opts = {}; @@ -207,7 +207,7 @@ VersionList = function VersionList(version, id) { /* jshint ignore:start */ /** - * Retrieve a single page of VersionInstance records from the API. + * Retrieve a single page of SchemaVersionInstance records from the API. * * The request is executed immediately. * @@ -215,7 +215,7 @@ VersionList = function VersionList(version, id) { * function. * * @function page - * @memberof Twilio.Events.V1.SchemaContext.VersionList# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionList# * * @param {object} [opts] - Options for request * @param {string} [opts.pageToken] - PageToken provided by the API @@ -227,7 +227,7 @@ VersionList = function VersionList(version, id) { * @returns {Promise} Resolves to a list of records */ /* jshint ignore:end */ - VersionListInstance.page = function page(opts, callback) { + SchemaVersionListInstance.page = function page(opts, callback) { if (_.isFunction(opts)) { callback = opts; opts = {}; @@ -244,7 +244,7 @@ VersionList = function VersionList(version, id) { var promise = this._version.page({uri: this._uri, method: 'GET', params: data}); promise = promise.then(function(payload) { - deferred.resolve(new VersionPage(this._version, payload, this._solution)); + deferred.resolve(new SchemaVersionPage(this._version, payload, this._solution)); }.bind(this)); promise.catch(function(error) { @@ -260,7 +260,7 @@ VersionList = function VersionList(version, id) { /* jshint ignore:start */ /** - * Retrieve a single target page of VersionInstance records from the API. + * Retrieve a single target page of SchemaVersionInstance records from the API. * * The request is executed immediately. * @@ -268,7 +268,7 @@ VersionList = function VersionList(version, id) { * function. * * @function getPage - * @memberof Twilio.Events.V1.SchemaContext.VersionList# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionList# * * @param {string} [targetUrl] - API-generated URL for the requested results page * @param {function} [callback] - Callback to handle list of records @@ -276,13 +276,13 @@ VersionList = function VersionList(version, id) { * @returns {Promise} Resolves to a list of records */ /* jshint ignore:end */ - VersionListInstance.getPage = function getPage(targetUrl, callback) { + SchemaVersionListInstance.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 VersionPage(this._version, payload, this._solution)); + deferred.resolve(new SchemaVersionPage(this._version, payload, this._solution)); }.bind(this)); promise.catch(function(error) { @@ -298,18 +298,18 @@ VersionList = function VersionList(version, id) { /* jshint ignore:start */ /** - * Constructs a version + * Constructs a schema_version * * @function get - * @memberof Twilio.Events.V1.SchemaContext.VersionList# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionList# * * @param {string} schemaVersion - The version of the schema * - * @returns {Twilio.Events.V1.SchemaContext.VersionContext} + * @returns {Twilio.Events.V1.SchemaContext.SchemaVersionContext} */ /* jshint ignore:end */ - VersionListInstance.get = function get(schemaVersion) { - return new VersionContext(this._version, this._solution.id, schemaVersion); + SchemaVersionListInstance.get = function get(schemaVersion) { + return new SchemaVersionContext(this._version, this._solution.id, schemaVersion); }; /* jshint ignore:start */ @@ -317,63 +317,64 @@ VersionList = function VersionList(version, id) { * Provide a user-friendly representation * * @function toJSON - * @memberof Twilio.Events.V1.SchemaContext.VersionList# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionList# * * @returns Object */ /* jshint ignore:end */ - VersionListInstance.toJSON = function toJSON() { + SchemaVersionListInstance.toJSON = function toJSON() { return this._solution; }; - VersionListInstance[util.inspect.custom] = function inspect(depth, options) { + SchemaVersionListInstance[util.inspect.custom] = function inspect(depth, + options) { return util.inspect(this.toJSON(), options); }; - return VersionListInstance; + return SchemaVersionListInstance; }; /* jshint ignore:start */ /** - * Initialize the VersionPage + * Initialize the SchemaVersionPage * * PLEASE NOTE that this class contains beta products that are subject to change. * Use them with caution. * - * @constructor Twilio.Events.V1.SchemaContext.VersionPage + * @constructor Twilio.Events.V1.SchemaContext.SchemaVersionPage * * @param {V1} version - Version of the resource * @param {Response} response - Response from the API - * @param {VersionSolution} solution - Path solution + * @param {SchemaVersionSolution} solution - Path solution * - * @returns VersionPage + * @returns SchemaVersionPage */ /* jshint ignore:end */ -VersionPage = function VersionPage(version, response, solution) { +SchemaVersionPage = function SchemaVersionPage(version, response, solution) { // Path Solution this._solution = solution; Page.prototype.constructor.call(this, version, response, this._solution); }; -_.extend(VersionPage.prototype, Page.prototype); -VersionPage.prototype.constructor = VersionPage; +_.extend(SchemaVersionPage.prototype, Page.prototype); +SchemaVersionPage.prototype.constructor = SchemaVersionPage; /* jshint ignore:start */ /** - * Build an instance of VersionInstance + * Build an instance of SchemaVersionInstance * * @function getInstance - * @memberof Twilio.Events.V1.SchemaContext.VersionPage# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionPage# * - * @param {VersionPayload} payload - Payload response from the API + * @param {SchemaVersionPayload} payload - Payload response from the API * - * @returns VersionInstance + * @returns SchemaVersionInstance */ /* jshint ignore:end */ -VersionPage.prototype.getInstance = function getInstance(payload) { - return new VersionInstance(this._version, payload, this._solution.id); +SchemaVersionPage.prototype.getInstance = function getInstance(payload) { + return new SchemaVersionInstance(this._version, payload, this._solution.id); }; /* jshint ignore:start */ @@ -381,12 +382,12 @@ VersionPage.prototype.getInstance = function getInstance(payload) { * Provide a user-friendly representation * * @function toJSON - * @memberof Twilio.Events.V1.SchemaContext.VersionPage# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionPage# * * @returns Object */ /* jshint ignore:end */ -VersionPage.prototype.toJSON = function toJSON() { +SchemaVersionPage.prototype.toJSON = function toJSON() { let clone = {}; _.forOwn(this, function(value, key) { if (!_.startsWith(key, '_') && ! _.isFunction(value)) { @@ -396,19 +397,20 @@ VersionPage.prototype.toJSON = function toJSON() { return clone; }; -VersionPage.prototype[util.inspect.custom] = function inspect(depth, options) { +SchemaVersionPage.prototype[util.inspect.custom] = function inspect(depth, + options) { return util.inspect(this.toJSON(), options); }; /* jshint ignore:start */ /** - * Initialize the VersionContext + * Initialize the SchemaVersionContext * * PLEASE NOTE that this class contains beta products that are subject to change. * Use them with caution. * - * @constructor Twilio.Events.V1.SchemaContext.VersionInstance + * @constructor Twilio.Events.V1.SchemaContext.SchemaVersionInstance * * @property {string} id - The unique identifier of the schema. * @property {number} schemaVersion - The version of this schema. @@ -417,13 +419,13 @@ VersionPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {string} raw - The raw * * @param {V1} version - Version of the resource - * @param {VersionPayload} payload - The instance payload + * @param {SchemaVersionPayload} payload - The instance payload * @param {string} id - The unique identifier of the schema. * @param {integer} schemaVersion - The version of the schema */ /* jshint ignore:end */ -VersionInstance = function VersionInstance(version, payload, id, schemaVersion) - { +SchemaVersionInstance = function SchemaVersionInstance(version, payload, id, + schemaVersion) { this._version = version; // Marshaled Properties @@ -438,11 +440,15 @@ VersionInstance = function VersionInstance(version, payload, id, schemaVersion) this._solution = {id: id, schemaVersion: schemaVersion || this.schemaVersion, }; }; -Object.defineProperty(VersionInstance.prototype, +Object.defineProperty(SchemaVersionInstance.prototype, '_proxy', { get: function() { if (!this._context) { - this._context = new VersionContext(this._version, this._solution.id, this._solution.schemaVersion); + this._context = new SchemaVersionContext( + this._version, + this._solution.id, + this._solution.schemaVersion + ); } return this._context; @@ -451,17 +457,17 @@ Object.defineProperty(VersionInstance.prototype, /* jshint ignore:start */ /** - * fetch a VersionInstance + * fetch a SchemaVersionInstance * * @function fetch - * @memberof Twilio.Events.V1.SchemaContext.VersionInstance# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionInstance# * * @param {function} [callback] - Callback to handle processed record * - * @returns {Promise} Resolves to processed VersionInstance + * @returns {Promise} Resolves to processed SchemaVersionInstance */ /* jshint ignore:end */ -VersionInstance.prototype.fetch = function fetch(callback) { +SchemaVersionInstance.prototype.fetch = function fetch(callback) { return this._proxy.fetch(callback); }; @@ -470,12 +476,12 @@ VersionInstance.prototype.fetch = function fetch(callback) { * Provide a user-friendly representation * * @function toJSON - * @memberof Twilio.Events.V1.SchemaContext.VersionInstance# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionInstance# * * @returns Object */ /* jshint ignore:end */ -VersionInstance.prototype.toJSON = function toJSON() { +SchemaVersionInstance.prototype.toJSON = function toJSON() { let clone = {}; _.forOwn(this, function(value, key) { if (!_.startsWith(key, '_') && ! _.isFunction(value)) { @@ -485,7 +491,7 @@ VersionInstance.prototype.toJSON = function toJSON() { return clone; }; -VersionInstance.prototype[util.inspect.custom] = function inspect(depth, +SchemaVersionInstance.prototype[util.inspect.custom] = function inspect(depth, options) { return util.inspect(this.toJSON(), options); }; @@ -493,19 +499,20 @@ VersionInstance.prototype[util.inspect.custom] = function inspect(depth, /* jshint ignore:start */ /** - * Initialize the VersionContext + * Initialize the SchemaVersionContext * * PLEASE NOTE that this class contains beta products that are subject to change. * Use them with caution. * - * @constructor Twilio.Events.V1.SchemaContext.VersionContext + * @constructor Twilio.Events.V1.SchemaContext.SchemaVersionContext * * @param {V1} version - Version of the resource * @param {string} id - The unique identifier of the schema. * @param {integer} schemaVersion - The version of the schema */ /* jshint ignore:end */ -VersionContext = function VersionContext(version, id, schemaVersion) { +SchemaVersionContext = function SchemaVersionContext(version, id, schemaVersion) + { this._version = version; // Path Solution @@ -515,22 +522,22 @@ VersionContext = function VersionContext(version, id, schemaVersion) { /* jshint ignore:start */ /** - * fetch a VersionInstance + * fetch a SchemaVersionInstance * * @function fetch - * @memberof Twilio.Events.V1.SchemaContext.VersionContext# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionContext# * * @param {function} [callback] - Callback to handle processed record * - * @returns {Promise} Resolves to processed VersionInstance + * @returns {Promise} Resolves to processed SchemaVersionInstance */ /* jshint ignore:end */ -VersionContext.prototype.fetch = function fetch(callback) { +SchemaVersionContext.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 VersionInstance( + deferred.resolve(new SchemaVersionInstance( this._version, payload, this._solution.id, @@ -554,23 +561,23 @@ VersionContext.prototype.fetch = function fetch(callback) { * Provide a user-friendly representation * * @function toJSON - * @memberof Twilio.Events.V1.SchemaContext.VersionContext# + * @memberof Twilio.Events.V1.SchemaContext.SchemaVersionContext# * * @returns Object */ /* jshint ignore:end */ -VersionContext.prototype.toJSON = function toJSON() { +SchemaVersionContext.prototype.toJSON = function toJSON() { return this._solution; }; -VersionContext.prototype[util.inspect.custom] = function inspect(depth, options) - { +SchemaVersionContext.prototype[util.inspect.custom] = function inspect(depth, + options) { return util.inspect(this.toJSON(), options); }; module.exports = { - VersionList: VersionList, - VersionPage: VersionPage, - VersionInstance: VersionInstance, - VersionContext: VersionContext + SchemaVersionList: SchemaVersionList, + SchemaVersionPage: SchemaVersionPage, + SchemaVersionInstance: SchemaVersionInstance, + SchemaVersionContext: SchemaVersionContext }; diff --git a/lib/rest/events/v1/subscription/subscribedEvent.d.ts b/lib/rest/events/v1/subscription/subscribedEvent.d.ts index 24a4960009..6b967d8b69 100644 --- a/lib/rest/events/v1/subscription/subscribedEvent.d.ts +++ b/lib/rest/events/v1/subscription/subscribedEvent.d.ts @@ -24,10 +24,10 @@ declare function SubscribedEventList(version: V1, subscriptionSid: string): Subs /** * Options to pass to update * - * @property version - The schema version that the subscription should use. + * @property schemaVersion - The schema version that the subscription should use. */ interface SubscribedEventInstanceUpdateOptions { - version?: number; + schemaVersion?: number; } interface SubscribedEventListInstance { @@ -153,12 +153,12 @@ interface SubscribedEventListInstance { /** * Options to pass to create * + * @property schemaVersion - The schema version that the subscription should use. * @property type - Type of event being subscribed to. - * @property version - The schema version that the subscription should use. */ interface SubscribedEventListInstanceCreateOptions { + schemaVersion?: number; type: string; - version?: number; } /** @@ -223,10 +223,10 @@ interface SubscribedEventPayload extends SubscribedEventResource, Page.TwilioRes interface SubscribedEventResource { account_sid: string; + schema_version: number; subscription_sid: string; type: string; url: string; - version: number; } interface SubscribedEventSolution { @@ -307,6 +307,7 @@ declare class SubscribedEventInstance extends SerializableClass { * @param callback - Callback to handle processed record */ remove(callback?: (error: Error | null, items: SubscribedEventInstance) => any): Promise; + schemaVersion: number; subscriptionSid: string; /** * Provide a user-friendly representation @@ -327,7 +328,6 @@ declare class SubscribedEventInstance extends SerializableClass { */ update(opts?: SubscribedEventInstanceUpdateOptions, callback?: (error: Error | null, items: SubscribedEventInstance) => any): Promise; url: string; - version: number; } diff --git a/lib/rest/events/v1/subscription/subscribedEvent.js b/lib/rest/events/v1/subscription/subscribedEvent.js index 76b9893cfb..48fdc209b5 100644 --- a/lib/rest/events/v1/subscription/subscribedEvent.js +++ b/lib/rest/events/v1/subscription/subscribedEvent.js @@ -305,7 +305,7 @@ SubscribedEventList = function SubscribedEventList(version, subscriptionSid) { * * @param {object} opts - Options for request * @param {string} opts.type - Type of event being subscribed to. - * @param {number} [opts.version] - + * @param {number} [opts.schemaVersion] - * The schema version that the subscription should use. * @param {function} [callback] - Callback to handle processed record * @@ -321,7 +321,7 @@ SubscribedEventList = function SubscribedEventList(version, subscriptionSid) { } var deferred = Q.defer(); - var data = values.of({'Type': _.get(opts, 'type'), 'Version': _.get(opts, 'version')}); + var data = values.of({'Type': _.get(opts, 'type'), 'SchemaVersion': _.get(opts, 'schemaVersion')}); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); @@ -464,7 +464,7 @@ SubscribedEventPage.prototype[util.inspect.custom] = function inspect(depth, * * @property {string} accountSid - Account SID. * @property {string} type - Type of event being subscribed to. - * @property {number} version - + * @property {number} schemaVersion - * The schema version that the subscription should use. * @property {string} subscriptionSid - Subscription SID. * @property {string} url - The URL of this resource. @@ -483,7 +483,7 @@ SubscribedEventInstance = function SubscribedEventInstance(version, payload, // Marshaled Properties this.accountSid = payload.account_sid; // jshint ignore:line this.type = payload.type; // jshint ignore:line - this.version = deserialize.integer(payload.version); // jshint ignore:line + this.schemaVersion = deserialize.integer(payload.schema_version); // jshint ignore:line this.subscriptionSid = payload.subscription_sid; // jshint ignore:line this.url = payload.url; // jshint ignore:line @@ -531,7 +531,7 @@ SubscribedEventInstance.prototype.fetch = function fetch(callback) { * @memberof Twilio.Events.V1.SubscriptionContext.SubscribedEventInstance# * * @param {object} [opts] - Options for request - * @param {number} [opts.version] - + * @param {number} [opts.schemaVersion] - * The schema version that the subscription should use. * @param {function} [callback] - Callback to handle processed record * @@ -652,7 +652,7 @@ SubscribedEventContext.prototype.fetch = function fetch(callback) { * @memberof Twilio.Events.V1.SubscriptionContext.SubscribedEventContext# * * @param {object} [opts] - Options for request - * @param {number} [opts.version] - + * @param {number} [opts.schemaVersion] - * The schema version that the subscription should use. * @param {function} [callback] - Callback to handle processed record * @@ -667,7 +667,7 @@ SubscribedEventContext.prototype.update = function update(opts, callback) { opts = opts || {}; var deferred = Q.defer(); - var data = values.of({'Version': _.get(opts, 'version')}); + var data = values.of({'SchemaVersion': _.get(opts, 'schemaVersion')}); var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/messaging/v1/service.d.ts b/lib/rest/messaging/v1/service.d.ts index f842fad8ef..4d1d7df22f 100644 --- a/lib/rest/messaging/v1/service.d.ts +++ b/lib/rest/messaging/v1/service.d.ts @@ -38,16 +38,17 @@ declare function ServiceList(version: V1): ServiceListInstance; * @property areaCodeGeomatch - Whether to enable Area Code Geomatch on the Service Instance * @property fallbackMethod - The HTTP method we should use to call fallback_url * @property fallbackToLongCode - Whether to enable Fallback to Long Code for messages sent through the Service instance - * @property fallbackUrl - The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL + * @property fallbackUrl - The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @property friendlyName - A string to describe the resource * @property inboundMethod - The HTTP method we should use to call inbound_request_url - * @property inboundRequestUrl - The URL we call using inbound_method when a message is received by any phone number or short code in the Service + * @property inboundRequestUrl - The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @property mmsConverter - Whether to enable the MMS Converter for messages sent through the Service instance * @property scanMessageContent - Reserved * @property smartEncoding - Whether to enable Encoding for messages sent through the Service instance * @property statusCallback - The URL we should call to pass status updates about message delivery * @property stickySender - Whether to enable Sticky Sender on the Service instance * @property synchronousValidation - Reserved + * @property useInboundWebhookOnNumber - If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. * @property validityPeriod - How long, in seconds, messages sent from the Service are valid */ interface ServiceInstanceUpdateOptions { @@ -64,6 +65,7 @@ interface ServiceInstanceUpdateOptions { statusCallback?: string; stickySender?: boolean; synchronousValidation?: boolean; + useInboundWebhookOnNumber?: boolean; validityPeriod?: number; } @@ -193,16 +195,17 @@ interface ServiceListInstance { * @property areaCodeGeomatch - Whether to enable Area Code Geomatch on the Service Instance * @property fallbackMethod - The HTTP method we should use to call fallback_url * @property fallbackToLongCode - Whether to enable Fallback to Long Code for messages sent through the Service instance - * @property fallbackUrl - The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL + * @property fallbackUrl - The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @property friendlyName - A string to describe the resource * @property inboundMethod - The HTTP method we should use to call inbound_request_url - * @property inboundRequestUrl - The URL we call using inbound_method when a message is received by any phone number or short code in the Service + * @property inboundRequestUrl - The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @property mmsConverter - Whether to enable the MMS Converter for messages sent through the Service instance * @property scanMessageContent - Reserved * @property smartEncoding - Whether to enable Encoding for messages sent through the Service instance * @property statusCallback - The URL we should call to pass status updates about message delivery * @property stickySender - Whether to enable Sticky Sender on the Service instance * @property synchronousValidation - Reserved + * @property useInboundWebhookOnNumber - If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. * @property validityPeriod - How long, in seconds, messages sent from the Service are valid */ interface ServiceListInstanceCreateOptions { @@ -219,6 +222,7 @@ interface ServiceListInstanceCreateOptions { statusCallback?: string; stickySender?: boolean; synchronousValidation?: boolean; + useInboundWebhookOnNumber?: boolean; validityPeriod?: number; } @@ -302,6 +306,7 @@ interface ServiceResource { sticky_sender: boolean; synchronous_validation: boolean; url: string; + use_inbound_webhook_on_number: boolean; validity_period: number; } @@ -440,6 +445,7 @@ declare class ServiceInstance extends SerializableClass { * Access the usAppToPersonUsecases */ usAppToPersonUsecases(): UsAppToPersonUsecaseListInstance; + useInboundWebhookOnNumber: boolean; validityPeriod: number; } diff --git a/lib/rest/messaging/v1/service.js b/lib/rest/messaging/v1/service.js index 07f1f30c3f..0b38c3ed47 100644 --- a/lib/rest/messaging/v1/service.js +++ b/lib/rest/messaging/v1/service.js @@ -70,11 +70,11 @@ ServiceList = function ServiceList(version) { * @param {object} opts - Options for request * @param {string} opts.friendlyName - A string to describe the resource * @param {string} [opts.inboundRequestUrl] - - * The URL we call using inbound_method when a message is received by any phone number or short code in the Service + * The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @param {string} [opts.inboundMethod] - * The HTTP method we should use to call inbound_request_url * @param {string} [opts.fallbackUrl] - - * The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL + * The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @param {string} [opts.fallbackMethod] - * The HTTP method we should use to call fallback_url * @param {string} [opts.statusCallback] - @@ -93,6 +93,8 @@ ServiceList = function ServiceList(version) { * @param {number} [opts.validityPeriod] - * How long, in seconds, messages sent from the Service are valid * @param {boolean} [opts.synchronousValidation] - Reserved + * @param {boolean} [opts.useInboundWebhookOnNumber] - + * If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed ServiceInstance @@ -121,7 +123,8 @@ ServiceList = function ServiceList(version) { 'FallbackToLongCode': serialize.bool(_.get(opts, 'fallbackToLongCode')), 'AreaCodeGeomatch': serialize.bool(_.get(opts, 'areaCodeGeomatch')), 'ValidityPeriod': _.get(opts, 'validityPeriod'), - 'SynchronousValidation': serialize.bool(_.get(opts, 'synchronousValidation')) + 'SynchronousValidation': serialize.bool(_.get(opts, 'synchronousValidation')), + 'UseInboundWebhookOnNumber': serialize.bool(_.get(opts, 'useInboundWebhookOnNumber')) }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); @@ -506,11 +509,11 @@ ServicePage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {Date} dateUpdated - * The ISO 8601 date and time in GMT when the resource was last updated * @property {string} inboundRequestUrl - - * The URL we call using inbound_method when a message is received by any phone number or short code in the Service + * The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @property {string} inboundMethod - * The HTTP method we use to call inbound_request_url * @property {string} fallbackUrl - - * The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL + * The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @property {string} fallbackMethod - The HTTP method we use to call fallback_url * @property {string} statusCallback - * The URL we call to pass status updates about message delivery @@ -530,6 +533,8 @@ ServicePage.prototype[util.inspect.custom] = function inspect(depth, options) { * How long, in seconds, messages sent from the Service are valid * @property {string} url - The absolute URL of the Service resource * @property {string} links - The absolute URLs of related resources + * @property {boolean} useInboundWebhookOnNumber - + * If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. * * @param {V1} version - Version of the resource * @param {ServicePayload} payload - The instance payload @@ -560,6 +565,7 @@ ServiceInstance = function ServiceInstance(version, payload, sid) { this.validityPeriod = deserialize.integer(payload.validity_period); // jshint ignore:line this.url = payload.url; // jshint ignore:line this.links = payload.links; // jshint ignore:line + this.useInboundWebhookOnNumber = payload.use_inbound_webhook_on_number; // jshint ignore:line // Context this._context = undefined; @@ -587,11 +593,11 @@ Object.defineProperty(ServiceInstance.prototype, * @param {object} [opts] - Options for request * @param {string} [opts.friendlyName] - A string to describe the resource * @param {string} [opts.inboundRequestUrl] - - * The URL we call using inbound_method when a message is received by any phone number or short code in the Service + * The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @param {string} [opts.inboundMethod] - * The HTTP method we should use to call inbound_request_url * @param {string} [opts.fallbackUrl] - - * The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL + * The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @param {string} [opts.fallbackMethod] - * The HTTP method we should use to call fallback_url * @param {string} [opts.statusCallback] - @@ -610,6 +616,8 @@ Object.defineProperty(ServiceInstance.prototype, * @param {number} [opts.validityPeriod] - * How long, in seconds, messages sent from the Service are valid * @param {boolean} [opts.synchronousValidation] - Reserved + * @param {boolean} [opts.useInboundWebhookOnNumber] - + * If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed ServiceInstance @@ -797,11 +805,11 @@ ServiceContext = function ServiceContext(version, sid) { * @param {object} [opts] - Options for request * @param {string} [opts.friendlyName] - A string to describe the resource * @param {string} [opts.inboundRequestUrl] - - * The URL we call using inbound_method when a message is received by any phone number or short code in the Service + * The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @param {string} [opts.inboundMethod] - * The HTTP method we should use to call inbound_request_url * @param {string} [opts.fallbackUrl] - - * The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL + * The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the `use_inbound_webhook_on_number` field is enabled. * @param {string} [opts.fallbackMethod] - * The HTTP method we should use to call fallback_url * @param {string} [opts.statusCallback] - @@ -820,6 +828,8 @@ ServiceContext = function ServiceContext(version, sid) { * @param {number} [opts.validityPeriod] - * How long, in seconds, messages sent from the Service are valid * @param {boolean} [opts.synchronousValidation] - Reserved + * @param {boolean} [opts.useInboundWebhookOnNumber] - + * If enabled, the webhook url configured on the phone number will be used and will override the `inbound_request_url`/`fallback_url` url called when an inbound message is received. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed ServiceInstance @@ -847,7 +857,8 @@ ServiceContext.prototype.update = function update(opts, callback) { 'FallbackToLongCode': serialize.bool(_.get(opts, 'fallbackToLongCode')), 'AreaCodeGeomatch': serialize.bool(_.get(opts, 'areaCodeGeomatch')), 'ValidityPeriod': _.get(opts, 'validityPeriod'), - 'SynchronousValidation': serialize.bool(_.get(opts, 'synchronousValidation')) + 'SynchronousValidation': serialize.bool(_.get(opts, 'synchronousValidation')), + 'UseInboundWebhookOnNumber': serialize.bool(_.get(opts, 'useInboundWebhookOnNumber')) }); var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/supersim/v1/smsCommand.d.ts b/lib/rest/supersim/v1/smsCommand.d.ts index 4e262d278e..0d07674372 100644 --- a/lib/rest/supersim/v1/smsCommand.d.ts +++ b/lib/rest/supersim/v1/smsCommand.d.ts @@ -177,7 +177,7 @@ interface SmsCommandListInstanceCreateOptions { * 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) - * @property sim - The SID or unique name of the Sim that SMS Command was sent to or from. + * @property sim - The SID or unique name of the Sim resource that SMS Command was sent to or from. * @property status - The status of the SMS Command */ interface SmsCommandListInstanceEachOptions { @@ -204,7 +204,7 @@ interface SmsCommandListInstanceEachOptions { * 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) - * @property sim - The SID or unique name of the Sim that SMS Command was sent to or from. + * @property sim - The SID or unique name of the Sim resource that SMS Command was sent to or from. * @property status - The status of the SMS Command */ interface SmsCommandListInstanceOptions { @@ -222,7 +222,7 @@ interface SmsCommandListInstanceOptions { * @property pageNumber - Page Number, this value is simply for client state * @property pageSize - Number of records to return, defaults to 50 * @property pageToken - PageToken provided by the API - * @property sim - The SID or unique name of the Sim that SMS Command was sent to or from. + * @property sim - The SID or unique name of the Sim resource that SMS Command was sent to or from. * @property status - The status of the SMS Command */ interface SmsCommandListInstancePageOptions { diff --git a/lib/rest/supersim/v1/smsCommand.js b/lib/rest/supersim/v1/smsCommand.js index f0ccc9eb91..6b01cc40ef 100644 --- a/lib/rest/supersim/v1/smsCommand.js +++ b/lib/rest/supersim/v1/smsCommand.js @@ -127,7 +127,7 @@ SmsCommandList = function SmsCommandList(version) { * * @param {object} [opts] - Options for request * @param {string} [opts.sim] - - * The SID or unique name of the Sim that SMS Command was sent to or from. + * The SID or unique name of the Sim resource that SMS Command was sent to or from. * @param {sms_command.status} [opts.status] - The status of the SMS Command * @param {sms_command.direction} [opts.direction] - * The direction of the SMS Command @@ -219,7 +219,7 @@ SmsCommandList = function SmsCommandList(version) { * * @param {object} [opts] - Options for request * @param {string} [opts.sim] - - * The SID or unique name of the Sim that SMS Command was sent to or from. + * The SID or unique name of the Sim resource that SMS Command was sent to or from. * @param {sms_command.status} [opts.status] - The status of the SMS Command * @param {sms_command.direction} [opts.direction] - * The direction of the SMS Command @@ -284,7 +284,7 @@ SmsCommandList = function SmsCommandList(version) { * * @param {object} [opts] - Options for request * @param {string} [opts.sim] - - * The SID or unique name of the Sim that SMS Command was sent to or from. + * The SID or unique name of the Sim resource that SMS Command was sent to or from. * @param {sms_command.status} [opts.status] - The status of the SMS Command * @param {sms_command.direction} [opts.direction] - * The direction of the SMS Command diff --git a/lib/rest/taskrouter/v1/workspace/task.d.ts b/lib/rest/taskrouter/v1/workspace/task.d.ts index 9ec711d0e0..372bb5eee4 100644 --- a/lib/rest/taskrouter/v1/workspace/task.d.ts +++ b/lib/rest/taskrouter/v1/workspace/task.d.ts @@ -22,6 +22,15 @@ type TaskStatus = 'pending'|'reserved'|'assigned'|'canceled'|'completed'|'wrappi */ declare function TaskList(version: V1, workspaceSid: string): TaskListInstance; +/** + * Options to pass to remove + * + * @property ifMatch - The If-Match HTTP request header + */ +interface TaskInstanceRemoveOptions { + ifMatch?: string; +} + /** * Options to pass to update * @@ -349,6 +358,13 @@ declare class TaskContext { * @param callback - Callback to handle processed record */ remove(callback?: (error: Error | null, items: TaskInstance) => any): Promise; + /** + * remove a TaskInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + remove(opts?: TaskInstanceRemoveOptions, callback?: (error: Error | null, items: TaskInstance) => any): Promise; reservations: ReservationListInstance; /** * Provide a user-friendly representation @@ -404,6 +420,13 @@ declare class TaskInstance extends SerializableClass { * @param callback - Callback to handle processed record */ remove(callback?: (error: Error | null, items: TaskInstance) => any): Promise; + /** + * remove a TaskInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + remove(opts?: TaskInstanceRemoveOptions, callback?: (error: Error | null, items: TaskInstance) => any): Promise; /** * Access the reservations */ @@ -461,4 +484,4 @@ declare class TaskPage extends Page toJSON(): any; } -export { TaskContext, TaskInstance, TaskInstanceUpdateOptions, TaskList, TaskListInstance, TaskListInstanceCreateOptions, TaskListInstanceEachOptions, TaskListInstanceOptions, TaskListInstancePageOptions, TaskPage, TaskPayload, TaskResource, TaskSolution, TaskStatus } +export { TaskContext, TaskInstance, TaskInstanceRemoveOptions, TaskInstanceUpdateOptions, TaskList, TaskListInstance, TaskListInstanceCreateOptions, TaskListInstanceEachOptions, TaskListInstanceOptions, TaskListInstancePageOptions, TaskPage, TaskPayload, TaskResource, TaskSolution, TaskStatus } diff --git a/lib/rest/taskrouter/v1/workspace/task.js b/lib/rest/taskrouter/v1/workspace/task.js index b14846f445..af9d29097f 100644 --- a/lib/rest/taskrouter/v1/workspace/task.js +++ b/lib/rest/taskrouter/v1/workspace/task.js @@ -648,13 +648,15 @@ TaskInstance.prototype.update = function update(opts, callback) { * @function remove * @memberof Twilio.Taskrouter.V1.WorkspaceContext.TaskInstance# * + * @param {object} [opts] - Options for request + * @param {string} [opts.ifMatch] - The If-Match HTTP request header * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed TaskInstance */ /* jshint ignore:end */ -TaskInstance.prototype.remove = function remove(callback) { - return this._proxy.remove(callback); +TaskInstance.prototype.remove = function remove(opts, callback) { + return this._proxy.remove(opts, callback); }; /* jshint ignore:start */ @@ -825,14 +827,24 @@ TaskContext.prototype.update = function update(opts, callback) { * @function remove * @memberof Twilio.Taskrouter.V1.WorkspaceContext.TaskContext# * + * @param {object} [opts] - Options for request + * @param {string} [opts.ifMatch] - The If-Match HTTP request header * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed TaskInstance */ /* jshint ignore:end */ -TaskContext.prototype.remove = function remove(callback) { +TaskContext.prototype.remove = function remove(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + var deferred = Q.defer(); - var promise = this._version.remove({uri: this._uri, method: 'DELETE'}); + var headers = values.of({'If-Match': _.get(opts, 'ifMatch')}); + + var promise = this._version.remove({uri: this._uri, method: 'DELETE', headers: headers}); promise = promise.then(function(payload) { deferred.resolve(payload); diff --git a/lib/rest/verify/v2/service.d.ts b/lib/rest/verify/v2/service.d.ts index 7b46b592a9..483e3af651 100644 --- a/lib/rest/verify/v2/service.d.ts +++ b/lib/rest/verify/v2/service.d.ts @@ -45,6 +45,10 @@ declare function ServiceList(version: V2): ServiceListInstance; * @property push.fcmCredentialSid - Optional. Set FCM Credential for this service. * @property push.includeDate - Optional. Include the date in the Challenge's reponse. Default: true * @property skipSmsToLandlines - Whether to skip sending SMS verifications to landlines + * @property totp.codeLength - Optional. Number of digits for generated TOTP codes + * @property totp.issuer - Optional. Set TOTP Issuer for this service. + * @property totp.skew - Optional. The number of past and future time-steps valid at a given time + * @property totp.timeStep - Optional. How often, in seconds, are TOTP codes generated * @property ttsName - The name of an alternative text-to-speech service to use in phone calls */ interface ServiceInstanceUpdateOptions { @@ -61,6 +65,12 @@ interface ServiceInstanceUpdateOptions { fcmCredentialSid?: string; }; skipSmsToLandlines?: boolean; + totp?: { + issuer?: string; + timeStep?: number; + codeLength?: number; + skew?: number; + }; ttsName?: string; } @@ -198,6 +208,10 @@ interface ServiceListInstance { * @property push.fcmCredentialSid - Optional. Set FCM Credential for this service. * @property push.includeDate - Optional. Include the date in the Challenge's reponse. Default: true * @property skipSmsToLandlines - Whether to skip sending SMS verifications to landlines + * @property totp.codeLength - Optional. Number of digits for generated TOTP codes + * @property totp.issuer - Optional. Set TOTP Issuer for this service. + * @property totp.skew - Optional. The number of past and future time-steps valid at a given time + * @property totp.timeStep - Optional. How often, in seconds, are TOTP codes generated * @property ttsName - The name of an alternative text-to-speech service to use in phone calls */ interface ServiceListInstanceCreateOptions { @@ -214,6 +228,12 @@ interface ServiceListInstanceCreateOptions { fcmCredentialSid?: string; }; skipSmsToLandlines?: boolean; + totp?: { + issuer?: string; + timeStep?: number; + codeLength?: number; + skew?: number; + }; ttsName?: string; } @@ -292,6 +312,7 @@ interface ServiceResource { push: object; sid: string; skip_sms_to_landlines: boolean; + totp: object; tts_name: string; url: string; } @@ -405,6 +426,7 @@ declare class ServiceInstance extends SerializableClass { * Provide a user-friendly representation */ toJSON(): any; + totp: any; ttsName: string; /** * update a ServiceInstance diff --git a/lib/rest/verify/v2/service.js b/lib/rest/verify/v2/service.js index 1ac5de8bab..7a00476ac8 100644 --- a/lib/rest/verify/v2/service.js +++ b/lib/rest/verify/v2/service.js @@ -92,6 +92,13 @@ ServiceList = function ServiceList(version) { * Optional. Set APN Credential for this service. * @param {string} [opts.push.fcmCredentialSid] - * Optional. Set FCM Credential for this service. + * @param {string} [opts.totp.issuer] - Optional. Set TOTP Issuer for this service. + * @param {number} [opts.totp.timeStep] - + * Optional. How often, in seconds, are TOTP codes generated + * @param {number} [opts.totp.codeLength] - + * Optional. Number of digits for generated TOTP codes + * @param {number} [opts.totp.skew] - + * Optional. The number of past and future time-steps valid at a given time * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed ServiceInstance @@ -118,7 +125,11 @@ ServiceList = function ServiceList(version) { 'CustomCodeEnabled': serialize.bool(_.get(opts, 'customCodeEnabled')), 'Push.IncludeDate': serialize.bool(_.get(opts, 'push.includeDate')), 'Push.ApnCredentialSid': _.get(opts, 'push.apnCredentialSid'), - 'Push.FcmCredentialSid': _.get(opts, 'push.fcmCredentialSid') + 'Push.FcmCredentialSid': _.get(opts, 'push.fcmCredentialSid'), + 'Totp.Issuer': _.get(opts, 'totp.issuer'), + 'Totp.TimeStep': _.get(opts, 'totp.timeStep'), + 'Totp.CodeLength': _.get(opts, 'totp.codeLength'), + 'Totp.Skew': _.get(opts, 'totp.skew') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); @@ -508,6 +519,7 @@ ServicePage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {boolean} customCodeEnabled - * Whether to allow sending verifications with a custom code. * @property {object} push - The service level configuration of factor push type. + * @property {object} totp - The service level configuration of factor TOTP type. * @property {Date} dateCreated - * The RFC 2822 date and time in GMT when the resource was created * @property {Date} dateUpdated - @@ -536,6 +548,7 @@ ServiceInstance = function ServiceInstance(version, payload, sid) { this.doNotShareWarningEnabled = payload.do_not_share_warning_enabled; // jshint ignore:line this.customCodeEnabled = payload.custom_code_enabled; // jshint ignore:line this.push = payload.push; // jshint ignore:line + this.totp = payload.totp; // 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 @@ -621,6 +634,13 @@ ServiceInstance.prototype.remove = function remove(callback) { * Optional. Set APN Credential for this service. * @param {string} [opts.push.fcmCredentialSid] - * Optional. Set FCM Credential for this service. + * @param {string} [opts.totp.issuer] - Optional. Set TOTP Issuer for this service. + * @param {number} [opts.totp.timeStep] - + * Optional. How often, in seconds, are TOTP codes generated + * @param {number} [opts.totp.codeLength] - + * Optional. Number of digits for generated TOTP codes + * @param {number} [opts.totp.skew] - + * Optional. The number of past and future time-steps valid at a given time * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed ServiceInstance @@ -891,6 +911,13 @@ ServiceContext.prototype.remove = function remove(callback) { * Optional. Set APN Credential for this service. * @param {string} [opts.push.fcmCredentialSid] - * Optional. Set FCM Credential for this service. + * @param {string} [opts.totp.issuer] - Optional. Set TOTP Issuer for this service. + * @param {number} [opts.totp.timeStep] - + * Optional. How often, in seconds, are TOTP codes generated + * @param {number} [opts.totp.codeLength] - + * Optional. Number of digits for generated TOTP codes + * @param {number} [opts.totp.skew] - + * Optional. The number of past and future time-steps valid at a given time * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed ServiceInstance @@ -916,7 +943,11 @@ ServiceContext.prototype.update = function update(opts, callback) { 'CustomCodeEnabled': serialize.bool(_.get(opts, 'customCodeEnabled')), 'Push.IncludeDate': serialize.bool(_.get(opts, 'push.includeDate')), 'Push.ApnCredentialSid': _.get(opts, 'push.apnCredentialSid'), - 'Push.FcmCredentialSid': _.get(opts, 'push.fcmCredentialSid') + 'Push.FcmCredentialSid': _.get(opts, 'push.fcmCredentialSid'), + 'Totp.Issuer': _.get(opts, 'totp.issuer'), + 'Totp.TimeStep': _.get(opts, 'totp.timeStep'), + 'Totp.CodeLength': _.get(opts, 'totp.codeLength'), + 'Totp.Skew': _.get(opts, 'totp.skew') }); var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/verify/v2/service/entity/challenge.d.ts b/lib/rest/verify/v2/service/entity/challenge.d.ts index 7ea9556c59..023529da15 100644 --- a/lib/rest/verify/v2/service/entity/challenge.d.ts +++ b/lib/rest/verify/v2/service/entity/challenge.d.ts @@ -8,6 +8,8 @@ import Page = require('../../../../../base/Page'); import Response = require('../../../../../http/response'); import V2 = require('../../../V2'); +import { NotificationList } from './challenge/notification'; +import { NotificationListInstance } from './challenge/notification'; import { SerializableClass } from '../../../../../interfaces'; type ChallengeChallengeReasons = 'none'|'not_needed'|'not_requested'; @@ -160,6 +162,7 @@ interface ChallengeListInstance { /** * Options to pass to create * + * @property authPayload - Optional payload to verify the Challenge * @property details.fields - A list of objects that describe the Fields included in the Challenge * @property details.message - Shown to the user when the push notification arrives * @property expirationDate - The date-time when this Challenge expires @@ -167,6 +170,7 @@ interface ChallengeListInstance { * @property hiddenDetails - Hidden details provided to contextualize the Challenge */ interface ChallengeListInstanceCreateOptions { + authPayload?: string; details?: { message?: string; fields?: object | object[]; @@ -260,6 +264,7 @@ interface ChallengeResource { factor_type: ChallengeFactorTypes; hidden_details: object; identity: string; + links: string; responded_reason: ChallengeChallengeReasons; service_sid: string; sid: string; @@ -293,6 +298,7 @@ declare class ChallengeContext { * @param callback - Callback to handle processed record */ fetch(callback?: (error: Error | null, items: ChallengeInstance) => any): Promise; + notifications: NotificationListInstance; /** * Provide a user-friendly representation */ @@ -346,6 +352,11 @@ declare class ChallengeInstance extends SerializableClass { fetch(callback?: (error: Error | null, items: ChallengeInstance) => any): Promise; hiddenDetails: any; identity: string; + links: string; + /** + * Access the notifications + */ + notifications(): NotificationListInstance; respondedReason: ChallengeChallengeReasons; serviceSid: string; sid: string; diff --git a/lib/rest/verify/v2/service/entity/challenge.js b/lib/rest/verify/v2/service/entity/challenge.js index e0326850f7..d73d677d14 100644 --- a/lib/rest/verify/v2/service/entity/challenge.js +++ b/lib/rest/verify/v2/service/entity/challenge.js @@ -12,6 +12,7 @@ var Q = require('q'); /* jshint ignore:line */ var _ = require('lodash'); /* jshint ignore:line */ var util = require('util'); /* jshint ignore:line */ +var NotificationList = require('./challenge/notification').NotificationList; var Page = require('../../../../../base/Page'); /* jshint ignore:line */ var deserialize = require( '../../../../../base/deserialize'); /* jshint ignore:line */ @@ -73,6 +74,7 @@ ChallengeList = function ChallengeList(version, serviceSid, identity) { * A list of objects that describe the Fields included in the Challenge * @param {object} [opts.hiddenDetails] - * Hidden details provided to contextualize the Challenge + * @param {string} [opts.authPayload] - Optional payload to verify the Challenge * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed ChallengeInstance @@ -92,7 +94,8 @@ ChallengeList = function ChallengeList(version, serviceSid, identity) { 'ExpirationDate': serialize.iso8601DateTime(_.get(opts, 'expirationDate')), 'Details.Message': _.get(opts, 'details.message'), 'Details.Fields': serialize.map(_.get(opts, 'details.fields'), function(e) { return serialize.object(e); }), - 'HiddenDetails': serialize.object(_.get(opts, 'hiddenDetails')) + 'HiddenDetails': serialize.object(_.get(opts, 'hiddenDetails')), + 'AuthPayload': _.get(opts, 'authPayload') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); @@ -509,6 +512,7 @@ ChallengePage.prototype[util.inspect.custom] = function inspect(depth, options) * @property {challenge.factor_types} factorType - * The Factor Type of this Challenge * @property {string} url - The URL of this resource. + * @property {string} links - Nested resource URLs. * * @param {V2} version - Version of the resource * @param {ChallengePayload} payload - The instance payload @@ -538,6 +542,7 @@ ChallengeInstance = function ChallengeInstance(version, payload, serviceSid, this.hiddenDetails = payload.hidden_details; // jshint ignore:line this.factorType = payload.factor_type; // jshint ignore:line this.url = payload.url; // jshint ignore:line + this.links = payload.links; // jshint ignore:line // Context this._context = undefined; @@ -594,6 +599,20 @@ ChallengeInstance.prototype.update = function update(opts, callback) { return this._proxy.update(opts, callback); }; +/* jshint ignore:start */ +/** + * Access the notifications + * + * @function notifications + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeInstance# + * + * @returns {Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationList} + */ +/* jshint ignore:end */ +ChallengeInstance.prototype.notifications = function notifications() { + return this._proxy.notifications; +}; + /* jshint ignore:start */ /** * Provide a user-friendly representation @@ -629,6 +648,9 @@ ChallengeInstance.prototype[util.inspect.custom] = function inspect(depth, * * @constructor Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext * + * @property {Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationList} notifications - + * notifications resource + * * @param {V2} version - Version of the resource * @param {sid} serviceSid - Service Sid. * @param {string} identity - Unique external identifier of the Entity @@ -642,6 +664,9 @@ ChallengeContext = function ChallengeContext(version, serviceSid, identity, sid) // Path Solution this._solution = {serviceSid: serviceSid, identity: identity, sid: sid, }; this._uri = `/Services/${serviceSid}/Entities/${identity}/Challenges/${sid}`; + + // Dependents + this._notifications = undefined; }; /* jshint ignore:start */ @@ -728,6 +753,21 @@ ChallengeContext.prototype.update = function update(opts, callback) { return deferred.promise; }; +Object.defineProperty(ChallengeContext.prototype, + 'notifications', { + get: function() { + if (!this._notifications) { + this._notifications = new NotificationList( + this._version, + this._solution.serviceSid, + this._solution.identity, + this._solution.sid + ); + } + return this._notifications; + } +}); + /* jshint ignore:start */ /** * Provide a user-friendly representation diff --git a/lib/rest/verify/v2/service/entity/challenge/notification.d.ts b/lib/rest/verify/v2/service/entity/challenge/notification.d.ts new file mode 100644 index 0000000000..d361a65623 --- /dev/null +++ b/lib/rest/verify/v2/service/entity/challenge/notification.d.ts @@ -0,0 +1,133 @@ +/** + * 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 NotificationList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param serviceSid - Service Sid. + * @param identity - Unique external identifier of the Entity + * @param challengeSid - Challenge Sid. + */ +declare function NotificationList(version: V2, serviceSid: string, identity: string, challengeSid: string): NotificationListInstance; + +interface NotificationListInstance { + /** + * create a NotificationInstance + * + * @param callback - Callback to handle processed record + */ + create(callback?: (error: Error | null, item: NotificationInstance) => any): Promise; + /** + * create a NotificationInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts?: NotificationListInstanceCreateOptions, callback?: (error: Error | null, item: NotificationInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to create + * + * @property ttl - How long, in seconds, the Notification is valid. + */ +interface NotificationListInstanceCreateOptions { + ttl?: number; +} + +interface NotificationPayload extends NotificationResource, Page.TwilioResponsePayload { +} + +interface NotificationResource { + account_sid: string; + challenge_sid: string; + date_created: Date; + entity_sid: string; + identity: string; + priority: string; + service_sid: string; + sid: string; + ttl: number; +} + +interface NotificationSolution { + challengeSid?: string; + identity?: string; + serviceSid?: string; +} + + +declare class NotificationInstance extends SerializableClass { + /** + * Initialize the NotificationContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param serviceSid - Service Sid. + * @param identity - Unique external identifier of the Entity + * @param challengeSid - Challenge Sid. + */ + constructor(version: V2, payload: NotificationPayload, serviceSid: string, identity: string, challengeSid: string); + + accountSid: string; + challengeSid: string; + dateCreated: Date; + entitySid: string; + identity: string; + priority: string; + serviceSid: string; + sid: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + ttl: number; +} + + +declare class NotificationPage extends Page { + /** + * Initialize the NotificationPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V2, response: Response, solution: NotificationSolution); + + /** + * Build an instance of NotificationInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: NotificationPayload): NotificationInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { NotificationInstance, NotificationList, NotificationListInstance, NotificationListInstanceCreateOptions, NotificationPage, NotificationPayload, NotificationResource, NotificationSolution } diff --git a/lib/rest/verify/v2/service/entity/challenge/notification.js b/lib/rest/verify/v2/service/entity/challenge/notification.js new file mode 100644 index 0000000000..0f9ae99b19 --- /dev/null +++ b/lib/rest/verify/v2/service/entity/challenge/notification.js @@ -0,0 +1,277 @@ +'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 NotificationList; +var NotificationPage; +var NotificationInstance; + +/* jshint ignore:start */ +/** + * Initialize the NotificationList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationList + * + * @param {Twilio.Verify.V2} version - Version of the resource + * @param {string} serviceSid - Service Sid. + * @param {string} identity - Unique external identifier of the Entity + * @param {string} challengeSid - Challenge Sid. + */ +/* jshint ignore:end */ +NotificationList = function NotificationList(version, serviceSid, identity, + challengeSid) { + /* jshint ignore:start */ + /** + * @function notifications + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationContext} + */ + /* jshint ignore:end */ + function NotificationListInstance(sid) { + return NotificationListInstance.get(sid); + } + + NotificationListInstance._version = version; + // Path Solution + NotificationListInstance._solution = { + serviceSid: serviceSid, + identity: identity, + challengeSid: challengeSid + }; + NotificationListInstance._uri = `/Services/${serviceSid}/Entities/${identity}/Challenges/${challengeSid}/Notifications`; + /* jshint ignore:start */ + /** + * create a NotificationInstance + * + * @function create + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationList# + * + * @param {object} [opts] - Options for request + * @param {number} [opts.ttl] - How long, in seconds, the Notification is valid. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed NotificationInstance + */ + /* jshint ignore:end */ + NotificationListInstance.create = function create(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({'Ttl': _.get(opts, 'ttl')}); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new NotificationInstance(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.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationList# + * + * @returns Object + */ + /* jshint ignore:end */ + NotificationListInstance.toJSON = function toJSON() { + return this._solution; + }; + + NotificationListInstance[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); + }; + + return NotificationListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the NotificationPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationPage + * + * @param {V2} version - Version of the resource + * @param {Response} response - Response from the API + * @param {NotificationSolution} solution - Path solution + * + * @returns NotificationPage + */ +/* jshint ignore:end */ +NotificationPage = function NotificationPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(NotificationPage.prototype, Page.prototype); +NotificationPage.prototype.constructor = NotificationPage; + +/* jshint ignore:start */ +/** + * Build an instance of NotificationInstance + * + * @function getInstance + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationPage# + * + * @param {NotificationPayload} payload - Payload response from the API + * + * @returns NotificationInstance + */ +/* jshint ignore:end */ +NotificationPage.prototype.getInstance = function getInstance(payload) { + return new NotificationInstance( + this._version, + payload, + this._solution.serviceSid, + this._solution.identity, + this._solution.challengeSid + ); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationPage# + * + * @returns Object + */ +/* jshint ignore:end */ +NotificationPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +NotificationPage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the NotificationContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationInstance + * + * @property {string} sid - A string that uniquely identifies this Notification. + * @property {string} accountSid - Account Sid. + * @property {string} serviceSid - Service Sid. + * @property {string} entitySid - Entity Sid. + * @property {string} identity - Unique external identifier of the Entity + * @property {string} challengeSid - Challenge Sid. + * @property {string} priority - The priority of the Notification. + * @property {number} ttl - How long, in seconds, the Notification is valid. + * @property {Date} dateCreated - The date this Notification was created + * + * @param {V2} version - Version of the resource + * @param {NotificationPayload} payload - The instance payload + * @param {sid} serviceSid - Service Sid. + * @param {string} identity - Unique external identifier of the Entity + * @param {sid} challengeSid - Challenge Sid. + */ +/* jshint ignore:end */ +NotificationInstance = function NotificationInstance(version, payload, + serviceSid, identity, + challengeSid) { + this._version = version; + + // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.serviceSid = payload.service_sid; // jshint ignore:line + this.entitySid = payload.entity_sid; // jshint ignore:line + this.identity = payload.identity; // jshint ignore:line + this.challengeSid = payload.challenge_sid; // jshint ignore:line + this.priority = payload.priority; // jshint ignore:line + this.ttl = deserialize.integer(payload.ttl); // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {serviceSid: serviceSid, identity: identity, challengeSid: challengeSid, }; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +NotificationInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +NotificationInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + NotificationList: NotificationList, + NotificationPage: NotificationPage, + NotificationInstance: NotificationInstance +}; diff --git a/lib/twiml/VoiceResponse.d.ts b/lib/twiml/VoiceResponse.d.ts index cb039be369..923e04c729 100644 --- a/lib/twiml/VoiceResponse.d.ts +++ b/lib/twiml/VoiceResponse.d.ts @@ -251,7 +251,7 @@ declare namespace VoiceResponse { type SayLanguage = 'arb'|'ca-ES'|'cy-GB'|'da-DK'|'de-DE'|'en-AU'|'en-CA'|'en-GB'|'en-GB-WLS'|'en-IN'|'en-US'|'es-ES'|'es-MX'|'es-US'|'fi-FI'|'fr-CA'|'fr-FR'|'hi-IN'|'is-IS'|'it-IT'|'ja-JP'|'ko-KR'|'nb-NO'|'nl-NL'|'pl-PL'|'pt-BR'|'pt-PT'|'ro-RO'|'ru-RU'|'sv-SE'|'tr-TR'|'zh-CN'|'zh-HK'|'zh-TW'; - type SayVoice = 'man'|'woman'|'alice'|'Polly.Aditi'|'Polly.Amy'|'Polly.Astrid'|'Polly.Bianca'|'Polly.Brian'|'Polly.Camila'|'Polly.Carla'|'Polly.Carmen'|'Polly.Celine'|'Polly.Chantal'|'Polly.Conchita'|'Polly.Cristiano'|'Polly.Dora'|'Polly.Emma'|'Polly.Enrique'|'Polly.Ewa'|'Polly.Filiz'|'Polly.Geraint'|'Polly.Giorgio'|'Polly.Gwyneth'|'Polly.Hans'|'Polly.Ines'|'Polly.Ivy'|'Polly.Jacek'|'Polly.Jan'|'Polly.Joanna'|'Polly.Joey'|'Polly.Justin'|'Polly.Karl'|'Polly.Kendra'|'Polly.Kimberly'|'Polly.Lea'|'Polly.Liv'|'Polly.Lotte'|'Polly.Lucia'|'Polly.Lupe'|'Polly.Mads'|'Polly.Maja'|'Polly.Marlene'|'Polly.Mathieu'|'Polly.Matthew'|'Polly.Maxim'|'Polly.Mia'|'Polly.Miguel'|'Polly.Mizuki'|'Polly.Naja'|'Polly.Nicole'|'Polly.Penelope'|'Polly.Raveena'|'Polly.Ricardo'|'Polly.Ruben'|'Polly.Russell'|'Polly.Salli'|'Polly.Seoyeon'|'Polly.Takumi'|'Polly.Tatyana'|'Polly.Vicki'|'Polly.Vitoria'|'Polly.Zeina'|'Polly.Zhiyu'|'Polly.Amy-Neural'|'Polly.Emma-Neural'|'Polly.Brian-Neural'|'Polly.Salli-Neural'|'Polly.Ivy-Neural'|'Polly.Joanna-Neural'|'Polly.Kendra-Neural'|'Polly.Kimberly-Neural'|'Polly.Joey-Neural'|'Polly.Justin-Neural'|'Polly.Matthew-Neural'|'Polly.Camila-Neural'|'Polly.Lupe-Neural'; + type SayVoice = 'man'|'woman'|'alice'|'Polly.Aditi'|'Polly.Amy'|'Polly.Astrid'|'Polly.Bianca'|'Polly.Brian'|'Polly.Camila'|'Polly.Carla'|'Polly.Carmen'|'Polly.Celine'|'Polly.Chantal'|'Polly.Conchita'|'Polly.Cristiano'|'Polly.Dora'|'Polly.Emma'|'Polly.Enrique'|'Polly.Ewa'|'Polly.Filiz'|'Polly.Geraint'|'Polly.Giorgio'|'Polly.Gwyneth'|'Polly.Hans'|'Polly.Ines'|'Polly.Ivy'|'Polly.Jacek'|'Polly.Jan'|'Polly.Joanna'|'Polly.Joey'|'Polly.Justin'|'Polly.Karl'|'Polly.Kendra'|'Polly.Kimberly'|'Polly.Lea'|'Polly.Liv'|'Polly.Lotte'|'Polly.Lucia'|'Polly.Lupe'|'Polly.Mads'|'Polly.Maja'|'Polly.Marlene'|'Polly.Mathieu'|'Polly.Matthew'|'Polly.Maxim'|'Polly.Mia'|'Polly.Miguel'|'Polly.Mizuki'|'Polly.Naja'|'Polly.Nicole'|'Polly.Penelope'|'Polly.Raveena'|'Polly.Ricardo'|'Polly.Ruben'|'Polly.Russell'|'Polly.Salli'|'Polly.Seoyeon'|'Polly.Takumi'|'Polly.Tatyana'|'Polly.Vicki'|'Polly.Vitoria'|'Polly.Zeina'|'Polly.Zhiyu'|'Polly.Amy-Neural'|'Polly.Emma-Neural'|'Polly.Brian-Neural'|'Polly.Salli-Neural'|'Polly.Ivy-Neural'|'Polly.Joanna-Neural'|'Polly.Kendra-Neural'|'Polly.Kimberly-Neural'|'Polly.Joey-Neural'|'Polly.Justin-Neural'|'Polly.Matthew-Neural'|'Polly.Camila-Neural'|'Polly.Lupe-Neural'|'Polly.Olivia-Neural'|'Polly.Kevin-Neural'; type SipEvent = 'initiated'|'ringing'|'answered'|'completed'; diff --git a/spec/integration/rest/events/v1/eventType.spec.js b/spec/integration/rest/events/v1/eventType.spec.js index 63d2b9fcea..91b137cae0 100644 --- a/spec/integration/rest/events/v1/eventType.spec.js +++ b/spec/integration/rest/events/v1/eventType.spec.js @@ -34,25 +34,25 @@ describe('EventType', function() { var body = { 'types': [ { - 'date_created': '2020-08-13T12:50:18Z', - 'date_updated': '2020-08-13T13:28:48Z', - 'type': 'com.twilio.test.example', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'A sample event type', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example', + 'date_created': '2020-08-13T13:28:20Z', + 'date_updated': '2020-08-13T13:28:20Z', + 'type': 'com.twilio.messaging.message.delivered', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- delivered message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } }, { - 'date_created': '2020-08-13T12:50:19Z', - 'date_updated': '2020-08-13T13:28:49Z', - 'type': 'com.twilio.test.example2', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'Another sample event type', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example2', + 'date_created': '2020-08-13T13:28:19Z', + 'date_updated': '2020-08-13T13:28:19Z', + 'type': 'com.twilio.messaging.message.failed', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- failed message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.failed', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } } ], @@ -75,25 +75,25 @@ describe('EventType', function() { var body = { 'types': [ { - 'date_created': '2020-08-13T12:50:18Z', - 'date_updated': '2020-08-13T13:28:48Z', - 'type': 'com.twilio.test.example', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'A sample event type', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example', + 'date_created': '2020-08-13T13:28:20Z', + 'date_updated': '2020-08-13T13:28:20Z', + 'type': 'com.twilio.messaging.message.delivered', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- delivered message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } }, { - 'date_created': '2020-08-13T12:50:19Z', - 'date_updated': '2020-08-13T13:28:49Z', - 'type': 'com.twilio.test.example2', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'Another sample event type', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example2', + 'date_created': '2020-08-13T13:28:19Z', + 'date_updated': '2020-08-13T13:28:19Z', + 'type': 'com.twilio.messaging.message.failed', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- failed message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.failed', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } } ], @@ -121,25 +121,25 @@ describe('EventType', function() { var body = { 'types': [ { - 'date_created': '2020-08-13T12:50:18Z', - 'date_updated': '2020-08-13T13:28:48Z', - 'type': 'com.twilio.test.example', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'A sample event type', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example', + 'date_created': '2020-08-13T13:28:20Z', + 'date_updated': '2020-08-13T13:28:20Z', + 'type': 'com.twilio.messaging.message.delivered', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- delivered message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } }, { - 'date_created': '2020-08-13T12:50:19Z', - 'date_updated': '2020-08-13T13:28:49Z', - 'type': 'com.twilio.test.example2', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'Another sample event type', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example2', + 'date_created': '2020-08-13T13:28:19Z', + 'date_updated': '2020-08-13T13:28:19Z', + 'type': 'com.twilio.messaging.message.failed', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- failed message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.failed', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } } ], @@ -208,25 +208,25 @@ describe('EventType', function() { var body = { 'types': [ { - 'date_created': '2020-08-13T12:50:18Z', - 'date_updated': '2020-08-13T13:28:48Z', - 'type': 'com.twilio.test.example', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'A sample event type', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example', + 'date_created': '2020-08-13T13:28:20Z', + 'date_updated': '2020-08-13T13:28:20Z', + 'type': 'com.twilio.messaging.message.delivered', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- delivered message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } }, { - 'date_created': '2020-08-13T12:50:19Z', - 'date_updated': '2020-08-13T13:28:49Z', - 'type': 'com.twilio.test.example2', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'Another sample event type', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example2', + 'date_created': '2020-08-13T13:28:19Z', + 'date_updated': '2020-08-13T13:28:19Z', + 'type': 'com.twilio.messaging.message.failed', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- failed message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.failed', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } } ], @@ -276,14 +276,14 @@ describe('EventType', function() { it('should generate valid fetch response', function(done) { var body = { - 'date_created': '2020-08-13T12:50:18Z', - 'date_updated': '2020-08-13T13:28:48Z', - 'type': 'com.twilio.test.example', - 'schema_id': 'EventStreams.SampleSchema', - 'description': 'A sample subscription', - 'url': 'https://events.twilio.com/v1/Types/com.twilio.test.example', + 'date_created': '2020-08-13T13:28:20Z', + 'date_updated': '2020-08-13T13:28:20Z', + 'type': 'com.twilio.messaging.message.delivered', + 'schema_id': 'Messaging.MessageStatus', + 'description': 'Messaging- delivered message', + 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { - 'schema': 'https://events.twilio.com/v1/Schemas/EventStreams.SampleSchema/Versions' + 'schema': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } }; diff --git a/spec/integration/rest/events/v1/schema.spec.js b/spec/integration/rest/events/v1/schema.spec.js index 844cc6f265..c030e491e3 100644 --- a/spec/integration/rest/events/v1/schema.spec.js +++ b/spec/integration/rest/events/v1/schema.spec.js @@ -53,12 +53,12 @@ describe('Schema', function() { it('should generate valid fetch response', function(done) { var body = { - 'id': 'DataTaps.TestEventSchema', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema', - 'last_created': '2018-07-30T20:00:00Z', - 'last_version': 1, + 'id': 'Messaging.MessageStatus', + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus', + 'latest_version_date_created': '2020-07-30T20:00:00Z', + 'latest_version': 1, 'links': { - 'versions': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions' + 'versions': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions' } }; diff --git a/spec/integration/rest/events/v1/schema/schemaVersion.spec.js b/spec/integration/rest/events/v1/schema/version.spec.js similarity index 69% rename from spec/integration/rest/events/v1/schema/schemaVersion.spec.js rename to spec/integration/rest/events/v1/schema/version.spec.js index 5dc25a95c1..8d91d36ce2 100644 --- a/spec/integration/rest/events/v1/schema/schemaVersion.spec.js +++ b/spec/integration/rest/events/v1/schema/version.spec.js @@ -22,7 +22,7 @@ var Twilio = require('../../../../../../lib'); /* jshint ignore:line */ var client; var holodeck; -describe('Version', function() { +describe('SchemaVersion', function() { beforeEach(function() { holodeck = new Holodeck(); client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { @@ -34,26 +34,26 @@ describe('Version', function() { var body = { 'schema_versions': [ { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 1, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/1', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/1' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' }, { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 2, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/2', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/2' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/2' } ], 'meta': { 'page': 0, 'page_size': 50, - 'first_page_url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=50&Page=0', + 'first_page_url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0', 'previous_page_url': null, - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=50&Page=0', + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0', 'next_page_url': null, 'key': 'schema_versions' } @@ -68,26 +68,26 @@ describe('Version', function() { var body = { 'schema_versions': [ { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 1, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/1', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/1' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' }, { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 2, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/2', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/2' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/2' } ], 'meta': { 'page': 0, 'page_size': 50, - 'first_page_url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=50&Page=0', + 'first_page_url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0', 'previous_page_url': null, - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=50&Page=0', + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0', 'next_page_url': null, 'key': 'schema_versions' } @@ -107,26 +107,26 @@ describe('Version', function() { var body = { 'schema_versions': [ { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 1, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/1', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/1' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' }, { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 2, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/2', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/2' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/2' } ], 'meta': { 'page': 0, 'page_size': 50, - 'first_page_url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=50&Page=0', + 'first_page_url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0', 'previous_page_url': null, - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=50&Page=0', + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0', 'next_page_url': null, 'key': 'schema_versions' } @@ -165,9 +165,9 @@ describe('Version', function() { 'meta': { 'page': 0, 'page_size': 10, - 'first_page_url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=10&Page=0', + 'first_page_url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=10&Page=0', 'previous_page_url': null, - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=10&Page=0', + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=10&Page=0', 'next_page_url': null, 'key': 'schema_versions' } @@ -190,26 +190,26 @@ describe('Version', function() { var body = { 'schema_versions': [ { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 1, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/1', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/1' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' }, { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 2, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/2', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/2' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/2' } ], 'meta': { 'page': 0, 'page_size': 50, - 'first_page_url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=50&Page=0', + 'first_page_url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0', 'previous_page_url': null, - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions?PageSize=50&Page=0', + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0', 'next_page_url': null, 'key': 'schema_versions' } @@ -253,11 +253,11 @@ describe('Version', function() { it('should generate valid fetch response', function(done) { var body = { - 'id': 'DataTaps.TestEventSchema', + 'id': 'Messaging.MessageStatus', 'schema_version': 1, 'date_created': '2015-07-30T20:00:00Z', - 'url': 'https://events.twilio.com/v1/Schemas/DataTaps.TestEventSchema/Versions/1', - 'raw': 'https://events-schemas.twilio.com/DataTaps.TestEventSchema/1' + 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', + 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' }; holodeck.mock(new Response(200, body)); diff --git a/spec/integration/rest/events/v1/subscription/subscribedEvent.spec.js b/spec/integration/rest/events/v1/subscription/subscribedEvent.spec.js index 0992b51673..5442f9e16c 100644 --- a/spec/integration/rest/events/v1/subscription/subscribedEvent.spec.js +++ b/spec/integration/rest/events/v1/subscription/subscribedEvent.spec.js @@ -35,17 +35,17 @@ describe('SubscribedEvent', function() { 'types': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'Voice.Calls', - 'version': 2, + 'type': 'com.twilio.messaging.message.delivered', + 'schema_version': 2, 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/Voice.Calls' + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered' }, { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'Video.Rooms', - 'version': 15, + 'type': 'com.twilio.messaging.message.failed', + 'schema_version': 15, 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/Video.Rooms' + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.failed' } ], 'meta': { @@ -69,17 +69,17 @@ describe('SubscribedEvent', function() { 'types': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'Voice.Calls', - 'version': 2, + 'type': 'com.twilio.messaging.message.delivered', + 'schema_version': 2, 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/Voice.Calls' + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered' }, { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'Video.Rooms', - 'version': 15, + 'type': 'com.twilio.messaging.message.failed', + 'schema_version': 15, 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/Video.Rooms' + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.failed' } ], 'meta': { @@ -108,17 +108,17 @@ describe('SubscribedEvent', function() { 'types': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'Voice.Calls', - 'version': 2, + 'type': 'com.twilio.messaging.message.delivered', + 'schema_version': 2, 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/Voice.Calls' + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered' }, { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'Video.Rooms', - 'version': 15, + 'type': 'com.twilio.messaging.message.failed', + 'schema_version': 15, 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/Video.Rooms' + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.failed' } ], 'meta': { @@ -191,17 +191,17 @@ describe('SubscribedEvent', function() { 'types': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'Voice.Calls', - 'version': 2, + 'type': 'com.twilio.messaging.message.delivered', + 'schema_version': 2, 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/Voice.Calls' + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered' }, { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'Video.Rooms', - 'version': 15, + 'type': 'com.twilio.messaging.message.failed', + 'schema_version': 15, 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/Video.Rooms' + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.failed' } ], 'meta': { @@ -257,9 +257,9 @@ describe('SubscribedEvent', function() { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'event.type', - 'version': 2, - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/event.type' + 'type': 'com.twilio.messaging.message.delivered', + 'schema_version': 2, + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered' }; holodeck.mock(new Response(201, body)); @@ -303,9 +303,9 @@ describe('SubscribedEvent', function() { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'event.type', - 'version': 2, - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/event.type' + 'type': 'com.twilio.messaging.message.delivered', + 'schema_version': 2, + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered' }; holodeck.mock(new Response(200, body)); @@ -348,9 +348,9 @@ describe('SubscribedEvent', function() { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'subscription_sid': 'DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'type': 'event.type', - 'version': 2, - 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/event.type' + 'type': 'com.twilio.messaging.message.delivered', + 'schema_version': 2, + 'url': 'https://events.twilio.com/v1/Subscriptions/DFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SubscribedEvents/com.twilio.messaging.message.delivered' }; holodeck.mock(new Response(200, body)); diff --git a/spec/integration/rest/messaging/v1/service.spec.js b/spec/integration/rest/messaging/v1/service.spec.js index 211f379239..cf1807e27b 100644 --- a/spec/integration/rest/messaging/v1/service.spec.js +++ b/spec/integration/rest/messaging/v1/service.spec.js @@ -75,6 +75,7 @@ describe('Service', function() { 'synchronous_validation': true, 'usecase': 'marketing', 'us_app_to_person_registered': false, + 'use_inbound_webhook_on_number': true, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', @@ -143,6 +144,7 @@ describe('Service', function() { 'status_callback': 'https://www.example.com', 'usecase': 'marketing', 'us_app_to_person_registered': false, + 'use_inbound_webhook_on_number': true, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', @@ -200,6 +202,7 @@ describe('Service', function() { 'status_callback': 'https://www.example.com', 'usecase': 'marketing', 'us_app_to_person_registered': false, + 'use_inbound_webhook_on_number': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', @@ -251,6 +254,7 @@ describe('Service', function() { 'status_callback': 'https://www.example.com', 'usecase': 'marketing', 'us_app_to_person_registered': false, + 'use_inbound_webhook_on_number': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', @@ -307,6 +311,7 @@ describe('Service', function() { 'status_callback': 'https://www.example.com', 'usecase': 'marketing', 'us_app_to_person_registered': false, + 'use_inbound_webhook_on_number': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', @@ -378,6 +383,7 @@ describe('Service', function() { 'status_callback': 'https://www.example.com', 'usecase': 'marketing', 'us_app_to_person_registered': false, + 'use_inbound_webhook_on_number': false, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', @@ -447,6 +453,7 @@ describe('Service', function() { 'synchronous_validation': true, 'usecase': 'marketing', 'us_app_to_person_registered': false, + 'use_inbound_webhook_on_number': true, 'links': { 'phone_numbers': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', 'short_codes': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', diff --git a/spec/integration/rest/supersim/v1/sim.spec.js b/spec/integration/rest/supersim/v1/sim.spec.js index e8f3d3f324..455d8f63c9 100644 --- a/spec/integration/rest/supersim/v1/sim.spec.js +++ b/spec/integration/rest/supersim/v1/sim.spec.js @@ -57,10 +57,10 @@ describe('Sim', function() { var body = { 'sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'unique_name': 'MySIM', + 'unique_name': '', 'status': 'new', 'fleet_sid': null, - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -107,7 +107,7 @@ describe('Sim', function() { 'unique_name': 'My SIM', 'status': 'new', 'fleet_sid': null, - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -153,7 +153,7 @@ describe('Sim', function() { 'unique_name': 'MySIM', 'status': 'new', 'fleet_sid': null, - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -178,7 +178,7 @@ describe('Sim', function() { 'unique_name': null, 'status': 'scheduled', 'fleet_sid': null, - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -203,7 +203,7 @@ describe('Sim', function() { 'unique_name': null, 'status': 'new', 'fleet_sid': 'HFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -228,7 +228,7 @@ describe('Sim', function() { 'unique_name': null, 'status': 'new', 'fleet_sid': 'HFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -253,7 +253,7 @@ describe('Sim', function() { 'unique_name': null, 'status': 'new', 'fleet_sid': 'HFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -289,7 +289,7 @@ describe('Sim', function() { 'unique_name': 'My SIM', 'status': 'new', 'fleet_sid': 'HFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -319,7 +319,7 @@ describe('Sim', function() { 'unique_name': 'My SIM', 'status': 'new', 'fleet_sid': 'HFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -354,7 +354,7 @@ describe('Sim', function() { 'unique_name': 'My SIM', 'status': 'new', 'fleet_sid': 'HFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -430,7 +430,7 @@ describe('Sim', function() { 'unique_name': 'My SIM', 'status': 'new', 'fleet_sid': 'HFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -468,7 +468,7 @@ describe('Sim', function() { 'unique_name': 'My SIM', 'status': 'new', 'fleet_sid': 'HFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'iccid': 'iccid', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' @@ -491,13 +491,13 @@ describe('Sim', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://supersim.twilio.com/v1/Sims?Iccid=11111111111111111111&PageSize=50&Page=0', + 'first_page_url': 'https://supersim.twilio.com/v1/Sims?Iccid=89883070000123456789&PageSize=50&Page=0', 'key': 'sims', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://supersim.twilio.com/v1/Sims?Iccid=11111111111111111111&PageSize=50&Page=0' + 'url': 'https://supersim.twilio.com/v1/Sims?Iccid=89883070000123456789&PageSize=50&Page=0' }, 'sims': [ { @@ -506,7 +506,7 @@ describe('Sim', function() { 'unique_name': 'My SIM', 'status': 'new', 'fleet_sid': null, - 'iccid': '11111111111111111111', + 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' diff --git a/spec/integration/rest/supersim/v1/smsCommand.spec.js b/spec/integration/rest/supersim/v1/smsCommand.spec.js index 3f3bdcf4b5..35c6c998c5 100644 --- a/spec/integration/rest/supersim/v1/smsCommand.spec.js +++ b/spec/integration/rest/supersim/v1/smsCommand.spec.js @@ -154,13 +154,13 @@ describe('SmsCommand', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', + 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', 'key': 'sms_commands', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' + 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' }, 'sms_commands': [ { @@ -168,7 +168,7 @@ describe('SmsCommand', function() { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'payload': 'content of the command', 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'status': 'queued', + 'status': 'received', 'direction': 'from_sim', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -184,13 +184,13 @@ describe('SmsCommand', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', + 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', 'key': 'sms_commands', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' + 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' }, 'sms_commands': [ { @@ -198,7 +198,7 @@ describe('SmsCommand', function() { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'payload': 'content of the command', 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'status': 'queued', + 'status': 'received', 'direction': 'from_sim', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -219,13 +219,13 @@ describe('SmsCommand', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', + 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', 'key': 'sms_commands', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' + 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' }, 'sms_commands': [ { @@ -233,7 +233,7 @@ describe('SmsCommand', function() { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'payload': 'content of the command', 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'status': 'queued', + 'status': 'received', 'direction': 'from_sim', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -270,13 +270,13 @@ describe('SmsCommand', function() { var body = { 'sms_commands': [], 'meta': { - 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', + 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', 'key': 'sms_commands', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' + 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' } }; @@ -295,13 +295,13 @@ describe('SmsCommand', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', + 'first_page_url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', 'key': 'sms_commands', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=queued&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' + 'url': 'https://supersim.twilio.com/v1/SmsCommands?Status=received&Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' }, 'sms_commands': [ { @@ -309,7 +309,7 @@ describe('SmsCommand', function() { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'payload': 'content of the command', 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'status': 'queued', + 'status': 'received', 'direction': 'from_sim', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', diff --git a/spec/integration/rest/taskrouter/v1/workspace/task.spec.js b/spec/integration/rest/taskrouter/v1/workspace/task.spec.js index 37aefaf576..d6626cba5b 100644 --- a/spec/integration/rest/taskrouter/v1/workspace/task.spec.js +++ b/spec/integration/rest/taskrouter/v1/workspace/task.spec.js @@ -168,8 +168,9 @@ describe('Task', function() { function(done) { holodeck.mock(new Response(500, {})); + var opts = {ifMatch: 'if_match'}; var promise = client.taskrouter.v1.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); + .tasks('WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(opts); promise.then(function() { throw new Error('failed'); }, function(error) { @@ -181,9 +182,11 @@ describe('Task', function() { var sid = 'WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; var url = `https://taskrouter.twilio.com/v1/Workspaces/${workspaceSid}/Tasks/${sid}`; + var headers = {'If-Match': 'if_match'}; holodeck.assertHasRequest(new Request({ method: 'DELETE', - url: url + url: url, + headers: headers })); } ); diff --git a/spec/integration/rest/verify/v2/service.spec.js b/spec/integration/rest/verify/v2/service.spec.js index dbc6122f53..7965a561da 100644 --- a/spec/integration/rest/verify/v2/service.spec.js +++ b/spec/integration/rest/verify/v2/service.spec.js @@ -72,6 +72,12 @@ describe('Service', function() { 'apn_credential_sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'fcm_credential_sid': null }, + 'totp': { + 'issuer': 'test-issuer', + 'time_step': 30, + 'code_length': 3, + 'skew': 2 + }, 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -139,6 +145,12 @@ describe('Service', function() { 'apn_credential_sid': null, 'fcm_credential_sid': null }, + 'totp': { + 'issuer': null, + 'time_step': null, + 'code_length': null, + 'skew': null + }, 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -231,6 +243,12 @@ describe('Service', function() { 'apn_credential_sid': null, 'fcm_credential_sid': null }, + 'totp': { + 'issuer': null, + 'time_step': null, + 'code_length': null, + 'skew': null + }, 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -281,6 +299,12 @@ describe('Service', function() { 'apn_credential_sid': null, 'fcm_credential_sid': null }, + 'totp': { + 'issuer': null, + 'time_step': null, + 'code_length': null, + 'skew': null + }, 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -336,6 +360,12 @@ describe('Service', function() { 'apn_credential_sid': null, 'fcm_credential_sid': null }, + 'totp': { + 'issuer': null, + 'time_step': null, + 'code_length': null, + 'skew': null + }, 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -406,6 +436,12 @@ describe('Service', function() { 'apn_credential_sid': null, 'fcm_credential_sid': null }, + 'totp': { + 'issuer': null, + 'time_step': null, + 'code_length': null, + 'skew': null + }, 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -474,6 +510,12 @@ describe('Service', function() { 'apn_credential_sid': null, 'fcm_credential_sid': 'CRbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' }, + 'totp': { + 'issuer': 'test-issuer', + 'time_step': 30, + 'code_length': 3, + 'skew': 2 + }, 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', diff --git a/spec/integration/rest/verify/v2/service/entity/challenge.spec.js b/spec/integration/rest/verify/v2/service/entity/challenge.spec.js index e9efc8a86c..4dd59efe6b 100644 --- a/spec/integration/rest/verify/v2/service/entity/challenge.spec.js +++ b/spec/integration/rest/verify/v2/service/entity/challenge.spec.js @@ -56,7 +56,7 @@ describe('Challenge', function() { })); } ); - it('should generate valid create response', + it('should generate valid create_without_auth_payload response', function(done) { var body = { 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -85,7 +85,59 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } + }; + + holodeck.mock(new Response(201, body)); + + var opts = {factorSid: 'YFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .challenges.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid create_with_auth_payload response', + function(done) { + var body = { + 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'date_responded': '2015-07-30T20:00:00Z', + 'expiration_date': '2015-07-30T20:00:00Z', + 'status': 'approved', + 'responded_reason': 'none', + 'details': { + 'message': 'Hi! Mr. John Doe, would you like to sign up?', + 'date': '2020-07-01T12:13:14Z', + 'fields': [ + { + 'label': 'Action', + 'value': 'Sign up in portal' + } + ] + }, + 'hidden_details': { + 'ip': '172.168.1.234' + }, + 'factor_type': 'push', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } }; holodeck.mock(new Response(201, body)); @@ -156,7 +208,10 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } }; holodeck.mock(new Response(200, body)); @@ -203,7 +258,10 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } } ], 'meta': { @@ -253,7 +311,10 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } } ], 'meta': { @@ -308,7 +369,10 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } } ], 'meta': { @@ -410,7 +474,10 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } } ], 'meta': { @@ -491,7 +558,10 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } }; holodeck.mock(new Response(200, body)); diff --git a/spec/integration/rest/verify/v2/service/entity/challenge/notification.spec.js b/spec/integration/rest/verify/v2/service/entity/challenge/notification.spec.js new file mode 100644 index 0000000000..a063af4a75 --- /dev/null +++ b/spec/integration/rest/verify/v2/service/entity/challenge/notification.spec.js @@ -0,0 +1,114 @@ +'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('Notification', 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.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .challenges('YCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .notifications.create(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var serviceSid = 'VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var identity = 'identity'; + var challengeSid = 'YCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://verify.twilio.com/v2/Services/${serviceSid}/Entities/${identity}/Challenges/${challengeSid}/Notifications`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid create_with_ttl response', + function(done) { + var body = { + 'sid': 'NTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'challenge_sid': 'YC03XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + 'date_created': '2015-07-30T20:00:00Z', + 'priority': 'high', + 'ttl': 150 + }; + + holodeck.mock(new Response(201, body)); + + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .challenges('YCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .notifications.create(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid create_without_ttl response', + function(done) { + var body = { + 'sid': 'NTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'challenge_sid': 'YC03XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + 'date_created': '2015-07-30T20:00:00Z', + 'priority': 'high', + 'ttl': 300 + }; + + holodeck.mock(new Response(201, body)); + + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .challenges('YCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .notifications.create(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); From fb827cbfef18cfcfedcccd42f8708d833ee57539 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 21 Apr 2021 19:52:37 +0000 Subject: [PATCH 06/30] Release 3.61.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ec15bcef5..1ea410d107 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.60.0", + "version": "3.61.0", "author": "API Team ", "contributors": [ { From e088d33370121f315f5898f58830520959f5db69 Mon Sep 17 00:00:00 2001 From: shwetharadhakrishna Date: Fri, 23 Apr 2021 12:37:24 -0700 Subject: [PATCH 07/30] chore: update slack notification token --- .travis.yml | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 566c5c9060..2bb1ed805c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,26 @@ language: node_js node_js: - - "node" - - "lts/*" - - "10" - - "8" - - "6" +- node +- lts/* +- '10' +- '8' +- '6' services: - - docker +- docker script: npm run ci - deploy: - - provider: script - script: make docker-build && make docker-push - skip_cleanup: true - on: - tags: true - node: "8" - - provider: npm - email: team_interfaces@twilio.com - api_key: $NPM_TOKEN - on: - tags: true - node: "8" - +- provider: script + script: make docker-build && make docker-push + skip_cleanup: true + on: + tags: true + node: '8' +- provider: npm + email: team_interfaces@twilio.com + api_key: "$NPM_TOKEN" + on: + tags: true + node: '8' notifications: slack: if: branch = main @@ -30,4 +28,4 @@ notifications: on_success: never on_failure: change rooms: - - secure: Y6eefesugmhL9jLjlyMggLaOty5vvtFT7vzxj9AG2kRZs2zc8ZwKOLED9F5ceC6gObYJut5Qsns8tPXZmF9lJpLTeBmGA7IxewLUlJiim0G08myXT7FnU8wDiew6BUSy8xIhqLnAA4mG25oJ/Wx4ZZN7QZMZv+vKP3lEeqdwdL0= + secure: hhVGtw3ogUdCazgfsy5fh0BnCrgQJuZ56mRmRv9fqv7JYJRktf73HT7ZtyxqWW0zYuzfxPcLeEHhU02CKNfYVuaJMtukDQT40LBKIudsTOGJllulYXmM2VJYm2NChalwcx9JPx7Sxy5dBkz+AMrXlX7fmw4943e+fbve+tivj90= From e8008981b2f4def375066b3db6b80dbfa706d0d5 Mon Sep 17 00:00:00 2001 From: Elise Shanholtz Date: Mon, 3 May 2021 09:41:46 -0700 Subject: [PATCH 08/30] chore: integrate with SonarCloud (#672) --- .nycrc.json | 10 ++++++++++ .travis.yml | 15 +++++++++++++-- package.json | 7 +++++-- sonar-project.properties | 12 ++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 .nycrc.json create mode 100644 sonar-project.properties diff --git a/.nycrc.json b/.nycrc.json new file mode 100644 index 0000000000..f9dab11751 --- /dev/null +++ b/.nycrc.json @@ -0,0 +1,10 @@ +{ + "exclude": [ + "lib/rest/**/*.js", + "**/*.spec.js" + ], + "reporter": [ + "lcovonly", + "text" + ] +} diff --git a/.travis.yml b/.travis.yml index 2bb1ed805c..7ea10e72d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,18 @@ language: node_js node_js: - node - lts/* -- '10' - '8' - '6' services: - docker -script: npm run ci +jobs: + include: + - language: node_js + node_js: '10' + after_success: + - sonar-scanner +script: +- npm run ci deploy: - provider: script script: make docker-build && make docker-push @@ -29,3 +35,8 @@ notifications: on_failure: change rooms: secure: hhVGtw3ogUdCazgfsy5fh0BnCrgQJuZ56mRmRv9fqv7JYJRktf73HT7ZtyxqWW0zYuzfxPcLeEHhU02CKNfYVuaJMtukDQT40LBKIudsTOGJllulYXmM2VJYm2NChalwcx9JPx7Sxy5dBkz+AMrXlX7fmw4943e+fbve+tivj90= +addons: + sonarcloud: + organization: twilio + token: + secure: nCBPvVz97nV1YyOxwyHtgkWBXpICTVGk5XzMBoml2fp1EY8UP2tdik8IbhwFnFv5jyrxWSfo7hoGMciQZu65cIFl1S+3DjI0G3oyPdBkfi8kgRlt4cThK/saiJYHlFee96rvVMvcvpWX4s0XcKww8WjKVSkhvhAZ8d2NoZz+bxw= diff --git a/package.json b/package.json index 1ea410d107..63319b34b7 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "mock-fs": "^4.12.0", "nock": "^10.0.6", "node-mocks-http": "^1.8.1", + "nyc": "^15.1.0", "proxyquire": "^2.1.3", "typescript": "^2.8.3" }, @@ -55,9 +56,11 @@ "jshint": "jshint lib/rest/** lib/base/** lib/http/**", "jscs": "eslint lib/base/**/**.js lib/http/**/**.js --fix", "check": "npm run jshint && npm run jscs", - "ci": "npm test && npm run nsp", + "ci": "npm run nyc && npm run nsp", + "coverage": "nyc npm test", "jsdoc": "jsdoc -r lib -d docs", - "nsp": "if [ `npm --version | cut -d'.' -f1` -ge \"6\" ]; then npm audit; else echo \"npm audit is not available for npm < 6.0\"; fi" + "nsp": "if [ `npm --version | cut -d'.' -f1` -ge \"6\" ]; then npm audit; else echo \"npm audit is not available for npm < 6.0\"; fi", + "nyc": "if [ `node --version | cut -d'.' -f1 | cut -c2-` -ge \"8\" ]; then npm run coverage; else npm test; fi" }, "files": [ "lib", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000..4aa5b04d39 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=twilio_twilio-node +sonar.projectName=twilio-node +sonar.organization=twilio + +sonar.sources=lib/ +sonar.exclusions=lib/rest/**/* +sonar.tests=spec/ +sonar.test.exclusions=spec/integration/**/*.spec.js + +# For Code Coverage analysis +sonar.javascript.lcov.reportPaths=coverage/lcov.info +sonar.coverage.exclusions=lib/rest/**/* From b9af8d0ac24815a628e548cb64a0a741e0f303df Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 5 May 2021 18:48:22 +0000 Subject: [PATCH 09/30] [Librarian] Regenerated @ c95de69ef589811189089c789616f1b139c1ae3e --- CHANGES.md | 23 +++ lib/rest/api/v2010/account/call/feedback.d.ts | 18 +- lib/rest/api/v2010/account/call/feedback.js | 89 +++++---- .../v2010/account/call/feedbackSummary.d.ts | 4 +- .../api/v2010/account/call/feedbackSummary.js | 6 +- lib/rest/bulkexports/v1/export.d.ts | 12 -- lib/rest/bulkexports/v1/export.js | 12 -- lib/rest/bulkexports/v1/export/day.d.ts | 12 -- lib/rest/bulkexports/v1/export/day.js | 12 -- .../v1/export/exportCustomJob.d.ts | 9 - .../bulkexports/v1/export/exportCustomJob.js | 9 - lib/rest/bulkexports/v1/export/job.d.ts | 12 -- lib/rest/bulkexports/v1/export/job.js | 12 -- .../bulkexports/v1/exportConfiguration.d.ts | 12 -- .../bulkexports/v1/exportConfiguration.js | 12 -- lib/rest/events/v1/sink.d.ts | 25 ++- lib/rest/events/v1/sink.js | 60 ++++++ .../messaging/v1/service/usAppToPerson.d.ts | 4 +- .../messaging/v1/service/usAppToPerson.js | 4 +- lib/rest/studio/v1/flow/execution.d.ts | 2 +- lib/rest/studio/v1/flow/execution.js | 2 +- lib/rest/studio/v2/flow/execution.d.ts | 2 +- lib/rest/studio/v2/flow/execution.js | 2 +- .../api/v2010/account/call/feedback.spec.js | 57 +++--- .../account/call/feedbackSummary.spec.js | 48 ++--- .../account/conference/participant.spec.js | 66 +++++++ .../rest/api/v2010/account/message.spec.js | 27 +-- .../rest/events/v1/eventType.spec.js | 9 + .../rest/events/v1/schema/version.spec.js | 9 + spec/integration/rest/events/v1/sink.spec.js | 177 ++++++++++++++---- .../v1/service/usAppToPerson.spec.js | 4 +- .../v2/service/entity/challenge.spec.js | 71 +++++-- .../v2/service/entity/newFactor.spec.js | 2 +- 33 files changed, 533 insertions(+), 292 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4313978c2e..28536e615b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,29 @@ twilio-node changelog ===================== +[2021-05-05] Version 3.62.0 +--------------------------- +**Library - Chore** +- [PR #672](https://github.com/twilio/twilio-node/pull/672): integrate with SonarCloud. Thanks to [@eshanholtz](https://github.com/eshanholtz)! + +**Api** +- Corrected the data types for feedback summary fields **(breaking change)** +- Update the conference participant create `from` and `to` param to be endpoint type for supporting client identifier and sip address + +**Bulkexports** +- promoting API maturity to GA + +**Events** +- Add endpoint to update description in sink +- Remove beta-feature account flag + +**Messaging** +- Update `status` field in us_app_to_person api to `campaign_status` **(breaking change)** + +**Verify** +- Improve documentation regarding `push` factor and include extra information about `totp` factor. + + [2021-04-21] Version 3.61.0 --------------------------- **Library - Fix** diff --git a/lib/rest/api/v2010/account/call/feedback.d.ts b/lib/rest/api/v2010/account/call/feedback.d.ts index 09931110b0..a96521edd3 100644 --- a/lib/rest/api/v2010/account/call/feedback.d.ts +++ b/lib/rest/api/v2010/account/call/feedback.d.ts @@ -40,7 +40,7 @@ interface FeedbackInstanceCreateOptions { */ interface FeedbackInstanceUpdateOptions { issue?: FeedbackIssues | FeedbackIssues[]; - qualityScore: number; + qualityScore?: number; } interface FeedbackListInstance { @@ -103,13 +103,19 @@ declare class FeedbackContext { * Provide a user-friendly representation */ toJSON(): any; + /** + * update a FeedbackInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: FeedbackInstance) => any): Promise; /** * update a FeedbackInstance * * @param opts - Options for request * @param callback - Callback to handle processed record */ - update(opts: FeedbackInstanceUpdateOptions, callback?: (error: Error | null, items: FeedbackInstance) => any): Promise; + update(opts?: FeedbackInstanceUpdateOptions, callback?: (error: Error | null, items: FeedbackInstance) => any): Promise; } @@ -148,13 +154,19 @@ declare class FeedbackInstance extends SerializableClass { * Provide a user-friendly representation */ toJSON(): any; + /** + * update a FeedbackInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: FeedbackInstance) => any): Promise; /** * update a FeedbackInstance * * @param opts - Options for request * @param callback - Callback to handle processed record */ - update(opts: FeedbackInstanceUpdateOptions, callback?: (error: Error | null, items: FeedbackInstance) => any): Promise; + update(opts?: FeedbackInstanceUpdateOptions, callback?: (error: Error | null, items: FeedbackInstance) => any): Promise; } diff --git a/lib/rest/api/v2010/account/call/feedback.js b/lib/rest/api/v2010/account/call/feedback.js index 768124e594..da3a471748 100644 --- a/lib/rest/api/v2010/account/call/feedback.js +++ b/lib/rest/api/v2010/account/call/feedback.js @@ -212,38 +212,38 @@ Object.defineProperty(FeedbackInstance.prototype, /* jshint ignore:start */ /** - * create a FeedbackInstance + * fetch a FeedbackInstance * - * @function create + * @function fetch * @memberof Twilio.Api.V2010.AccountContext.CallContext.FeedbackInstance# * - * @param {object} opts - Options for request - * @param {number} opts.qualityScore - - * The call quality expressed as an integer from 1 to 5 - * @param {feedback.issues|list} [opts.issue] - Issues experienced during the call * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FeedbackInstance */ /* jshint ignore:end */ -FeedbackInstance.prototype.create = function create(opts, callback) { - return this._proxy.create(opts, callback); +FeedbackInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); }; /* jshint ignore:start */ /** - * fetch a FeedbackInstance + * create a FeedbackInstance * - * @function fetch + * @function create * @memberof Twilio.Api.V2010.AccountContext.CallContext.FeedbackInstance# * + * @param {object} opts - Options for request + * @param {number} opts.qualityScore - + * The call quality expressed as an integer from 1 to 5 + * @param {feedback.issues|list} [opts.issue] - Issues experienced during the call * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FeedbackInstance */ /* jshint ignore:end */ -FeedbackInstance.prototype.fetch = function fetch(callback) { - return this._proxy.fetch(callback); +FeedbackInstance.prototype.create = function create(opts, callback) { + return this._proxy.create(opts, callback); }; /* jshint ignore:start */ @@ -253,8 +253,8 @@ FeedbackInstance.prototype.fetch = function fetch(callback) { * @function update * @memberof Twilio.Api.V2010.AccountContext.CallContext.FeedbackInstance# * - * @param {object} opts - Options for request - * @param {number} opts.qualityScore - + * @param {object} [opts] - Options for request + * @param {number} [opts.qualityScore] - * The call quality expressed as an integer from 1 to 5 * @param {feedback.issues|list} [opts.issue] - Issues experienced during the call * @param {function} [callback] - Callback to handle processed record @@ -313,35 +313,19 @@ FeedbackContext = function FeedbackContext(version, accountSid, callSid) { /* jshint ignore:start */ /** - * create a FeedbackInstance + * fetch a FeedbackInstance * - * @function create + * @function fetch * @memberof Twilio.Api.V2010.AccountContext.CallContext.FeedbackContext# * - * @param {object} opts - Options for request - * @param {number} opts.qualityScore - - * The call quality expressed as an integer from 1 to 5 - * @param {feedback.issues|list} [opts.issue] - Issues experienced during the call * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FeedbackInstance */ /* jshint ignore:end */ -FeedbackContext.prototype.create = function create(opts, callback) { - if (_.isUndefined(opts)) { - throw new Error('Required parameter "opts" missing.'); - } - if (_.isUndefined(opts.qualityScore)) { - throw new Error('Required parameter "opts.qualityScore" missing.'); - } - +FeedbackContext.prototype.fetch = function fetch(callback) { var deferred = Q.defer(); - var data = values.of({ - 'QualityScore': _.get(opts, 'qualityScore'), - 'Issue': serialize.map(_.get(opts, 'issue'), function(e) { return e; }) - }); - - var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + var promise = this._version.fetch({uri: this._uri, method: 'GET'}); promise = promise.then(function(payload) { deferred.resolve(new FeedbackInstance( @@ -365,19 +349,35 @@ FeedbackContext.prototype.create = function create(opts, callback) { /* jshint ignore:start */ /** - * fetch a FeedbackInstance + * create a FeedbackInstance * - * @function fetch + * @function create * @memberof Twilio.Api.V2010.AccountContext.CallContext.FeedbackContext# * + * @param {object} opts - Options for request + * @param {number} opts.qualityScore - + * The call quality expressed as an integer from 1 to 5 + * @param {feedback.issues|list} [opts.issue] - Issues experienced during the call * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FeedbackInstance */ /* jshint ignore:end */ -FeedbackContext.prototype.fetch = function fetch(callback) { +FeedbackContext.prototype.create = function create(opts, callback) { + if (_.isUndefined(opts)) { + throw new Error('Required parameter "opts" missing.'); + } + if (_.isUndefined(opts.qualityScore)) { + throw new Error('Required parameter "opts.qualityScore" missing.'); + } + var deferred = Q.defer(); - var promise = this._version.fetch({uri: this._uri, method: 'GET'}); + var data = values.of({ + 'QualityScore': _.get(opts, 'qualityScore'), + 'Issue': serialize.map(_.get(opts, 'issue'), function(e) { return e; }) + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); promise = promise.then(function(payload) { deferred.resolve(new FeedbackInstance( @@ -406,8 +406,8 @@ FeedbackContext.prototype.fetch = function fetch(callback) { * @function update * @memberof Twilio.Api.V2010.AccountContext.CallContext.FeedbackContext# * - * @param {object} opts - Options for request - * @param {number} opts.qualityScore - + * @param {object} [opts] - Options for request + * @param {number} [opts.qualityScore] - * The call quality expressed as an integer from 1 to 5 * @param {feedback.issues|list} [opts.issue] - Issues experienced during the call * @param {function} [callback] - Callback to handle processed record @@ -416,12 +416,11 @@ FeedbackContext.prototype.fetch = function fetch(callback) { */ /* jshint ignore:end */ FeedbackContext.prototype.update = function update(opts, callback) { - if (_.isUndefined(opts)) { - throw new Error('Required parameter "opts" missing.'); - } - if (_.isUndefined(opts.qualityScore)) { - throw new Error('Required parameter "opts.qualityScore" missing.'); + if (_.isFunction(opts)) { + callback = opts; + opts = {}; } + opts = opts || {}; var deferred = Q.defer(); var data = values.of({ diff --git a/lib/rest/api/v2010/account/call/feedbackSummary.d.ts b/lib/rest/api/v2010/account/call/feedbackSummary.d.ts index 9b122d2b4c..33a672d4d6 100644 --- a/lib/rest/api/v2010/account/call/feedbackSummary.d.ts +++ b/lib/rest/api/v2010/account/call/feedbackSummary.d.ts @@ -72,7 +72,7 @@ interface FeedbackSummaryResource { date_updated: Date; end_date: Date; include_subaccounts: boolean; - issues: string[]; + issues: object[]; quality_score_average: number; quality_score_median: number; quality_score_standard_deviation: number; @@ -140,7 +140,7 @@ declare class FeedbackSummaryInstance extends SerializableClass { */ fetch(callback?: (error: Error | null, items: FeedbackSummaryInstance) => any): Promise; includeSubaccounts: boolean; - issues: string[]; + issues: object[]; qualityScoreAverage: number; qualityScoreMedian: number; qualityScoreStandardDeviation: number; diff --git a/lib/rest/api/v2010/account/call/feedbackSummary.js b/lib/rest/api/v2010/account/call/feedbackSummary.js index aaafed648f..e418ff8512 100644 --- a/lib/rest/api/v2010/account/call/feedbackSummary.js +++ b/lib/rest/api/v2010/account/call/feedbackSummary.js @@ -237,7 +237,7 @@ FeedbackSummaryPage.prototype[util.inspect.custom] = function inspect(depth, * @property {Date} endDate - The latest feedback entry date in the summary * @property {boolean} includeSubaccounts - * Whether the feedback summary includes subaccounts - * @property {string} issues - Issues experienced during the call + * @property {object} issues - Issues experienced during the call * @property {number} qualityScoreAverage - * The average QualityScore of the feedback entries * @property {number} qualityScoreMedian - @@ -265,14 +265,14 @@ FeedbackSummaryInstance = function FeedbackSummaryInstance(version, payload, this.callFeedbackCount = deserialize.integer(payload.call_feedback_count); // jshint ignore:line this.dateCreated = deserialize.rfc2822DateTime(payload.date_created); // jshint ignore:line this.dateUpdated = deserialize.rfc2822DateTime(payload.date_updated); // jshint ignore:line - this.endDate = deserialize.iso8601DateTime(payload.end_date); // jshint ignore:line + this.endDate = deserialize.iso8601Date(payload.end_date); // jshint ignore:line this.includeSubaccounts = payload.include_subaccounts; // jshint ignore:line this.issues = payload.issues; // jshint ignore:line this.qualityScoreAverage = deserialize.decimal(payload.quality_score_average); // jshint ignore:line this.qualityScoreMedian = deserialize.decimal(payload.quality_score_median); // jshint ignore:line this.qualityScoreStandardDeviation = deserialize.decimal(payload.quality_score_standard_deviation); // jshint ignore:line this.sid = payload.sid; // jshint ignore:line - this.startDate = deserialize.iso8601DateTime(payload.start_date); // jshint ignore:line + this.startDate = deserialize.iso8601Date(payload.start_date); // jshint ignore:line this.status = payload.status; // jshint ignore:line // Context diff --git a/lib/rest/bulkexports/v1/export.d.ts b/lib/rest/bulkexports/v1/export.d.ts index 61a8d3cecb..682fdaaf77 100644 --- a/lib/rest/bulkexports/v1/export.d.ts +++ b/lib/rest/bulkexports/v1/export.d.ts @@ -18,9 +18,6 @@ import { SerializableClass } from '../../../interfaces'; /** * Initialize the ExportList * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource */ declare function ExportList(version: V1): ExportListInstance; @@ -60,9 +57,6 @@ declare class ExportContext { /** * Initialize the ExportContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants */ @@ -87,9 +81,6 @@ declare class ExportInstance extends SerializableClass { /** * Initialize the ExportContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource * @param payload - The instance payload * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants @@ -125,9 +116,6 @@ declare class ExportPage extends Page { /** * Initialize the DayPage * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource * @param response - Response from the API * @param solution - Path solution diff --git a/lib/rest/bulkexports/v1/export/day.js b/lib/rest/bulkexports/v1/export/day.js index 23c5ef9cb0..4c5355fdbd 100644 --- a/lib/rest/bulkexports/v1/export/day.js +++ b/lib/rest/bulkexports/v1/export/day.js @@ -26,9 +26,6 @@ var DayContext; /** * Initialize the DayList * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @constructor Twilio.Bulkexports.V1.ExportContext.DayList * * @param {Twilio.Bulkexports.V1} version - Version of the resource @@ -339,9 +336,6 @@ DayList = function DayList(version, resourceType) { /** * Initialize the DayPage * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @constructor Twilio.Bulkexports.V1.ExportContext.DayPage * * @param {V1} version - Version of the resource @@ -406,9 +400,6 @@ DayPage.prototype[util.inspect.custom] = function inspect(depth, options) { /** * Initialize the DayContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @constructor Twilio.Bulkexports.V1.ExportContext.DayInstance * * @property {string} redirectTo - The redirect_to @@ -499,9 +490,6 @@ DayInstance.prototype[util.inspect.custom] = function inspect(depth, options) { /** * Initialize the DayContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @constructor Twilio.Bulkexports.V1.ExportContext.DayContext * * @param {V1} version - Version of the resource diff --git a/lib/rest/bulkexports/v1/export/exportCustomJob.d.ts b/lib/rest/bulkexports/v1/export/exportCustomJob.d.ts index a98caa8c89..306925483e 100644 --- a/lib/rest/bulkexports/v1/export/exportCustomJob.d.ts +++ b/lib/rest/bulkexports/v1/export/exportCustomJob.d.ts @@ -15,9 +15,6 @@ type ExportCustomJobStatus = 'ErrorDuringRun'|'Submitted'|'Running'|'CompletedEm /** * Initialize the ExportCustomJobList * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants */ @@ -235,9 +232,6 @@ declare class ExportCustomJobInstance extends SerializableClass { /** * Initialize the ExportCustomJobContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource * @param payload - The instance payload * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants @@ -266,9 +260,6 @@ declare class ExportCustomJobPage extends Page { /** * Initialize the JobPage * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource * @param response - Response from the API * @param solution - Path solution diff --git a/lib/rest/bulkexports/v1/export/job.js b/lib/rest/bulkexports/v1/export/job.js index e727b90d79..6a8382c143 100644 --- a/lib/rest/bulkexports/v1/export/job.js +++ b/lib/rest/bulkexports/v1/export/job.js @@ -24,9 +24,6 @@ var JobContext; /** * Initialize the JobList * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @constructor Twilio.Bulkexports.V1.ExportContext.JobList * * @param {Twilio.Bulkexports.V1} version - Version of the resource @@ -93,9 +90,6 @@ JobList = function JobList(version) { /** * Initialize the JobPage * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @constructor Twilio.Bulkexports.V1.ExportContext.JobPage * * @param {V1} version - Version of the resource @@ -160,9 +154,6 @@ JobPage.prototype[util.inspect.custom] = function inspect(depth, options) { /** * Initialize the JobContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @constructor Twilio.Bulkexports.V1.ExportContext.JobInstance * * @property {string} resourceType - @@ -286,9 +277,6 @@ JobInstance.prototype[util.inspect.custom] = function inspect(depth, options) { /** * Initialize the JobContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @constructor Twilio.Bulkexports.V1.ExportContext.JobContext * * @param {V1} version - Version of the resource diff --git a/lib/rest/bulkexports/v1/exportConfiguration.d.ts b/lib/rest/bulkexports/v1/exportConfiguration.d.ts index 7102b1d7a0..6c5f39c7f4 100644 --- a/lib/rest/bulkexports/v1/exportConfiguration.d.ts +++ b/lib/rest/bulkexports/v1/exportConfiguration.d.ts @@ -13,9 +13,6 @@ import { SerializableClass } from '../../../interfaces'; /** * Initialize the ExportConfigurationList * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource */ declare function ExportConfigurationList(version: V1): ExportConfigurationListInstance; @@ -69,9 +66,6 @@ declare class ExportConfigurationContext { /** * Initialize the ExportConfigurationContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants */ @@ -107,9 +101,6 @@ declare class ExportConfigurationInstance extends SerializableClass { /** * Initialize the ExportConfigurationContext * - * PLEASE NOTE that this class contains beta products that are subject to change. - * Use them with caution. - * * @param version - Version of the resource * @param payload - The instance payload * @param resourceType - The type of communication – Messages, Calls, Conferences, and Participants @@ -152,9 +143,6 @@ declare class ExportConfigurationPage extends Page any): Promise; } @@ -316,6 +332,13 @@ declare class SinkInstance extends SerializableClass { * Provide a user-friendly representation */ toJSON(): any; + /** + * update a SinkInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts: SinkInstanceUpdateOptions, callback?: (error: Error | null, items: SinkInstance) => any): Promise; url: string; } @@ -345,4 +368,4 @@ declare class SinkPage extends Page toJSON(): any; } -export { SinkContext, SinkInstance, SinkList, SinkListInstance, SinkListInstanceCreateOptions, SinkListInstanceEachOptions, SinkListInstanceOptions, SinkListInstancePageOptions, SinkPage, SinkPayload, SinkResource, SinkSinkType, SinkSolution, SinkStatus } +export { SinkContext, SinkInstance, SinkInstanceUpdateOptions, SinkList, SinkListInstance, SinkListInstanceCreateOptions, SinkListInstanceEachOptions, SinkListInstanceOptions, SinkListInstancePageOptions, SinkPage, SinkPayload, SinkResource, SinkSinkType, SinkSolution, SinkStatus } diff --git a/lib/rest/events/v1/sink.js b/lib/rest/events/v1/sink.js index 18c71ae2a7..dbb2424ad9 100644 --- a/lib/rest/events/v1/sink.js +++ b/lib/rest/events/v1/sink.js @@ -543,6 +543,24 @@ SinkInstance.prototype.remove = function remove(callback) { return this._proxy.remove(callback); }; +/* jshint ignore:start */ +/** + * update a SinkInstance + * + * @function update + * @memberof Twilio.Events.V1.SinkInstance# + * + * @param {object} opts - Options for request + * @param {string} opts.description - Sink Description + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SinkInstance + */ +/* jshint ignore:end */ +SinkInstance.prototype.update = function update(opts, callback) { + return this._proxy.update(opts, callback); +}; + /* jshint ignore:start */ /** * Access the sinkTest @@ -688,6 +706,48 @@ SinkContext.prototype.remove = function remove(callback) { return deferred.promise; }; +/* jshint ignore:start */ +/** + * update a SinkInstance + * + * @function update + * @memberof Twilio.Events.V1.SinkContext# + * + * @param {object} opts - Options for request + * @param {string} opts.description - Sink Description + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed SinkInstance + */ +/* jshint ignore:end */ +SinkContext.prototype.update = function update(opts, callback) { + if (_.isUndefined(opts)) { + throw new Error('Required parameter "opts" missing.'); + } + if (_.isUndefined(opts.description)) { + throw new Error('Required parameter "opts.description" missing.'); + } + + var deferred = Q.defer(); + var data = values.of({'Description': _.get(opts, 'description')}); + + var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new SinkInstance(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; +}; + Object.defineProperty(SinkContext.prototype, 'sinkTest', { get: function() { diff --git a/lib/rest/messaging/v1/service/usAppToPerson.d.ts b/lib/rest/messaging/v1/service/usAppToPerson.d.ts index 074bd4ad1d..740e9e6d7a 100644 --- a/lib/rest/messaging/v1/service/usAppToPerson.d.ts +++ b/lib/rest/messaging/v1/service/usAppToPerson.d.ts @@ -73,6 +73,7 @@ interface UsAppToPersonResource { account_sid: string; brand_registration_sid: string; campaign_id: string; + campaign_status: string; date_created: Date; date_updated: Date; description: string; @@ -82,7 +83,6 @@ interface UsAppToPersonResource { message_samples: string[]; messaging_service_sid: string; rate_limits: object; - status: string; url: string; us_app_to_person_usecase: string; } @@ -108,6 +108,7 @@ declare class UsAppToPersonInstance extends SerializableClass { accountSid: string; brandRegistrationSid: string; campaignId: string; + campaignStatus: string; dateCreated: Date; dateUpdated: Date; description: string; @@ -117,7 +118,6 @@ declare class UsAppToPersonInstance extends SerializableClass { messageSamples: string[]; messagingServiceSid: string; rateLimits: any; - status: string; /** * Provide a user-friendly representation */ diff --git a/lib/rest/messaging/v1/service/usAppToPerson.js b/lib/rest/messaging/v1/service/usAppToPerson.js index 8923ca7da0..41e5a9fe72 100644 --- a/lib/rest/messaging/v1/service/usAppToPerson.js +++ b/lib/rest/messaging/v1/service/usAppToPerson.js @@ -309,7 +309,7 @@ UsAppToPersonPage.prototype[util.inspect.custom] = function inspect(depth, * Indicate that this SMS campaign will send messages that contain links * @property {boolean} hasEmbeddedPhone - * Indicates that this SMS campaign will send messages that contain phone numbers - * @property {string} status - Campaign status + * @property {string} campaignStatus - Campaign status * @property {string} campaignId - The Campaign Registry (TCR) Campaign ID. * @property {boolean} isExternallyRegistered - * Indicates whether the campaign was registered externally or not @@ -340,7 +340,7 @@ UsAppToPersonInstance = function UsAppToPersonInstance(version, payload, this.usAppToPersonUsecase = payload.us_app_to_person_usecase; // jshint ignore:line this.hasEmbeddedLinks = payload.has_embedded_links; // jshint ignore:line this.hasEmbeddedPhone = payload.has_embedded_phone; // jshint ignore:line - this.status = payload.status; // jshint ignore:line + this.campaignStatus = payload.campaign_status; // jshint ignore:line this.campaignId = payload.campaign_id; // jshint ignore:line this.isExternallyRegistered = payload.is_externally_registered; // jshint ignore:line this.rateLimits = payload.rate_limits; // jshint ignore:line diff --git a/lib/rest/studio/v1/flow/execution.d.ts b/lib/rest/studio/v1/flow/execution.d.ts index 2125da9232..c6a532383e 100644 --- a/lib/rest/studio/v1/flow/execution.d.ts +++ b/lib/rest/studio/v1/flow/execution.d.ts @@ -156,7 +156,7 @@ interface ExecutionListInstance { /** * Options to pass to create * - * @property from - The Twilio phone number to send messages or initiate calls from during the Flow Execution + * @property from - The Twilio phone number or Messaging Service SID to send messages or initiate calls from during the Flow Execution * @property parameters - JSON data that will be added to the Flow's context * @property to - The Contact phone number to start a Studio Flow Execution */ diff --git a/lib/rest/studio/v1/flow/execution.js b/lib/rest/studio/v1/flow/execution.js index a452d2704f..cb24dad3bc 100644 --- a/lib/rest/studio/v1/flow/execution.js +++ b/lib/rest/studio/v1/flow/execution.js @@ -322,7 +322,7 @@ ExecutionList = function ExecutionList(version, flowSid) { * @param {string} opts.to - * The Contact phone number to start a Studio Flow Execution * @param {string} opts.from - - * The Twilio phone number to send messages or initiate calls from during the Flow Execution + * The Twilio phone number or Messaging Service SID to send messages or initiate calls from during the Flow Execution * @param {object} [opts.parameters] - * JSON data that will be added to the Flow's context * @param {function} [callback] - Callback to handle processed record diff --git a/lib/rest/studio/v2/flow/execution.d.ts b/lib/rest/studio/v2/flow/execution.d.ts index 89f54934da..a1e39fd867 100644 --- a/lib/rest/studio/v2/flow/execution.d.ts +++ b/lib/rest/studio/v2/flow/execution.d.ts @@ -156,7 +156,7 @@ interface ExecutionListInstance { /** * Options to pass to create * - * @property from - The Twilio phone number to send messages or initiate calls from during the Flow Execution + * @property from - The Twilio phone number or Messaging Service SID to send messages or initiate calls from during the Flow Execution * @property parameters - JSON data that will be added to the Flow's context * @property to - The Contact phone number to start a Studio Flow Execution */ diff --git a/lib/rest/studio/v2/flow/execution.js b/lib/rest/studio/v2/flow/execution.js index 5301b88b8b..4971b72a8c 100644 --- a/lib/rest/studio/v2/flow/execution.js +++ b/lib/rest/studio/v2/flow/execution.js @@ -322,7 +322,7 @@ ExecutionList = function ExecutionList(version, flowSid) { * @param {string} opts.to - * The Contact phone number to start a Studio Flow Execution * @param {string} opts.from - - * The Twilio phone number to send messages or initiate calls from during the Flow Execution + * The Twilio phone number or Messaging Service SID to send messages or initiate calls from during the Flow Execution * @param {object} [opts.parameters] - * JSON data that will be added to the Flow's context * @param {function} [callback] - Callback to handle processed record diff --git a/spec/integration/rest/api/v2010/account/call/feedback.spec.js b/spec/integration/rest/api/v2010/account/call/feedback.spec.js index d2ea5206dc..6690653322 100644 --- a/spec/integration/rest/api/v2010/account/call/feedback.spec.js +++ b/spec/integration/rest/api/v2010/account/call/feedback.spec.js @@ -29,14 +29,13 @@ describe('Feedback', function() { httpClient: holodeck }); }); - it('should generate valid create request', + it('should generate valid fetch request', function(done) { holodeck.mock(new Response(500, {})); - var opts = {qualityScore: 1}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .feedback().create(opts); + .feedback().fetch(); promise.then(function() { throw new Error('failed'); }, function(error) { @@ -48,15 +47,13 @@ describe('Feedback', function() { var callSid = 'CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; var url = `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Calls/${callSid}/Feedback.json`; - var values = {QualityScore: 1, }; holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url, - data: values + method: 'GET', + url: url })); } ); - it('should generate valid create response', + it('should generate valid fetch response', function(done) { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -66,16 +63,15 @@ describe('Feedback', function() { 'imperfect-audio', 'post-dial-delay' ], - 'quality_score': 5, + 'quality_score': 1, 'sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; - holodeck.mock(new Response(201, body)); + holodeck.mock(new Response(200, body)); - var opts = {qualityScore: 1}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .feedback().create(opts); + .feedback().fetch(); promise.then(function(response) { expect(response).toBeDefined(); done(); @@ -84,13 +80,14 @@ describe('Feedback', function() { }).done(); } ); - it('should generate valid fetch request', + it('should generate valid create request', function(done) { holodeck.mock(new Response(500, {})); + var opts = {qualityScore: 1}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .feedback().fetch(); + .feedback().create(opts); promise.then(function() { throw new Error('failed'); }, function(error) { @@ -102,13 +99,15 @@ describe('Feedback', function() { var callSid = 'CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; var url = `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Calls/${callSid}/Feedback.json`; + var values = {QualityScore: 1, }; holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url + method: 'POST', + url: url, + data: values })); } ); - it('should generate valid fetch response', + it('should generate valid create response', function(done) { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -118,15 +117,16 @@ describe('Feedback', function() { 'imperfect-audio', 'post-dial-delay' ], - 'quality_score': 5, + 'quality_score': 1, 'sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; - holodeck.mock(new Response(200, body)); + holodeck.mock(new Response(201, body)); + var opts = {qualityScore: 1}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .feedback().fetch(); + .feedback().create(opts); promise.then(function(response) { expect(response).toBeDefined(); done(); @@ -139,10 +139,9 @@ describe('Feedback', function() { function(done) { holodeck.mock(new Response(500, {})); - var opts = {qualityScore: 1}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .feedback().update(opts); + .feedback().update(); promise.then(function() { throw new Error('failed'); }, function(error) { @@ -154,11 +153,9 @@ describe('Feedback', function() { var callSid = 'CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; var url = `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Calls/${callSid}/Feedback.json`; - var values = {QualityScore: 1, }; holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url, - data: values + method: 'POST', + url: url })); } ); @@ -169,19 +166,17 @@ describe('Feedback', function() { 'date_created': 'Thu, 20 Aug 2015 21:45:46 +0000', 'date_updated': 'Thu, 20 Aug 2015 21:45:46 +0000', 'issues': [ - 'imperfect-audio', - 'post-dial-delay' + 'audio-latency' ], - 'quality_score': 5, + 'quality_score': 2, 'sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; holodeck.mock(new Response(200, body)); - var opts = {qualityScore: 1}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .feedback().update(opts); + .feedback().update(); promise.then(function(response) { expect(response).toBeDefined(); done(); diff --git a/spec/integration/rest/api/v2010/account/call/feedbackSummary.spec.js b/spec/integration/rest/api/v2010/account/call/feedbackSummary.spec.js index e19d6a04a3..ada600e892 100644 --- a/spec/integration/rest/api/v2010/account/call/feedbackSummary.spec.js +++ b/spec/integration/rest/api/v2010/account/call/feedbackSummary.spec.js @@ -63,26 +63,26 @@ describe('FeedbackSummary', function() { it('should generate valid create response', function(done) { var body = { + 'include_subaccounts': false, + 'call_feedback_count': 729, + 'quality_score_standard_deviation': '1.0', + 'end_date': '2014-01-01', + 'quality_score_median': '4.0', + 'quality_score_average': '4.5', + 'date_updated': 'Tue, 31 Aug 2010 20:36:28 +0000', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'completed', 'call_count': 10200, - 'call_feedback_count': 729, - 'end_date': '2011-01-01', - 'include_subaccounts': false, + 'sid': 'FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': 'Tue, 31 Aug 2010 20:36:28 +0000', + 'start_date': '2014-01-01', 'issues': [ { 'count': 45, 'description': 'imperfect-audio', 'percentage_of_total_calls': '0.04%' } - ], - 'quality_score_average': 4.5, - 'quality_score_median': 4, - 'quality_score_standard_deviation': 1, - 'sid': 'FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'start_date': '2011-01-01', - 'status': 'completed', - 'date_created': 'Tue, 31 Aug 2010 20:36:28 +0000', - 'date_updated': 'Tue, 31 Aug 2010 20:36:44 +0000' + ] }; holodeck.mock(new Response(201, body)); @@ -126,26 +126,26 @@ describe('FeedbackSummary', function() { it('should generate valid fetch response', function(done) { var body = { + 'include_subaccounts': false, + 'call_feedback_count': 729, + 'quality_score_standard_deviation': '1.0', + 'end_date': '2014-01-01', + 'quality_score_median': '4.0', + 'quality_score_average': '4.5', + 'date_updated': 'Tue, 31 Aug 2010 20:36:28 +0000', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'completed', 'call_count': 10200, - 'call_feedback_count': 729, - 'end_date': '2011-01-01', - 'include_subaccounts': false, + 'sid': 'FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': 'Tue, 31 Aug 2010 20:36:28 +0000', + 'start_date': '2014-01-01', 'issues': [ { 'count': 45, 'description': 'imperfect-audio', 'percentage_of_total_calls': '0.04%' } - ], - 'quality_score_average': 4.5, - 'quality_score_median': 4, - 'quality_score_standard_deviation': 1, - 'sid': 'FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'start_date': '2011-01-01', - 'status': 'completed', - 'date_created': 'Tue, 31 Aug 2010 20:36:28 +0000', - 'date_updated': 'Tue, 31 Aug 2010 20:36:44 +0000' + ] }; holodeck.mock(new Response(200, body)); diff --git a/spec/integration/rest/api/v2010/account/conference/participant.spec.js b/spec/integration/rest/api/v2010/account/conference/participant.spec.js index e7339c5fe3..5dc02c3bab 100644 --- a/spec/integration/rest/api/v2010/account/conference/participant.spec.js +++ b/spec/integration/rest/api/v2010/account/conference/participant.spec.js @@ -595,6 +595,72 @@ describe('Participant', function() { }).done(); } ); + it('should generate valid create_with_from_to_client response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'label': 'customer', + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': 'Fri, 18 Feb 2011 21:07:19 +0000', + 'date_updated': 'Fri, 18 Feb 2011 21:07:19 +0000', + 'end_conference_on_exit': false, + 'muted': false, + 'hold': false, + 'status': 'complete', + 'start_conference_on_enter': true, + 'coaching': false, + 'call_sid_to_coach': null, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {from: '+15017122661', to: '+15558675310'}; + var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participants.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid create_with_from_to_sip response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'label': 'customer', + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': 'Fri, 18 Feb 2011 21:07:19 +0000', + 'date_updated': 'Fri, 18 Feb 2011 21:07:19 +0000', + 'end_conference_on_exit': false, + 'muted': false, + 'hold': false, + 'status': 'complete', + 'start_conference_on_enter': true, + 'coaching': false, + 'call_sid_to_coach': null, + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {from: '+15017122661', to: '+15558675310'}; + var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participants.create(opts); + 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, {})); diff --git a/spec/integration/rest/api/v2010/account/message.spec.js b/spec/integration/rest/api/v2010/account/message.spec.js index 6b64a74a87..4ccfb606a2 100644 --- a/spec/integration/rest/api/v2010/account/message.spec.js +++ b/spec/integration/rest/api/v2010/account/message.spec.js @@ -809,31 +809,32 @@ describe('Message', function() { })); } ); - it('should generate valid update response', + it('should generate valid redact_body response', function(done) { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'api_version': '2010-04-01', - 'body': 'Hello, this is trash Benson cut and pasted and probably does not do anything useful! \ud83d\udc4d', - 'date_created': 'Thu, 30 Jul 2015 20:12:31 +0000', - 'date_sent': 'Thu, 30 Jul 2015 20:12:33 +0000', - 'date_updated': 'Thu, 30 Jul 2015 20:12:33 +0000', + 'body': '', + 'date_created': 'Fri, 24 May 2019 17:18:27 +0000', + 'date_sent': 'Fri, 24 May 2019 17:18:28 +0000', + 'date_updated': 'Fri, 24 May 2019 17:18:28 +0000', 'direction': 'outbound-api', - 'error_code': null, - 'error_message': null, - 'from': '+14155552345', - 'messaging_service_sid': 'MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'error_code': 30007, + 'error_message': 'Carrier violation', + 'from': '+12019235161', + 'messaging_service_sid': 'MGdeadbeefdeadbeefdeadbeefdeadbeef', 'num_media': '0', 'num_segments': '1', 'price': '-0.00750', 'price_unit': 'USD', - 'sid': 'SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'SMb7c0a2ce80504485a6f653a7110836f5', 'status': 'sent', 'subresource_uris': { - 'media': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json' + 'media': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Media.json', + 'feedback': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Feedback.json' }, - 'to': '+14155552345', - 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json' + 'to': '+18182008801', + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5.json' }; holodeck.mock(new Response(200, body)); diff --git a/spec/integration/rest/events/v1/eventType.spec.js b/spec/integration/rest/events/v1/eventType.spec.js index 91b137cae0..0188264416 100644 --- a/spec/integration/rest/events/v1/eventType.spec.js +++ b/spec/integration/rest/events/v1/eventType.spec.js @@ -38,6 +38,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:20Z', 'type': 'com.twilio.messaging.message.delivered', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- delivered message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { @@ -49,6 +50,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:19Z', 'type': 'com.twilio.messaging.message.failed', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- failed message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.failed', 'links': { @@ -79,6 +81,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:20Z', 'type': 'com.twilio.messaging.message.delivered', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- delivered message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { @@ -90,6 +93,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:19Z', 'type': 'com.twilio.messaging.message.failed', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- failed message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.failed', 'links': { @@ -125,6 +129,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:20Z', 'type': 'com.twilio.messaging.message.delivered', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- delivered message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { @@ -136,6 +141,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:19Z', 'type': 'com.twilio.messaging.message.failed', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- failed message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.failed', 'links': { @@ -212,6 +218,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:20Z', 'type': 'com.twilio.messaging.message.delivered', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- delivered message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { @@ -223,6 +230,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:19Z', 'type': 'com.twilio.messaging.message.failed', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- failed message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.failed', 'links': { @@ -280,6 +288,7 @@ describe('EventType', function() { 'date_updated': '2020-08-13T13:28:20Z', 'type': 'com.twilio.messaging.message.delivered', 'schema_id': 'Messaging.MessageStatus', + 'public': true, 'description': 'Messaging- delivered message', 'url': 'https://events.twilio.com/v1/Types/com.twilio.messaging.message.delivered', 'links': { diff --git a/spec/integration/rest/events/v1/schema/version.spec.js b/spec/integration/rest/events/v1/schema/version.spec.js index 8d91d36ce2..ac622d100a 100644 --- a/spec/integration/rest/events/v1/schema/version.spec.js +++ b/spec/integration/rest/events/v1/schema/version.spec.js @@ -36,6 +36,7 @@ describe('SchemaVersion', function() { { 'id': 'Messaging.MessageStatus', 'schema_version': 1, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' @@ -43,6 +44,7 @@ describe('SchemaVersion', function() { { 'id': 'Messaging.MessageStatus', 'schema_version': 2, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/2' @@ -70,6 +72,7 @@ describe('SchemaVersion', function() { { 'id': 'Messaging.MessageStatus', 'schema_version': 1, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' @@ -77,6 +80,7 @@ describe('SchemaVersion', function() { { 'id': 'Messaging.MessageStatus', 'schema_version': 2, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/2' @@ -109,6 +113,7 @@ describe('SchemaVersion', function() { { 'id': 'Messaging.MessageStatus', 'schema_version': 1, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' @@ -116,6 +121,7 @@ describe('SchemaVersion', function() { { 'id': 'Messaging.MessageStatus', 'schema_version': 2, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/2' @@ -192,6 +198,7 @@ describe('SchemaVersion', function() { { 'id': 'Messaging.MessageStatus', 'schema_version': 1, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' @@ -199,6 +206,7 @@ describe('SchemaVersion', function() { { 'id': 'Messaging.MessageStatus', 'schema_version': 2, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/2' @@ -255,6 +263,7 @@ describe('SchemaVersion', function() { var body = { 'id': 'Messaging.MessageStatus', 'schema_version': 1, + 'public': true, 'date_created': '2015-07-30T20:00:00Z', 'url': 'https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1', 'raw': 'https://events-schemas.twilio.com/Messaging.MessageStatus/1' diff --git a/spec/integration/rest/events/v1/sink.spec.js b/spec/integration/rest/events/v1/sink.spec.js index a609d098e8..2909a14002 100644 --- a/spec/integration/rest/events/v1/sink.spec.js +++ b/spec/integration/rest/events/v1/sink.spec.js @@ -56,8 +56,12 @@ describe('Sink', function() { function(done) { var body = { 'status': 'initialized', - 'sink_configuration': {}, - 'description': 'description', + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:111111111:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, + 'description': 'A Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'sink_type': 'kinesis', @@ -112,11 +116,11 @@ describe('Sink', function() { var body = { 'status': 'initialized', 'sink_configuration': { - 'arn': '4242', - 'role_arn': 'abc123', - 'external_id': '010101' + 'arn': 'arn:aws:kinesis:us-east-1:111111111:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' }, - 'description': 'description', + 'description': 'My Kinesis Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'sink_type': 'kinesis', @@ -182,12 +186,16 @@ describe('Sink', function() { 'sinks': [ { 'status': 'initialized', - 'sink_configuration': {}, + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:111111111:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, 'description': 'A Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', + 'date_created': '2015-07-30T19:00:00Z', 'sink_type': 'kinesis', - 'date_updated': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T19:00:00Z', 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test', @@ -196,7 +204,11 @@ describe('Sink', function() { }, { 'status': 'initialized', - 'sink_configuration': {}, + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:222222222:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, 'description': 'ANOTHER Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', 'date_created': '2015-07-30T20:00:00Z', @@ -210,12 +222,16 @@ describe('Sink', function() { }, { 'status': 'active', - 'sink_configuration': {}, + 'sink_configuration': { + 'destination': 'http://example.org/webhook', + 'method': 'POST', + 'batch_events': true + }, 'description': 'A webhook Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac', - 'date_created': '2015-07-30T20:00:00Z', + 'date_created': '2015-07-30T21:00:00Z', 'sink_type': 'webhook', - 'date_updated': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T21:00:00Z', 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac', 'links': { 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac/Test', @@ -243,12 +259,16 @@ describe('Sink', function() { 'sinks': [ { 'status': 'initialized', - 'sink_configuration': {}, + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:111111111:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, 'description': 'A Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', + 'date_created': '2015-07-30T19:00:00Z', 'sink_type': 'kinesis', - 'date_updated': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T19:00:00Z', 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test', @@ -257,7 +277,11 @@ describe('Sink', function() { }, { 'status': 'initialized', - 'sink_configuration': {}, + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:222222222:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, 'description': 'ANOTHER Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', 'date_created': '2015-07-30T20:00:00Z', @@ -271,12 +295,16 @@ describe('Sink', function() { }, { 'status': 'active', - 'sink_configuration': {}, + 'sink_configuration': { + 'destination': 'http://example.org/webhook', + 'method': 'POST', + 'batch_events': true + }, 'description': 'A webhook Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac', - 'date_created': '2015-07-30T20:00:00Z', + 'date_created': '2015-07-30T21:00:00Z', 'sink_type': 'webhook', - 'date_updated': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T21:00:00Z', 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac', 'links': { 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac/Test', @@ -309,12 +337,16 @@ describe('Sink', function() { 'sinks': [ { 'status': 'initialized', - 'sink_configuration': {}, + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:111111111:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, 'description': 'A Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', + 'date_created': '2015-07-30T19:00:00Z', 'sink_type': 'kinesis', - 'date_updated': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T19:00:00Z', 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test', @@ -323,7 +355,11 @@ describe('Sink', function() { }, { 'status': 'initialized', - 'sink_configuration': {}, + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:222222222:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, 'description': 'ANOTHER Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', 'date_created': '2015-07-30T20:00:00Z', @@ -337,12 +373,16 @@ describe('Sink', function() { }, { 'status': 'active', - 'sink_configuration': {}, + 'sink_configuration': { + 'destination': 'http://example.org/webhook', + 'method': 'POST', + 'batch_events': true + }, 'description': 'A webhook Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac', - 'date_created': '2015-07-30T20:00:00Z', + 'date_created': '2015-07-30T21:00:00Z', 'sink_type': 'webhook', - 'date_updated': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T21:00:00Z', 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac', 'links': { 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac/Test', @@ -416,12 +456,16 @@ describe('Sink', function() { 'sinks': [ { 'status': 'initialized', - 'sink_configuration': {}, + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:111111111:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, 'description': 'A Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', + 'date_created': '2015-07-30T19:00:00Z', 'sink_type': 'kinesis', - 'date_updated': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T19:00:00Z', 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test', @@ -430,7 +474,11 @@ describe('Sink', function() { }, { 'status': 'initialized', - 'sink_configuration': {}, + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:222222222:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, 'description': 'ANOTHER Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', 'date_created': '2015-07-30T20:00:00Z', @@ -444,12 +492,16 @@ describe('Sink', function() { }, { 'status': 'active', - 'sink_configuration': {}, + 'sink_configuration': { + 'destination': 'http://example.org/webhook', + 'method': 'POST', + 'batch_events': true + }, 'description': 'A webhook Sink', 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac', - 'date_created': '2015-07-30T20:00:00Z', + 'date_created': '2015-07-30T21:00:00Z', 'sink_type': 'webhook', - 'date_updated': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T21:00:00Z', 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac', 'links': { 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac/Test', @@ -479,4 +531,61 @@ describe('Sink', function() { }).done(); } ); + it('should generate valid update request', + function(done) { + holodeck.mock(new Response(500, {})); + + var opts = {description: 'description'}; + var promise = client.events.v1.sinks('DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(opts); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sid = 'DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://events.twilio.com/v1/Sinks/${sid}`; + + var values = {Description: 'description', }; + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url, + data: values + })); + } + ); + it('should generate valid update response', + function(done) { + var body = { + 'status': 'initialized', + 'sink_configuration': { + 'arn': 'arn:aws:kinesis:us-east-1:111111111:stream/test', + 'role_arn': 'arn:aws:iam::111111111:role/Role', + 'external_id': '1234567890' + }, + 'description': 'My Kinesis Sink', + 'sid': 'DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'sink_type': 'kinesis', + 'date_updated': '2015-07-30T20:00:00Z', + 'url': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'sink_test': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Test', + 'sink_validate': 'https://events.twilio.com/v1/Sinks/DGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Validate' + } + }; + + holodeck.mock(new Response(200, body)); + + var opts = {description: 'description'}; + var promise = client.events.v1.sinks('DGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); }); diff --git a/spec/integration/rest/messaging/v1/service/usAppToPerson.spec.js b/spec/integration/rest/messaging/v1/service/usAppToPerson.spec.js index fae0770187..6d2f9630dc 100644 --- a/spec/integration/rest/messaging/v1/service/usAppToPerson.spec.js +++ b/spec/integration/rest/messaging/v1/service/usAppToPerson.spec.js @@ -84,7 +84,7 @@ describe('UsAppToPerson', function() { 'us_app_to_person_usecase': 'MARKETING', 'has_embedded_links': true, 'has_embedded_phone': false, - 'status': 'PENDING', + 'campaign_status': 'PENDING', 'campaign_id': 'CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'is_externally_registered': false, 'rate_limits': { @@ -195,7 +195,7 @@ describe('UsAppToPerson', function() { 'us_app_to_person_usecase': 'MARKETING', 'has_embedded_links': true, 'has_embedded_phone': false, - 'status': 'PENDING', + 'campaign_status': 'PENDING', 'campaign_id': 'CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'is_externally_registered': false, 'rate_limits': { diff --git a/spec/integration/rest/verify/v2/service/entity/challenge.spec.js b/spec/integration/rest/verify/v2/service/entity/challenge.spec.js index 4dd59efe6b..9a9a9459eb 100644 --- a/spec/integration/rest/verify/v2/service/entity/challenge.spec.js +++ b/spec/integration/rest/verify/v2/service/entity/challenge.spec.js @@ -56,15 +56,15 @@ describe('Challenge', function() { })); } ); - it('should generate valid create_without_auth_payload response', + it('should generate valid create_push_without_auth_payload response', function(done) { var body = { - 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'factor_sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'factor_sid': 'YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', @@ -85,9 +85,9 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' } }; @@ -105,15 +105,64 @@ describe('Challenge', function() { }).done(); } ); - it('should generate valid create_with_auth_payload response', + it('should generate valid create_totp_without_auth_payload response', function(done) { var body = { - 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'factor_sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'factor_sid': 'YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'date_responded': '2015-07-30T20:00:00Z', + 'expiration_date': '2015-07-30T20:00:00Z', + 'status': 'pending', + 'responded_reason': 'none', + 'details': { + 'message': 'Hi! Mr. John Doe, would you like to sign up?', + 'date': '2020-07-01T12:13:14Z', + 'fields': [ + { + 'label': 'Action', + 'value': 'Sign up in portal' + } + ] + }, + 'hidden_details': { + 'ip': '172.168.1.234' + }, + 'factor_type': 'totp', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } + }; + + holodeck.mock(new Response(201, body)); + + var opts = {factorSid: 'YFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .challenges.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid create_totp_with_auth_payload response', + function(done) { + var body = { + 'sid': 'YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_sid': 'YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', @@ -133,10 +182,10 @@ describe('Challenge', function() { 'hidden_details': { 'ip': '172.168.1.234' }, - 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'factor_type': 'totp', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' } }; diff --git a/spec/integration/rest/verify/v2/service/entity/newFactor.spec.js b/spec/integration/rest/verify/v2/service/entity/newFactor.spec.js index 32799ce401..8be2dc8392 100644 --- a/spec/integration/rest/verify/v2/service/entity/newFactor.spec.js +++ b/spec/integration/rest/verify/v2/service/entity/newFactor.spec.js @@ -106,7 +106,7 @@ describe('NewFactor', function() { 'identity': 'ff483d1ff591898a9942916050d2ca3f', 'binding': { 'secret': 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ', - 'uri': 'otpauth://totp/The%20Issuer:My%20Account?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=The%20Issuer&algorithm=SHA1&digits=4&period=40' + 'uri': 'otpauth://totp/test-issuer:John%E2%80%99s%20Account%20Name?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=test-issuer&algorithm=SHA1&digits=6&period=30' }, 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', From 8b91200d4bb6c6de0eff5d02bf209ca520b433c2 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 5 May 2021 19:11:49 +0000 Subject: [PATCH 10/30] Release 3.62.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 63319b34b7..7897e197d3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.61.0", + "version": "3.62.0", "author": "API Team ", "contributors": [ { From 6986ba9e95485ec73bbb48c58e4cf0c88136e435 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 18 May 2021 13:05:42 -0700 Subject: [PATCH 11/30] chore: resolves jsdoc / underscore security vulnerability (#673) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7897e197d3..a24fbf0e48 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "eslint": "^7.3.1", "express": "^4.17.1", "jasmine": "~3.5.0", - "jsdoc": "^3.6.4", + "jsdoc": "^3.6.7", "jshint": "^2.11.0", "mock-fs": "^4.12.0", "nock": "^10.0.6", From c827ef8cb9e77c17190f03e64e983b87ed2fbe81 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 19 May 2021 19:02:39 +0000 Subject: [PATCH 12/30] [Librarian] Regenerated @ 277e53a232b830747a98a7b463b89f7d9a99ce03 --- CHANGES.md | 23 + lib/rest/events/v1/eventType.d.ts | 6 + lib/rest/events/v1/eventType.js | 4 + lib/rest/events/v1/sink.d.ts | 14 +- lib/rest/events/v1/sink.js | 13 +- lib/rest/flexApi/v1/flexFlow.d.ts | 4 +- lib/rest/flexApi/v1/flexFlow.js | 9 +- lib/rest/messaging/v1/externalCampaign.d.ts | 2 + lib/rest/messaging/v1/externalCampaign.js | 3 + .../messaging/v1/service/usAppToPerson.d.ts | 215 +++++++++- .../messaging/v1/service/usAppToPerson.js | 406 +++++++++++++++++- lib/rest/supersim/v1/sim.d.ts | 2 +- lib/rest/supersim/v1/sim.js | 2 +- lib/rest/video/v1/composition.d.ts | 16 - lib/rest/video/v1/composition.js | 16 - lib/rest/video/v1/compositionHook.d.ts | 16 - lib/rest/video/v1/compositionHook.js | 16 - .../account/conference/participant.spec.js | 18 +- .../autopilot/v1/assistant/dialogue.spec.js | 4 +- .../rest/bulkexports/v1/export/job.spec.js | 2 +- .../rest/events/v1/eventType.spec.js | 51 +++ spec/integration/rest/events/v1/sink.spec.js | 126 ++++++ spec/integration/rest/fax/v1/fax.spec.js | 12 +- .../rest/flexApi/v1/flexFlow.spec.js | 14 +- .../integration/rest/insights/v1/room.spec.js | 10 +- .../rest/insights/v1/room/participant.spec.js | 10 +- .../messaging/v1/externalCampaign.spec.js | 1 + .../messaging/v1/service/phoneNumber.spec.js | 4 +- .../v1/service/usAppToPerson.spec.js | 255 ++++++++++- .../integration/rest/monitor/v1/alert.spec.js | 10 +- .../integration/rest/monitor/v1/event.spec.js | 20 +- .../integration/rest/proxy/v1/service.spec.js | 6 +- .../v1/service/session/participant.spec.js | 4 +- .../rest/serverless/v1/service/build.spec.js | 2 +- .../rest/taskrouter/v1/workspace/task.spec.js | 52 +-- .../taskrouter/v1/workspace/workflow.spec.js | 70 +-- .../trunking/v1/trunk/phoneNumber.spec.js | 48 +-- .../trusthub/v1/supportingDocument.spec.js | 14 +- .../v2/service/entity/challenge.spec.js | 218 +++++++++- .../entity/challenge/notification.spec.js | 4 +- .../rest/wireless/v1/command.spec.js | 2 +- 41 files changed, 1436 insertions(+), 288 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 28536e615b..d4ba258544 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,29 @@ twilio-node changelog ===================== +[2021-05-19] Version 3.63.0 +--------------------------- +**Library - Chore** +- [PR #673](https://github.com/twilio/twilio-node/pull/673): resolves jsdoc / underscore security vulnerability. Thanks to [@thinkingserious](https://github.com/thinkingserious)! + +**Events** +- add query param to return types filtered by Schema Id +- Add query param to return sinks filtered by status +- Add query param to return sinks used/not used by a subscription + +**Messaging** +- Add fetch and delete instance endpoints to us_app_to_person api **(breaking change)** +- Remove delete list endpoint from us_app_to_person api **(breaking change)** +- Update read list endpoint to return a list of us_app_to_person compliance objects **(breaking change)** +- Add `sid` field to Preregistered US App To Person response + +**Supersim** +- Mark `unique_name` in Sim, Fleet, NAP resources as not PII + +**Video** +- [Composer] GA maturity level + + [2021-05-05] Version 3.62.0 --------------------------- **Library - Chore** diff --git a/lib/rest/events/v1/eventType.d.ts b/lib/rest/events/v1/eventType.d.ts index d2f9763648..a670cc5112 100644 --- a/lib/rest/events/v1/eventType.d.ts +++ b/lib/rest/events/v1/eventType.d.ts @@ -150,12 +150,14 @@ interface EventTypeListInstance { * 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) + * @property schemaId - A string to filter Event Types by schema. */ interface EventTypeListInstanceEachOptions { callback?: (item: EventTypeInstance, done: (err?: Error) => void) => void; done?: Function; limit?: number; pageSize?: number; + schemaId?: string; } /** @@ -171,10 +173,12 @@ interface EventTypeListInstanceEachOptions { * 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) + * @property schemaId - A string to filter Event Types by schema. */ interface EventTypeListInstanceOptions { limit?: number; pageSize?: number; + schemaId?: string; } /** @@ -183,11 +187,13 @@ interface EventTypeListInstanceOptions { * @property pageNumber - Page Number, this value is simply for client state * @property pageSize - Number of records to return, defaults to 50 * @property pageToken - PageToken provided by the API + * @property schemaId - A string to filter Event Types by schema. */ interface EventTypeListInstancePageOptions { pageNumber?: number; pageSize?: number; pageToken?: string; + schemaId?: string; } interface EventTypePayload extends EventTypeResource, Page.TwilioResponsePayload { diff --git a/lib/rest/events/v1/eventType.js b/lib/rest/events/v1/eventType.js index a6a4aab41f..c41374b07b 100644 --- a/lib/rest/events/v1/eventType.js +++ b/lib/rest/events/v1/eventType.js @@ -70,6 +70,7 @@ EventTypeList = function EventTypeList(version) { * @memberof Twilio.Events.V1.EventTypeList# * * @param {object} [opts] - Options for request + * @param {string} [opts.schemaId] - A string to filter Event Types by schema. * @param {number} [opts.limit] - * Upper limit for the number of records to return. * each() guarantees never to return more than limit. @@ -157,6 +158,7 @@ EventTypeList = function EventTypeList(version) { * @memberof Twilio.Events.V1.EventTypeList# * * @param {object} [opts] - Options for request + * @param {string} [opts.schemaId] - A string to filter Event Types by schema. * @param {number} [opts.limit] - * Upper limit for the number of records to return. * list() guarantees never to return more than limit. @@ -217,6 +219,7 @@ EventTypeList = function EventTypeList(version) { * @memberof Twilio.Events.V1.EventTypeList# * * @param {object} [opts] - Options for request + * @param {string} [opts.schemaId] - A string to filter Event Types by schema. * @param {string} [opts.pageToken] - PageToken provided by the API * @param {number} [opts.pageNumber] - * Page Number, this value is simply for client state @@ -235,6 +238,7 @@ EventTypeList = function EventTypeList(version) { var deferred = Q.defer(); var data = values.of({ + 'SchemaId': _.get(opts, 'schemaId'), 'PageToken': opts.pageToken, 'Page': opts.pageNumber, 'PageSize': opts.pageSize diff --git a/lib/rest/events/v1/sink.d.ts b/lib/rest/events/v1/sink.d.ts index 8678d43ddc..30a706a093 100644 --- a/lib/rest/events/v1/sink.d.ts +++ b/lib/rest/events/v1/sink.d.ts @@ -160,7 +160,7 @@ interface SinkListInstance { /** * Options to pass to create * - * @property description - Sink Description + * @property description - Sink Description. * @property sinkConfiguration - JSON Sink configuration. * @property sinkType - Sink type. */ @@ -177,6 +177,7 @@ interface SinkListInstanceCreateOptions { * Function to process each record. If this and a positional * callback are passed, this one will be used * @property done - Function to be called upon completion of streaming + * @property inUse - A boolean to return sinks used/not used by a subscription. * @property limit - * Upper limit for the number of records to return. * each() guarantees never to return more than limit. @@ -187,17 +188,21 @@ interface SinkListInstanceCreateOptions { * 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) + * @property status - A string to filter sinks by status. */ interface SinkListInstanceEachOptions { callback?: (item: SinkInstance, done: (err?: Error) => void) => void; done?: Function; + inUse?: boolean; limit?: number; pageSize?: number; + status?: string; } /** * Options to pass to list * + * @property inUse - A boolean to return sinks used/not used by a subscription. * @property limit - * Upper limit for the number of records to return. * list() guarantees never to return more than limit. @@ -208,23 +213,30 @@ interface SinkListInstanceEachOptions { * 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) + * @property status - A string to filter sinks by status. */ interface SinkListInstanceOptions { + inUse?: boolean; limit?: number; pageSize?: number; + status?: string; } /** * Options to pass to page * + * @property inUse - A boolean to return sinks used/not used by a subscription. * @property pageNumber - Page Number, this value is simply for client state * @property pageSize - Number of records to return, defaults to 50 * @property pageToken - PageToken provided by the API + * @property status - A string to filter sinks by status. */ interface SinkListInstancePageOptions { + inUse?: boolean; pageNumber?: number; pageSize?: number; pageToken?: string; + status?: string; } interface SinkPayload extends SinkResource, Page.TwilioResponsePayload { diff --git a/lib/rest/events/v1/sink.js b/lib/rest/events/v1/sink.js index dbb2424ad9..ed705e6391 100644 --- a/lib/rest/events/v1/sink.js +++ b/lib/rest/events/v1/sink.js @@ -64,7 +64,7 @@ SinkList = function SinkList(version) { * @memberof Twilio.Events.V1.SinkList# * * @param {object} opts - Options for request - * @param {string} opts.description - Sink Description + * @param {string} opts.description - Sink Description. * @param {object} opts.sinkConfiguration - JSON Sink configuration. * @param {sink.sink_type} opts.sinkType - Sink type. * @param {function} [callback] - Callback to handle processed record @@ -127,6 +127,9 @@ SinkList = function SinkList(version) { * @memberof Twilio.Events.V1.SinkList# * * @param {object} [opts] - Options for request + * @param {boolean} [opts.inUse] - + * A boolean to return sinks used/not used by a subscription. + * @param {string} [opts.status] - A string to filter sinks by status. * @param {number} [opts.limit] - * Upper limit for the number of records to return. * each() guarantees never to return more than limit. @@ -214,6 +217,9 @@ SinkList = function SinkList(version) { * @memberof Twilio.Events.V1.SinkList# * * @param {object} [opts] - Options for request + * @param {boolean} [opts.inUse] - + * A boolean to return sinks used/not used by a subscription. + * @param {string} [opts.status] - A string to filter sinks by status. * @param {number} [opts.limit] - * Upper limit for the number of records to return. * list() guarantees never to return more than limit. @@ -274,6 +280,9 @@ SinkList = function SinkList(version) { * @memberof Twilio.Events.V1.SinkList# * * @param {object} [opts] - Options for request + * @param {boolean} [opts.inUse] - + * A boolean to return sinks used/not used by a subscription. + * @param {string} [opts.status] - A string to filter sinks by status. * @param {string} [opts.pageToken] - PageToken provided by the API * @param {number} [opts.pageNumber] - * Page Number, this value is simply for client state @@ -292,6 +301,8 @@ SinkList = function SinkList(version) { var deferred = Q.defer(); var data = values.of({ + 'InUse': serialize.bool(_.get(opts, 'inUse')), + 'Status': _.get(opts, 'status'), 'PageToken': opts.pageToken, 'Page': opts.pageNumber, 'PageSize': opts.pageSize diff --git a/lib/rest/flexApi/v1/flexFlow.d.ts b/lib/rest/flexApi/v1/flexFlow.d.ts index 00ea19c897..94a0ec9094 100644 --- a/lib/rest/flexApi/v1/flexFlow.d.ts +++ b/lib/rest/flexApi/v1/flexFlow.d.ts @@ -38,7 +38,7 @@ declare function FlexFlowList(version: V1): FlexFlowListInstance; * @property integration.url - The External Webhook URL * @property integration.workflowSid - The Workflow SID for a new Task * @property integration.workspaceSid - The Workspace SID for a new Task - * @property integrationType - The integration type + * @property integrationType - The software that will handle inbound messages. * @property janitorEnabled - Remove active Proxy sessions if the corresponding Task is deleted * @property longLived - Reuse this chat channel for future interactions with a contact */ @@ -201,7 +201,7 @@ interface FlexFlowListInstance { * @property integration.url - The External Webhook URL * @property integration.workflowSid - The Workflow SID for a new Task * @property integration.workspaceSid - The Workspace SID for a new Task - * @property integrationType - The integration type + * @property integrationType - The software that will handle inbound messages. * @property janitorEnabled - Remove active Proxy sessions if the corresponding Task is deleted * @property longLived - Reuse this chat channel for future interactions with a contact */ diff --git a/lib/rest/flexApi/v1/flexFlow.js b/lib/rest/flexApi/v1/flexFlow.js index c7f0560dc6..4fcd1aeb97 100644 --- a/lib/rest/flexApi/v1/flexFlow.js +++ b/lib/rest/flexApi/v1/flexFlow.js @@ -314,7 +314,7 @@ FlexFlowList = function FlexFlowList(version) { * @param {string} [opts.contactIdentity] - The channel contact's Identity * @param {boolean} [opts.enabled] - Whether the new Flex Flow is enabled * @param {flex_flow.integration_type} [opts.integrationType] - - * The integration type + * The software that will handle inbound messages. * @param {string} [opts.integration.flowSid] - The SID of the Studio Flow * @param {string} [opts.integration.url] - The External Webhook URL * @param {string} [opts.integration.workspaceSid] - @@ -509,7 +509,8 @@ FlexFlowPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {flex_flow.channel_type} channelType - The channel type * @property {string} contactIdentity - The channel contact's Identity * @property {boolean} enabled - Whether the Flex Flow is enabled - * @property {flex_flow.integration_type} integrationType - The integration type + * @property {flex_flow.integration_type} integrationType - + * The software that will handle inbound messages. * @property {object} integration - * An object that contains specific parameters for the integration * @property {boolean} longLived - @@ -588,7 +589,7 @@ FlexFlowInstance.prototype.fetch = function fetch(callback) { * @param {string} [opts.contactIdentity] - The channel contact's Identity * @param {boolean} [opts.enabled] - Whether the new Flex Flow is enabled * @param {flex_flow.integration_type} [opts.integrationType] - - * The integration type + * The software that will handle inbound messages. * @param {string} [opts.integration.flowSid] - The SID of the Studio Flow * @param {string} [opts.integration.url] - The External Webhook URL * @param {string} [opts.integration.workspaceSid] - @@ -720,7 +721,7 @@ FlexFlowContext.prototype.fetch = function fetch(callback) { * @param {string} [opts.contactIdentity] - The channel contact's Identity * @param {boolean} [opts.enabled] - Whether the new Flex Flow is enabled * @param {flex_flow.integration_type} [opts.integrationType] - - * The integration type + * The software that will handle inbound messages. * @param {string} [opts.integration.flowSid] - The SID of the Studio Flow * @param {string} [opts.integration.url] - The External Webhook URL * @param {string} [opts.integration.workspaceSid] - diff --git a/lib/rest/messaging/v1/externalCampaign.d.ts b/lib/rest/messaging/v1/externalCampaign.d.ts index 7dbb440e39..0680e73f25 100644 --- a/lib/rest/messaging/v1/externalCampaign.d.ts +++ b/lib/rest/messaging/v1/externalCampaign.d.ts @@ -53,6 +53,7 @@ interface ExternalCampaignResource { campaign_id: string; date_created: Date; messaging_service_sid: string; + sid: string; } interface ExternalCampaignSolution { @@ -75,6 +76,7 @@ declare class ExternalCampaignInstance extends SerializableClass { campaignId: string; dateCreated: Date; messagingServiceSid: string; + sid: string; /** * Provide a user-friendly representation */ diff --git a/lib/rest/messaging/v1/externalCampaign.js b/lib/rest/messaging/v1/externalCampaign.js index 3780e00b1d..0ce585abec 100644 --- a/lib/rest/messaging/v1/externalCampaign.js +++ b/lib/rest/messaging/v1/externalCampaign.js @@ -203,6 +203,8 @@ ExternalCampaignPage.prototype[util.inspect.custom] = function inspect(depth, * * @constructor Twilio.Messaging.V1.ExternalCampaignInstance * + * @property {string} sid - + * The unique string that identifies a US A2P Compliance resource * @property {string} accountSid - The SID of the Account that created the resource * @property {string} campaignId - ID of the preregistered campaign. * @property {string} messagingServiceSid - @@ -218,6 +220,7 @@ ExternalCampaignInstance = function ExternalCampaignInstance(version, payload) { this._version = version; // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line this.accountSid = payload.account_sid; // jshint ignore:line this.campaignId = payload.campaign_id; // jshint ignore:line this.messagingServiceSid = payload.messaging_service_sid; // jshint ignore:line diff --git a/lib/rest/messaging/v1/service/usAppToPerson.d.ts b/lib/rest/messaging/v1/service/usAppToPerson.d.ts index 740e9e6d7a..99c9fc9157 100644 --- a/lib/rest/messaging/v1/service/usAppToPerson.d.ts +++ b/lib/rest/messaging/v1/service/usAppToPerson.d.ts @@ -22,6 +22,10 @@ import { SerializableClass } from '../../../../interfaces'; declare function UsAppToPersonList(version: V1, messagingServiceSid: string): UsAppToPersonListInstance; interface UsAppToPersonListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): UsAppToPersonContext; /** * create a UsAppToPersonInstance * @@ -30,17 +34,107 @@ interface UsAppToPersonListInstance { */ create(opts: UsAppToPersonListInstanceCreateOptions, callback?: (error: Error | null, item: UsAppToPersonInstance) => any): Promise; /** - * fetch a UsAppToPersonInstance + * Streams UsAppToPersonInstance records from the API. * - * @param callback - Callback to handle processed record + * 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. + * + * @param callback - Function to process each record */ - fetch(callback?: (error: Error | null, items: UsAppToPersonListInstance) => any): Promise; + each(callback?: (item: UsAppToPersonInstance, done: (err?: Error) => void) => void): void; /** - * remove a UsAppToPersonInstance + * Streams UsAppToPersonInstance records from the API. * - * @param callback - Callback to handle processed record + * 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. + * + * @param opts - Options for request + * @param callback - Function to process each record */ - remove(callback?: (error: Error | null, items: UsAppToPersonListInstance) => any): Promise; + each(opts?: UsAppToPersonListInstanceEachOptions, callback?: (item: UsAppToPersonInstance, done: (err?: Error) => void) => void): void; + /** + * Constructs a us_app_to_person + * + * @param sid - The SID that identifies the US A2P Compliance resource to fetch + */ + get(sid: string): UsAppToPersonContext; + /** + * Retrieve a single target page of UsAppToPersonInstance 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. + * + * @param callback - Callback to handle list of records + */ + getPage(callback?: (error: Error | null, items: UsAppToPersonPage) => any): Promise; + /** + * Retrieve a single target page of UsAppToPersonInstance 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. + * + * @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: UsAppToPersonPage) => any): Promise; + /** + * Lists UsAppToPersonInstance 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: UsAppToPersonInstance[]) => any): Promise; + /** + * Lists UsAppToPersonInstance 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 opts - Options for request + * @param callback - Callback to handle list of records + */ + list(opts?: UsAppToPersonListInstanceOptions, callback?: (error: Error | null, items: UsAppToPersonInstance[]) => any): Promise; + /** + * Retrieve a single page of UsAppToPersonInstance 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. + * + * @param callback - Callback to handle list of records + */ + page(callback?: (error: Error | null, items: UsAppToPersonPage) => any): Promise; + /** + * Retrieve a single page of UsAppToPersonInstance 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. + * + * @param opts - Options for request + * @param callback - Callback to handle list of records + */ + page(opts?: UsAppToPersonListInstancePageOptions, callback?: (error: Error | null, items: UsAppToPersonPage) => any): Promise; /** * Provide a user-friendly representation */ @@ -66,6 +160,63 @@ interface UsAppToPersonListInstanceCreateOptions { usAppToPersonUsecase: string; } +/** + * Options to pass to each + * + * @property callback - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @property done - Function to be called upon completion of streaming + * @property limit - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface UsAppToPersonListInstanceEachOptions { + callback?: (item: UsAppToPersonInstance, done: (err?: Error) => void) => void; + done?: Function; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to list + * + * @property limit - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface UsAppToPersonListInstanceOptions { + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to page + * + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + */ +interface UsAppToPersonListInstancePageOptions { + pageNumber?: number; + pageSize?: number; + pageToken?: string; +} + interface UsAppToPersonPayload extends UsAppToPersonResource, Page.TwilioResponsePayload { } @@ -83,6 +234,7 @@ interface UsAppToPersonResource { message_samples: string[]; messaging_service_sid: string; rate_limits: object; + sid: string; url: string; us_app_to_person_usecase: string; } @@ -92,6 +244,38 @@ interface UsAppToPersonSolution { } +declare class UsAppToPersonContext { + /** + * Initialize the UsAppToPersonContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param messagingServiceSid - The SID of the Messaging Service to fetch the resource from + * @param sid - The SID that identifies the US A2P Compliance resource to fetch + */ + constructor(version: V1, messagingServiceSid: string, sid: string); + + /** + * fetch a UsAppToPersonInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UsAppToPersonInstance) => any): Promise; + /** + * remove a UsAppToPersonInstance + * + * @param callback - Callback to handle processed record + */ + remove(callback?: (error: Error | null, items: UsAppToPersonInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + declare class UsAppToPersonInstance extends SerializableClass { /** * Initialize the UsAppToPersonContext @@ -102,9 +286,11 @@ declare class UsAppToPersonInstance extends SerializableClass { * @param version - Version of the resource * @param payload - The instance payload * @param messagingServiceSid - The SID of the Messaging Service the resource is associated with + * @param sid - The SID that identifies the US A2P Compliance resource to fetch */ - constructor(version: V1, payload: UsAppToPersonPayload, messagingServiceSid: string); + constructor(version: V1, payload: UsAppToPersonPayload, messagingServiceSid: string, sid: string); + private _proxy: UsAppToPersonContext; accountSid: string; brandRegistrationSid: string; campaignId: string; @@ -112,12 +298,25 @@ declare class UsAppToPersonInstance extends SerializableClass { dateCreated: Date; dateUpdated: Date; description: string; + /** + * fetch a UsAppToPersonInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UsAppToPersonInstance) => any): Promise; hasEmbeddedLinks: boolean; hasEmbeddedPhone: boolean; isExternallyRegistered: boolean; messageSamples: string[]; messagingServiceSid: string; rateLimits: any; + /** + * remove a UsAppToPersonInstance + * + * @param callback - Callback to handle processed record + */ + remove(callback?: (error: Error | null, items: UsAppToPersonInstance) => any): Promise; + sid: string; /** * Provide a user-friendly representation */ @@ -152,4 +351,4 @@ declare class UsAppToPersonPage extends Page= opts.limit)) { + done = true; + return false; + } + + currentResource++; + callback(instance, onComplete); + }); + + if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists UsAppToPersonInstance records from the API as a list. * - * @returns {Promise} Resolves to processed UsAppToPersonInstance + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @function list + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonList# + * + * @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 */ - UsAppToPersonListInstance.remove = function remove(callback) { + UsAppToPersonListInstance.list = function list(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; var deferred = Q.defer(); - var promise = this._version.remove({uri: this._uri, method: 'DELETE'}); + 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 UsAppToPersonInstance 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.Messaging.V1.ServiceContext.UsAppToPersonList# + * + * @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 */ + UsAppToPersonListInstance.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(payload); + deferred.resolve(new UsAppToPersonPage(this._version, payload, this._solution)); }.bind(this)); promise.catch(function(error) { @@ -164,26 +339,29 @@ UsAppToPersonList = function UsAppToPersonList(version, messagingServiceSid) { /* jshint ignore:start */ /** - * fetch a UsAppToPersonInstance + * Retrieve a single target page of UsAppToPersonInstance 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 fetch + * @function getPage * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonList# * - * @param {function} [callback] - Callback to handle processed record + * @param {string} [targetUrl] - API-generated URL for the requested results page + * @param {function} [callback] - Callback to handle list of records * - * @returns {Promise} Resolves to processed UsAppToPersonInstance + * @returns {Promise} Resolves to a list of records */ /* jshint ignore:end */ - UsAppToPersonListInstance.fetch = function fetch(callback) { + UsAppToPersonListInstance.getPage = function getPage(targetUrl, callback) { var deferred = Q.defer(); - var promise = this._version.fetch({uri: this._uri, method: 'GET'}); + + var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl}); promise = promise.then(function(payload) { - deferred.resolve(new UsAppToPersonInstance( - this._version, - payload, - this._solution.messagingServiceSid - )); + deferred.resolve(new UsAppToPersonPage(this._version, payload, this._solution)); }.bind(this)); promise.catch(function(error) { @@ -197,6 +375,23 @@ UsAppToPersonList = function UsAppToPersonList(version, messagingServiceSid) { return deferred.promise; }; + /* jshint ignore:start */ + /** + * Constructs a us_app_to_person + * + * @function get + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonList# + * + * @param {string} sid - + * The SID that identifies the US A2P Compliance resource to fetch + * + * @returns {Twilio.Messaging.V1.ServiceContext.UsAppToPersonContext} + */ + /* jshint ignore:end */ + UsAppToPersonListInstance.get = function get(sid) { + return new UsAppToPersonContext(this._version, this._solution.messagingServiceSid, sid); + }; + /* jshint ignore:start */ /** * Provide a user-friendly representation @@ -297,6 +492,8 @@ UsAppToPersonPage.prototype[util.inspect.custom] = function inspect(depth, * * @constructor Twilio.Messaging.V1.ServiceContext.UsAppToPersonInstance * + * @property {string} sid - + * The unique string that identifies a US A2P Compliance resource * @property {string} accountSid - The SID of the Account that created the resource * @property {string} brandRegistrationSid - A2P Brand Registration SID * @property {string} messagingServiceSid - @@ -325,13 +522,17 @@ UsAppToPersonPage.prototype[util.inspect.custom] = function inspect(depth, * @param {UsAppToPersonPayload} payload - The instance payload * @param {sid} messagingServiceSid - * The SID of the Messaging Service the resource is associated with + * @param {sid} sid - + * The SID that identifies the US A2P Compliance resource to fetch */ /* jshint ignore:end */ UsAppToPersonInstance = function UsAppToPersonInstance(version, payload, - messagingServiceSid) { + messagingServiceSid, + sid) { this._version = version; // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line this.accountSid = payload.account_sid; // jshint ignore:line this.brandRegistrationSid = payload.brand_registration_sid; // jshint ignore:line this.messagingServiceSid = payload.messaging_service_sid; // jshint ignore:line @@ -350,7 +551,54 @@ UsAppToPersonInstance = function UsAppToPersonInstance(version, payload, // Context this._context = undefined; - this._solution = {messagingServiceSid: messagingServiceSid, }; + this._solution = {messagingServiceSid: messagingServiceSid, sid: sid || this.sid, }; +}; + +Object.defineProperty(UsAppToPersonInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new UsAppToPersonContext( + this._version, + this._solution.messagingServiceSid, + this._solution.sid + ); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * remove a UsAppToPersonInstance + * + * @function remove + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsAppToPersonInstance + */ +/* jshint ignore:end */ +UsAppToPersonInstance.prototype.remove = function remove(callback) { + return this._proxy.remove(callback); +}; + +/* jshint ignore:start */ +/** + * fetch a UsAppToPersonInstance + * + * @function fetch + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsAppToPersonInstance + */ +/* jshint ignore:end */ +UsAppToPersonInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); }; /* jshint ignore:start */ @@ -378,8 +626,122 @@ UsAppToPersonInstance.prototype[util.inspect.custom] = function inspect(depth, return util.inspect(this.toJSON(), options); }; + +/* jshint ignore:start */ +/** + * Initialize the UsAppToPersonContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Messaging.V1.ServiceContext.UsAppToPersonContext + * + * @param {V1} version - Version of the resource + * @param {sid} messagingServiceSid - + * The SID of the Messaging Service to fetch the resource from + * @param {sid} sid - + * The SID that identifies the US A2P Compliance resource to fetch + */ +/* jshint ignore:end */ +UsAppToPersonContext = function UsAppToPersonContext(version, + messagingServiceSid, sid) + { + this._version = version; + + // Path Solution + this._solution = {messagingServiceSid: messagingServiceSid, sid: sid, }; + this._uri = `/Services/${messagingServiceSid}/Compliance/Usa2p/${sid}`; +}; + +/* jshint ignore:start */ +/** + * remove a UsAppToPersonInstance + * + * @function remove + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsAppToPersonInstance + */ +/* jshint ignore:end */ +UsAppToPersonContext.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 */ +/** + * fetch a UsAppToPersonInstance + * + * @function fetch + * @memberof Twilio.Messaging.V1.ServiceContext.UsAppToPersonContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UsAppToPersonInstance + */ +/* jshint ignore:end */ +UsAppToPersonContext.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 UsAppToPersonInstance( + this._version, + payload, + this._solution.messagingServiceSid, + 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.Messaging.V1.ServiceContext.UsAppToPersonContext# + * + * @returns Object + */ +/* jshint ignore:end */ +UsAppToPersonContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +UsAppToPersonContext.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + module.exports = { UsAppToPersonList: UsAppToPersonList, UsAppToPersonPage: UsAppToPersonPage, - UsAppToPersonInstance: UsAppToPersonInstance + UsAppToPersonInstance: UsAppToPersonInstance, + UsAppToPersonContext: UsAppToPersonContext }; diff --git a/lib/rest/supersim/v1/sim.d.ts b/lib/rest/supersim/v1/sim.d.ts index 764517498c..3b244fe34c 100644 --- a/lib/rest/supersim/v1/sim.d.ts +++ b/lib/rest/supersim/v1/sim.d.ts @@ -167,7 +167,7 @@ interface SimListInstance { * Options to pass to create * * @property iccid - The {@link https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID|ICCID} of the Super SIM to be added to your Account - * @property registrationCode - The 10 digit code required to claim the Super SIM for your Account + * @property registrationCode - The 10-digit code required to claim the Super SIM for your Account */ interface SimListInstanceCreateOptions { iccid: string; diff --git a/lib/rest/supersim/v1/sim.js b/lib/rest/supersim/v1/sim.js index 3d48308e62..ee7131270c 100644 --- a/lib/rest/supersim/v1/sim.js +++ b/lib/rest/supersim/v1/sim.js @@ -64,7 +64,7 @@ SimList = function SimList(version) { * @param {string} opts.iccid - * The {@link https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID|ICCID} of the Super SIM to be added to your Account * @param {string} opts.registrationCode - - * The 10 digit code required to claim the Super SIM for your Account + * The 10-digit code required to claim the Super SIM for your Account * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed SimInstance diff --git a/lib/rest/video/v1/composition.d.ts b/lib/rest/video/v1/composition.d.ts index a4ab6f377d..01ab207566 100644 --- a/lib/rest/video/v1/composition.d.ts +++ b/lib/rest/video/v1/composition.d.ts @@ -17,10 +17,6 @@ type CompositionStatus = 'enqueued'|'processing'|'completed'|'deleted'|'failed'; /** * Initialize the CompositionList * - * 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 CompositionList(version: V1): CompositionListInstance; @@ -283,10 +279,6 @@ declare class CompositionContext { /** * Initialize the CompositionContext * - * 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 - The SID that identifies the resource to fetch */ @@ -315,10 +307,6 @@ declare class CompositionInstance extends SerializableClass { /** * Initialize the CompositionContext * - * 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 sid - The SID that identifies the resource to fetch @@ -367,10 +355,6 @@ declare class CompositionPage extends Page done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'compliance': [ + { + 'sid': 'QE2c6890da8086d771620e9b13fadeba0b', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'brand_registration_sid': 'BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'messaging_service_sid': 'MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'description': 'Send marketing messages about sales to opted in customers.', + 'message_samples': [ + 'EXPRESS: Denim Days Event is ON', + 'LAST CHANCE: Book your next flight for just 1 (ONE) EUR' + ], + 'us_app_to_person_usecase': 'MARKETING', + 'has_embedded_links': true, + 'has_embedded_phone': false, + 'campaign_status': 'PENDING', + 'campaign_id': 'CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'is_externally_registered': false, + 'rate_limits': { + 'att': { + 'mps': 600, + 'msg_class': 'A' + }, + 'tmobile': { + 'brand_tier': 'TOP' + } + }, + 'date_created': '2021-02-18T14:48:52Z', + 'date_updated': '2021-02-18T14:48:52Z', + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0', + 'previous_page_url': null, + 'next_page_url': null, + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0', + 'key': 'compliance' + } + }; + holodeck.mock(new Response(200, body)); + client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://messaging.twilio.com/v1/Services/${messagingServiceSid}/Compliance/Usa2p', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'compliance': [ + { + 'sid': 'QE2c6890da8086d771620e9b13fadeba0b', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'brand_registration_sid': 'BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'messaging_service_sid': 'MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'description': 'Send marketing messages about sales to opted in customers.', + 'message_samples': [ + 'EXPRESS: Denim Days Event is ON', + 'LAST CHANCE: Book your next flight for just 1 (ONE) EUR' + ], + 'us_app_to_person_usecase': 'MARKETING', + 'has_embedded_links': true, + 'has_embedded_phone': false, + 'campaign_status': 'PENDING', + 'campaign_id': 'CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'is_externally_registered': false, + 'rate_limits': { + 'att': { + 'mps': 600, + 'msg_class': 'A' + }, + 'tmobile': { + 'brand_tier': 'TOP' + } + }, + 'date_created': '2021-02-18T14:48:52Z', + 'date_updated': '2021-02-18T14:48:52Z', + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0', + 'previous_page_url': null, + 'next_page_url': null, + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0', + 'key': 'compliance' + } + }; + holodeck.mock(new Response(200, body)); + client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', function(done) { holodeck.mock(new Response(500, {})); var promise = client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .usAppToPerson.fetch(); + .usAppToPerson.list(); promise.then(function() { throw new Error('failed'); }, function(error) { @@ -181,13 +335,94 @@ describe('UsAppToPerson', function() { })); } ); + it('should generate valid read_full response', + function(done) { + var body = { + 'compliance': [ + { + 'sid': 'QE2c6890da8086d771620e9b13fadeba0b', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'brand_registration_sid': 'BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'messaging_service_sid': 'MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'description': 'Send marketing messages about sales to opted in customers.', + 'message_samples': [ + 'EXPRESS: Denim Days Event is ON', + 'LAST CHANCE: Book your next flight for just 1 (ONE) EUR' + ], + 'us_app_to_person_usecase': 'MARKETING', + 'has_embedded_links': true, + 'has_embedded_phone': false, + 'campaign_status': 'PENDING', + 'campaign_id': 'CXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'is_externally_registered': false, + 'rate_limits': { + 'att': { + 'mps': 600, + 'msg_class': 'A' + }, + 'tmobile': { + 'brand_tier': 'TOP' + } + }, + 'date_created': '2021-02-18T14:48:52Z', + 'date_updated': '2021-02-18T14:48:52Z', + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0', + 'previous_page_url': null, + 'next_page_url': null, + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p?PageSize=50&Page=0', + 'key': 'compliance' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson.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.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .usAppToPerson('QEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var messagingServiceSid = 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var sid = 'QEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://messaging.twilio.com/v1/Services/${messagingServiceSid}/Compliance/Usa2p/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); it('should generate valid fetch response', function(done) { var body = { + 'sid': 'QE2c6890da8086d771620e9b13fadeba0b', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'brand_registration_sid': 'BNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'messaging_service_sid': 'MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'description': 'Send marketing messages about sales and offers to opted in customers.', + 'description': 'Send marketing messages about sales to opted in customers.', 'message_samples': [ 'EXPRESS: Denim Days Event is ON', 'LAST CHANCE: Book your next flight for just 1 (ONE) EUR' @@ -209,13 +444,13 @@ describe('UsAppToPerson', function() { }, 'date_created': '2021-02-18T14:48:52Z', 'date_updated': '2021-02-18T14:48:52Z', - 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p' + 'url': 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/QE2c6890da8086d771620e9b13fadeba0b' }; holodeck.mock(new Response(200, body)); var promise = client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .usAppToPerson.fetch(); + .usAppToPerson('QEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); promise.then(function(response) { expect(response).toBeDefined(); done(); diff --git a/spec/integration/rest/monitor/v1/alert.spec.js b/spec/integration/rest/monitor/v1/alert.spec.js index 877e33e9f2..ca5742f95b 100644 --- a/spec/integration/rest/monitor/v1/alert.spec.js +++ b/spec/integration/rest/monitor/v1/alert.spec.js @@ -65,7 +65,7 @@ describe('Alert', function() { 'request_method': 'GET', 'request_url': 'http://www.example.com', 'request_variables': 'request_variables', - 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'response_body': 'response_body', 'response_headers': 'response_headers', 'request_headers': 'request_headers', @@ -101,7 +101,7 @@ describe('Alert', function() { 'more_info': 'more_info', 'request_method': 'GET', 'request_url': 'http://www.example.com', - 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'sid': 'NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://monitor.twilio.com/v1/Alerts/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'PNe2cd757cd5257b0217a447933a0290d2' @@ -137,7 +137,7 @@ describe('Alert', function() { 'more_info': 'more_info', 'request_method': 'GET', 'request_url': 'http://www.example.com', - 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'sid': 'NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://monitor.twilio.com/v1/Alerts/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'PNe2cd757cd5257b0217a447933a0290d2' @@ -178,7 +178,7 @@ describe('Alert', function() { 'more_info': 'more_info', 'request_method': 'GET', 'request_url': 'http://www.example.com', - 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'sid': 'NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://monitor.twilio.com/v1/Alerts/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'PNe2cd757cd5257b0217a447933a0290d2' @@ -260,7 +260,7 @@ describe('Alert', function() { 'more_info': 'more_info', 'request_method': 'GET', 'request_url': 'http://www.example.com', - 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'resource_sid': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'sid': 'NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://monitor.twilio.com/v1/Alerts/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'PNe2cd757cd5257b0217a447933a0290d2' diff --git a/spec/integration/rest/monitor/v1/event.spec.js b/spec/integration/rest/monitor/v1/event.spec.js index ac26f6d10e..8ae87dcff7 100644 --- a/spec/integration/rest/monitor/v1/event.spec.js +++ b/spec/integration/rest/monitor/v1/event.spec.js @@ -54,7 +54,7 @@ describe('Event', function() { function(done) { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'actor_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'actor_type': 'account', 'description': null, 'event_data': { @@ -66,7 +66,7 @@ describe('Event', function() { 'event_date': '2014-10-03T16:48:25Z', 'event_type': 'account.updated', 'links': { - 'actor': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor': 'https://api.twilio.com/2010-04-01/Accounts/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'resource': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }, 'resource_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -94,7 +94,7 @@ describe('Event', function() { 'events': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'actor_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'actor_type': 'account', 'description': null, 'event_data': { @@ -106,7 +106,7 @@ describe('Event', function() { 'event_date': '2014-10-03T16:48:25Z', 'event_type': 'account.updated', 'links': { - 'actor': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor': 'https://api.twilio.com/2010-04-01/Accounts/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'resource': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }, 'resource_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -137,7 +137,7 @@ describe('Event', function() { 'events': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'actor_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'actor_type': 'account', 'description': null, 'event_data': { @@ -149,7 +149,7 @@ describe('Event', function() { 'event_date': '2014-10-03T16:48:25Z', 'event_type': 'account.updated', 'links': { - 'actor': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor': 'https://api.twilio.com/2010-04-01/Accounts/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'resource': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }, 'resource_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -185,7 +185,7 @@ describe('Event', function() { 'events': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'actor_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'actor_type': 'account', 'description': null, 'event_data': { @@ -197,7 +197,7 @@ describe('Event', function() { 'event_date': '2014-10-03T16:48:25Z', 'event_type': 'account.updated', 'links': { - 'actor': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor': 'https://api.twilio.com/2010-04-01/Accounts/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'resource': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }, 'resource_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -248,7 +248,7 @@ describe('Event', function() { 'events': [ { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'actor_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'actor_type': 'account', 'description': null, 'event_data': { @@ -260,7 +260,7 @@ describe('Event', function() { 'event_date': '2014-10-03T16:48:25Z', 'event_type': 'account.updated', 'links': { - 'actor': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'actor': 'https://api.twilio.com/2010-04-01/Accounts/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'resource': 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }, 'resource_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', diff --git a/spec/integration/rest/proxy/v1/service.spec.js b/spec/integration/rest/proxy/v1/service.spec.js index 779bf7aa4e..1e3e6d6742 100644 --- a/spec/integration/rest/proxy/v1/service.spec.js +++ b/spec/integration/rest/proxy/v1/service.spec.js @@ -60,7 +60,7 @@ describe('Service', function() { 'default_ttl': 3600, 'callback_url': 'http://www.example.com', 'geo_match_level': 'country', - 'number_selection_behavior': 'prefer_sticky', + 'number_selection_behavior': 'prefer-sticky', 'intercept_callback_url': 'http://www.example.com', 'out_of_session_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', @@ -163,7 +163,7 @@ describe('Service', function() { 'default_ttl': 3600, 'callback_url': 'http://www.example.com', 'geo_match_level': 'country', - 'number_selection_behavior': 'prefer_sticky', + 'number_selection_behavior': 'prefer-sticky', 'intercept_callback_url': 'http://www.example.com', 'out_of_session_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', @@ -255,7 +255,7 @@ describe('Service', function() { 'default_ttl': 3600, 'callback_url': 'http://www.example.com', 'geo_match_level': 'country', - 'number_selection_behavior': 'prefer_sticky', + 'number_selection_behavior': 'prefer-sticky', 'intercept_callback_url': 'http://www.example.com', 'out_of_session_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', diff --git a/spec/integration/rest/proxy/v1/service/session/participant.spec.js b/spec/integration/rest/proxy/v1/service/session/participant.spec.js index 6d06abea6c..13b4d15f28 100644 --- a/spec/integration/rest/proxy/v1/service/session/participant.spec.js +++ b/spec/integration/rest/proxy/v1/service/session/participant.spec.js @@ -96,7 +96,7 @@ describe('Participant', function() { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identifier': 'messenger:14155551212', 'proxy_identifier': 'messenger:14155559999', - 'proxy_identifier_sid': 'XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'proxy_identifier_sid': 'PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'friendly_name': 'a facebook user', 'date_deleted': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -242,7 +242,7 @@ describe('Participant', function() { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identifier': 'messenger:123456', 'proxy_identifier': 'messenger:987654532', - 'proxy_identifier_sid': 'XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'proxy_identifier_sid': 'PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'friendly_name': 'a facebook user', 'date_deleted': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', diff --git a/spec/integration/rest/serverless/v1/service/build.spec.js b/spec/integration/rest/serverless/v1/service/build.spec.js index 2c38358c5c..6979b14cbf 100644 --- a/spec/integration/rest/serverless/v1/service/build.spec.js +++ b/spec/integration/rest/serverless/v1/service/build.spec.js @@ -140,7 +140,7 @@ describe('Build', function() { } ], 'runtime': 'node10', - 'status': 'deploying', + 'status': 'building', 'date_created': '2018-11-10T20:00:00Z', 'date_updated': '2018-11-10T20:00:00Z', 'url': 'https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds/ZB00000000000000000000000000000000', diff --git a/spec/integration/rest/taskrouter/v1/workspace/task.spec.js b/spec/integration/rest/taskrouter/v1/workspace/task.spec.js index d6626cba5b..68f9593c54 100644 --- a/spec/integration/rest/taskrouter/v1/workspace/task.spec.js +++ b/spec/integration/rest/taskrouter/v1/workspace/task.spec.js @@ -70,14 +70,14 @@ describe('Task', function() { 'task_channel_unique_name': 'task-channel', 'timeout': 60, 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow_sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow_sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workflow_friendly_name': 'Test Workflow', 'task_queue_friendly_name': 'Test Queue', 'addons': '{}', 'links': { 'task_queue': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reservations': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations' } @@ -139,14 +139,14 @@ describe('Task', function() { 'task_channel_unique_name': 'task-channel', 'timeout': 60, 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow_sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow_sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workflow_friendly_name': 'Test Workflow', 'task_queue_friendly_name': 'Test Queue', 'addons': '{}', 'links': { 'task_queue': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reservations': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations' } @@ -210,13 +210,13 @@ describe('Task', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0', 'key': 'tasks', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0' }, 'tasks': [ { @@ -235,14 +235,14 @@ describe('Task', function() { 'task_channel_unique_name': 'task-channel', 'timeout': 60, 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow_sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow_sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workflow_friendly_name': 'Test Workflow', 'task_queue_friendly_name': 'Test Queue', 'addons': '{}', 'links': { 'task_queue': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reservations': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations' } @@ -258,13 +258,13 @@ describe('Task', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0', 'key': 'tasks', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0' }, 'tasks': [ { @@ -283,14 +283,14 @@ describe('Task', function() { 'task_channel_unique_name': 'task-channel', 'timeout': 60, 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow_sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow_sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workflow_friendly_name': 'Test Workflow', 'task_queue_friendly_name': 'Test Queue', 'addons': '{}', 'links': { 'task_queue': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reservations': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations' } @@ -311,13 +311,13 @@ describe('Task', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0', 'key': 'tasks', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0' }, 'tasks': [ { @@ -336,14 +336,14 @@ describe('Task', function() { 'task_channel_unique_name': 'task-channel', 'timeout': 60, 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow_sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow_sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workflow_friendly_name': 'Test Workflow', 'task_queue_friendly_name': 'Test Queue', 'addons': '{}', 'links': { 'task_queue': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reservations': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations' } @@ -381,13 +381,13 @@ describe('Task', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0', 'key': 'tasks', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending%2Creserved&PageSize=50&Page=0' }, 'tasks': [ { @@ -406,14 +406,14 @@ describe('Task', function() { 'task_channel_unique_name': 'task-channel', 'timeout': 60, 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow_sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow_sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workflow_friendly_name': 'Test Workflow', 'task_queue_friendly_name': 'Test Queue', 'addons': '{}', 'links': { 'task_queue': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reservations': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations' } @@ -437,13 +437,13 @@ describe('Task', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending&PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending&PageSize=50&Page=0', 'key': 'tasks', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending&PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending&PageSize=50&Page=0' }, 'tasks': [] }; @@ -464,13 +464,13 @@ describe('Task', function() { function(done) { var body = { 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending&PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending&PageSize=50&Page=0', 'key': 'tasks', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending&PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?TaskQueueSid=WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Priority=1&TaskQueueName=task_queue_name&WorkflowName=workflow_name&WorkflowSid=WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&AssignmentStatus=pending&PageSize=50&Page=0' }, 'tasks': [] }; @@ -528,13 +528,13 @@ describe('Task', function() { 'timeout': 60, 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow_sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow_sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workflow_friendly_name': 'Example Workflow', 'task_queue_friendly_name': 'Example Task Queue', 'addons': '{}', 'links': { 'task_queue': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'workflow': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reservations': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations' } diff --git a/spec/integration/rest/taskrouter/v1/workspace/workflow.spec.js b/spec/integration/rest/taskrouter/v1/workspace/workflow.spec.js index 3a88680b38..9ea4b3efcc 100644 --- a/spec/integration/rest/taskrouter/v1/workspace/workflow.spec.js +++ b/spec/integration/rest/taskrouter/v1/workspace/workflow.spec.js @@ -63,14 +63,14 @@ describe('Workflow', function() { 'document_content_type': 'application/json', 'fallback_assignment_callback_url': null, 'friendly_name': 'Default Fifo Workflow', - 'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_reservation_timeout': 120, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', - 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', - 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' + 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', + 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', + 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' } }; @@ -120,13 +120,13 @@ describe('Workflow', function() { 'document_content_type': 'application/json', 'fallback_assignment_callback_url': null, 'friendly_name': 'Default Fifo Workflow', - 'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_reservation_timeout': 120, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', - 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', - 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' + 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', + 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', + 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' }, 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; @@ -204,13 +204,13 @@ describe('Workflow', function() { 'document_content_type': 'application/json', 'fallback_assignment_callback_url': null, 'friendly_name': 'Default Fifo Workflow', - 'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_reservation_timeout': 120, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', - 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', - 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' + 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', + 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', + 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' }, 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -243,13 +243,13 @@ describe('Workflow', function() { 'document_content_type': 'application/json', 'fallback_assignment_callback_url': null, 'friendly_name': 'Default Fifo Workflow', - 'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_reservation_timeout': 120, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', - 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', - 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' + 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', + 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', + 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' }, 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -287,13 +287,13 @@ describe('Workflow', function() { 'document_content_type': 'application/json', 'fallback_assignment_callback_url': null, 'friendly_name': 'Default Fifo Workflow', - 'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_reservation_timeout': 120, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', - 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', - 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' + 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', + 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', + 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' }, 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -348,13 +348,13 @@ describe('Workflow', function() { 'document_content_type': 'application/json', 'fallback_assignment_callback_url': null, 'friendly_name': 'Default Fifo Workflow', - 'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_reservation_timeout': 120, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', - 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', - 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' + 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', + 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', + 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' }, 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -436,14 +436,14 @@ describe('Workflow', function() { 'document_content_type': 'application/json', 'fallback_assignment_callback_url': null, 'friendly_name': 'Default Fifo Workflow', - 'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_reservation_timeout': 120, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', - 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', - 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' + 'statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', + 'real_time_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', + 'cumulative_statistics': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics' } }; diff --git a/spec/integration/rest/trunking/v1/trunk/phoneNumber.spec.js b/spec/integration/rest/trunking/v1/trunk/phoneNumber.spec.js index 6b2be6ea5f..b8f4e15ab9 100644 --- a/spec/integration/rest/trunking/v1/trunk/phoneNumber.spec.js +++ b/spec/integration/rest/trunking/v1/trunk/phoneNumber.spec.js @@ -63,19 +63,19 @@ describe('PhoneNumber', function() { 'phone_number': '+14158675309', 'api_version': '2010-04-01', 'voice_caller_id_lookup': null, - 'voice_url': '', + 'voice_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Call', 'voice_method': 'POST', 'voice_fallback_url': null, 'voice_fallback_method': null, 'status_callback': '', 'status_callback_method': 'POST', - 'voice_application_sid': null, + 'voice_application_sid': '', 'trunk_sid': 'TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'sms_url': '', + 'sms_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Message', 'sms_method': 'POST', 'sms_fallback_url': '', 'sms_fallback_method': 'POST', - 'sms_application_sid': '', + 'sms_application_sid': 'APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'address_requirements': 'none', 'beta': false, 'url': 'https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -176,19 +176,19 @@ describe('PhoneNumber', function() { 'phone_number': '+14158675309', 'api_version': '2010-04-01', 'voice_caller_id_lookup': null, - 'voice_url': '', + 'voice_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Call', 'voice_method': 'POST', 'voice_fallback_url': null, 'voice_fallback_method': null, 'status_callback': '', 'status_callback_method': 'POST', - 'voice_application_sid': null, + 'voice_application_sid': '', 'trunk_sid': 'TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'sms_url': '', + 'sms_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Message', 'sms_method': 'POST', 'sms_fallback_url': '', 'sms_fallback_method': 'POST', - 'sms_application_sid': '', + 'sms_application_sid': 'APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'address_requirements': 'none', 'beta': false, 'url': 'https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -237,19 +237,19 @@ describe('PhoneNumber', function() { 'phone_number': '+14158675309', 'api_version': '2010-04-01', 'voice_caller_id_lookup': null, - 'voice_url': '', + 'voice_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Call', 'voice_method': 'POST', 'voice_fallback_url': null, 'voice_fallback_method': null, 'status_callback': '', 'status_callback_method': 'POST', - 'voice_application_sid': null, + 'voice_application_sid': '', 'trunk_sid': 'TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'sms_url': '', + 'sms_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Message', 'sms_method': 'POST', 'sms_fallback_url': '', 'sms_fallback_method': 'POST', - 'sms_application_sid': '', + 'sms_application_sid': 'APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'address_requirements': 'none', 'beta': false, 'url': 'https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -291,19 +291,19 @@ describe('PhoneNumber', function() { 'phone_number': '+14158675309', 'api_version': '2010-04-01', 'voice_caller_id_lookup': null, - 'voice_url': '', + 'voice_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Call', 'voice_method': 'POST', 'voice_fallback_url': null, 'voice_fallback_method': null, 'status_callback': '', 'status_callback_method': 'POST', - 'voice_application_sid': null, + 'voice_application_sid': '', 'trunk_sid': 'TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'sms_url': '', + 'sms_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Message', 'sms_method': 'POST', 'sms_fallback_url': '', 'sms_fallback_method': 'POST', - 'sms_application_sid': '', + 'sms_application_sid': 'APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'address_requirements': 'none', 'beta': false, 'url': 'https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -350,19 +350,19 @@ describe('PhoneNumber', function() { 'phone_number': '+14158675309', 'api_version': '2010-04-01', 'voice_caller_id_lookup': null, - 'voice_url': '', + 'voice_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Call', 'voice_method': 'POST', 'voice_fallback_url': null, 'voice_fallback_method': null, 'status_callback': '', 'status_callback_method': 'POST', - 'voice_application_sid': null, + 'voice_application_sid': '', 'trunk_sid': 'TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'sms_url': '', + 'sms_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Message', 'sms_method': 'POST', 'sms_fallback_url': '', 'sms_fallback_method': 'POST', - 'sms_application_sid': '', + 'sms_application_sid': 'APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'address_requirements': 'none', 'beta': false, 'url': 'https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -426,19 +426,19 @@ describe('PhoneNumber', function() { 'phone_number': '+14158675309', 'api_version': '2010-04-01', 'voice_caller_id_lookup': null, - 'voice_url': '', + 'voice_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Call', 'voice_method': 'POST', 'voice_fallback_url': null, 'voice_fallback_method': null, 'status_callback': '', 'status_callback_method': 'POST', - 'voice_application_sid': null, + 'voice_application_sid': '', 'trunk_sid': 'TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'sms_url': '', + 'sms_url': 'https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Message', 'sms_method': 'POST', 'sms_fallback_url': '', 'sms_fallback_method': 'POST', - 'sms_application_sid': '', + 'sms_application_sid': 'APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'address_requirements': 'none', 'beta': false, 'url': 'https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', diff --git a/spec/integration/rest/trusthub/v1/supportingDocument.spec.js b/spec/integration/rest/trusthub/v1/supportingDocument.spec.js index b29a643ceb..293ead51a3 100644 --- a/spec/integration/rest/trusthub/v1/supportingDocument.spec.js +++ b/spec/integration/rest/trusthub/v1/supportingDocument.spec.js @@ -55,7 +55,7 @@ describe('SupportingDocument', function() { it('should generate valid create response', function(done) { var body = { - 'status': 'DRAFT', + 'status': 'draft', 'date_updated': '2021-02-11T17:23:00Z', 'friendly_name': 'Business-profile-physical-address', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -86,7 +86,7 @@ describe('SupportingDocument', function() { var body = { 'results': [ { - 'status': 'DRAFT', + 'status': 'draft', 'date_updated': '2021-02-11T17:23:00Z', 'friendly_name': 'Business-profile-physical-address', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -119,7 +119,7 @@ describe('SupportingDocument', function() { var body = { 'results': [ { - 'status': 'DRAFT', + 'status': 'draft', 'date_updated': '2021-02-11T17:23:00Z', 'friendly_name': 'Business-profile-physical-address', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -157,7 +157,7 @@ describe('SupportingDocument', function() { var body = { 'results': [ { - 'status': 'DRAFT', + 'status': 'draft', 'date_updated': '2021-02-11T17:23:00Z', 'friendly_name': 'Business-profile-physical-address', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -236,7 +236,7 @@ describe('SupportingDocument', function() { var body = { 'results': [ { - 'status': 'DRAFT', + 'status': 'draft', 'date_updated': '2021-02-11T17:23:00Z', 'friendly_name': 'Business-profile-physical-address', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -296,7 +296,7 @@ describe('SupportingDocument', function() { it('should generate valid fetch response', function(done) { var body = { - 'status': 'DRAFT', + 'status': 'draft', 'date_updated': '2021-02-11T17:23:00Z', 'friendly_name': 'Business-profile-physical-address', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -345,7 +345,7 @@ describe('SupportingDocument', function() { it('should generate valid update response', function(done) { var body = { - 'status': 'DRAFT', + 'status': 'draft', 'date_updated': '2021-02-11T17:23:00Z', 'friendly_name': 'friendly_name', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', diff --git a/spec/integration/rest/verify/v2/service/entity/challenge.spec.js b/spec/integration/rest/verify/v2/service/entity/challenge.spec.js index 9a9a9459eb..6b3ce9898c 100644 --- a/spec/integration/rest/verify/v2/service/entity/challenge.spec.js +++ b/spec/integration/rest/verify/v2/service/entity/challenge.spec.js @@ -281,12 +281,12 @@ describe('Challenge', function() { var body = { 'challenges': [ { - 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'factor_sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'factor_sid': 'YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', @@ -307,9 +307,41 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } + }, + { + 'sid': 'YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_sid': 'YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'date_responded': '2015-07-30T20:00:00Z', + 'expiration_date': '2015-07-30T20:00:00Z', + 'status': 'pending', + 'responded_reason': 'none', + 'details': { + 'message': 'Hi! Mr. John Doe, would you like to sign up?', + 'date': '2020-07-01T12:13:14Z', + 'fields': [ + { + 'label': 'Action', + 'value': 'Sign up in portal' + } + ] + }, + 'hidden_details': { + 'ip': '172.168.1.234' + }, + 'factor_type': 'totp', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' } } ], @@ -334,12 +366,12 @@ describe('Challenge', function() { var body = { 'challenges': [ { - 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'factor_sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'factor_sid': 'YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', @@ -360,9 +392,41 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } + }, + { + 'sid': 'YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_sid': 'YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'date_responded': '2015-07-30T20:00:00Z', + 'expiration_date': '2015-07-30T20:00:00Z', + 'status': 'pending', + 'responded_reason': 'none', + 'details': { + 'message': 'Hi! Mr. John Doe, would you like to sign up?', + 'date': '2020-07-01T12:13:14Z', + 'fields': [ + { + 'label': 'Action', + 'value': 'Sign up in portal' + } + ] + }, + 'hidden_details': { + 'ip': '172.168.1.234' + }, + 'factor_type': 'totp', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' } } ], @@ -392,12 +456,12 @@ describe('Challenge', function() { var body = { 'challenges': [ { - 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'factor_sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'factor_sid': 'YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', @@ -418,9 +482,41 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } + }, + { + 'sid': 'YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_sid': 'YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'date_responded': '2015-07-30T20:00:00Z', + 'expiration_date': '2015-07-30T20:00:00Z', + 'status': 'pending', + 'responded_reason': 'none', + 'details': { + 'message': 'Hi! Mr. John Doe, would you like to sign up?', + 'date': '2020-07-01T12:13:14Z', + 'fields': [ + { + 'label': 'Action', + 'value': 'Sign up in portal' + } + ] + }, + 'hidden_details': { + 'ip': '172.168.1.234' + }, + 'factor_type': 'totp', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' } } ], @@ -497,12 +593,12 @@ describe('Challenge', function() { var body = { 'challenges': [ { - 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'factor_sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'factor_sid': 'YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', @@ -523,9 +619,41 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } + }, + { + 'sid': 'YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_sid': 'YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'date_responded': '2015-07-30T20:00:00Z', + 'expiration_date': '2015-07-30T20:00:00Z', + 'status': 'pending', + 'responded_reason': 'none', + 'details': { + 'message': 'Hi! Mr. John Doe, would you like to sign up?', + 'date': '2020-07-01T12:13:14Z', + 'fields': [ + { + 'label': 'Action', + 'value': 'Sign up in portal' + } + ] + }, + 'hidden_details': { + 'ip': '172.168.1.234' + }, + 'factor_type': 'totp', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' } } ], @@ -578,15 +706,15 @@ describe('Challenge', function() { })); } ); - it('should generate valid verify_sid response', + it('should generate valid verify_push response', function(done) { var body = { - 'sid': 'YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sid': 'YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'factor_sid': 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'factor_sid': 'YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', @@ -607,9 +735,57 @@ describe('Challenge', function() { 'ip': '172.168.1.234' }, 'factor_type': 'push', - 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { - 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .entities('identity') + .challenges('YCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid verify_totp response', + function(done) { + var body = { + 'sid': 'YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_sid': 'YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'date_responded': '2015-07-30T20:00:00Z', + 'expiration_date': '2015-07-30T20:00:00Z', + 'status': 'approved', + 'responded_reason': 'none', + 'details': { + 'message': 'Hi! Mr. John Doe, would you like to sign up?', + 'date': '2020-07-01T12:13:14Z', + 'fields': [ + { + 'label': 'Action', + 'value': 'Sign up in portal' + } + ] + }, + 'hidden_details': { + 'ip': '172.168.1.234' + }, + 'factor_type': 'totp', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'notifications': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications' } }; diff --git a/spec/integration/rest/verify/v2/service/entity/challenge/notification.spec.js b/spec/integration/rest/verify/v2/service/entity/challenge/notification.spec.js index a063af4a75..623fb86e80 100644 --- a/spec/integration/rest/verify/v2/service/entity/challenge/notification.spec.js +++ b/spec/integration/rest/verify/v2/service/entity/challenge/notification.spec.js @@ -63,7 +63,7 @@ describe('Notification', function() { 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'challenge_sid': 'YC03XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + 'challenge_sid': 'YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'priority': 'high', 'ttl': 150 @@ -91,7 +91,7 @@ describe('Notification', function() { 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'entity_sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'challenge_sid': 'YC03XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + 'challenge_sid': 'YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'date_created': '2015-07-30T20:00:00Z', 'priority': 'high', 'ttl': 300 diff --git a/spec/integration/rest/wireless/v1/command.spec.js b/spec/integration/rest/wireless/v1/command.spec.js index 30b384b369..e73d2b1ed9 100644 --- a/spec/integration/rest/wireless/v1/command.spec.js +++ b/spec/integration/rest/wireless/v1/command.spec.js @@ -304,7 +304,7 @@ describe('Command', function() { { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'command': 'command', - 'command_mode': 'not_confirmable', + 'command_mode': 'binary', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'delivery_receipt_requested': true, From 1ecd18f69e0955ade3438c4f617c82f6cdacee5f Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 19 May 2021 19:43:15 +0000 Subject: [PATCH 13/30] Release 3.63.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a24fbf0e48..6e70d11b49 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.62.0", + "version": "3.63.0", "author": "API Team ", "contributors": [ { From 2b5365baba8e099227282a5b45fbf9c56b4d4019 Mon Sep 17 00:00:00 2001 From: Jennifer Mah <42650198+JenniferMah@users.noreply.github.com> Date: Thu, 27 May 2021 09:22:11 -0600 Subject: [PATCH 14/30] fix: remove @type/express (#675) Co-authored-by: Elise Shanholtz --- examples/typescript/example.ts | 4 ++-- lib/webhooks/webhooks.d.ts | 23 +++++++++++++---------- package.json | 5 +---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/typescript/example.ts b/examples/typescript/example.ts index 032250f664..cb9ef54f3b 100644 --- a/examples/typescript/example.ts +++ b/examples/typescript/example.ts @@ -115,7 +115,7 @@ client.messages.list({}, (err, messages) => { console.log('Listing messages using callbacks'); messages.forEach(function(message){ console.log(message.sid); - }); + }); }); // List messages using promises @@ -124,7 +124,7 @@ promiseMessage.then(messages => { console.log('Listing messages using promises'); messages.forEach(function(message){ console.log(message.sid); - }); + }); }); const twiml = new twilio.twiml.VoiceResponse(); diff --git a/lib/webhooks/webhooks.d.ts b/lib/webhooks/webhooks.d.ts index f0d249d399..f75302ed31 100644 --- a/lib/webhooks/webhooks.d.ts +++ b/lib/webhooks/webhooks.d.ts @@ -1,10 +1,13 @@ -import { Request, Response } from 'express'; +import {IncomingHttpHeaders} from "http2"; -type Middleware = ( - request: Request, - response: Response, - next: () => void -) => any; +interface Request { + protocol: string; + header(name: string): string | undefined; + headers: IncomingHttpHeaders; + originalUrl: string; + rawBody?: any; + body: any; +} export interface RequestValidatorOptions { /** @@ -144,7 +147,7 @@ export function validateExpressRequest( * protocol: 'https' * }); */ -export function webhook(): Middleware; -export function webhook(opts: WebhookOptions): Middleware; -export function webhook(authToken: string, opts: WebhookOptions): Middleware; -export function webhook(opts: WebhookOptions, authToken: string): Middleware; +export function webhook(): any; +export function webhook(opts: WebhookOptions): any; +export function webhook(authToken: string, opts: WebhookOptions): any; +export function webhook(opts: WebhookOptions, authToken: string): any; diff --git a/package.json b/package.json index 6e70d11b49..0c5144f360 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,7 @@ "xmlbuilder": "^13.0.2" }, "devDependencies": { - "@types/express": "^4.17.7", - "@types/lodash": "4.14.112", "@types/node": "9.6.57", - "@types/qs": "6.9.4", "eslint": "^7.3.1", "express": "^4.17.1", "jasmine": "~3.5.0", @@ -47,7 +44,7 @@ "node-mocks-http": "^1.8.1", "nyc": "^15.1.0", "proxyquire": "^2.1.3", - "typescript": "^2.8.3" + "typescript": "^2.9.2" }, "scripts": { "test": "npm run test:javascript && npm run test:typescript", From ad05e72aec062627cbbd48f54d9446576bd100d9 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 2 Jun 2021 19:41:12 +0000 Subject: [PATCH 15/30] [Librarian] Regenerated @ ace337a1be26cdd69f455a9a0f82789cd255d3a1 --- CHANGES.md | 13 +++++++++++++ .../v2/service/entity/challenge/notification.d.ts | 2 +- .../v2/service/entity/challenge/notification.js | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d4ba258544..7bc17bc045 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,19 @@ twilio-node changelog ===================== +[2021-06-02] Version 3.63.1 +--------------------------- +**Library - Fix** +- [PR #675](https://github.com/twilio/twilio-node/pull/675): remove @type/express. Thanks to [@JenniferMah](https://github.com/JenniferMah)! + +**Events** +- join Sinks and Subscriptions service + +**Verify** +- Improved the documentation of `challenge` adding the maximum and minimum expected lengths of some fields. +- Improve documentation regarding `notification` by updating the documentation of the field `ttl`. + + [2021-05-19] Version 3.63.0 --------------------------- **Library - Chore** diff --git a/lib/rest/verify/v2/service/entity/challenge/notification.d.ts b/lib/rest/verify/v2/service/entity/challenge/notification.d.ts index d361a65623..21464a3965 100644 --- a/lib/rest/verify/v2/service/entity/challenge/notification.d.ts +++ b/lib/rest/verify/v2/service/entity/challenge/notification.d.ts @@ -46,7 +46,7 @@ interface NotificationListInstance { /** * Options to pass to create * - * @property ttl - How long, in seconds, the Notification is valid. + * @property ttl - How long, in seconds, the notification is valid. */ interface NotificationListInstanceCreateOptions { ttl?: number; diff --git a/lib/rest/verify/v2/service/entity/challenge/notification.js b/lib/rest/verify/v2/service/entity/challenge/notification.js index 0f9ae99b19..111452e992 100644 --- a/lib/rest/verify/v2/service/entity/challenge/notification.js +++ b/lib/rest/verify/v2/service/entity/challenge/notification.js @@ -68,7 +68,7 @@ NotificationList = function NotificationList(version, serviceSid, identity, * @memberof Twilio.Verify.V2.ServiceContext.EntityContext.ChallengeContext.NotificationList# * * @param {object} [opts] - Options for request - * @param {number} [opts.ttl] - How long, in seconds, the Notification is valid. + * @param {number} [opts.ttl] - How long, in seconds, the notification is valid. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed NotificationInstance @@ -213,8 +213,8 @@ NotificationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {string} entitySid - Entity Sid. * @property {string} identity - Unique external identifier of the Entity * @property {string} challengeSid - Challenge Sid. - * @property {string} priority - The priority of the Notification. - * @property {number} ttl - How long, in seconds, the Notification is valid. + * @property {string} priority - The priority of the notification. + * @property {number} ttl - How long, in seconds, the notification is valid. * @property {Date} dateCreated - The date this Notification was created * * @param {V2} version - Version of the resource From aceecf54df6daae23a7ef27287fa8c3f9c89cc3d Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 2 Jun 2021 20:21:37 +0000 Subject: [PATCH 16/30] Release 3.63.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c5144f360..66e8737df7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.63.0", + "version": "3.63.1", "author": "API Team ", "contributors": [ { From 51c08a749a436d3c1f9c2b0f2ecf273411381bae Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 15 Jun 2021 14:12:27 -0700 Subject: [PATCH 17/30] update slack token --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7ea10e72d3..0d20011849 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,10 @@ services: - docker jobs: include: - - language: node_js - node_js: '10' - after_success: - - sonar-scanner + - language: node_js + node_js: '10' + after_success: + - sonar-scanner script: - npm run ci deploy: @@ -34,7 +34,7 @@ notifications: on_success: never on_failure: change rooms: - secure: hhVGtw3ogUdCazgfsy5fh0BnCrgQJuZ56mRmRv9fqv7JYJRktf73HT7ZtyxqWW0zYuzfxPcLeEHhU02CKNfYVuaJMtukDQT40LBKIudsTOGJllulYXmM2VJYm2NChalwcx9JPx7Sxy5dBkz+AMrXlX7fmw4943e+fbve+tivj90= + secure: jQ2AF/kqOdO7HxO2y56yzLH2jIm/mvV1fprAEKo8NdLRXq3HRpFQbEumMlZRl8vr+BD173LYRmzm5C5Sk4ef9Nt+y6KJRWpGkkTYts/xSmmE30xVmRD7vzMQthjyPhwdp2EF/OP4hL1BQ+Xod2WSjaqJUTutFAZggB/Umfg+PBo= addons: sonarcloud: organization: twilio From 3618278ba3a716abbb0348e455a6869c342fe973 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 15 Jun 2021 15:09:46 -0700 Subject: [PATCH 18/30] always notify on failure --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0d20011849..d4934c4c6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ notifications: if: branch = main on_pull_requests: false on_success: never - on_failure: change + on_failure: always rooms: secure: jQ2AF/kqOdO7HxO2y56yzLH2jIm/mvV1fprAEKo8NdLRXq3HRpFQbEumMlZRl8vr+BD173LYRmzm5C5Sk4ef9Nt+y6KJRWpGkkTYts/xSmmE30xVmRD7vzMQthjyPhwdp2EF/OP4hL1BQ+Xod2WSjaqJUTutFAZggB/Umfg+PBo= addons: From e2a83c136476a422c08fe731467bdee48b259ab5 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Wed, 16 Jun 2021 11:00:01 -0700 Subject: [PATCH 19/30] update slack on change from build success to fail --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d4934c4c6a..0d20011849 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ notifications: if: branch = main on_pull_requests: false on_success: never - on_failure: always + on_failure: change rooms: secure: jQ2AF/kqOdO7HxO2y56yzLH2jIm/mvV1fprAEKo8NdLRXq3HRpFQbEumMlZRl8vr+BD173LYRmzm5C5Sk4ef9Nt+y6KJRWpGkkTYts/xSmmE30xVmRD7vzMQthjyPhwdp2EF/OP4hL1BQ+Xod2WSjaqJUTutFAZggB/Umfg+PBo= addons: From dcfd1fa19c0c3809148e18823386b9d1c351648d Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Wed, 16 Jun 2021 12:22:14 -0700 Subject: [PATCH 20/30] chore: bump lodash and eslint per npm audit (#677) --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 66e8737df7..2a3145911f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "dayjs": "^1.8.29", "https-proxy-agent": "^5.0.0", "jsonwebtoken": "^8.5.1", - "lodash": "^4.17.19", + "lodash": "^4.17.21", "q": "2.0.x", "qs": "^6.9.4", "rootpath": "^0.1.2", @@ -34,7 +34,7 @@ }, "devDependencies": { "@types/node": "9.6.57", - "eslint": "^7.3.1", + "eslint": "^7.28.0", "express": "^4.17.1", "jasmine": "~3.5.0", "jsdoc": "^3.6.7", From 7fb0be89e9dd54a1b47b3ea7f69296966f923c6c Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 16 Jun 2021 19:32:41 +0000 Subject: [PATCH 21/30] [Librarian] Regenerated @ e1d98e904674be752473dcb1f0e54c720a5d0754 --- CHANGES.md | 13 + lib/rest/FrontlineApi.d.ts | 26 ++ lib/rest/FrontlineApi.js | 54 +++ lib/rest/Twilio.d.ts | 2 + lib/rest/Twilio.js | 14 + lib/rest/api/v2010/account/message.d.ts | 6 +- lib/rest/frontlineApi/V1.d.ts | 25 ++ lib/rest/frontlineApi/V1.js | 46 ++ lib/rest/frontlineApi/v1/user.d.ts | 180 ++++++++ lib/rest/frontlineApi/v1/user.js | 395 ++++++++++++++++++ .../rest/frontlineApi/v1/user.spec.js | 118 ++++++ .../customerProfilesEvaluations.spec.js | 6 +- .../trustProductsEvaluations.spec.js | 6 +- 13 files changed, 883 insertions(+), 8 deletions(-) create mode 100644 lib/rest/FrontlineApi.d.ts create mode 100644 lib/rest/FrontlineApi.js create mode 100644 lib/rest/frontlineApi/V1.d.ts create mode 100644 lib/rest/frontlineApi/V1.js create mode 100644 lib/rest/frontlineApi/v1/user.d.ts create mode 100644 lib/rest/frontlineApi/v1/user.js create mode 100644 spec/integration/rest/frontlineApi/v1/user.spec.js diff --git a/CHANGES.md b/CHANGES.md index 7bc17bc045..8a7965d3b8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,19 @@ twilio-node changelog ===================== +[2021-06-16] Version 3.64.0 +--------------------------- +**Library - Chore** +- [PR #677](https://github.com/twilio/twilio-node/pull/677): bump lodash and eslint per npm audit. Thanks to [@thinkingserious](https://github.com/thinkingserious)! + +**Api** +- Update `status` enum for Messages to include 'canceled' +- Update `update_status` enum for Messages to include 'canceled' + +**Trusthub** +- Corrected the sid for policy sid in customer_profile_evaluation.json and trust_product_evaluation.json **(breaking change)** + + [2021-06-02] Version 3.63.1 --------------------------- **Library - Fix** diff --git a/lib/rest/FrontlineApi.d.ts b/lib/rest/FrontlineApi.d.ts new file mode 100644 index 0000000000..101c317103 --- /dev/null +++ b/lib/rest/FrontlineApi.d.ts @@ -0,0 +1,26 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Domain = require('../base/Domain'); +import Twilio = require('./Twilio'); +import V1 = require('./frontlineApi/V1'); +import { UserListInstance } from './frontlineApi/v1/user'; + + +declare class FrontlineApi extends Domain { + /** + * Initialize frontline_api domain + * + * @param twilio - The twilio client + */ + constructor(twilio: Twilio); + + readonly users: UserListInstance; + readonly v1: V1; +} + +export = FrontlineApi; diff --git a/lib/rest/FrontlineApi.js b/lib/rest/FrontlineApi.js new file mode 100644 index 0000000000..88469b08b2 --- /dev/null +++ b/lib/rest/FrontlineApi.js @@ -0,0 +1,54 @@ +'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('./frontlineApi/V1'); /* jshint ignore:line */ + + +/* jshint ignore:start */ +/** + * Initialize frontline_api domain + * + * @constructor Twilio.FrontlineApi + * + * @property {Twilio.FrontlineApi.V1} v1 - v1 version + * @property {Twilio.FrontlineApi.V1.UserList} users - users resource + * + * @param {Twilio} twilio - The twilio client + */ +/* jshint ignore:end */ +function FrontlineApi(twilio) { + Domain.prototype.constructor.call(this, twilio, 'https://frontline-api.twilio.com'); + + // Versions + this._v1 = undefined; +} + +_.extend(FrontlineApi.prototype, Domain.prototype); +FrontlineApi.prototype.constructor = FrontlineApi; + +Object.defineProperty(FrontlineApi.prototype, + 'v1', { + get: function() { + this._v1 = this._v1 || new V1(this); + return this._v1; + } +}); + +Object.defineProperty(FrontlineApi.prototype, + 'users', { + get: function() { + return this.v1.users; + } +}); + +module.exports = FrontlineApi; diff --git a/lib/rest/Twilio.d.ts b/lib/rest/Twilio.d.ts index ce4086188e..fb3c0a60ed 100644 --- a/lib/rest/Twilio.d.ts +++ b/lib/rest/Twilio.d.ts @@ -14,6 +14,7 @@ import Conversations = require('./Conversations'); import Events = require('./Events'); import Fax = require('./Fax'); import FlexApi = require('./FlexApi'); +import FrontlineApi = require('./FrontlineApi'); import Insights = require('./Insights'); import IpMessaging = require('./IpMessaging'); import Lookups = require('./Lookups'); @@ -64,6 +65,7 @@ declare class Twilio { events: Events; fax: Fax; flexApi: FlexApi; + frontlineApi: FrontlineApi; httpClient?: RequestClient; incomingPhoneNumbers: (typeof Api.prototype.account.incomingPhoneNumbers); insights: Insights; diff --git a/lib/rest/Twilio.js b/lib/rest/Twilio.js index a6d2c89142..3a6e871135 100644 --- a/lib/rest/Twilio.js +++ b/lib/rest/Twilio.js @@ -29,6 +29,7 @@ var RestException = require('../base/RestException'); /* jshint ignore:line */ * @property {Twilio.Events} events - events domain * @property {Twilio.Fax} fax - fax domain * @property {Twilio.FlexApi} flexApi - flex_api domain + * @property {Twilio.FrontlineApi} frontlineApi - frontline_api domain * @property {Twilio.Insights} insights - insights domain * @property {Twilio.IpMessaging} ipMessaging - ip_messaging domain * @property {Twilio.Lookups} lookups - lookups domain @@ -150,6 +151,7 @@ function Twilio(username, password, opts) { this._events = undefined; this._fax = undefined; this._flexApi = undefined; + this._frontlineApi = undefined; this._insights = undefined; this._ipMessaging = undefined; this._lookups = undefined; @@ -182,6 +184,7 @@ function Twilio(username, password, opts) { this.events; this.fax; this.flexApi; + this.frontlineApi; this.insights; this.ipMessaging; this.lookups; @@ -430,6 +433,17 @@ Object.defineProperty(Twilio.prototype, } }); +Object.defineProperty(Twilio.prototype, + 'frontlineApi', { + get: function() { + if (!this._frontlineApi) { + var FrontlineApi = require('./FrontlineApi'); /* jshint ignore:line */ + this._frontlineApi = new FrontlineApi(this); + } + return this._frontlineApi; + } +}); + Object.defineProperty(Twilio.prototype, 'insights', { get: function() { diff --git a/lib/rest/api/v2010/account/message.d.ts b/lib/rest/api/v2010/account/message.d.ts index 1f46627bb0..60bce552d2 100644 --- a/lib/rest/api/v2010/account/message.d.ts +++ b/lib/rest/api/v2010/account/message.d.ts @@ -22,10 +22,12 @@ type MessageDirection = 'inbound'|'outbound-api'|'outbound-call'|'outbound-reply type MessageScheduleType = 'fixed'|'optimize'; -type MessageStatus = 'queued'|'sending'|'sent'|'failed'|'delivered'|'undelivered'|'receiving'|'received'|'accepted'|'scheduled'|'read'|'partially_delivered'; +type MessageStatus = 'queued'|'sending'|'sent'|'failed'|'delivered'|'undelivered'|'receiving'|'received'|'accepted'|'scheduled'|'read'|'partially_delivered'|'canceled'; type MessageTrafficType = 'free'; +type MessageUpdateStatus = 'canceled'; + /** * Initialize the MessageList * @@ -446,4 +448,4 @@ declare class MessagePage extends Page any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a UserInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: UserInstance) => any): Promise; + /** + * update a UserInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: UserInstanceUpdateOptions, callback?: (error: Error | null, items: UserInstance) => any): Promise; +} + + +declare class UserInstance extends SerializableClass { + /** + * Initialize the UserContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param sid - The SID of the User resource to fetch + */ + constructor(version: V1, payload: UserPayload, sid: string); + + private _proxy: UserContext; + avatar: string; + /** + * fetch a UserInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UserInstance) => any): Promise; + friendlyName: string; + identity: string; + sid: string; + state: UserStateType; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a UserInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: UserInstance) => any): Promise; + /** + * update a UserInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: UserInstanceUpdateOptions, callback?: (error: Error | null, items: UserInstance) => any): Promise; + url: string; +} + + +declare class UserPage extends Page { + /** + * Initialize the UserPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: UserSolution); + + /** + * Build an instance of UserInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: UserPayload): UserInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { UserContext, UserInstance, UserInstanceUpdateOptions, UserList, UserListInstance, UserPage, UserPayload, UserResource, UserSolution, UserStateType } diff --git a/lib/rest/frontlineApi/v1/user.js b/lib/rest/frontlineApi/v1/user.js new file mode 100644 index 0000000000..e3cdba1cee --- /dev/null +++ b/lib/rest/frontlineApi/v1/user.js @@ -0,0 +1,395 @@ +'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 UserList; +var UserPage; +var UserInstance; +var UserContext; + +/* jshint ignore:start */ +/** + * Initialize the UserList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.FrontlineApi.V1.UserList + * + * @param {Twilio.FrontlineApi.V1} version - Version of the resource + */ +/* jshint ignore:end */ +UserList = function UserList(version) { + /* jshint ignore:start */ + /** + * @function users + * @memberof Twilio.FrontlineApi.V1# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.FrontlineApi.V1.UserContext} + */ + /* jshint ignore:end */ + function UserListInstance(sid) { + return UserListInstance.get(sid); + } + + UserListInstance._version = version; + // Path Solution + UserListInstance._solution = {}; + /* jshint ignore:start */ + /** + * Constructs a user + * + * @function get + * @memberof Twilio.FrontlineApi.V1.UserList# + * + * @param {string} sid - The SID of the User resource to fetch + * + * @returns {Twilio.FrontlineApi.V1.UserContext} + */ + /* jshint ignore:end */ + UserListInstance.get = function get(sid) { + return new UserContext(this._version, sid); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.FrontlineApi.V1.UserList# + * + * @returns Object + */ + /* jshint ignore:end */ + UserListInstance.toJSON = function toJSON() { + return this._solution; + }; + + UserListInstance[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return UserListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserPage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.FrontlineApi.V1.UserPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {UserSolution} solution - Path solution + * + * @returns UserPage + */ +/* jshint ignore:end */ +UserPage = function UserPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(UserPage.prototype, Page.prototype); +UserPage.prototype.constructor = UserPage; + +/* jshint ignore:start */ +/** + * Build an instance of UserInstance + * + * @function getInstance + * @memberof Twilio.FrontlineApi.V1.UserPage# + * + * @param {UserPayload} payload - Payload response from the API + * + * @returns UserInstance + */ +/* jshint ignore:end */ +UserPage.prototype.getInstance = function getInstance(payload) { + return new UserInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.FrontlineApi.V1.UserPage# + * + * @returns Object + */ +/* jshint ignore:end */ +UserPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UserPage.prototype[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.FrontlineApi.V1.UserInstance + * + * @property {string} sid - The unique string that identifies the resource + * @property {string} identity - The string that identifies the resource's User + * @property {string} friendlyName - + * The string that you assigned to describe the User + * @property {string} avatar - + * The avatar URL which will be shown in Frontline application + * @property {user.state_type} state - Current state of this user + * @property {string} url - An absolute URL for this user. + * + * @param {V1} version - Version of the resource + * @param {UserPayload} payload - The instance payload + * @param {string} sid - The SID of the User resource to fetch + */ +/* jshint ignore:end */ +UserInstance = function UserInstance(version, payload, sid) { + this._version = version; + + // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line + this.identity = payload.identity; // jshint ignore:line + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.avatar = payload.avatar; // jshint ignore:line + this.state = payload.state; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {sid: sid || this.sid, }; +}; + +Object.defineProperty(UserInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new UserContext(this._version, this._solution.sid); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * fetch a UserInstance + * + * @function fetch + * @memberof Twilio.FrontlineApi.V1.UserInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserInstance + */ +/* jshint ignore:end */ +UserInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * update a UserInstance + * + * @function update + * @memberof Twilio.FrontlineApi.V1.UserInstance# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.friendlyName] - + * The string that you assigned to describe the User + * @param {string} [opts.avatar] - + * The avatar URL which will be shown in Frontline application + * @param {user.state_type} [opts.state] - Current state of this user + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserInstance + */ +/* jshint ignore:end */ +UserInstance.prototype.update = function update(opts, callback) { + return this._proxy.update(opts, callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.FrontlineApi.V1.UserInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +UserInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UserInstance.prototype[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.FrontlineApi.V1.UserContext + * + * @param {V1} version - Version of the resource + * @param {string} sid - The SID of the User resource to fetch + */ +/* jshint ignore:end */ +UserContext = function UserContext(version, sid) { + this._version = version; + + // Path Solution + this._solution = {sid: sid, }; + this._uri = `/Users/${sid}`; +}; + +/* jshint ignore:start */ +/** + * fetch a UserInstance + * + * @function fetch + * @memberof Twilio.FrontlineApi.V1.UserContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserInstance + */ +/* jshint ignore:end */ +UserContext.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 UserInstance(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 UserInstance + * + * @function update + * @memberof Twilio.FrontlineApi.V1.UserContext# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.friendlyName] - + * The string that you assigned to describe the User + * @param {string} [opts.avatar] - + * The avatar URL which will be shown in Frontline application + * @param {user.state_type} [opts.state] - Current state of this user + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserInstance + */ +/* jshint ignore:end */ +UserContext.prototype.update = function update(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'FriendlyName': _.get(opts, 'friendlyName'), + 'Avatar': _.get(opts, 'avatar'), + 'State': _.get(opts, 'state') + }); + + var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new UserInstance(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.FrontlineApi.V1.UserContext# + * + * @returns Object + */ +/* jshint ignore:end */ +UserContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +UserContext.prototype[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + UserList: UserList, + UserPage: UserPage, + UserInstance: UserInstance, + UserContext: UserContext +}; diff --git a/spec/integration/rest/frontlineApi/v1/user.spec.js b/spec/integration/rest/frontlineApi/v1/user.spec.js new file mode 100644 index 0000000000..dc4ffeda78 --- /dev/null +++ b/spec/integration/rest/frontlineApi/v1/user.spec.js @@ -0,0 +1,118 @@ +'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('User', 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.frontlineApi.v1.users('sid').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sid = 'sid'; + var url = `https://frontline-api.twilio.com/v1/Users/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'john@example.com', + 'friendly_name': 'John Doe', + 'avatar': 'https://example.com/profile.png', + 'state': 'active', + 'url': 'https://frontline-api.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.frontlineApi.v1.users('sid').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.frontlineApi.v1.users('sid').update(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sid = 'sid'; + var url = `https://frontline-api.twilio.com/v1/Users/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid update response', + function(done) { + var body = { + 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'identity': 'john@example.com', + 'friendly_name': 'John Doe', + 'avatar': 'https://example.com/profile.png', + 'state': 'active', + 'url': 'https://frontline-api.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.frontlineApi.v1.users('sid').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/trusthub/v1/customerProfiles/customerProfilesEvaluations.spec.js b/spec/integration/rest/trusthub/v1/customerProfiles/customerProfilesEvaluations.spec.js index 23c67a1b4b..3f28866202 100644 --- a/spec/integration/rest/trusthub/v1/customerProfiles/customerProfilesEvaluations.spec.js +++ b/spec/integration/rest/trusthub/v1/customerProfiles/customerProfilesEvaluations.spec.js @@ -33,7 +33,7 @@ describe('CustomerProfilesEvaluations', function() { function(done) { holodeck.mock(new Response(500, {})); - var opts = {policySid: 'BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; + var opts = {policySid: 'RNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; var promise = client.trusthub.v1.customerProfiles('BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .customerProfilesEvaluations.create(opts); promise.then(function() { @@ -46,7 +46,7 @@ describe('CustomerProfilesEvaluations', function() { var customerProfileSid = 'BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; var url = `https://trusthub.twilio.com/v1/CustomerProfiles/${customerProfileSid}/Evaluations`; - var values = {PolicySid: 'BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', }; + var values = {PolicySid: 'RNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', }; holodeck.assertHasRequest(new Request({ method: 'POST', url: url, @@ -219,7 +219,7 @@ describe('CustomerProfilesEvaluations', function() { holodeck.mock(new Response(201, body)); - var opts = {policySid: 'BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; + var opts = {policySid: 'RNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; var promise = client.trusthub.v1.customerProfiles('BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .customerProfilesEvaluations.create(opts); promise.then(function(response) { diff --git a/spec/integration/rest/trusthub/v1/trustProducts/trustProductsEvaluations.spec.js b/spec/integration/rest/trusthub/v1/trustProducts/trustProductsEvaluations.spec.js index cb915da759..c6c8b3441e 100644 --- a/spec/integration/rest/trusthub/v1/trustProducts/trustProductsEvaluations.spec.js +++ b/spec/integration/rest/trusthub/v1/trustProducts/trustProductsEvaluations.spec.js @@ -33,7 +33,7 @@ describe('TrustProductsEvaluations', function() { function(done) { holodeck.mock(new Response(500, {})); - var opts = {policySid: 'BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; + var opts = {policySid: 'RNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; var promise = client.trusthub.v1.trustProducts('BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .trustProductsEvaluations.create(opts); promise.then(function() { @@ -46,7 +46,7 @@ describe('TrustProductsEvaluations', function() { var trustProductSid = 'BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; var url = `https://trusthub.twilio.com/v1/TrustProducts/${trustProductSid}/Evaluations`; - var values = {PolicySid: 'BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', }; + var values = {PolicySid: 'RNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', }; holodeck.assertHasRequest(new Request({ method: 'POST', url: url, @@ -219,7 +219,7 @@ describe('TrustProductsEvaluations', function() { holodeck.mock(new Response(201, body)); - var opts = {policySid: 'BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; + var opts = {policySid: 'RNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; var promise = client.trusthub.v1.trustProducts('BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .trustProductsEvaluations.create(opts); promise.then(function(response) { From 624e8048293e04a82e8bc05b3f7884c48e43797f Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 16 Jun 2021 19:48:22 +0000 Subject: [PATCH 22/30] Release 3.64.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a3145911f..c9b2f2bfdd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.63.1", + "version": "3.64.0", "author": "API Team ", "contributors": [ { From 043dd653ff869f3cbb30314460f1f0e89546b1c1 Mon Sep 17 00:00:00 2001 From: Jennifer Mah Date: Wed, 16 Jun 2021 18:01:30 -0700 Subject: [PATCH 23/30] chore: add docker credentials to travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0d20011849..f70a0e2f5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ script: - npm run ci deploy: - provider: script - script: make docker-build && make docker-push + script: echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin && make docker-build && make docker-push skip_cleanup: true on: tags: true From 68ec83025c9d917481a303684cd5d58abfb8580f Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 30 Jun 2021 19:40:57 +0000 Subject: [PATCH 24/30] [Librarian] Regenerated @ 4e75c7be2507558854a659be2e05b171bcf7512b --- CHANGES.md | 18 + lib/rest/api/v2010/account/message.d.ts | 18 +- lib/rest/api/v2010/account/message.js | 17 +- lib/rest/conversations/v1/conversation.d.ts | 2 + lib/rest/conversations/v1/conversation.js | 2 + .../v1/service/conversation.d.ts | 2 + .../conversations/v1/service/conversation.js | 2 + lib/rest/supersim/v1/sim.d.ts | 9 + lib/rest/supersim/v1/sim.js | 33 ++ lib/rest/supersim/v1/sim/billingPeriod.d.ts | 249 ++++++++++ lib/rest/supersim/v1/sim/billingPeriod.js | 454 ++++++++++++++++++ lib/twiml/VoiceResponse.d.ts | 2 +- .../rest/api/v2010/account/message.spec.js | 52 +- .../conversations/v1/conversation.spec.js | 8 + .../v1/service/conversation.spec.js | 8 + spec/integration/rest/supersim/v1/sim.spec.js | 65 ++- .../supersim/v1/sim/billingPeriod.spec.js | 252 ++++++++++ spec/integration/rest/video/v1/room.spec.js | 14 +- 18 files changed, 1166 insertions(+), 41 deletions(-) create mode 100644 lib/rest/supersim/v1/sim/billingPeriod.d.ts create mode 100644 lib/rest/supersim/v1/sim/billingPeriod.js create mode 100644 spec/integration/rest/supersim/v1/sim/billingPeriod.spec.js diff --git a/CHANGES.md b/CHANGES.md index 8a7965d3b8..21fbaae980 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,24 @@ twilio-node changelog ===================== +[2021-06-30] Version 3.65.0 +--------------------------- +**Conversations** +- Read-only Conversation Email Binding property `binding` + +**Supersim** +- Add Billing Period resource for the Super Sim Pilot +- Add List endpoint to Billing Period resource for Super Sim Pilot +- Add Fetch endpoint to Billing Period resource for Super Sim Pilot + +**Taskrouter** +- Update `transcribe` & `transcription_configuration` form params in Reservation update endpoint to have private visibility **(breaking change)** +- Add `transcribe` & `transcription_configuration` form params to Reservation update endpoint + +**Twiml** +- Add `modify` event to `statusCallbackEvent` for ``. + + [2021-06-16] Version 3.64.0 --------------------------- **Library - Chore** diff --git a/lib/rest/api/v2010/account/message.d.ts b/lib/rest/api/v2010/account/message.d.ts index 60bce552d2..96a9a386a7 100644 --- a/lib/rest/api/v2010/account/message.d.ts +++ b/lib/rest/api/v2010/account/message.d.ts @@ -42,7 +42,7 @@ declare function MessageList(version: V2010, accountSid: string): MessageListIns * @property body - The text of the message you want to send */ interface MessageInstanceUpdateOptions { - body: string; + body?: string; } interface MessageListInstance { @@ -350,13 +350,19 @@ declare class MessageContext { * Provide a user-friendly representation */ toJSON(): any; + /** + * update a MessageInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: MessageInstance) => any): Promise; /** * update a MessageInstance * * @param opts - Options for request * @param callback - Callback to handle processed record */ - update(opts: MessageInstanceUpdateOptions, callback?: (error: Error | null, items: MessageInstance) => any): Promise; + update(opts?: MessageInstanceUpdateOptions, callback?: (error: Error | null, items: MessageInstance) => any): Promise; } @@ -415,13 +421,19 @@ declare class MessageInstance extends SerializableClass { * Provide a user-friendly representation */ toJSON(): any; + /** + * update a MessageInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: MessageInstance) => any): Promise; /** * update a MessageInstance * * @param opts - Options for request * @param callback - Callback to handle processed record */ - update(opts: MessageInstanceUpdateOptions, callback?: (error: Error | null, items: MessageInstance) => any): Promise; + update(opts?: MessageInstanceUpdateOptions, callback?: (error: Error | null, items: MessageInstance) => any): Promise; uri: string; } diff --git a/lib/rest/api/v2010/account/message.js b/lib/rest/api/v2010/account/message.js index 0bdf4f7bcf..df66f241e4 100644 --- a/lib/rest/api/v2010/account/message.js +++ b/lib/rest/api/v2010/account/message.js @@ -630,8 +630,8 @@ MessageInstance.prototype.fetch = function fetch(callback) { * @function update * @memberof Twilio.Api.V2010.AccountContext.MessageInstance# * - * @param {object} opts - Options for request - * @param {string} opts.body - The text of the message you want to send + * @param {object} [opts] - Options for request + * @param {string} [opts.body] - The text of the message you want to send * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MessageInstance @@ -798,20 +798,19 @@ MessageContext.prototype.fetch = function fetch(callback) { * @function update * @memberof Twilio.Api.V2010.AccountContext.MessageContext# * - * @param {object} opts - Options for request - * @param {string} opts.body - The text of the message you want to send + * @param {object} [opts] - Options for request + * @param {string} [opts.body] - The text of the message you want to send * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MessageInstance */ /* jshint ignore:end */ MessageContext.prototype.update = function update(opts, callback) { - if (_.isUndefined(opts)) { - throw new Error('Required parameter "opts" missing.'); - } - if (_.isUndefined(opts.body)) { - throw new Error('Required parameter "opts.body" missing.'); + if (_.isFunction(opts)) { + callback = opts; + opts = {}; } + opts = opts || {}; var deferred = Q.defer(); var data = values.of({'Body': _.get(opts, 'body')}); diff --git a/lib/rest/conversations/v1/conversation.d.ts b/lib/rest/conversations/v1/conversation.d.ts index 749f951484..cd8faf6d97 100644 --- a/lib/rest/conversations/v1/conversation.d.ts +++ b/lib/rest/conversations/v1/conversation.d.ts @@ -283,6 +283,7 @@ interface ConversationPayload extends ConversationResource, Page.TwilioResponseP interface ConversationResource { account_sid: string; attributes: string; + bindings: object; chat_service_sid: string; date_created: Date; date_updated: Date; @@ -364,6 +365,7 @@ declare class ConversationInstance extends SerializableClass { private _proxy: ConversationContext; accountSid: string; attributes: string; + bindings: any; chatServiceSid: string; dateCreated: Date; dateUpdated: Date; diff --git a/lib/rest/conversations/v1/conversation.js b/lib/rest/conversations/v1/conversation.js index 25c678ef5e..c71f5d71dd 100644 --- a/lib/rest/conversations/v1/conversation.js +++ b/lib/rest/conversations/v1/conversation.js @@ -495,6 +495,7 @@ ConversationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {string} url - An absolute URL for this conversation. * @property {string} links - * Absolute URLs to access the participants, messages and webhooks of this conversation. + * @property {object} bindings - The bindings * * @param {V1} version - Version of the resource * @param {ConversationPayload} payload - The instance payload @@ -519,6 +520,7 @@ ConversationInstance = function ConversationInstance(version, payload, sid) { this.timers = payload.timers; // jshint ignore:line this.url = payload.url; // jshint ignore:line this.links = payload.links; // jshint ignore:line + this.bindings = payload.bindings; // jshint ignore:line // Context this._context = undefined; diff --git a/lib/rest/conversations/v1/service/conversation.d.ts b/lib/rest/conversations/v1/service/conversation.d.ts index 853f9b498e..405358b385 100644 --- a/lib/rest/conversations/v1/service/conversation.d.ts +++ b/lib/rest/conversations/v1/service/conversation.d.ts @@ -284,6 +284,7 @@ interface ConversationPayload extends ConversationResource, Page.TwilioResponseP interface ConversationResource { account_sid: string; attributes: string; + bindings: object; chat_service_sid: string; date_created: Date; date_updated: Date; @@ -368,6 +369,7 @@ declare class ConversationInstance extends SerializableClass { private _proxy: ConversationContext; accountSid: string; attributes: string; + bindings: any; chatServiceSid: string; dateCreated: Date; dateUpdated: Date; diff --git a/lib/rest/conversations/v1/service/conversation.js b/lib/rest/conversations/v1/service/conversation.js index a3097be89b..41a97e7967 100644 --- a/lib/rest/conversations/v1/service/conversation.js +++ b/lib/rest/conversations/v1/service/conversation.js @@ -502,6 +502,7 @@ ConversationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {string} url - An absolute URL for this conversation. * @property {string} links - * Absolute URLs to access the participants, messages and webhooks of this conversation. + * @property {object} bindings - The bindings * * @param {V1} version - Version of the resource * @param {ConversationPayload} payload - The instance payload @@ -529,6 +530,7 @@ ConversationInstance = function ConversationInstance(version, payload, this.timers = payload.timers; // jshint ignore:line this.url = payload.url; // jshint ignore:line this.links = payload.links; // jshint ignore:line + this.bindings = payload.bindings; // jshint ignore:line // Context this._context = undefined; diff --git a/lib/rest/supersim/v1/sim.d.ts b/lib/rest/supersim/v1/sim.d.ts index 3b244fe34c..e7927a6728 100644 --- a/lib/rest/supersim/v1/sim.d.ts +++ b/lib/rest/supersim/v1/sim.d.ts @@ -8,6 +8,8 @@ import Page = require('../../../base/Page'); import Response = require('../../../http/response'); import V1 = require('../V1'); +import { BillingPeriodList } from './sim/billingPeriod'; +import { BillingPeriodListInstance } from './sim/billingPeriod'; import { SerializableClass } from '../../../interfaces'; type SimStatus = 'new'|'ready'|'active'|'inactive'|'scheduled'; @@ -258,6 +260,7 @@ interface SimResource { date_updated: Date; fleet_sid: string; iccid: string; + links: string; sid: string; status: SimStatus; unique_name: string; @@ -280,6 +283,7 @@ declare class SimContext { */ constructor(version: V1, sid: string); + billingPeriods: BillingPeriodListInstance; /** * fetch a SimInstance * @@ -321,6 +325,10 @@ declare class SimInstance extends SerializableClass { private _proxy: SimContext; accountSid: string; + /** + * Access the billingPeriods + */ + billingPeriods(): BillingPeriodListInstance; dateCreated: Date; dateUpdated: Date; /** @@ -331,6 +339,7 @@ declare class SimInstance extends SerializableClass { fetch(callback?: (error: Error | null, items: SimInstance) => any): Promise; fleetSid: string; iccid: string; + links: string; sid: string; status: SimStatus; /** diff --git a/lib/rest/supersim/v1/sim.js b/lib/rest/supersim/v1/sim.js index ee7131270c..3f8c43fbdd 100644 --- a/lib/rest/supersim/v1/sim.js +++ b/lib/rest/supersim/v1/sim.js @@ -12,6 +12,7 @@ var Q = require('q'); /* jshint ignore:line */ var _ = require('lodash'); /* jshint ignore:line */ var util = require('util'); /* jshint ignore:line */ +var BillingPeriodList = require('./sim/billingPeriod').BillingPeriodList; var Page = require('../../../base/Page'); /* jshint ignore:line */ var deserialize = require( '../../../base/deserialize'); /* jshint ignore:line */ @@ -491,6 +492,7 @@ SimPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {Date} dateUpdated - * The ISO 8601 date and time in GMT when the resource was last updated * @property {string} url - The absolute URL of the Sim Resource + * @property {string} links - The links * * @param {V1} version - Version of the resource * @param {SimPayload} payload - The instance payload @@ -510,6 +512,7 @@ SimInstance = function SimInstance(version, payload, sid) { 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 + this.links = payload.links; // jshint ignore:line // Context this._context = undefined; @@ -571,6 +574,20 @@ SimInstance.prototype.update = function update(opts, callback) { return this._proxy.update(opts, callback); }; +/* jshint ignore:start */ +/** + * Access the billingPeriods + * + * @function billingPeriods + * @memberof Twilio.Supersim.V1.SimInstance# + * + * @returns {Twilio.Supersim.V1.SimContext.BillingPeriodList} + */ +/* jshint ignore:end */ +SimInstance.prototype.billingPeriods = function billingPeriods() { + return this._proxy.billingPeriods; +}; + /* jshint ignore:start */ /** * Provide a user-friendly representation @@ -605,6 +622,9 @@ SimInstance.prototype[util.inspect.custom] = function inspect(depth, options) { * * @constructor Twilio.Supersim.V1.SimContext * + * @property {Twilio.Supersim.V1.SimContext.BillingPeriodList} billingPeriods - + * billingPeriods resource + * * @param {V1} version - Version of the resource * @param {sid_like} sid - The SID that identifies the resource to fetch */ @@ -615,6 +635,9 @@ SimContext = function SimContext(version, sid) { // Path Solution this._solution = {sid: sid, }; this._uri = `/Sims/${sid}`; + + // Dependents + this._billingPeriods = undefined; }; /* jshint ignore:start */ @@ -706,6 +729,16 @@ SimContext.prototype.update = function update(opts, callback) { return deferred.promise; }; +Object.defineProperty(SimContext.prototype, + 'billingPeriods', { + get: function() { + if (!this._billingPeriods) { + this._billingPeriods = new BillingPeriodList(this._version, this._solution.sid); + } + return this._billingPeriods; + } +}); + /* jshint ignore:start */ /** * Provide a user-friendly representation diff --git a/lib/rest/supersim/v1/sim/billingPeriod.d.ts b/lib/rest/supersim/v1/sim/billingPeriod.d.ts new file mode 100644 index 0000000000..d7890ccdfe --- /dev/null +++ b/lib/rest/supersim/v1/sim/billingPeriod.d.ts @@ -0,0 +1,249 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../../base/Page'); +import Response = require('../../../../http/response'); +import V1 = require('../../V1'); +import { SerializableClass } from '../../../../interfaces'; + +type BillingPeriodBpType = 'ready'|'active'; + +/** + * Initialize the BillingPeriodList + * + * @param version - Version of the resource + * @param simSid - The SID of the Super SIM the Billing Period belongs to + */ +declare function BillingPeriodList(version: V1, simSid: string): BillingPeriodListInstance; + +interface BillingPeriodListInstance { + /** + * Streams BillingPeriodInstance 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. + * + * @param callback - Function to process each record + */ + each(callback?: (item: BillingPeriodInstance, done: (err?: Error) => void) => void): void; + /** + * Streams BillingPeriodInstance 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. + * + * @param opts - Options for request + * @param callback - Function to process each record + */ + each(opts?: BillingPeriodListInstanceEachOptions, callback?: (item: BillingPeriodInstance, done: (err?: Error) => void) => void): void; + /** + * Retrieve a single target page of BillingPeriodInstance 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. + * + * @param callback - Callback to handle list of records + */ + getPage(callback?: (error: Error | null, items: BillingPeriodPage) => any): Promise; + /** + * Retrieve a single target page of BillingPeriodInstance 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. + * + * @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: BillingPeriodPage) => any): Promise; + /** + * Lists BillingPeriodInstance 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: BillingPeriodInstance[]) => any): Promise; + /** + * Lists BillingPeriodInstance 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 opts - Options for request + * @param callback - Callback to handle list of records + */ + list(opts?: BillingPeriodListInstanceOptions, callback?: (error: Error | null, items: BillingPeriodInstance[]) => any): Promise; + /** + * Retrieve a single page of BillingPeriodInstance 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. + * + * @param callback - Callback to handle list of records + */ + page(callback?: (error: Error | null, items: BillingPeriodPage) => any): Promise; + /** + * Retrieve a single page of BillingPeriodInstance 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. + * + * @param opts - Options for request + * @param callback - Callback to handle list of records + */ + page(opts?: BillingPeriodListInstancePageOptions, callback?: (error: Error | null, items: BillingPeriodPage) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to each + * + * @property callback - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @property done - Function to be called upon completion of streaming + * @property limit - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface BillingPeriodListInstanceEachOptions { + callback?: (item: BillingPeriodInstance, done: (err?: Error) => void) => void; + done?: Function; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to list + * + * @property limit - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface BillingPeriodListInstanceOptions { + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to page + * + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + */ +interface BillingPeriodListInstancePageOptions { + pageNumber?: number; + pageSize?: number; + pageToken?: string; +} + +interface BillingPeriodPayload extends BillingPeriodResource, Page.TwilioResponsePayload { +} + +interface BillingPeriodResource { + account_sid: string; + date_created: Date; + date_updated: Date; + end_time: Date; + period_type: BillingPeriodBpType; + sid: string; + sim_sid: string; + start_time: Date; +} + +interface BillingPeriodSolution { + simSid?: string; +} + + +declare class BillingPeriodInstance extends SerializableClass { + /** + * Initialize the BillingPeriodContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param simSid - The SID of the Super SIM the Billing Period belongs to + */ + constructor(version: V1, payload: BillingPeriodPayload, simSid: string); + + accountSid: string; + dateCreated: Date; + dateUpdated: Date; + endTime: Date; + periodType: BillingPeriodBpType; + sid: string; + simSid: string; + startTime: Date; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + +declare class BillingPeriodPage extends Page { + /** + * Initialize the BillingPeriodPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: BillingPeriodSolution); + + /** + * Build an instance of BillingPeriodInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: BillingPeriodPayload): BillingPeriodInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { BillingPeriodBpType, BillingPeriodInstance, BillingPeriodList, BillingPeriodListInstance, BillingPeriodListInstanceEachOptions, BillingPeriodListInstanceOptions, BillingPeriodListInstancePageOptions, BillingPeriodPage, BillingPeriodPayload, BillingPeriodResource, BillingPeriodSolution } diff --git a/lib/rest/supersim/v1/sim/billingPeriod.js b/lib/rest/supersim/v1/sim/billingPeriod.js new file mode 100644 index 0000000000..2a512d1dd6 --- /dev/null +++ b/lib/rest/supersim/v1/sim/billingPeriod.js @@ -0,0 +1,454 @@ +'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 BillingPeriodList; +var BillingPeriodPage; +var BillingPeriodInstance; + +/* jshint ignore:start */ +/** + * Initialize the BillingPeriodList + * + * @constructor Twilio.Supersim.V1.SimContext.BillingPeriodList + * + * @param {Twilio.Supersim.V1} version - Version of the resource + * @param {string} simSid - The SID of the Super SIM the Billing Period belongs to + */ +/* jshint ignore:end */ +BillingPeriodList = function BillingPeriodList(version, simSid) { + /* jshint ignore:start */ + /** + * @function billingPeriods + * @memberof Twilio.Supersim.V1.SimContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Supersim.V1.SimContext.BillingPeriodContext} + */ + /* jshint ignore:end */ + function BillingPeriodListInstance(sid) { + return BillingPeriodListInstance.get(sid); + } + + BillingPeriodListInstance._version = version; + // Path Solution + BillingPeriodListInstance._solution = {simSid: simSid}; + BillingPeriodListInstance._uri = `/Sims/${simSid}/BillingPeriods`; + /* jshint ignore:start */ + /** + * Streams BillingPeriodInstance 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.Supersim.V1.SimContext.BillingPeriodList# + * + * @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 */ + BillingPeriodListInstance.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)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists BillingPeriodInstance 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.Supersim.V1.SimContext.BillingPeriodList# + * + * @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 */ + BillingPeriodListInstance.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 BillingPeriodInstance 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.Supersim.V1.SimContext.BillingPeriodList# + * + * @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 */ + BillingPeriodListInstance.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 BillingPeriodPage(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 BillingPeriodInstance 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.Supersim.V1.SimContext.BillingPeriodList# + * + * @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 */ + BillingPeriodListInstance.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 BillingPeriodPage(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 */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodList# + * + * @returns Object + */ + /* jshint ignore:end */ + BillingPeriodListInstance.toJSON = function toJSON() { + return this._solution; + }; + + BillingPeriodListInstance[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); + }; + + return BillingPeriodListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the BillingPeriodPage + * + * @constructor Twilio.Supersim.V1.SimContext.BillingPeriodPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {BillingPeriodSolution} solution - Path solution + * + * @returns BillingPeriodPage + */ +/* jshint ignore:end */ +BillingPeriodPage = function BillingPeriodPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(BillingPeriodPage.prototype, Page.prototype); +BillingPeriodPage.prototype.constructor = BillingPeriodPage; + +/* jshint ignore:start */ +/** + * Build an instance of BillingPeriodInstance + * + * @function getInstance + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodPage# + * + * @param {BillingPeriodPayload} payload - Payload response from the API + * + * @returns BillingPeriodInstance + */ +/* jshint ignore:end */ +BillingPeriodPage.prototype.getInstance = function getInstance(payload) { + return new BillingPeriodInstance(this._version, payload, this._solution.simSid); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodPage# + * + * @returns Object + */ +/* jshint ignore:end */ +BillingPeriodPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +BillingPeriodPage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the BillingPeriodContext + * + * @constructor Twilio.Supersim.V1.SimContext.BillingPeriodInstance + * + * @property {string} sid - The SID of the Billing Period + * @property {string} accountSid - The SID of the Account the Super SIM belongs to + * @property {string} simSid - + * The SID of the Super SIM the Billing Period belongs to + * @property {Date} startTime - The start time of the Billing Period + * @property {Date} endTime - The end time of the Billing Period + * @property {billing_period.bp_type} periodType - The type of the Billing Period + * @property {Date} dateCreated - + * The ISO 8601 date and time in GMT when the resource was created + * @property {Date} dateUpdated - + * The ISO 8601 date and time in GMT when the resource was last updated + * + * @param {V1} version - Version of the resource + * @param {BillingPeriodPayload} payload - The instance payload + * @param {sid} simSid - The SID of the Super SIM the Billing Period belongs to + */ +/* jshint ignore:end */ +BillingPeriodInstance = function BillingPeriodInstance(version, payload, simSid) + { + this._version = version; + + // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.simSid = payload.sim_sid; // jshint ignore:line + this.startTime = deserialize.iso8601DateTime(payload.start_time); // jshint ignore:line + this.endTime = deserialize.iso8601DateTime(payload.end_time); // jshint ignore:line + this.periodType = payload.period_type; // 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 = {simSid: simSid, }; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +BillingPeriodInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +BillingPeriodInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + BillingPeriodList: BillingPeriodList, + BillingPeriodPage: BillingPeriodPage, + BillingPeriodInstance: BillingPeriodInstance +}; diff --git a/lib/twiml/VoiceResponse.d.ts b/lib/twiml/VoiceResponse.d.ts index 923e04c729..9c9d0dc8e4 100644 --- a/lib/twiml/VoiceResponse.d.ts +++ b/lib/twiml/VoiceResponse.d.ts @@ -193,7 +193,7 @@ declare namespace VoiceResponse { type ConferenceBeep = 'true'|'false'|'onEnter'|'onExit'; - type ConferenceEvent = 'start'|'end'|'join'|'leave'|'mute'|'hold'|'speaker'|'announcement'; + type ConferenceEvent = 'start'|'end'|'join'|'leave'|'mute'|'hold'|'modify'|'speaker'|'announcement'; type ConferenceJitterBufferSize = 'large'|'medium'|'small'|'off'; diff --git a/spec/integration/rest/api/v2010/account/message.spec.js b/spec/integration/rest/api/v2010/account/message.spec.js index 4ccfb606a2..7bbeab25b6 100644 --- a/spec/integration/rest/api/v2010/account/message.spec.js +++ b/spec/integration/rest/api/v2010/account/message.spec.js @@ -787,9 +787,8 @@ describe('Message', function() { function(done) { holodeck.mock(new Response(500, {})); - var opts = {body: 'body'}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(opts); + .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); promise.then(function() { throw new Error('failed'); }, function(error) { @@ -801,11 +800,9 @@ describe('Message', function() { var sid = 'MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; var url = `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages/${sid}.json`; - var values = {Body: 'body', }; holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url, - data: values + method: 'POST', + url: url })); } ); @@ -839,9 +836,48 @@ describe('Message', function() { holodeck.mock(new Response(200, body)); - var opts = {body: 'body'}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(opts); + .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid cancel_message response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'api_version': '2010-04-01', + 'body': '', + 'date_created': 'Fri, 24 May 2019 17:18:27 +0000', + 'date_sent': 'Fri, 24 May 2019 17:18:28 +0000', + 'date_updated': 'Fri, 24 May 2019 17:18:28 +0000', + 'direction': 'outbound-api', + 'error_code': 30007, + 'error_message': 'Carrier violation', + 'from': '+12019235161', + 'messaging_service_sid': 'MGdeadbeefdeadbeefdeadbeefdeadbeef', + 'num_media': '0', + 'num_segments': '1', + 'price': '-0.00750', + 'price_unit': 'USD', + 'sid': 'SMb7c0a2ce80504485a6f653a7110836f5', + 'status': 'canceled', + 'subresource_uris': { + 'media': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Media.json', + 'feedback': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Feedback.json' + }, + 'to': '+18182008801', + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5.json' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); promise.then(function(response) { expect(response).toBeDefined(); done(); diff --git a/spec/integration/rest/conversations/v1/conversation.spec.js b/spec/integration/rest/conversations/v1/conversation.spec.js index 7ec1baef06..882bc4a4a0 100644 --- a/spec/integration/rest/conversations/v1/conversation.spec.js +++ b/spec/integration/rest/conversations/v1/conversation.spec.js @@ -69,6 +69,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -102,6 +103,7 @@ describe('Conversation', function() { 'date_updated': '2020-07-01T22:18:37Z', 'state': 'active', 'timers': {}, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -162,6 +164,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -258,6 +261,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -296,6 +300,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -337,6 +342,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -383,6 +389,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -444,6 +451,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', diff --git a/spec/integration/rest/conversations/v1/service/conversation.spec.js b/spec/integration/rest/conversations/v1/service/conversation.spec.js index 102ee45453..0b0770a6fb 100644 --- a/spec/integration/rest/conversations/v1/service/conversation.spec.js +++ b/spec/integration/rest/conversations/v1/service/conversation.spec.js @@ -71,6 +71,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -105,6 +106,7 @@ describe('Conversation', function() { 'date_updated': '2020-07-01T22:18:37Z', 'state': 'active', 'timers': {}, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -168,6 +170,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -270,6 +273,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -309,6 +313,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -351,6 +356,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -398,6 +404,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -462,6 +469,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', diff --git a/spec/integration/rest/supersim/v1/sim.spec.js b/spec/integration/rest/supersim/v1/sim.spec.js index 455d8f63c9..8e00859cac 100644 --- a/spec/integration/rest/supersim/v1/sim.spec.js +++ b/spec/integration/rest/supersim/v1/sim.spec.js @@ -63,7 +63,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(201, body)); @@ -110,7 +113,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -156,7 +162,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -181,7 +190,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -206,7 +218,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -231,7 +246,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -256,7 +274,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -292,7 +313,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -322,7 +346,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -357,7 +384,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -433,7 +463,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -471,7 +504,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -509,7 +545,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; diff --git a/spec/integration/rest/supersim/v1/sim/billingPeriod.spec.js b/spec/integration/rest/supersim/v1/sim/billingPeriod.spec.js new file mode 100644 index 0000000000..68d79899f3 --- /dev/null +++ b/spec/integration/rest/supersim/v1/sim/billingPeriod.spec.js @@ -0,0 +1,252 @@ +'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('BillingPeriod', 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 = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'active', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'active', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://supersim.twilio.com/v1/Sims/${simSid}/BillingPeriods', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'active', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var simSid = 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://supersim.twilio.com/v1/Sims/${simSid}/BillingPeriods`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_empty response', + function(done) { + var body = { + 'billing_periods': [], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full_active_period response', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'active', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full_ready_period response', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'ready', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/video/v1/room.spec.js b/spec/integration/rest/video/v1/room.spec.js index dc4a9a9908..e39cc8b6a4 100644 --- a/spec/integration/rest/video/v1/room.spec.js +++ b/spec/integration/rest/video/v1/room.spec.js @@ -65,7 +65,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 0, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -126,7 +126,7 @@ describe('Room', function() { 'max_participants': 10, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -167,7 +167,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 0, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -208,7 +208,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 170, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -249,7 +249,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 170, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -290,7 +290,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 16, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -597,7 +597,7 @@ describe('Room', function() { 'max_participants': 10, 'max_concurrent_published_tracks': 10, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' From 1af382d2cde4853b2e2f8b6886d6878f82047a25 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 30 Jun 2021 20:04:40 +0000 Subject: [PATCH 25/30] Release 3.65.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9b2f2bfdd..d75de5db4e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.64.0", + "version": "3.65.0", "author": "API Team ", "contributors": [ { From 596622722ee17f13c3a2dead133ab498b7f3f8c4 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 14 Jul 2021 18:36:15 +0000 Subject: [PATCH 26/30] [Librarian] Regenerated @ 7987bc34448d66e36aaa4f7174e25f3d57ccccef --- CHANGES.md | 10 + lib/rest/conversations/v1/service/user.d.ts | 9 + lib/rest/conversations/v1/service/user.js | 38 + .../v1/service/user/userConversation.d.ts | 367 +++++++++ .../v1/service/user/userConversation.js | 766 ++++++++++++++++++ lib/rest/conversations/v1/user.d.ts | 9 + lib/rest/conversations/v1/user.js | 34 + .../v1/user/userConversation.d.ts | 363 +++++++++ .../conversations/v1/user/userConversation.js | 735 +++++++++++++++++ lib/rest/messaging/v1/brandRegistration.d.ts | 2 + lib/rest/messaging/v1/brandRegistration.js | 2 + .../conversations/v1/service/user.spec.js | 55 +- .../v1/service/user/userConversation.spec.js | 461 +++++++++++ .../rest/conversations/v1/user.spec.js | 55 +- .../v1/user/userConversation.spec.js | 445 ++++++++++ .../messaging/v1/brandRegistration.spec.js | 18 +- .../notify/v1/service/notification.spec.js | 4 +- spec/integration/rest/wireless/v1/sim.spec.js | 80 +- 18 files changed, 3383 insertions(+), 70 deletions(-) create mode 100644 lib/rest/conversations/v1/service/user/userConversation.d.ts create mode 100644 lib/rest/conversations/v1/service/user/userConversation.js create mode 100644 lib/rest/conversations/v1/user/userConversation.d.ts create mode 100644 lib/rest/conversations/v1/user/userConversation.js create mode 100644 spec/integration/rest/conversations/v1/service/user/userConversation.spec.js create mode 100644 spec/integration/rest/conversations/v1/user/userConversation.spec.js diff --git a/CHANGES.md b/CHANGES.md index 21fbaae980..6e755f3e08 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,16 @@ twilio-node changelog ===================== +[2021-07-14] Version 3.66.0 +--------------------------- +**Conversations** +- Changed `last_read_message_index` and `unread_messages_count` type in User Conversation's resource **(breaking change)** +- Expose UserConversations resource + +**Messaging** +- Add brand_score field to brand registration responses + + [2021-06-30] Version 3.65.0 --------------------------- **Conversations** diff --git a/lib/rest/conversations/v1/service/user.d.ts b/lib/rest/conversations/v1/service/user.d.ts index 54c32bea1d..afd43ec8ed 100644 --- a/lib/rest/conversations/v1/service/user.d.ts +++ b/lib/rest/conversations/v1/service/user.d.ts @@ -9,6 +9,8 @@ import Page = require('../../../../base/Page'); import Response = require('../../../../http/response'); import V1 = require('../../V1'); import { SerializableClass } from '../../../../interfaces'; +import { UserConversationList } from './user/userConversation'; +import { UserConversationListInstance } from './user/userConversation'; type UserWebhookEnabledType = 'true'|'false'; @@ -251,6 +253,7 @@ interface UserResource { identity: string; is_notifiable: boolean; is_online: boolean; + links: string; role_sid: string; sid: string; url: string; @@ -307,6 +310,7 @@ declare class UserContext { * @param callback - Callback to handle processed record */ update(opts?: UserInstanceUpdateOptions, callback?: (error: Error | null, items: UserInstance) => any): Promise; + userConversations: UserConversationListInstance; } @@ -337,6 +341,7 @@ declare class UserInstance extends SerializableClass { identity: string; isNotifiable: boolean; isOnline: boolean; + links: string; /** * remove a UserInstance * @@ -370,6 +375,10 @@ declare class UserInstance extends SerializableClass { */ update(opts?: UserInstanceUpdateOptions, callback?: (error: Error | null, items: UserInstance) => any): Promise; url: string; + /** + * Access the userConversations + */ + userConversations(): UserConversationListInstance; } diff --git a/lib/rest/conversations/v1/service/user.js b/lib/rest/conversations/v1/service/user.js index 3fd86795a1..a3bae9361e 100644 --- a/lib/rest/conversations/v1/service/user.js +++ b/lib/rest/conversations/v1/service/user.js @@ -13,6 +13,8 @@ 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 UserConversationList = require( + './user/userConversation').UserConversationList; var deserialize = require( '../../../../base/deserialize'); /* jshint ignore:line */ var values = require('../../../../base/values'); /* jshint ignore:line */ @@ -483,6 +485,7 @@ UserPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {Date} dateUpdated - * The ISO 8601 date and time in GMT when the resource was last updated * @property {string} url - An absolute URL for this user. + * @property {string} links - The links * * @param {V1} version - Version of the resource * @param {UserPayload} payload - The instance payload @@ -507,6 +510,7 @@ UserInstance = function UserInstance(version, payload, chatServiceSid, sid) { 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 + this.links = payload.links; // jshint ignore:line // Context this._context = undefined; @@ -584,6 +588,20 @@ UserInstance.prototype.fetch = function fetch(callback) { return this._proxy.fetch(callback); }; +/* jshint ignore:start */ +/** + * Access the userConversations + * + * @function userConversations + * @memberof Twilio.Conversations.V1.ServiceContext.UserInstance# + * + * @returns {Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationList} + */ +/* jshint ignore:end */ +UserInstance.prototype.userConversations = function userConversations() { + return this._proxy.userConversations; +}; + /* jshint ignore:start */ /** * Provide a user-friendly representation @@ -615,6 +633,9 @@ UserInstance.prototype[util.inspect.custom] = function inspect(depth, options) { * * @constructor Twilio.Conversations.V1.ServiceContext.UserContext * + * @property {Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationList} userConversations - + * userConversations resource + * * @param {V1} version - Version of the resource * @param {sid} chatServiceSid - * The SID of the Conversation Service to fetch the resource from @@ -627,6 +648,9 @@ UserContext = function UserContext(version, chatServiceSid, sid) { // Path Solution this._solution = {chatServiceSid: chatServiceSid, sid: sid, }; this._uri = `/Services/${chatServiceSid}/Users/${sid}`; + + // Dependents + this._userConversations = undefined; }; /* jshint ignore:start */ @@ -765,6 +789,20 @@ UserContext.prototype.fetch = function fetch(callback) { return deferred.promise; }; +Object.defineProperty(UserContext.prototype, + 'userConversations', { + get: function() { + if (!this._userConversations) { + this._userConversations = new UserConversationList( + this._version, + this._solution.chatServiceSid, + this._solution.sid + ); + } + return this._userConversations; + } +}); + /* jshint ignore:start */ /** * Provide a user-friendly representation diff --git a/lib/rest/conversations/v1/service/user/userConversation.d.ts b/lib/rest/conversations/v1/service/user/userConversation.d.ts new file mode 100644 index 0000000000..26b7730722 --- /dev/null +++ b/lib/rest/conversations/v1/service/user/userConversation.d.ts @@ -0,0 +1,367 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../../../base/Page'); +import Response = require('../../../../../http/response'); +import V1 = require('../../../V1'); +import { SerializableClass } from '../../../../../interfaces'; + +type UserConversationNotificationLevel = 'default'|'muted'; + +type UserConversationState = 'inactive'|'active'|'closed'; + +/** + * Initialize the UserConversationList + * + * @param version - Version of the resource + * @param chatServiceSid - The unique ID of the Conversation Service this conversation belongs to. + * @param userSid - The unique ID for the User. + */ +declare function UserConversationList(version: V1, chatServiceSid: string, userSid: string): UserConversationListInstance; + +/** + * Options to pass to update + * + * @property lastReadMessageIndex - The index of the last read Message. + * @property lastReadTimestamp - The date of the last message read in conversation by the user. + * @property notificationLevel - The Notification Level of this User Conversation. + */ +interface UserConversationInstanceUpdateOptions { + lastReadMessageIndex?: number; + lastReadTimestamp?: Date; + notificationLevel?: UserConversationNotificationLevel; +} + +interface UserConversationListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): UserConversationContext; + /** + * Streams UserConversationInstance 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. + * + * @param callback - Function to process each record + */ + each(callback?: (item: UserConversationInstance, done: (err?: Error) => void) => void): void; + /** + * Streams UserConversationInstance 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. + * + * @param opts - Options for request + * @param callback - Function to process each record + */ + each(opts?: UserConversationListInstanceEachOptions, callback?: (item: UserConversationInstance, done: (err?: Error) => void) => void): void; + /** + * Constructs a user_conversation + * + * @param conversationSid - The unique SID identifier of the Conversation. + */ + get(conversationSid: string): UserConversationContext; + /** + * Retrieve a single target page of UserConversationInstance 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. + * + * @param callback - Callback to handle list of records + */ + getPage(callback?: (error: Error | null, items: UserConversationPage) => any): Promise; + /** + * Retrieve a single target page of UserConversationInstance 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. + * + * @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: UserConversationPage) => any): Promise; + /** + * Lists UserConversationInstance 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: UserConversationInstance[]) => any): Promise; + /** + * Lists UserConversationInstance 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 opts - Options for request + * @param callback - Callback to handle list of records + */ + list(opts?: UserConversationListInstanceOptions, callback?: (error: Error | null, items: UserConversationInstance[]) => any): Promise; + /** + * Retrieve a single page of UserConversationInstance 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. + * + * @param callback - Callback to handle list of records + */ + page(callback?: (error: Error | null, items: UserConversationPage) => any): Promise; + /** + * Retrieve a single page of UserConversationInstance 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. + * + * @param opts - Options for request + * @param callback - Callback to handle list of records + */ + page(opts?: UserConversationListInstancePageOptions, callback?: (error: Error | null, items: UserConversationPage) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to each + * + * @property callback - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @property done - Function to be called upon completion of streaming + * @property limit - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface UserConversationListInstanceEachOptions { + callback?: (item: UserConversationInstance, done: (err?: Error) => void) => void; + done?: Function; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to list + * + * @property limit - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface UserConversationListInstanceOptions { + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to page + * + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + */ +interface UserConversationListInstancePageOptions { + pageNumber?: number; + pageSize?: number; + pageToken?: string; +} + +interface UserConversationPayload extends UserConversationResource, Page.TwilioResponsePayload { +} + +interface UserConversationResource { + account_sid: string; + attributes: string; + chat_service_sid: string; + conversation_sid: string; + conversation_state: UserConversationState; + created_by: string; + date_created: Date; + date_updated: Date; + friendly_name: string; + last_read_message_index: number; + links: string; + notification_level: UserConversationNotificationLevel; + participant_sid: string; + timers: object; + unique_name: string; + unread_messages_count: number; + url: string; + user_sid: string; +} + +interface UserConversationSolution { + chatServiceSid?: string; + userSid?: string; +} + + +declare class UserConversationContext { + /** + * Initialize the UserConversationContext + * + * @param version - Version of the resource + * @param chatServiceSid - The SID of the Conversation Service that the resource is associated with. + * @param userSid - The unique SID identifier of the User. + * @param conversationSid - The unique SID identifier of the Conversation. + */ + constructor(version: V1, chatServiceSid: string, userSid: string, conversationSid: string); + + /** + * fetch a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + /** + * remove a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + remove(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + /** + * update a UserConversationInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: UserConversationInstanceUpdateOptions, callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; +} + + +declare class UserConversationInstance extends SerializableClass { + /** + * Initialize the UserConversationContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param chatServiceSid - The unique ID of the Conversation Service this conversation belongs to. + * @param userSid - The unique ID for the User. + * @param conversationSid - The unique SID identifier of the Conversation. + */ + constructor(version: V1, payload: UserConversationPayload, chatServiceSid: string, userSid: string, conversationSid: string); + + private _proxy: UserConversationContext; + accountSid: string; + attributes: string; + chatServiceSid: string; + conversationSid: string; + conversationState: UserConversationState; + createdBy: string; + dateCreated: Date; + dateUpdated: Date; + /** + * fetch a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + friendlyName: string; + lastReadMessageIndex: number; + links: string; + notificationLevel: UserConversationNotificationLevel; + participantSid: string; + /** + * remove a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + remove(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + timers: any; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + uniqueName: string; + unreadMessagesCount: number; + /** + * update a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + /** + * update a UserConversationInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: UserConversationInstanceUpdateOptions, callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + url: string; + userSid: string; +} + + +declare class UserConversationPage extends Page { + /** + * Initialize the UserConversationPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: UserConversationSolution); + + /** + * Build an instance of UserConversationInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: UserConversationPayload): UserConversationInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { UserConversationContext, UserConversationInstance, UserConversationInstanceUpdateOptions, UserConversationList, UserConversationListInstance, UserConversationListInstanceEachOptions, UserConversationListInstanceOptions, UserConversationListInstancePageOptions, UserConversationNotificationLevel, UserConversationPage, UserConversationPayload, UserConversationResource, UserConversationSolution, UserConversationState } diff --git a/lib/rest/conversations/v1/service/user/userConversation.js b/lib/rest/conversations/v1/service/user/userConversation.js new file mode 100644 index 0000000000..2787ef4eca --- /dev/null +++ b/lib/rest/conversations/v1/service/user/userConversation.js @@ -0,0 +1,766 @@ +'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 UserConversationList; +var UserConversationPage; +var UserConversationInstance; +var UserConversationContext; + +/* jshint ignore:start */ +/** + * Initialize the UserConversationList + * + * @constructor Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationList + * + * @param {Twilio.Conversations.V1} version - Version of the resource + * @param {string} chatServiceSid - + * The unique ID of the Conversation Service this conversation belongs to. + * @param {string} userSid - The unique ID for the User. + */ +/* jshint ignore:end */ +UserConversationList = function UserConversationList(version, chatServiceSid, + userSid) { + /* jshint ignore:start */ + /** + * @function userConversations + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationContext} + */ + /* jshint ignore:end */ + function UserConversationListInstance(sid) { + return UserConversationListInstance.get(sid); + } + + UserConversationListInstance._version = version; + // Path Solution + UserConversationListInstance._solution = {chatServiceSid: chatServiceSid, userSid: userSid}; + UserConversationListInstance._uri = `/Services/${chatServiceSid}/Users/${userSid}/Conversations`; + /* jshint ignore:start */ + /** + * Streams UserConversationInstance 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.Conversations.V1.ServiceContext.UserContext.UserConversationList# + * + * @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 */ + UserConversationListInstance.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)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists UserConversationInstance 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.Conversations.V1.ServiceContext.UserContext.UserConversationList# + * + * @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 */ + UserConversationListInstance.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 UserConversationInstance 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.Conversations.V1.ServiceContext.UserContext.UserConversationList# + * + * @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 */ + UserConversationListInstance.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 UserConversationPage(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 UserConversationInstance 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.Conversations.V1.ServiceContext.UserContext.UserConversationList# + * + * @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 */ + UserConversationListInstance.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 UserConversationPage(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 user_conversation + * + * @function get + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationList# + * + * @param {string} conversationSid - The unique SID identifier of the Conversation. + * + * @returns {Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationContext} + */ + /* jshint ignore:end */ + UserConversationListInstance.get = function get(conversationSid) { + return new UserConversationContext( + this._version, + this._solution.chatServiceSid, + this._solution.userSid, + conversationSid + ); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationList# + * + * @returns Object + */ + /* jshint ignore:end */ + UserConversationListInstance.toJSON = function toJSON() { + return this._solution; + }; + + UserConversationListInstance[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); + }; + + return UserConversationListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserConversationPage + * + * @constructor Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {UserConversationSolution} solution - Path solution + * + * @returns UserConversationPage + */ +/* jshint ignore:end */ +UserConversationPage = function UserConversationPage(version, response, + solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(UserConversationPage.prototype, Page.prototype); +UserConversationPage.prototype.constructor = UserConversationPage; + +/* jshint ignore:start */ +/** + * Build an instance of UserConversationInstance + * + * @function getInstance + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationPage# + * + * @param {UserConversationPayload} payload - Payload response from the API + * + * @returns UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationPage.prototype.getInstance = function getInstance(payload) { + return new UserConversationInstance( + this._version, + payload, + this._solution.chatServiceSid, + this._solution.userSid + ); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationPage# + * + * @returns Object + */ +/* jshint ignore:end */ +UserConversationPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UserConversationPage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserConversationContext + * + * @constructor Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationInstance + * + * @property {string} accountSid - + * The unique ID of the Account responsible for this conversation. + * @property {string} chatServiceSid - + * The unique ID of the Conversation Service this conversation belongs to. + * @property {string} conversationSid - + * The unique ID of the Conversation for this message. + * @property {number} unreadMessagesCount - + * The number of unread Messages in the Conversation. + * @property {number} lastReadMessageIndex - The index of the last read Message . + * @property {string} participantSid - Participant Sid. + * @property {string} userSid - The unique ID for the User. + * @property {string} friendlyName - The human-readable name of this conversation. + * @property {user_conversation.state} conversationState - + * The current state of this User Conversation + * @property {object} timers - Timer date values for this conversation. + * @property {string} attributes - + * An optional string metadata field you can use to store any data you wish. + * @property {Date} dateCreated - The date that this conversation was created. + * @property {Date} dateUpdated - The date that this conversation was last updated. + * @property {string} createdBy - Creator of this conversation. + * @property {user_conversation.notification_level} notificationLevel - + * The Notification Level of this User Conversation. + * @property {string} uniqueName - + * An application-defined string that uniquely identifies the resource + * @property {string} url - The url + * @property {string} links - + * Absolute URLs to access the participant and conversation of this user conversation. + * + * @param {V1} version - Version of the resource + * @param {UserConversationPayload} payload - The instance payload + * @param {sid} chatServiceSid - + * The unique ID of the Conversation Service this conversation belongs to. + * @param {sid} userSid - The unique ID for the User. + * @param {sid_like} conversationSid - + * The unique SID identifier of the Conversation. + */ +/* jshint ignore:end */ +UserConversationInstance = function UserConversationInstance(version, payload, + chatServiceSid, userSid, conversationSid) { + this._version = version; + + // Marshaled Properties + this.accountSid = payload.account_sid; // jshint ignore:line + this.chatServiceSid = payload.chat_service_sid; // jshint ignore:line + this.conversationSid = payload.conversation_sid; // jshint ignore:line + this.unreadMessagesCount = deserialize.integer(payload.unread_messages_count); // jshint ignore:line + this.lastReadMessageIndex = deserialize.integer(payload.last_read_message_index); // jshint ignore:line + this.participantSid = payload.participant_sid; // jshint ignore:line + this.userSid = payload.user_sid; // jshint ignore:line + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.conversationState = payload.conversation_state; // jshint ignore:line + this.timers = payload.timers; // jshint ignore:line + this.attributes = payload.attributes; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + this.createdBy = payload.created_by; // jshint ignore:line + this.notificationLevel = payload.notification_level; // jshint ignore:line + this.uniqueName = payload.unique_name; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + this.links = payload.links; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = { + chatServiceSid: chatServiceSid, + userSid: userSid, + conversationSid: conversationSid || this.conversationSid, + }; +}; + +Object.defineProperty(UserConversationInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new UserConversationContext( + this._version, + this._solution.chatServiceSid, + this._solution.userSid, + this._solution.conversationSid + ); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * update a UserConversationInstance + * + * @function update + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationInstance# + * + * @param {object} [opts] - Options for request + * @param {user_conversation.notification_level} [opts.notificationLevel] - + * The Notification Level of this User Conversation. + * @param {Date} [opts.lastReadTimestamp] - + * The date of the last message read in conversation by the user. + * @param {number} [opts.lastReadMessageIndex] - + * The index of the last read Message. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationInstance.prototype.update = function update(opts, callback) { + return this._proxy.update(opts, callback); +}; + +/* jshint ignore:start */ +/** + * remove a UserConversationInstance + * + * @function remove + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationInstance.prototype.remove = function remove(callback) { + return this._proxy.remove(callback); +}; + +/* jshint ignore:start */ +/** + * fetch a UserConversationInstance + * + * @function fetch + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +UserConversationInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UserConversationInstance.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserConversationContext + * + * @constructor Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationContext + * + * @param {V1} version - Version of the resource + * @param {sid} chatServiceSid - + * The SID of the Conversation Service that the resource is associated with. + * @param {sid_like} userSid - The unique SID identifier of the User. + * @param {sid_like} conversationSid - + * The unique SID identifier of the Conversation. + */ +/* jshint ignore:end */ +UserConversationContext = function UserConversationContext(version, + chatServiceSid, + userSid, + conversationSid) { + this._version = version; + + // Path Solution + this._solution = { + chatServiceSid: chatServiceSid, + userSid: userSid, + conversationSid: conversationSid, + }; + this._uri = `/Services/${chatServiceSid}/Users/${userSid}/Conversations/${conversationSid}`; +}; + +/* jshint ignore:start */ +/** + * update a UserConversationInstance + * + * @function update + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationContext# + * + * @param {object} [opts] - Options for request + * @param {user_conversation.notification_level} [opts.notificationLevel] - + * The Notification Level of this User Conversation. + * @param {Date} [opts.lastReadTimestamp] - + * The date of the last message read in conversation by the user. + * @param {number} [opts.lastReadMessageIndex] - + * The index of the last read Message. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationContext.prototype.update = function update(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'NotificationLevel': _.get(opts, 'notificationLevel'), + 'LastReadTimestamp': serialize.iso8601DateTime(_.get(opts, 'lastReadTimestamp')), + 'LastReadMessageIndex': _.get(opts, 'lastReadMessageIndex') + }); + + var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new UserConversationInstance( + this._version, + payload, + this._solution.chatServiceSid, + this._solution.userSid, + this._solution.conversationSid + )); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * remove a UserConversationInstance + * + * @function remove + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationContext.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 */ +/** + * fetch a UserConversationInstance + * + * @function fetch + * @memberof Twilio.Conversations.V1.ServiceContext.UserContext.UserConversationContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationContext.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 UserConversationInstance( + this._version, + payload, + this._solution.chatServiceSid, + this._solution.userSid, + this._solution.conversationSid + )); + }.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.Conversations.V1.ServiceContext.UserContext.UserConversationContext# + * + * @returns Object + */ +/* jshint ignore:end */ +UserConversationContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +UserConversationContext.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + UserConversationList: UserConversationList, + UserConversationPage: UserConversationPage, + UserConversationInstance: UserConversationInstance, + UserConversationContext: UserConversationContext +}; diff --git a/lib/rest/conversations/v1/user.d.ts b/lib/rest/conversations/v1/user.d.ts index 513f6226fa..058597dedb 100644 --- a/lib/rest/conversations/v1/user.d.ts +++ b/lib/rest/conversations/v1/user.d.ts @@ -9,6 +9,8 @@ import Page = require('../../../base/Page'); import Response = require('../../../http/response'); import V1 = require('../V1'); import { SerializableClass } from '../../../interfaces'; +import { UserConversationList } from './user/userConversation'; +import { UserConversationListInstance } from './user/userConversation'; type UserWebhookEnabledType = 'true'|'false'; @@ -250,6 +252,7 @@ interface UserResource { identity: string; is_notifiable: boolean; is_online: boolean; + links: string; role_sid: string; sid: string; url: string; @@ -304,6 +307,7 @@ declare class UserContext { * @param callback - Callback to handle processed record */ update(opts?: UserInstanceUpdateOptions, callback?: (error: Error | null, items: UserInstance) => any): Promise; + userConversations: UserConversationListInstance; } @@ -333,6 +337,7 @@ declare class UserInstance extends SerializableClass { identity: string; isNotifiable: boolean; isOnline: boolean; + links: string; /** * remove a UserInstance * @@ -366,6 +371,10 @@ declare class UserInstance extends SerializableClass { */ update(opts?: UserInstanceUpdateOptions, callback?: (error: Error | null, items: UserInstance) => any): Promise; url: string; + /** + * Access the userConversations + */ + userConversations(): UserConversationListInstance; } diff --git a/lib/rest/conversations/v1/user.js b/lib/rest/conversations/v1/user.js index 2b2acc7c06..3862f8b28d 100644 --- a/lib/rest/conversations/v1/user.js +++ b/lib/rest/conversations/v1/user.js @@ -13,6 +13,8 @@ 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 UserConversationList = require( + './user/userConversation').UserConversationList; var deserialize = require( '../../../base/deserialize'); /* jshint ignore:line */ var values = require('../../../base/values'); /* jshint ignore:line */ @@ -476,6 +478,7 @@ UserPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {Date} dateUpdated - * The ISO 8601 date and time in GMT when the resource was last updated * @property {string} url - An absolute URL for this user. + * @property {string} links - The links * * @param {V1} version - Version of the resource * @param {UserPayload} payload - The instance payload @@ -498,6 +501,7 @@ UserInstance = function UserInstance(version, payload, sid) { 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 + this.links = payload.links; // jshint ignore:line // Context this._context = undefined; @@ -575,6 +579,20 @@ UserInstance.prototype.fetch = function fetch(callback) { return this._proxy.fetch(callback); }; +/* jshint ignore:start */ +/** + * Access the userConversations + * + * @function userConversations + * @memberof Twilio.Conversations.V1.UserInstance# + * + * @returns {Twilio.Conversations.V1.UserContext.UserConversationList} + */ +/* jshint ignore:end */ +UserInstance.prototype.userConversations = function userConversations() { + return this._proxy.userConversations; +}; + /* jshint ignore:start */ /** * Provide a user-friendly representation @@ -606,6 +624,9 @@ UserInstance.prototype[util.inspect.custom] = function inspect(depth, options) { * * @constructor Twilio.Conversations.V1.UserContext * + * @property {Twilio.Conversations.V1.UserContext.UserConversationList} userConversations - + * userConversations resource + * * @param {V1} version - Version of the resource * @param {sid_like} sid - The SID of the User resource to fetch */ @@ -616,6 +637,9 @@ UserContext = function UserContext(version, sid) { // Path Solution this._solution = {sid: sid, }; this._uri = `/Users/${sid}`; + + // Dependents + this._userConversations = undefined; }; /* jshint ignore:start */ @@ -744,6 +768,16 @@ UserContext.prototype.fetch = function fetch(callback) { return deferred.promise; }; +Object.defineProperty(UserContext.prototype, + 'userConversations', { + get: function() { + if (!this._userConversations) { + this._userConversations = new UserConversationList(this._version, this._solution.sid); + } + return this._userConversations; + } +}); + /* jshint ignore:start */ /** * Provide a user-friendly representation diff --git a/lib/rest/conversations/v1/user/userConversation.d.ts b/lib/rest/conversations/v1/user/userConversation.d.ts new file mode 100644 index 0000000000..7da32382bc --- /dev/null +++ b/lib/rest/conversations/v1/user/userConversation.d.ts @@ -0,0 +1,363 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../../base/Page'); +import Response = require('../../../../http/response'); +import V1 = require('../../V1'); +import { SerializableClass } from '../../../../interfaces'; + +type UserConversationNotificationLevel = 'default'|'muted'; + +type UserConversationState = 'inactive'|'active'|'closed'; + +/** + * Initialize the UserConversationList + * + * @param version - Version of the resource + * @param userSid - The unique ID for the User. + */ +declare function UserConversationList(version: V1, userSid: string): UserConversationListInstance; + +/** + * Options to pass to update + * + * @property lastReadMessageIndex - The index of the last read Message. + * @property lastReadTimestamp - The date of the last message read in conversation by the user. + * @property notificationLevel - The Notification Level of this User Conversation. + */ +interface UserConversationInstanceUpdateOptions { + lastReadMessageIndex?: number; + lastReadTimestamp?: Date; + notificationLevel?: UserConversationNotificationLevel; +} + +interface UserConversationListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): UserConversationContext; + /** + * Streams UserConversationInstance 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. + * + * @param callback - Function to process each record + */ + each(callback?: (item: UserConversationInstance, done: (err?: Error) => void) => void): void; + /** + * Streams UserConversationInstance 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. + * + * @param opts - Options for request + * @param callback - Function to process each record + */ + each(opts?: UserConversationListInstanceEachOptions, callback?: (item: UserConversationInstance, done: (err?: Error) => void) => void): void; + /** + * Constructs a user_conversation + * + * @param conversationSid - The unique SID identifier of the Conversation. + */ + get(conversationSid: string): UserConversationContext; + /** + * Retrieve a single target page of UserConversationInstance 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. + * + * @param callback - Callback to handle list of records + */ + getPage(callback?: (error: Error | null, items: UserConversationPage) => any): Promise; + /** + * Retrieve a single target page of UserConversationInstance 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. + * + * @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: UserConversationPage) => any): Promise; + /** + * Lists UserConversationInstance 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: UserConversationInstance[]) => any): Promise; + /** + * Lists UserConversationInstance 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 opts - Options for request + * @param callback - Callback to handle list of records + */ + list(opts?: UserConversationListInstanceOptions, callback?: (error: Error | null, items: UserConversationInstance[]) => any): Promise; + /** + * Retrieve a single page of UserConversationInstance 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. + * + * @param callback - Callback to handle list of records + */ + page(callback?: (error: Error | null, items: UserConversationPage) => any): Promise; + /** + * Retrieve a single page of UserConversationInstance 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. + * + * @param opts - Options for request + * @param callback - Callback to handle list of records + */ + page(opts?: UserConversationListInstancePageOptions, callback?: (error: Error | null, items: UserConversationPage) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to each + * + * @property callback - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @property done - Function to be called upon completion of streaming + * @property limit - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface UserConversationListInstanceEachOptions { + callback?: (item: UserConversationInstance, done: (err?: Error) => void) => void; + done?: Function; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to list + * + * @property limit - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface UserConversationListInstanceOptions { + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to page + * + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + */ +interface UserConversationListInstancePageOptions { + pageNumber?: number; + pageSize?: number; + pageToken?: string; +} + +interface UserConversationPayload extends UserConversationResource, Page.TwilioResponsePayload { +} + +interface UserConversationResource { + account_sid: string; + attributes: string; + chat_service_sid: string; + conversation_sid: string; + conversation_state: UserConversationState; + created_by: string; + date_created: Date; + date_updated: Date; + friendly_name: string; + last_read_message_index: number; + links: string; + notification_level: UserConversationNotificationLevel; + participant_sid: string; + timers: object; + unique_name: string; + unread_messages_count: number; + url: string; + user_sid: string; +} + +interface UserConversationSolution { + userSid?: string; +} + + +declare class UserConversationContext { + /** + * Initialize the UserConversationContext + * + * @param version - Version of the resource + * @param userSid - The unique SID identifier of the User. + * @param conversationSid - The unique SID identifier of the Conversation. + */ + constructor(version: V1, userSid: string, conversationSid: string); + + /** + * fetch a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + /** + * remove a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + remove(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + /** + * update a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + /** + * update a UserConversationInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: UserConversationInstanceUpdateOptions, callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; +} + + +declare class UserConversationInstance extends SerializableClass { + /** + * Initialize the UserConversationContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param userSid - The unique ID for the User. + * @param conversationSid - The unique SID identifier of the Conversation. + */ + constructor(version: V1, payload: UserConversationPayload, userSid: string, conversationSid: string); + + private _proxy: UserConversationContext; + accountSid: string; + attributes: string; + chatServiceSid: string; + conversationSid: string; + conversationState: UserConversationState; + createdBy: string; + dateCreated: Date; + dateUpdated: Date; + /** + * fetch a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + friendlyName: string; + lastReadMessageIndex: number; + links: string; + notificationLevel: UserConversationNotificationLevel; + participantSid: string; + /** + * remove a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + remove(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + timers: any; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + uniqueName: string; + unreadMessagesCount: number; + /** + * update a UserConversationInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + /** + * update a UserConversationInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + update(opts?: UserConversationInstanceUpdateOptions, callback?: (error: Error | null, items: UserConversationInstance) => any): Promise; + url: string; + userSid: string; +} + + +declare class UserConversationPage extends Page { + /** + * Initialize the UserConversationPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: UserConversationSolution); + + /** + * Build an instance of UserConversationInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: UserConversationPayload): UserConversationInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { UserConversationContext, UserConversationInstance, UserConversationInstanceUpdateOptions, UserConversationList, UserConversationListInstance, UserConversationListInstanceEachOptions, UserConversationListInstanceOptions, UserConversationListInstancePageOptions, UserConversationNotificationLevel, UserConversationPage, UserConversationPayload, UserConversationResource, UserConversationSolution, UserConversationState } diff --git a/lib/rest/conversations/v1/user/userConversation.js b/lib/rest/conversations/v1/user/userConversation.js new file mode 100644 index 0000000000..b7bea5389a --- /dev/null +++ b/lib/rest/conversations/v1/user/userConversation.js @@ -0,0 +1,735 @@ +'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 UserConversationList; +var UserConversationPage; +var UserConversationInstance; +var UserConversationContext; + +/* jshint ignore:start */ +/** + * Initialize the UserConversationList + * + * @constructor Twilio.Conversations.V1.UserContext.UserConversationList + * + * @param {Twilio.Conversations.V1} version - Version of the resource + * @param {string} userSid - The unique ID for the User. + */ +/* jshint ignore:end */ +UserConversationList = function UserConversationList(version, userSid) { + /* jshint ignore:start */ + /** + * @function userConversations + * @memberof Twilio.Conversations.V1.UserContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Conversations.V1.UserContext.UserConversationContext} + */ + /* jshint ignore:end */ + function UserConversationListInstance(sid) { + return UserConversationListInstance.get(sid); + } + + UserConversationListInstance._version = version; + // Path Solution + UserConversationListInstance._solution = {userSid: userSid}; + UserConversationListInstance._uri = `/Users/${userSid}/Conversations`; + /* jshint ignore:start */ + /** + * Streams UserConversationInstance 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.Conversations.V1.UserContext.UserConversationList# + * + * @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 */ + UserConversationListInstance.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)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists UserConversationInstance 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.Conversations.V1.UserContext.UserConversationList# + * + * @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 */ + UserConversationListInstance.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 UserConversationInstance 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.Conversations.V1.UserContext.UserConversationList# + * + * @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 */ + UserConversationListInstance.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 UserConversationPage(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 UserConversationInstance 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.Conversations.V1.UserContext.UserConversationList# + * + * @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 */ + UserConversationListInstance.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 UserConversationPage(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 user_conversation + * + * @function get + * @memberof Twilio.Conversations.V1.UserContext.UserConversationList# + * + * @param {string} conversationSid - The unique SID identifier of the Conversation. + * + * @returns {Twilio.Conversations.V1.UserContext.UserConversationContext} + */ + /* jshint ignore:end */ + UserConversationListInstance.get = function get(conversationSid) { + return new UserConversationContext(this._version, this._solution.userSid, conversationSid); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.UserContext.UserConversationList# + * + * @returns Object + */ + /* jshint ignore:end */ + UserConversationListInstance.toJSON = function toJSON() { + return this._solution; + }; + + UserConversationListInstance[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); + }; + + return UserConversationListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserConversationPage + * + * @constructor Twilio.Conversations.V1.UserContext.UserConversationPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {UserConversationSolution} solution - Path solution + * + * @returns UserConversationPage + */ +/* jshint ignore:end */ +UserConversationPage = function UserConversationPage(version, response, + solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(UserConversationPage.prototype, Page.prototype); +UserConversationPage.prototype.constructor = UserConversationPage; + +/* jshint ignore:start */ +/** + * Build an instance of UserConversationInstance + * + * @function getInstance + * @memberof Twilio.Conversations.V1.UserContext.UserConversationPage# + * + * @param {UserConversationPayload} payload - Payload response from the API + * + * @returns UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationPage.prototype.getInstance = function getInstance(payload) { + return new UserConversationInstance(this._version, payload, this._solution.userSid); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.UserContext.UserConversationPage# + * + * @returns Object + */ +/* jshint ignore:end */ +UserConversationPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UserConversationPage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserConversationContext + * + * @constructor Twilio.Conversations.V1.UserContext.UserConversationInstance + * + * @property {string} accountSid - + * The unique ID of the Account responsible for this conversation. + * @property {string} chatServiceSid - + * The unique ID of the Conversation Service this conversation belongs to. + * @property {string} conversationSid - + * The unique ID of the Conversation for this message. + * @property {number} unreadMessagesCount - + * The number of unread Messages in the Conversation. + * @property {number} lastReadMessageIndex - The index of the last read Message . + * @property {string} participantSid - Participant Sid. + * @property {string} userSid - The unique ID for the User. + * @property {string} friendlyName - The human-readable name of this conversation. + * @property {user_conversation.state} conversationState - + * The current state of this User Conversation + * @property {object} timers - Timer date values for this conversation. + * @property {string} attributes - + * An optional string metadata field you can use to store any data you wish. + * @property {Date} dateCreated - The date that this conversation was created. + * @property {Date} dateUpdated - The date that this conversation was last updated. + * @property {string} createdBy - Creator of this conversation. + * @property {user_conversation.notification_level} notificationLevel - + * The Notification Level of this User Conversation. + * @property {string} uniqueName - + * An application-defined string that uniquely identifies the resource + * @property {string} url - The url + * @property {string} links - + * Absolute URLs to access the participant and conversation of this user conversation. + * + * @param {V1} version - Version of the resource + * @param {UserConversationPayload} payload - The instance payload + * @param {sid} userSid - The unique ID for the User. + * @param {sid_like} conversationSid - + * The unique SID identifier of the Conversation. + */ +/* jshint ignore:end */ +UserConversationInstance = function UserConversationInstance(version, payload, + userSid, conversationSid) { + this._version = version; + + // Marshaled Properties + this.accountSid = payload.account_sid; // jshint ignore:line + this.chatServiceSid = payload.chat_service_sid; // jshint ignore:line + this.conversationSid = payload.conversation_sid; // jshint ignore:line + this.unreadMessagesCount = deserialize.integer(payload.unread_messages_count); // jshint ignore:line + this.lastReadMessageIndex = deserialize.integer(payload.last_read_message_index); // jshint ignore:line + this.participantSid = payload.participant_sid; // jshint ignore:line + this.userSid = payload.user_sid; // jshint ignore:line + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.conversationState = payload.conversation_state; // jshint ignore:line + this.timers = payload.timers; // jshint ignore:line + this.attributes = payload.attributes; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + this.createdBy = payload.created_by; // jshint ignore:line + this.notificationLevel = payload.notification_level; // jshint ignore:line + this.uniqueName = payload.unique_name; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + this.links = payload.links; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {userSid: userSid, conversationSid: conversationSid || this.conversationSid, }; +}; + +Object.defineProperty(UserConversationInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new UserConversationContext( + this._version, + this._solution.userSid, + this._solution.conversationSid + ); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * update a UserConversationInstance + * + * @function update + * @memberof Twilio.Conversations.V1.UserContext.UserConversationInstance# + * + * @param {object} [opts] - Options for request + * @param {user_conversation.notification_level} [opts.notificationLevel] - + * The Notification Level of this User Conversation. + * @param {Date} [opts.lastReadTimestamp] - + * The date of the last message read in conversation by the user. + * @param {number} [opts.lastReadMessageIndex] - + * The index of the last read Message. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationInstance.prototype.update = function update(opts, callback) { + return this._proxy.update(opts, callback); +}; + +/* jshint ignore:start */ +/** + * remove a UserConversationInstance + * + * @function remove + * @memberof Twilio.Conversations.V1.UserContext.UserConversationInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationInstance.prototype.remove = function remove(callback) { + return this._proxy.remove(callback); +}; + +/* jshint ignore:start */ +/** + * fetch a UserConversationInstance + * + * @function fetch + * @memberof Twilio.Conversations.V1.UserContext.UserConversationInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.UserContext.UserConversationInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +UserConversationInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +UserConversationInstance.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the UserConversationContext + * + * @constructor Twilio.Conversations.V1.UserContext.UserConversationContext + * + * @param {V1} version - Version of the resource + * @param {sid_like} userSid - The unique SID identifier of the User. + * @param {sid_like} conversationSid - + * The unique SID identifier of the Conversation. + */ +/* jshint ignore:end */ +UserConversationContext = function UserConversationContext(version, userSid, + conversationSid) { + this._version = version; + + // Path Solution + this._solution = {userSid: userSid, conversationSid: conversationSid, }; + this._uri = `/Users/${userSid}/Conversations/${conversationSid}`; +}; + +/* jshint ignore:start */ +/** + * update a UserConversationInstance + * + * @function update + * @memberof Twilio.Conversations.V1.UserContext.UserConversationContext# + * + * @param {object} [opts] - Options for request + * @param {user_conversation.notification_level} [opts.notificationLevel] - + * The Notification Level of this User Conversation. + * @param {Date} [opts.lastReadTimestamp] - + * The date of the last message read in conversation by the user. + * @param {number} [opts.lastReadMessageIndex] - + * The index of the last read Message. + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationContext.prototype.update = function update(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'NotificationLevel': _.get(opts, 'notificationLevel'), + 'LastReadTimestamp': serialize.iso8601DateTime(_.get(opts, 'lastReadTimestamp')), + 'LastReadMessageIndex': _.get(opts, 'lastReadMessageIndex') + }); + + var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new UserConversationInstance( + this._version, + payload, + this._solution.userSid, + this._solution.conversationSid + )); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * remove a UserConversationInstance + * + * @function remove + * @memberof Twilio.Conversations.V1.UserContext.UserConversationContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationContext.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 */ +/** + * fetch a UserConversationInstance + * + * @function fetch + * @memberof Twilio.Conversations.V1.UserContext.UserConversationContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed UserConversationInstance + */ +/* jshint ignore:end */ +UserConversationContext.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 UserConversationInstance( + this._version, + payload, + this._solution.userSid, + this._solution.conversationSid + )); + }.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.Conversations.V1.UserContext.UserConversationContext# + * + * @returns Object + */ +/* jshint ignore:end */ +UserConversationContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +UserConversationContext.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + UserConversationList: UserConversationList, + UserConversationPage: UserConversationPage, + UserConversationInstance: UserConversationInstance, + UserConversationContext: UserConversationContext +}; diff --git a/lib/rest/messaging/v1/brandRegistration.d.ts b/lib/rest/messaging/v1/brandRegistration.d.ts index fcd650606a..2b5986b9f0 100644 --- a/lib/rest/messaging/v1/brandRegistration.d.ts +++ b/lib/rest/messaging/v1/brandRegistration.d.ts @@ -216,6 +216,7 @@ interface BrandRegistrationPayload extends BrandRegistrationResource, Page.Twili interface BrandRegistrationResource { a2p_profile_bundle_sid: string; account_sid: string; + brand_score: number; customer_profile_bundle_sid: string; date_created: Date; date_updated: Date; @@ -271,6 +272,7 @@ declare class BrandRegistrationInstance extends SerializableClass { private _proxy: BrandRegistrationContext; a2PProfileBundleSid: string; accountSid: string; + brandScore: number; customerProfileBundleSid: string; dateCreated: Date; dateUpdated: Date; diff --git a/lib/rest/messaging/v1/brandRegistration.js b/lib/rest/messaging/v1/brandRegistration.js index 098bbd5f4a..f6f0430ca3 100644 --- a/lib/rest/messaging/v1/brandRegistration.js +++ b/lib/rest/messaging/v1/brandRegistration.js @@ -474,6 +474,7 @@ BrandRegistrationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {string} tcrId - Campaign Registry (TCR) Brand ID * @property {string} failureReason - A reason why brand registration has failed * @property {string} url - The absolute URL of the Brand Registration + * @property {number} brandScore - Brand score * * @param {V1} version - Version of the resource * @param {BrandRegistrationPayload} payload - The instance payload @@ -495,6 +496,7 @@ BrandRegistrationInstance = function BrandRegistrationInstance(version, payload, this.tcrId = payload.tcr_id; // jshint ignore:line this.failureReason = payload.failure_reason; // jshint ignore:line this.url = payload.url; // jshint ignore:line + this.brandScore = deserialize.integer(payload.brand_score); // jshint ignore:line // Context this._context = undefined; diff --git a/spec/integration/rest/conversations/v1/service/user.spec.js b/spec/integration/rest/conversations/v1/service/user.spec.js index b6d71f2540..fa6db524ea 100644 --- a/spec/integration/rest/conversations/v1/service/user.spec.js +++ b/spec/integration/rest/conversations/v1/service/user.spec.js @@ -75,7 +75,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }; holodeck.mock(new Response(201, body)); @@ -131,7 +134,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }; holodeck.mock(new Response(200, body)); @@ -225,7 +231,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }; holodeck.mock(new Response(200, body)); @@ -265,7 +274,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }, { 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -279,7 +291,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2020-03-24T20:38:21Z', 'date_updated': '2020-03-24T20:38:21Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } } ] }; @@ -313,7 +328,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }, { 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -327,7 +345,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2020-03-24T20:38:21Z', 'date_updated': '2020-03-24T20:38:21Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } } ] }; @@ -366,7 +387,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }, { 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -380,7 +404,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2020-03-24T20:38:21Z', 'date_updated': '2020-03-24T20:38:21Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } } ] }; @@ -436,7 +463,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }, { 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -450,7 +480,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2020-03-24T20:38:21Z', 'date_updated': '2020-03-24T20:38:21Z', - 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } } ] }; diff --git a/spec/integration/rest/conversations/v1/service/user/userConversation.spec.js b/spec/integration/rest/conversations/v1/service/user/userConversation.spec.js new file mode 100644 index 0000000000..24b70811ef --- /dev/null +++ b/spec/integration/rest/conversations/v1/service/user/userConversation.spec.js @@ -0,0 +1,461 @@ +'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('UserConversation', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid update request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var chatServiceSid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var userSid = 'USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var conversationSid = 'CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Services/${chatServiceSid}/Users/${userSid}/Conversations/${conversationSid}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid update response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + 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.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var chatServiceSid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var userSid = 'USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var conversationSid = 'CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Services/${chatServiceSid}/Users/${userSid}/Conversations/${conversationSid}`; + + 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.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); + promise.then(function(response) { + expect(response).toBe(true); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var chatServiceSid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var userSid = 'USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var conversationSid = 'CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Services/${chatServiceSid}/Users/${userSid}/Conversations/${conversationSid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').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 = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://conversations.twilio.com/v1/Services/${chatServiceSid}/Users/${userSid}/Conversations', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var chatServiceSid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var userSid = 'USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Services/${chatServiceSid}/Users/${userSid}/Conversations`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_empty response', + function(done) { + var body = { + 'conversations': [], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.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 = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/conversations/v1/user.spec.js b/spec/integration/rest/conversations/v1/user.spec.js index 3b3b3a4f65..7cf27aa688 100644 --- a/spec/integration/rest/conversations/v1/user.spec.js +++ b/spec/integration/rest/conversations/v1/user.spec.js @@ -73,7 +73,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }; holodeck.mock(new Response(201, body)); @@ -126,7 +129,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }; holodeck.mock(new Response(200, body)); @@ -214,7 +220,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }; holodeck.mock(new Response(200, body)); @@ -253,7 +262,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }, { 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -267,7 +279,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2020-03-24T20:38:21Z', 'date_updated': '2020-03-24T20:38:21Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } } ] }; @@ -300,7 +315,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }, { 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -314,7 +332,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2020-03-24T20:38:21Z', 'date_updated': '2020-03-24T20:38:21Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } } ] }; @@ -352,7 +373,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }, { 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -366,7 +390,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2020-03-24T20:38:21Z', 'date_updated': '2020-03-24T20:38:21Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } } ] }; @@ -419,7 +446,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2019-12-16T22:18:37Z', 'date_updated': '2019-12-16T22:18:38Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } }, { 'sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -433,7 +463,10 @@ describe('User', function() { 'is_notifiable': null, 'date_created': '2020-03-24T20:38:21Z', 'date_updated': '2020-03-24T20:38:21Z', - 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'user_conversations': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations' + } } ] }; diff --git a/spec/integration/rest/conversations/v1/user/userConversation.spec.js b/spec/integration/rest/conversations/v1/user/userConversation.spec.js new file mode 100644 index 0000000000..8a1358e7d2 --- /dev/null +++ b/spec/integration/rest/conversations/v1/user/userConversation.spec.js @@ -0,0 +1,445 @@ +'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('UserConversation', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid update request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var userSid = 'USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var conversationSid = 'CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Users/${userSid}/Conversations/${conversationSid}`; + + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url + })); + } + ); + it('should generate valid update response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + 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.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var userSid = 'USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var conversationSid = 'CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Users/${userSid}/Conversations/${conversationSid}`; + + 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.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove(); + promise.then(function(response) { + expect(response).toBe(true); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var userSid = 'USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var conversationSid = 'CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Users/${userSid}/Conversations/${conversationSid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').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 = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://conversations.twilio.com/v1/Users/${userSid}/Conversations', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var userSid = 'USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Users/${userSid}/Conversations`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_empty response', + function(done) { + var body = { + 'conversations': [], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.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 = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'unread_messages_count': 100, + 'last_read_message_index': 100, + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'attributes': '{}', + 'date_created': '2015-07-30T20:00:00Z', + 'date_updated': '2015-07-30T20:00:00Z', + 'created_by': 'created_by', + 'notification_level': 'default', + 'unique_name': 'unique_name', + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .userConversations.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/messaging/v1/brandRegistration.spec.js b/spec/integration/rest/messaging/v1/brandRegistration.spec.js index 5f830142c2..8677ad6f9a 100644 --- a/spec/integration/rest/messaging/v1/brandRegistration.spec.js +++ b/spec/integration/rest/messaging/v1/brandRegistration.spec.js @@ -62,7 +62,8 @@ describe('BrandRegistration', function() { 'status': 'PENDING', 'tcr_id': 'BXXXXXX', 'failure_reason': 'Registration error', - 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85' + 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85', + 'brand_score': 42 }; holodeck.mock(new Response(200, body)); @@ -99,7 +100,8 @@ describe('BrandRegistration', function() { 'status': 'APPROVED', 'tcr_id': 'BXXXXXX', 'failure_reason': 'Registration error', - 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85' + 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85', + 'brand_score': 42 } ] }; @@ -130,7 +132,8 @@ describe('BrandRegistration', function() { 'status': 'APPROVED', 'tcr_id': 'BXXXXXX', 'failure_reason': 'Registration error', - 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85' + 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85', + 'brand_score': 42 } ] }; @@ -166,7 +169,8 @@ describe('BrandRegistration', function() { 'status': 'APPROVED', 'tcr_id': 'BXXXXXX', 'failure_reason': 'Registration error', - 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85' + 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85', + 'brand_score': 42 } ] }; @@ -217,7 +221,8 @@ describe('BrandRegistration', function() { 'status': 'APPROVED', 'tcr_id': 'BXXXXXX', 'failure_reason': 'Registration error', - 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85' + 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85', + 'brand_score': 42 } ] }; @@ -274,7 +279,8 @@ describe('BrandRegistration', function() { 'status': 'PENDING', 'tcr_id': 'BXXXXXX', 'failure_reason': 'Registration error', - 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85' + 'url': 'https://messaging.twilio.com/v1/a2p/BrandRegistrations/BN0044409f7e067e279523808d267e2d85', + 'brand_score': 42 }; holodeck.mock(new Response(201, body)); diff --git a/spec/integration/rest/notify/v1/service/notification.spec.js b/spec/integration/rest/notify/v1/service/notification.spec.js index 5d555b6f10..fbda2ed5d6 100644 --- a/spec/integration/rest/notify/v1/service/notification.spec.js +++ b/spec/integration/rest/notify/v1/service/notification.spec.js @@ -54,7 +54,7 @@ describe('Notification', function() { it('should generate valid create response', function(done) { var body = { - 'sid': 'NOb8021351170b4e1286adaac3fdd6d082', + 'sid': 'NTb8021351170b4e1286adaac3fdd6d082', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'IS699b53e02da45a1ba9d13b7d7d2766af', 'date_created': '2016-03-24T23:42:28Z', @@ -93,7 +93,7 @@ describe('Notification', function() { it('should generate valid create_direct_notification response', function(done) { var body = { - 'sid': 'NOb8021351170b4e1286adaac3fdd6d082', + 'sid': 'NTb8021351170b4e1286adaac3fdd6d082', 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'service_sid': 'IS699b53e02da45a1ba9d13b7d7d2766af', 'date_created': '2016-03-24T23:42:28Z', diff --git a/spec/integration/rest/wireless/v1/sim.spec.js b/spec/integration/rest/wireless/v1/sim.spec.js index 874ee89f8a..1749cde616 100644 --- a/spec/integration/rest/wireless/v1/sim.spec.js +++ b/spec/integration/rest/wireless/v1/sim.spec.js @@ -55,18 +55,18 @@ describe('Sim', function() { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'unique_name': 'unique_name', - 'commands_callback_method': 'http_method', + 'commands_callback_method': 'POST', 'commands_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', 'friendly_name': 'friendly_name', - 'sms_fallback_method': 'http_method', + 'sms_fallback_method': 'POST', 'sms_fallback_url': 'http://www.example.com', - 'sms_method': 'http_method', + 'sms_method': 'POST', 'sms_url': 'http://www.example.com', - 'voice_fallback_method': 'http_method', + 'voice_fallback_method': 'POST', 'voice_fallback_url': 'http://www.example.com', - 'voice_method': 'http_method', + 'voice_method': 'POST', 'voice_url': 'http://www.example.com', 'links': { 'data_sessions': 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DataSessions', @@ -101,7 +101,7 @@ describe('Sim', function() { { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'unique_name': 'unique_name', - 'commands_callback_method': 'http_method', + 'commands_callback_method': 'POST', 'commands_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -117,13 +117,13 @@ describe('Sim', function() { 'e_id': 'e_id', 'status': 'new', 'reset_status': 'resetting', - 'sms_fallback_method': 'http_method', + 'sms_fallback_method': 'POST', 'sms_fallback_url': 'http://www.example.com', - 'sms_method': 'http_method', + 'sms_method': 'POST', 'sms_url': 'http://www.example.com', - 'voice_fallback_method': 'http_method', + 'voice_fallback_method': 'POST', 'voice_fallback_url': 'http://www.example.com', - 'voice_method': 'http_method', + 'voice_method': 'POST', 'voice_url': 'http://www.example.com', 'url': 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ip_address': '192.168.1.30' @@ -150,7 +150,7 @@ describe('Sim', function() { { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'unique_name': 'unique_name', - 'commands_callback_method': 'http_method', + 'commands_callback_method': 'POST', 'commands_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -166,13 +166,13 @@ describe('Sim', function() { 'e_id': 'e_id', 'status': 'new', 'reset_status': 'resetting', - 'sms_fallback_method': 'http_method', + 'sms_fallback_method': 'POST', 'sms_fallback_url': 'http://www.example.com', - 'sms_method': 'http_method', + 'sms_method': 'POST', 'sms_url': 'http://www.example.com', - 'voice_fallback_method': 'http_method', + 'voice_fallback_method': 'POST', 'voice_fallback_url': 'http://www.example.com', - 'voice_method': 'http_method', + 'voice_method': 'POST', 'voice_url': 'http://www.example.com', 'url': 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ip_address': '192.168.1.30' @@ -204,7 +204,7 @@ describe('Sim', function() { { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'unique_name': 'unique_name', - 'commands_callback_method': 'http_method', + 'commands_callback_method': 'POST', 'commands_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -220,13 +220,13 @@ describe('Sim', function() { 'e_id': 'e_id', 'status': 'new', 'reset_status': 'resetting', - 'sms_fallback_method': 'http_method', + 'sms_fallback_method': 'POST', 'sms_fallback_url': 'http://www.example.com', - 'sms_method': 'http_method', + 'sms_method': 'POST', 'sms_url': 'http://www.example.com', - 'voice_fallback_method': 'http_method', + 'voice_fallback_method': 'POST', 'voice_fallback_url': 'http://www.example.com', - 'voice_method': 'http_method', + 'voice_method': 'POST', 'voice_url': 'http://www.example.com', 'url': 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ip_address': '192.168.1.30' @@ -299,7 +299,7 @@ describe('Sim', function() { { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'unique_name': 'unique_name', - 'commands_callback_method': 'http_method', + 'commands_callback_method': 'POST', 'commands_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -315,13 +315,13 @@ describe('Sim', function() { 'e_id': 'e_id', 'status': 'new', 'reset_status': 'resetting', - 'sms_fallback_method': 'http_method', + 'sms_fallback_method': 'POST', 'sms_fallback_url': 'http://www.example.com', - 'sms_method': 'http_method', + 'sms_method': 'POST', 'sms_url': 'http://www.example.com', - 'voice_fallback_method': 'http_method', + 'voice_fallback_method': 'POST', 'voice_fallback_url': 'http://www.example.com', - 'voice_method': 'http_method', + 'voice_method': 'POST', 'voice_url': 'http://www.example.com', 'url': 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ip_address': '192.168.1.30' @@ -375,7 +375,7 @@ describe('Sim', function() { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'unique_name': 'unique_name', - 'commands_callback_method': 'http_method', + 'commands_callback_method': 'POST', 'commands_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -391,13 +391,13 @@ describe('Sim', function() { 'e_id': 'e_id', 'status': 'new', 'reset_status': null, - 'sms_fallback_method': 'http_method', + 'sms_fallback_method': 'POST', 'sms_fallback_url': 'http://www.example.com', - 'sms_method': 'http_method', + 'sms_method': 'POST', 'sms_url': 'http://www.example.com', - 'voice_fallback_method': 'http_method', + 'voice_fallback_method': 'POST', 'voice_fallback_url': 'http://www.example.com', - 'voice_method': 'http_method', + 'voice_method': 'POST', 'voice_url': 'http://www.example.com', 'url': 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ip_address': '192.168.1.30' @@ -419,7 +419,7 @@ describe('Sim', function() { var body = { 'account_sid': 'ACbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'unique_name': 'unique_name', - 'commands_callback_method': 'http_method', + 'commands_callback_method': 'POST', 'commands_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -435,13 +435,13 @@ describe('Sim', function() { 'e_id': 'e_id', 'status': 'new', 'reset_status': null, - 'sms_fallback_method': 'http_method', + 'sms_fallback_method': 'POST', 'sms_fallback_url': 'http://www.example.com', - 'sms_method': 'http_method', + 'sms_method': 'POST', 'sms_url': 'http://www.example.com', - 'voice_fallback_method': 'http_method', + 'voice_fallback_method': 'POST', 'voice_fallback_url': 'http://www.example.com', - 'voice_method': 'http_method', + 'voice_method': 'POST', 'voice_url': 'http://www.example.com', 'url': 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ip_address': '192.168.1.30' @@ -463,7 +463,7 @@ describe('Sim', function() { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'unique_name': 'unique_name', - 'commands_callback_method': 'http_method', + 'commands_callback_method': 'GET', 'commands_callback_url': 'http://www.example.com', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', @@ -479,13 +479,13 @@ describe('Sim', function() { 'e_id': 'e_id', 'status': 'active', 'reset_status': 'resetting', - 'sms_fallback_method': 'http_method', + 'sms_fallback_method': 'POST', 'sms_fallback_url': 'http://www.example.com', - 'sms_method': 'http_method', + 'sms_method': 'POST', 'sms_url': 'http://www.example.com', - 'voice_fallback_method': 'http_method', + 'voice_fallback_method': 'POST', 'voice_fallback_url': 'http://www.example.com', - 'voice_method': 'http_method', + 'voice_method': 'POST', 'voice_url': 'http://www.example.com', 'url': 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ip_address': '192.168.1.30' From 76cc8da3ae422b8bec30e3a97e74bd23e6c9bfa6 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 14 Jul 2021 19:08:52 +0000 Subject: [PATCH 27/30] Release 3.66.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d75de5db4e..f0c7fbd079 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.65.0", + "version": "3.66.0", "author": "API Team ", "contributors": [ { From 3f015ce5d422f138e881a3c65c75963edcdc51a2 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 29 Jul 2021 02:30:59 +1000 Subject: [PATCH 28/30] chore: update user agent string for better debugging (#680) --- lib/rest/Twilio.d.ts | 2 + lib/rest/Twilio.js | 19 +++- spec/integration/holodeck.js | 5 +- spec/unit/rest/Twilio.spec.js | 172 +++++++++++++++++++++------------- 4 files changed, 129 insertions(+), 69 deletions(-) diff --git a/lib/rest/Twilio.d.ts b/lib/rest/Twilio.d.ts index fb3c0a60ed..1e6af0b07e 100644 --- a/lib/rest/Twilio.d.ts +++ b/lib/rest/Twilio.d.ts @@ -158,6 +158,7 @@ declare namespace Twilio { * @property lazyLoading - Enable lazy loading, loading time will decrease if enabled * @property logLevel - Debug logs will be shown. Defaults to none * @property region - Twilio region to use. Defaults to us1 if edge defined + * @property userAgentExtensions - Additions to the user agent string */ export interface TwilioClientOptions { accountSid?: string; @@ -167,6 +168,7 @@ declare namespace Twilio { lazyLoading?: boolean; logLevel?: string; region?: string; + userAgentExtensions?: string[]; } } diff --git a/lib/rest/Twilio.js b/lib/rest/Twilio.js index 3a6e871135..81861de5e2 100644 --- a/lib/rest/Twilio.js +++ b/lib/rest/Twilio.js @@ -12,6 +12,7 @@ var moduleInfo = require('../../package.json'); /* jshint ignore:line */ var url = require('url'); /* jshint ignore:line */ var util = require('util'); /* jshint ignore:line */ +var os = require('os'); var RestException = require('../base/RestException'); /* jshint ignore:line */ @@ -111,6 +112,7 @@ var RestException = require('../base/RestException'); /* jshint ignore:line */ * @param {boolean} [opts.lazyLoading] - * Enable lazy loading, loading time will decrease if enabled * @param {string} [opts.logLevel] - Debug logs will be shown. Defaults to none + * @param {string[]} [opts.userAgentExtensions] - Additions to the user agent string * * @returns {Twilio} A new instance of Twilio client */ @@ -129,6 +131,7 @@ function Twilio(username, password, opts) { this.edge = opts.edge || env.TWILIO_EDGE; this.region = opts.region || env.TWILIO_REGION; this.logLevel = opts.logLevel || env.TWILIO_LOG_LEVEL; + this.userAgentExtensions = opts.userAgentExtensions || []; if (!this.username) { throw new Error('username is required'); @@ -246,11 +249,21 @@ Twilio.prototype.request = function request(opts) { var password = opts.password || this.password; var headers = opts.headers || {}; + + var pkgVersion = moduleInfo.version; + var osName = os.platform(); + var osArch = os.arch(); + var nodeVersion = process.version; headers['User-Agent'] = util.format( - 'twilio-node/%s (node.js %s)', - moduleInfo.version, - process.version + 'twilio-node/%s (%s %s) node/%s', + pkgVersion, + osName, + osArch, + nodeVersion ); + this.userAgentExtensions.forEach(extension => { + headers['User-Agent'] += ` ${extension}`; + }); headers['Accept-Charset'] = 'utf-8'; if (opts.method === 'POST' && !headers['Content-Type']) { diff --git a/spec/integration/holodeck.js b/spec/integration/holodeck.js index 5615ede6b0..567b9b4451 100644 --- a/spec/integration/holodeck.js +++ b/spec/integration/holodeck.js @@ -5,6 +5,7 @@ var util = require('util'); var Request = require('../../lib/http/request'); var RequestClient = require('../../lib/base/RequestClient'); var moduleInfo = require('../../package.json'); +var os = require('os'); function Hologram(request, response) { this.request = request; @@ -28,8 +29,10 @@ Holodeck.prototype.addStandardHeaders = function(request) { 'Accept': 'application/json', 'Accept-Charset': 'utf-8', 'User-Agent': util.format( - 'twilio-node/%s (node.js %s)', + 'twilio-node/%s (%s %s) node/%s', moduleInfo.version, + os.platform(), + os.arch(), process.version ) }; diff --git a/spec/unit/rest/Twilio.spec.js b/spec/unit/rest/Twilio.spec.js index 5e900a2712..c6293be050 100644 --- a/spec/unit/rest/Twilio.spec.js +++ b/spec/unit/rest/Twilio.spec.js @@ -1,87 +1,129 @@ 'use strict'; const nock = require('nock'); +const util = require('util'); +var moduleInfo = require('../../../package.json'); +var os = require('os'); var url = require('url'); /* jshint ignore:line */ describe('client', () => { var client; const twilio = require('../../../lib'); - beforeEach(() => { - client = new twilio('ACXXXXXXXX', 'test-password'); - }); - describe('setting the region', () => { - it('should use the default region if only edge is defined', () => { - const scope = nock('https://api.edge.us1.twilio.com') - .get('/') - .reply(200, 'test response'); - client.edge = 'edge'; - return client.request({method: 'GET', uri: 'https://api.twilio.com'}) - .then(() => scope.done()); + describe('setting region and edge', () => { + beforeEach(() => { + client = new twilio('ACXXXXXXXX', 'test-password'); }); - it('should use the provided region if only edge is defined and there is a provided region', () => { - const scope = nock('https://api.edge.region.twilio.com') - .get('/') - .reply(200, 'test response'); - client.edge = 'edge'; - return client.request({method: 'GET', uri: 'https://api.region.twilio.com'}) - .then(() => scope.done()); + describe('setting the region', () => { + it('should use no region or edge by default', () => { + const scope = nock('https://api.twilio.com') + .get('/') + .reply(200, 'test response'); + return client.request({method: 'GET', uri: 'https://api.twilio.com'}) + .then(() => scope.done()); + }); + it('should use the default region if only edge is defined', () => { + const scope = nock('https://api.edge.us1.twilio.com') + .get('/') + .reply(200, 'test response'); + client.edge = 'edge'; + return client.request({method: 'GET', uri: 'https://api.twilio.com'}) + .then(() => scope.done()); + }); + it('should use the provided region if only edge is defined and there is a provided region', () => { + const scope = nock('https://api.edge.region.twilio.com') + .get('/') + .reply(200, 'test response'); + client.edge = 'edge'; + return client.request({method: 'GET', uri: 'https://api.region.twilio.com'}) + .then(() => scope.done()); + }); + it('should set the region properly if only the region is specified', () => { + const scope = nock('https://api.region.twilio.com') + .get('/') + .reply(200, 'test response'); + client.region = 'region'; + return client.request({method: 'GET', uri: 'https://api.twilio.com'}) + .then(() => scope.done()); + }); + it('should set the region and edge properly', () => { + const scope = nock('https://api.edge.region.twilio.com') + .get('/') + .reply(200, 'test response'); + client.edge = 'edge'; + client.region = 'region'; + return client.request({method: 'GET', uri: 'https://api.twilio.com'}) + .then(() => scope.done()); + }); + it('should set the region and edge properly when an edge is already included', () => { + const scope = nock('https://api.edge2.region.twilio.com') + .get('/') + .reply(200, 'test response'); + client.edge = 'edge2'; + return client.request({method: 'GET', uri: 'https://api.edge1.region.twilio.com'}) + .then(() => scope.done()); + }); + it('should set the region and edge properly when a region is already included', () => { + const scope = nock('https://api.edge.region2.twilio.com') + .get('/') + .reply(200, 'test response'); + client.region = 'region2'; + return client.request({method: 'GET', uri: 'https://api.edge.region.twilio.com'}) + .then(() => scope.done()); + }); + it('should set the region properly when a region is already included', () => { + const scope = nock('https://api.region2.twilio.com') + .get('/') + .reply(200, 'test response'); + client.region = 'region2'; + return client.request({method: 'GET', uri: 'https://api.region.twilio.com'}) + .then(() => scope.done()); + }); + it('should set the region properly on a custom domain', () => { + const scope = nock('https://api.region2.domain.com') + .get('/') + .reply(200, 'test response'); + client.region = 'region2'; + return client.request({method: 'GET', uri: 'https://api.domain.com'}) + .then(() => scope.done()); + }); + it('should set the region properly when a port is included', () => { + const scope = nock('https://api.region.twilio.com:123') + .get('/') + .reply(200, 'test response'); + client.region = 'region'; + return client.request({method: 'GET', uri: 'https://api.twilio.com:123'}) + .then(() => scope.done()); + }); }); - it('should set the region properly if only the region is specified', () => { - const scope = nock('https://api.region.twilio.com') + }); + + describe('adding user agent extensions', () => { + it('sets the user-agent by default', () => { + const client = new twilio('ACXXXXXXXX', 'test-password'); + const scope = nock('https://api.twilio.com', { + reqheaders: { + 'User-Agent': `twilio-node/${moduleInfo.version} \(${os.platform()} ${os.arch()}\) node\/${process.version}`, + }, + }) .get('/') .reply(200, 'test response'); - client.region = 'region'; return client.request({method: 'GET', uri: 'https://api.twilio.com'}) .then(() => scope.done()); }); - it('should set the region and edge properly', () => { - const scope = nock('https://api.edge.region.twilio.com') + + it('allows for user-agent extensions', () => { + const client = new twilio('ACXXXXXXXX', 'test-password', { + userAgentExtensions: ['twilio-run/2.0.0-test', '@twilio-labs/plugin-serverless/1.1.0-test'], + }); + const scope = nock('https://api.twilio.com', { + reqheaders: { + 'User-Agent': `twilio-node/${moduleInfo.version} \(${os.platform()} ${os.arch()}\) node\/${process.version} twilio-run\/2.0.0-test @twilio-labs\/plugin-serverless\/1.1.0-test`, + }, + }) .get('/') .reply(200, 'test response'); - client.edge = 'edge'; - client.region = 'region'; return client.request({method: 'GET', uri: 'https://api.twilio.com'}) .then(() => scope.done()); }); - it('should set the region and edge properly when an edge is already included', () => { - const scope = nock('https://api.edge2.region.twilio.com') - .get('/') - .reply(200, 'test response'); - client.edge = 'edge2'; - return client.request({method: 'GET', uri: 'https://api.edge1.region.twilio.com'}) - .then(() => scope.done()); - }); - it('should set the region and edge properly when a region is already included', () => { - const scope = nock('https://api.edge.region2.twilio.com') - .get('/') - .reply(200, 'test response'); - client.region = 'region2'; - return client.request({method: 'GET', uri: 'https://api.edge.region.twilio.com'}) - .then(() => scope.done()); - }); - it('should set the region properly when a region is already included', () => { - const scope = nock('https://api.region2.twilio.com') - .get('/') - .reply(200, 'test response'); - client.region = 'region2'; - return client.request({method: 'GET', uri: 'https://api.region.twilio.com'}) - .then(() => scope.done()); - }); - it('should set the region properly on a custom domain', () => { - const scope = nock('https://api.region2.domain.com') - .get('/') - .reply(200, 'test response'); - client.region = 'region2'; - return client.request({method: 'GET', uri: 'https://api.domain.com'}) - .then(() => scope.done()); - }); - it('should set the region properly when a port is included', () => { - const scope = nock('https://api.region.twilio.com:123') - .get('/') - .reply(200, 'test response'); - client.region = 'region'; - return client.request({method: 'GET', uri: 'https://api.twilio.com:123'}) - .then(() => scope.done()); - }); }); }); From 8b3e9d5fe8d0e5b24efe8fa1771e310c87a76dbd Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 28 Jul 2021 20:20:58 +0000 Subject: [PATCH 29/30] [Librarian] Regenerated @ 5f994412d6c6003c98a1ff03c7d1bb10b7d39e32 --- CHANGES.md | 15 + lib/rest/Conversations.d.ts | 2 + lib/rest/Conversations.js | 9 + lib/rest/Twilio.js | 7 +- lib/rest/conversations/V1.d.ts | 3 + lib/rest/conversations/V1.js | 13 + .../v1/participantConversation.d.ts | 276 ++++++++++ .../v1/participantConversation.js | 496 +++++++++++++++++ lib/rest/conversations/v1/service.d.ts | 7 + lib/rest/conversations/v1/service.js | 30 ++ .../v1/service/participantConversation.d.ts | 279 ++++++++++ .../v1/service/participantConversation.js | 501 ++++++++++++++++++ .../v1/service/user/userConversation.js | 4 +- .../conversations/v1/user/userConversation.js | 4 +- .../taskrouter/v1/workspace/activity.d.ts | 2 + lib/rest/taskrouter/v1/workspace/activity.js | 2 + lib/rest/verify/v2/service/webhook.d.ts | 10 +- lib/rest/verify/v2/service/webhook.js | 15 +- .../v1/participantConversation.spec.js | 321 +++++++++++ .../rest/conversations/v1/service.spec.js | 18 +- .../service/participantConversation.spec.js | 329 ++++++++++++ .../taskrouter/v1/workspace/activity.spec.js | 60 ++- .../v1/workspace/worker/workerChannel.spec.js | 56 +- .../rest/verify/v2/service/webhook.spec.js | 7 + 24 files changed, 2398 insertions(+), 68 deletions(-) create mode 100644 lib/rest/conversations/v1/participantConversation.d.ts create mode 100644 lib/rest/conversations/v1/participantConversation.js create mode 100644 lib/rest/conversations/v1/service/participantConversation.d.ts create mode 100644 lib/rest/conversations/v1/service/participantConversation.js create mode 100644 spec/integration/rest/conversations/v1/participantConversation.spec.js create mode 100644 spec/integration/rest/conversations/v1/service/participantConversation.spec.js diff --git a/CHANGES.md b/CHANGES.md index 6e755f3e08..e511108d07 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,21 @@ twilio-node changelog ===================== +[2021-07-28] Version 3.66.1 +--------------------------- +**Library - Chore** +- [PR #680](https://github.com/twilio/twilio-node/pull/680): update user agent string for better debugging. Thanks to [@philnash](https://github.com/philnash)! + +**Conversations** +- Expose ParticipantConversations resource + +**Taskrouter** +- Adding `links` to the activity resource + +**Verify** +- Added a `Version` to Verify Factors `Webhooks` to add new fields without breaking old Webhooks. + + [2021-07-14] Version 3.66.0 --------------------------- **Conversations** diff --git a/lib/rest/Conversations.d.ts b/lib/rest/Conversations.d.ts index fc2ab83528..699fd45352 100644 --- a/lib/rest/Conversations.d.ts +++ b/lib/rest/Conversations.d.ts @@ -11,6 +11,7 @@ import V1 = require('./conversations/V1'); import { ConfigurationListInstance } from './conversations/v1/configuration'; import { ConversationListInstance } from './conversations/v1/conversation'; import { CredentialListInstance } from './conversations/v1/credential'; +import { ParticipantConversationListInstance } from './conversations/v1/participantConversation'; import { RoleListInstance } from './conversations/v1/role'; import { ServiceListInstance } from './conversations/v1/service'; import { UserListInstance } from './conversations/v1/user'; @@ -27,6 +28,7 @@ declare class Conversations extends Domain { readonly configuration: ConfigurationListInstance; readonly conversations: ConversationListInstance; readonly credentials: CredentialListInstance; + readonly participantConversations: ParticipantConversationListInstance; readonly roles: RoleListInstance; readonly services: ServiceListInstance; readonly users: UserListInstance; diff --git a/lib/rest/Conversations.js b/lib/rest/Conversations.js index 8691efff2b..14041b09d2 100644 --- a/lib/rest/Conversations.js +++ b/lib/rest/Conversations.js @@ -27,6 +27,8 @@ var V1 = require('./conversations/V1'); /* jshint ignore:line */ * conversations resource * @property {Twilio.Conversations.V1.CredentialList} credentials - * credentials resource + * @property {Twilio.Conversations.V1.ParticipantConversationList} participantConversations - + * participantConversations resource * @property {Twilio.Conversations.V1.RoleList} roles - roles resource * @property {Twilio.Conversations.V1.ServiceList} services - services resource * @property {Twilio.Conversations.V1.UserList} users - users resource @@ -73,6 +75,13 @@ Object.defineProperty(Conversations.prototype, } }); +Object.defineProperty(Conversations.prototype, + 'participantConversations', { + get: function() { + return this.v1.participantConversations; + } +}); + Object.defineProperty(Conversations.prototype, 'roles', { get: function() { diff --git a/lib/rest/Twilio.js b/lib/rest/Twilio.js index 81861de5e2..c3e89223fe 100644 --- a/lib/rest/Twilio.js +++ b/lib/rest/Twilio.js @@ -9,10 +9,10 @@ */ /* jshint ignore:end */ -var moduleInfo = require('../../package.json'); /* jshint ignore:line */ +var os = require('os'); /* jshint ignore:line */ var url = require('url'); /* jshint ignore:line */ +var moduleInfo = require('../../package.json'); /* jshint ignore:line */ var util = require('util'); /* jshint ignore:line */ -var os = require('os'); var RestException = require('../base/RestException'); /* jshint ignore:line */ @@ -112,7 +112,8 @@ var RestException = require('../base/RestException'); /* jshint ignore:line */ * @param {boolean} [opts.lazyLoading] - * Enable lazy loading, loading time will decrease if enabled * @param {string} [opts.logLevel] - Debug logs will be shown. Defaults to none - * @param {string[]} [opts.userAgentExtensions] - Additions to the user agent string + * @param {string[]} [opts.userAgentExtensions] - + * Additions to the user agent string * * @returns {Twilio} A new instance of Twilio client */ diff --git a/lib/rest/conversations/V1.d.ts b/lib/rest/conversations/V1.d.ts index cf8fadb7f1..013b7ad5be 100644 --- a/lib/rest/conversations/V1.d.ts +++ b/lib/rest/conversations/V1.d.ts @@ -13,6 +13,8 @@ import { ConversationList } from './v1/conversation'; import { ConversationListInstance } from './v1/conversation'; import { CredentialList } from './v1/credential'; import { CredentialListInstance } from './v1/credential'; +import { ParticipantConversationList } from './v1/participantConversation'; +import { ParticipantConversationListInstance } from './v1/participantConversation'; import { RoleList } from './v1/role'; import { RoleListInstance } from './v1/role'; import { ServiceList } from './v1/service'; @@ -32,6 +34,7 @@ declare class V1 extends Version { readonly configuration: ConfigurationListInstance; readonly conversations: ConversationListInstance; readonly credentials: CredentialListInstance; + readonly participantConversations: ParticipantConversationListInstance; readonly roles: RoleListInstance; readonly services: ServiceListInstance; readonly users: UserListInstance; diff --git a/lib/rest/conversations/V1.js b/lib/rest/conversations/V1.js index 008733b47b..270cdf37fc 100644 --- a/lib/rest/conversations/V1.js +++ b/lib/rest/conversations/V1.js @@ -13,6 +13,8 @@ var _ = require('lodash'); /* jshint ignore:line */ var ConfigurationList = require('./v1/configuration').ConfigurationList; var ConversationList = require('./v1/conversation').ConversationList; var CredentialList = require('./v1/credential').CredentialList; +var ParticipantConversationList = require( + './v1/participantConversation').ParticipantConversationList; var RoleList = require('./v1/role').RoleList; var ServiceList = require('./v1/service').ServiceList; var UserList = require('./v1/user').UserList; @@ -31,6 +33,8 @@ var Version = require('../../base/Version'); /* jshint ignore:line */ * conversations resource * @property {Twilio.Conversations.V1.CredentialList} credentials - * credentials resource + * @property {Twilio.Conversations.V1.ParticipantConversationList} participantConversations - + * participantConversations resource * @property {Twilio.Conversations.V1.RoleList} roles - roles resource * @property {Twilio.Conversations.V1.ServiceList} services - services resource * @property {Twilio.Conversations.V1.UserList} users - users resource @@ -45,6 +49,7 @@ function V1(domain) { this._configuration = undefined; this._conversations = undefined; this._credentials = undefined; + this._participantConversations = undefined; this._roles = undefined; this._services = undefined; this._users = undefined; @@ -77,6 +82,14 @@ Object.defineProperty(V1.prototype, } }); +Object.defineProperty(V1.prototype, + 'participantConversations', { + get: function() { + this._participantConversations = this._participantConversations || new ParticipantConversationList(this); + return this._participantConversations; + } +}); + Object.defineProperty(V1.prototype, 'roles', { get: function() { diff --git a/lib/rest/conversations/v1/participantConversation.d.ts b/lib/rest/conversations/v1/participantConversation.d.ts new file mode 100644 index 0000000000..bc439e68b9 --- /dev/null +++ b/lib/rest/conversations/v1/participantConversation.d.ts @@ -0,0 +1,276 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V1 = require('../V1'); +import { SerializableClass } from '../../../interfaces'; + +type ParticipantConversationState = 'inactive'|'active'|'closed'; + +/** + * Initialize the ParticipantConversationList + * + * @param version - Version of the resource + */ +declare function ParticipantConversationList(version: V1): ParticipantConversationListInstance; + +interface ParticipantConversationListInstance { + /** + * Streams ParticipantConversationInstance 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. + * + * @param callback - Function to process each record + */ + each(callback?: (item: ParticipantConversationInstance, done: (err?: Error) => void) => void): void; + /** + * Streams ParticipantConversationInstance 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. + * + * @param opts - Options for request + * @param callback - Function to process each record + */ + each(opts?: ParticipantConversationListInstanceEachOptions, callback?: (item: ParticipantConversationInstance, done: (err?: Error) => void) => void): void; + /** + * Retrieve a single target page of ParticipantConversationInstance 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. + * + * @param callback - Callback to handle list of records + */ + getPage(callback?: (error: Error | null, items: ParticipantConversationPage) => any): Promise; + /** + * Retrieve a single target page of ParticipantConversationInstance 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. + * + * @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: ParticipantConversationPage) => any): Promise; + /** + * Lists ParticipantConversationInstance 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: ParticipantConversationInstance[]) => any): Promise; + /** + * Lists ParticipantConversationInstance 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 opts - Options for request + * @param callback - Callback to handle list of records + */ + list(opts?: ParticipantConversationListInstanceOptions, callback?: (error: Error | null, items: ParticipantConversationInstance[]) => any): Promise; + /** + * Retrieve a single page of ParticipantConversationInstance 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. + * + * @param callback - Callback to handle list of records + */ + page(callback?: (error: Error | null, items: ParticipantConversationPage) => any): Promise; + /** + * Retrieve a single page of ParticipantConversationInstance 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. + * + * @param opts - Options for request + * @param callback - Callback to handle list of records + */ + page(opts?: ParticipantConversationListInstancePageOptions, callback?: (error: Error | null, items: ParticipantConversationPage) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to each + * + * @property address - A unique string identifier for the conversation participant who's not a Conversation User. + * @property callback - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @property done - Function to be called upon completion of streaming + * @property identity - A unique string identifier for the conversation participant as Conversation User. + * @property limit - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface ParticipantConversationListInstanceEachOptions { + address?: string; + callback?: (item: ParticipantConversationInstance, done: (err?: Error) => void) => void; + done?: Function; + identity?: string; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to list + * + * @property address - A unique string identifier for the conversation participant who's not a Conversation User. + * @property identity - A unique string identifier for the conversation participant as Conversation User. + * @property limit - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface ParticipantConversationListInstanceOptions { + address?: string; + identity?: string; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to page + * + * @property address - A unique string identifier for the conversation participant who's not a Conversation User. + * @property identity - A unique string identifier for the conversation participant as Conversation User. + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + */ +interface ParticipantConversationListInstancePageOptions { + address?: string; + identity?: string; + pageNumber?: number; + pageSize?: number; + pageToken?: string; +} + +interface ParticipantConversationPayload extends ParticipantConversationResource, Page.TwilioResponsePayload { +} + +interface ParticipantConversationResource { + account_sid: string; + chat_service_sid: string; + conversation_attributes: string; + conversation_created_by: string; + conversation_date_created: Date; + conversation_date_updated: Date; + conversation_friendly_name: string; + conversation_sid: string; + conversation_state: ParticipantConversationState; + conversation_timers: object; + conversation_unique_name: string; + links: string; + participant_identity: string; + participant_messaging_binding: object; + participant_sid: string; + participant_user_sid: string; +} + +interface ParticipantConversationSolution { +} + + +declare class ParticipantConversationInstance extends SerializableClass { + /** + * Initialize the ParticipantConversationContext + * + * @param version - Version of the resource + * @param payload - The instance payload + */ + constructor(version: V1, payload: ParticipantConversationPayload); + + accountSid: string; + chatServiceSid: string; + conversationAttributes: string; + conversationCreatedBy: string; + conversationDateCreated: Date; + conversationDateUpdated: Date; + conversationFriendlyName: string; + conversationSid: string; + conversationState: ParticipantConversationState; + conversationTimers: any; + conversationUniqueName: string; + links: string; + participantIdentity: string; + participantMessagingBinding: any; + participantSid: string; + participantUserSid: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + +declare class ParticipantConversationPage extends Page { + /** + * Initialize the ParticipantConversationPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: ParticipantConversationSolution); + + /** + * Build an instance of ParticipantConversationInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: ParticipantConversationPayload): ParticipantConversationInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { ParticipantConversationInstance, ParticipantConversationList, ParticipantConversationListInstance, ParticipantConversationListInstanceEachOptions, ParticipantConversationListInstanceOptions, ParticipantConversationListInstancePageOptions, ParticipantConversationPage, ParticipantConversationPayload, ParticipantConversationResource, ParticipantConversationSolution, ParticipantConversationState } diff --git a/lib/rest/conversations/v1/participantConversation.js b/lib/rest/conversations/v1/participantConversation.js new file mode 100644 index 0000000000..78cd8088bb --- /dev/null +++ b/lib/rest/conversations/v1/participantConversation.js @@ -0,0 +1,496 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var Q = require('q'); /* jshint ignore:line */ +var _ = require('lodash'); /* jshint ignore:line */ +var 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 ParticipantConversationList; +var ParticipantConversationPage; +var ParticipantConversationInstance; + +/* jshint ignore:start */ +/** + * Initialize the ParticipantConversationList + * + * @constructor Twilio.Conversations.V1.ParticipantConversationList + * + * @param {Twilio.Conversations.V1} version - Version of the resource + */ +/* jshint ignore:end */ +ParticipantConversationList = function ParticipantConversationList(version) { + /* jshint ignore:start */ + /** + * @function participantConversations + * @memberof Twilio.Conversations.V1# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Conversations.V1.ParticipantConversationContext} + */ + /* jshint ignore:end */ + function ParticipantConversationListInstance(sid) { + return ParticipantConversationListInstance.get(sid); + } + + ParticipantConversationListInstance._version = version; + // Path Solution + ParticipantConversationListInstance._solution = {}; + ParticipantConversationListInstance._uri = `/ParticipantConversations`; + /* jshint ignore:start */ + /** + * Streams ParticipantConversationInstance 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.Conversations.V1.ParticipantConversationList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.identity] - + * A unique string identifier for the conversation participant as Conversation User. + * @param {string} [opts.address] - + * A unique string identifier for the conversation participant who's not a Conversation User. + * @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 */ + ParticipantConversationListInstance.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)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists ParticipantConversationInstance 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.Conversations.V1.ParticipantConversationList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.identity] - + * A unique string identifier for the conversation participant as Conversation User. + * @param {string} [opts.address] - + * A unique string identifier for the conversation participant who's not a Conversation User. + * @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 */ + ParticipantConversationListInstance.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 ParticipantConversationInstance 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.Conversations.V1.ParticipantConversationList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.identity] - + * A unique string identifier for the conversation participant as Conversation User. + * @param {string} [opts.address] - + * A unique string identifier for the conversation participant who's not a Conversation User. + * @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 */ + ParticipantConversationListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'Identity': _.get(opts, 'identity'), + 'Address': _.get(opts, 'address'), + '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 ParticipantConversationPage(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 ParticipantConversationInstance 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.Conversations.V1.ParticipantConversationList# + * + * @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 */ + ParticipantConversationListInstance.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 ParticipantConversationPage(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 */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ParticipantConversationList# + * + * @returns Object + */ + /* jshint ignore:end */ + ParticipantConversationListInstance.toJSON = function toJSON() { + return this._solution; + }; + + ParticipantConversationListInstance[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return ParticipantConversationListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the ParticipantConversationPage + * + * @constructor Twilio.Conversations.V1.ParticipantConversationPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {ParticipantConversationSolution} solution - Path solution + * + * @returns ParticipantConversationPage + */ +/* jshint ignore:end */ +ParticipantConversationPage = function ParticipantConversationPage(version, + response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(ParticipantConversationPage.prototype, Page.prototype); +ParticipantConversationPage.prototype.constructor = ParticipantConversationPage; + +/* jshint ignore:start */ +/** + * Build an instance of ParticipantConversationInstance + * + * @function getInstance + * @memberof Twilio.Conversations.V1.ParticipantConversationPage# + * + * @param {ParticipantConversationPayload} payload - Payload response from the API + * + * @returns ParticipantConversationInstance + */ +/* jshint ignore:end */ +ParticipantConversationPage.prototype.getInstance = function + getInstance(payload) { + return new ParticipantConversationInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ParticipantConversationPage# + * + * @returns Object + */ +/* jshint ignore:end */ +ParticipantConversationPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ParticipantConversationPage.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the ParticipantConversationContext + * + * @constructor Twilio.Conversations.V1.ParticipantConversationInstance + * + * @property {string} accountSid - + * The unique ID of the Account responsible for this conversation. + * @property {string} chatServiceSid - + * The unique ID of the Conversation Service this conversation belongs to. + * @property {string} participantSid - The unique ID of the Participant. + * @property {string} participantUserSid - + * The unique ID for the conversation participant as Conversation User. + * @property {string} participantIdentity - + * A unique string identifier for the conversation participant as Conversation User. + * @property {object} participantMessagingBinding - + * Information about how this participant exchanges messages with the conversation. + * @property {string} conversationSid - + * The unique ID of the Conversation this Participant belongs to. + * @property {string} conversationUniqueName - + * An application-defined string that uniquely identifies the Conversation resource + * @property {string} conversationFriendlyName - + * The human-readable name of this conversation. + * @property {string} conversationAttributes - + * An optional string metadata field you can use to store any data you wish. + * @property {Date} conversationDateCreated - + * The date that this conversation was created. + * @property {Date} conversationDateUpdated - + * The date that this conversation was last updated. + * @property {string} conversationCreatedBy - Creator of this conversation. + * @property {participant_conversation.state} conversationState - + * The current state of this User Conversation + * @property {object} conversationTimers - Timer date values for this conversation. + * @property {string} links - + * Absolute URLs to access the participant and conversation of this Participant Conversation. + * + * @param {V1} version - Version of the resource + * @param {ParticipantConversationPayload} payload - The instance payload + */ +/* jshint ignore:end */ +ParticipantConversationInstance = function + ParticipantConversationInstance(version, payload) { + this._version = version; + + // Marshaled Properties + this.accountSid = payload.account_sid; // jshint ignore:line + this.chatServiceSid = payload.chat_service_sid; // jshint ignore:line + this.participantSid = payload.participant_sid; // jshint ignore:line + this.participantUserSid = payload.participant_user_sid; // jshint ignore:line + this.participantIdentity = payload.participant_identity; // jshint ignore:line + this.participantMessagingBinding = payload.participant_messaging_binding; // jshint ignore:line + this.conversationSid = payload.conversation_sid; // jshint ignore:line + this.conversationUniqueName = payload.conversation_unique_name; // jshint ignore:line + this.conversationFriendlyName = payload.conversation_friendly_name; // jshint ignore:line + this.conversationAttributes = payload.conversation_attributes; // jshint ignore:line + this.conversationDateCreated = deserialize.iso8601DateTime(payload.conversation_date_created); // jshint ignore:line + this.conversationDateUpdated = deserialize.iso8601DateTime(payload.conversation_date_updated); // jshint ignore:line + this.conversationCreatedBy = payload.conversation_created_by; // jshint ignore:line + this.conversationState = payload.conversation_state; // jshint ignore:line + this.conversationTimers = payload.conversation_timers; // jshint ignore:line + this.links = payload.links; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {}; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ParticipantConversationInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +ParticipantConversationInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ParticipantConversationInstance.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + ParticipantConversationList: ParticipantConversationList, + ParticipantConversationPage: ParticipantConversationPage, + ParticipantConversationInstance: ParticipantConversationInstance +}; diff --git a/lib/rest/conversations/v1/service.d.ts b/lib/rest/conversations/v1/service.d.ts index c4ff35bd6f..0baf3fc15d 100644 --- a/lib/rest/conversations/v1/service.d.ts +++ b/lib/rest/conversations/v1/service.d.ts @@ -14,6 +14,8 @@ import { ConfigurationList } from './service/configuration'; import { ConfigurationListInstance } from './service/configuration'; import { ConversationList } from './service/conversation'; import { ConversationListInstance } from './service/conversation'; +import { ParticipantConversationList } from './service/participantConversation'; +import { ParticipantConversationListInstance } from './service/participantConversation'; import { RoleList } from './service/role'; import { RoleListInstance } from './service/role'; import { SerializableClass } from '../../../interfaces'; @@ -248,6 +250,7 @@ declare class ServiceContext { * @param callback - Callback to handle processed record */ fetch(callback?: (error: Error | null, items: ServiceInstance) => any): Promise; + participantConversations: ParticipantConversationListInstance; /** * remove a ServiceInstance * @@ -297,6 +300,10 @@ declare class ServiceInstance extends SerializableClass { fetch(callback?: (error: Error | null, items: ServiceInstance) => any): Promise; friendlyName: string; links: string; + /** + * Access the participantConversations + */ + participantConversations(): ParticipantConversationListInstance; /** * remove a ServiceInstance * diff --git a/lib/rest/conversations/v1/service.js b/lib/rest/conversations/v1/service.js index 70516ce7e0..05362793df 100644 --- a/lib/rest/conversations/v1/service.js +++ b/lib/rest/conversations/v1/service.js @@ -16,6 +16,8 @@ var BindingList = require('./service/binding').BindingList; var ConfigurationList = require('./service/configuration').ConfigurationList; var ConversationList = require('./service/conversation').ConversationList; var Page = require('../../../base/Page'); /* jshint ignore:line */ +var ParticipantConversationList = require( + './service/participantConversation').ParticipantConversationList; var RoleList = require('./service/role').RoleList; var UserList = require('./service/user').UserList; var deserialize = require( @@ -594,6 +596,21 @@ ServiceInstance.prototype.configuration = function configuration() { return this._proxy.configuration; }; +/* jshint ignore:start */ +/** + * Access the participantConversations + * + * @function participantConversations + * @memberof Twilio.Conversations.V1.ServiceInstance# + * + * @returns {Twilio.Conversations.V1.ServiceContext.ParticipantConversationList} + */ +/* jshint ignore:end */ +ServiceInstance.prototype.participantConversations = function + participantConversations() { + return this._proxy.participantConversations; +}; + /* jshint ignore:start */ /** * Provide a user-friendly representation @@ -636,6 +653,8 @@ ServiceInstance.prototype[util.inspect.custom] = function inspect(depth, * roles resource * @property {Twilio.Conversations.V1.ServiceContext.ConfigurationList} configuration - * configuration resource + * @property {Twilio.Conversations.V1.ServiceContext.ParticipantConversationList} participantConversations - + * participantConversations resource * * @param {V1} version - Version of the resource * @param {sid} sid - A 34 character string that uniquely identifies this resource. @@ -654,6 +673,7 @@ ServiceContext = function ServiceContext(version, sid) { this._users = undefined; this._roles = undefined; this._configuration = undefined; + this._participantConversations = undefined; }; /* jshint ignore:start */ @@ -768,6 +788,16 @@ Object.defineProperty(ServiceContext.prototype, } }); +Object.defineProperty(ServiceContext.prototype, + 'participantConversations', { + get: function() { + if (!this._participantConversations) { + this._participantConversations = new ParticipantConversationList(this._version, this._solution.sid); + } + return this._participantConversations; + } +}); + /* jshint ignore:start */ /** * Provide a user-friendly representation diff --git a/lib/rest/conversations/v1/service/participantConversation.d.ts b/lib/rest/conversations/v1/service/participantConversation.d.ts new file mode 100644 index 0000000000..ce6217c93d --- /dev/null +++ b/lib/rest/conversations/v1/service/participantConversation.d.ts @@ -0,0 +1,279 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../../base/Page'); +import Response = require('../../../../http/response'); +import V1 = require('../../V1'); +import { SerializableClass } from '../../../../interfaces'; + +type ParticipantConversationState = 'inactive'|'active'|'closed'; + +/** + * Initialize the ParticipantConversationList + * + * @param version - Version of the resource + * @param chatServiceSid - The unique ID of the Conversation Service this conversation belongs to. + */ +declare function ParticipantConversationList(version: V1, chatServiceSid: string): ParticipantConversationListInstance; + +interface ParticipantConversationListInstance { + /** + * Streams ParticipantConversationInstance 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. + * + * @param callback - Function to process each record + */ + each(callback?: (item: ParticipantConversationInstance, done: (err?: Error) => void) => void): void; + /** + * Streams ParticipantConversationInstance 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. + * + * @param opts - Options for request + * @param callback - Function to process each record + */ + each(opts?: ParticipantConversationListInstanceEachOptions, callback?: (item: ParticipantConversationInstance, done: (err?: Error) => void) => void): void; + /** + * Retrieve a single target page of ParticipantConversationInstance 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. + * + * @param callback - Callback to handle list of records + */ + getPage(callback?: (error: Error | null, items: ParticipantConversationPage) => any): Promise; + /** + * Retrieve a single target page of ParticipantConversationInstance 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. + * + * @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: ParticipantConversationPage) => any): Promise; + /** + * Lists ParticipantConversationInstance 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: ParticipantConversationInstance[]) => any): Promise; + /** + * Lists ParticipantConversationInstance 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 opts - Options for request + * @param callback - Callback to handle list of records + */ + list(opts?: ParticipantConversationListInstanceOptions, callback?: (error: Error | null, items: ParticipantConversationInstance[]) => any): Promise; + /** + * Retrieve a single page of ParticipantConversationInstance 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. + * + * @param callback - Callback to handle list of records + */ + page(callback?: (error: Error | null, items: ParticipantConversationPage) => any): Promise; + /** + * Retrieve a single page of ParticipantConversationInstance 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. + * + * @param opts - Options for request + * @param callback - Callback to handle list of records + */ + page(opts?: ParticipantConversationListInstancePageOptions, callback?: (error: Error | null, items: ParticipantConversationPage) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to each + * + * @property address - A unique string identifier for the conversation participant who's not a Conversation User. + * @property callback - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @property done - Function to be called upon completion of streaming + * @property identity - A unique string identifier for the conversation participant as Conversation User. + * @property limit - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface ParticipantConversationListInstanceEachOptions { + address?: string; + callback?: (item: ParticipantConversationInstance, done: (err?: Error) => void) => void; + done?: Function; + identity?: string; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to list + * + * @property address - A unique string identifier for the conversation participant who's not a Conversation User. + * @property identity - A unique string identifier for the conversation participant as Conversation User. + * @property limit - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @property 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) + */ +interface ParticipantConversationListInstanceOptions { + address?: string; + identity?: string; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to page + * + * @property address - A unique string identifier for the conversation participant who's not a Conversation User. + * @property identity - A unique string identifier for the conversation participant as Conversation User. + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + */ +interface ParticipantConversationListInstancePageOptions { + address?: string; + identity?: string; + pageNumber?: number; + pageSize?: number; + pageToken?: string; +} + +interface ParticipantConversationPayload extends ParticipantConversationResource, Page.TwilioResponsePayload { +} + +interface ParticipantConversationResource { + account_sid: string; + chat_service_sid: string; + conversation_attributes: string; + conversation_created_by: string; + conversation_date_created: Date; + conversation_date_updated: Date; + conversation_friendly_name: string; + conversation_sid: string; + conversation_state: ParticipantConversationState; + conversation_timers: object; + conversation_unique_name: string; + links: string; + participant_identity: string; + participant_messaging_binding: object; + participant_sid: string; + participant_user_sid: string; +} + +interface ParticipantConversationSolution { + chatServiceSid?: string; +} + + +declare class ParticipantConversationInstance extends SerializableClass { + /** + * Initialize the ParticipantConversationContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param chatServiceSid - The unique ID of the Conversation Service this conversation belongs to. + */ + constructor(version: V1, payload: ParticipantConversationPayload, chatServiceSid: string); + + accountSid: string; + chatServiceSid: string; + conversationAttributes: string; + conversationCreatedBy: string; + conversationDateCreated: Date; + conversationDateUpdated: Date; + conversationFriendlyName: string; + conversationSid: string; + conversationState: ParticipantConversationState; + conversationTimers: any; + conversationUniqueName: string; + links: string; + participantIdentity: string; + participantMessagingBinding: any; + participantSid: string; + participantUserSid: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + +declare class ParticipantConversationPage extends Page { + /** + * Initialize the ParticipantConversationPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: ParticipantConversationSolution); + + /** + * Build an instance of ParticipantConversationInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: ParticipantConversationPayload): ParticipantConversationInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { ParticipantConversationInstance, ParticipantConversationList, ParticipantConversationListInstance, ParticipantConversationListInstanceEachOptions, ParticipantConversationListInstanceOptions, ParticipantConversationListInstancePageOptions, ParticipantConversationPage, ParticipantConversationPayload, ParticipantConversationResource, ParticipantConversationSolution, ParticipantConversationState } diff --git a/lib/rest/conversations/v1/service/participantConversation.js b/lib/rest/conversations/v1/service/participantConversation.js new file mode 100644 index 0000000000..ac461cdeaa --- /dev/null +++ b/lib/rest/conversations/v1/service/participantConversation.js @@ -0,0 +1,501 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var Q = require('q'); /* jshint ignore:line */ +var _ = require('lodash'); /* jshint ignore:line */ +var 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 ParticipantConversationList; +var ParticipantConversationPage; +var ParticipantConversationInstance; + +/* jshint ignore:start */ +/** + * Initialize the ParticipantConversationList + * + * @constructor Twilio.Conversations.V1.ServiceContext.ParticipantConversationList + * + * @param {Twilio.Conversations.V1} version - Version of the resource + * @param {string} chatServiceSid - + * The unique ID of the Conversation Service this conversation belongs to. + */ +/* jshint ignore:end */ +ParticipantConversationList = function ParticipantConversationList(version, + chatServiceSid) { + /* jshint ignore:start */ + /** + * @function participantConversations + * @memberof Twilio.Conversations.V1.ServiceContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Conversations.V1.ServiceContext.ParticipantConversationContext} + */ + /* jshint ignore:end */ + function ParticipantConversationListInstance(sid) { + return ParticipantConversationListInstance.get(sid); + } + + ParticipantConversationListInstance._version = version; + // Path Solution + ParticipantConversationListInstance._solution = {chatServiceSid: chatServiceSid}; + ParticipantConversationListInstance._uri = `/Services/${chatServiceSid}/ParticipantConversations`; + /* jshint ignore:start */ + /** + * Streams ParticipantConversationInstance 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.Conversations.V1.ServiceContext.ParticipantConversationList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.identity] - + * A unique string identifier for the conversation participant as Conversation User. + * @param {string} [opts.address] - + * A unique string identifier for the conversation participant who's not a Conversation User. + * @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 */ + ParticipantConversationListInstance.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)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists ParticipantConversationInstance 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.Conversations.V1.ServiceContext.ParticipantConversationList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.identity] - + * A unique string identifier for the conversation participant as Conversation User. + * @param {string} [opts.address] - + * A unique string identifier for the conversation participant who's not a Conversation User. + * @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 */ + ParticipantConversationListInstance.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 ParticipantConversationInstance 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.Conversations.V1.ServiceContext.ParticipantConversationList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.identity] - + * A unique string identifier for the conversation participant as Conversation User. + * @param {string} [opts.address] - + * A unique string identifier for the conversation participant who's not a Conversation User. + * @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 */ + ParticipantConversationListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'Identity': _.get(opts, 'identity'), + 'Address': _.get(opts, 'address'), + '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 ParticipantConversationPage(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 ParticipantConversationInstance 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.Conversations.V1.ServiceContext.ParticipantConversationList# + * + * @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 */ + ParticipantConversationListInstance.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 ParticipantConversationPage(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 */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ServiceContext.ParticipantConversationList# + * + * @returns Object + */ + /* jshint ignore:end */ + ParticipantConversationListInstance.toJSON = function toJSON() { + return this._solution; + }; + + ParticipantConversationListInstance[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return ParticipantConversationListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the ParticipantConversationPage + * + * @constructor Twilio.Conversations.V1.ServiceContext.ParticipantConversationPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {ParticipantConversationSolution} solution - Path solution + * + * @returns ParticipantConversationPage + */ +/* jshint ignore:end */ +ParticipantConversationPage = function ParticipantConversationPage(version, + response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(ParticipantConversationPage.prototype, Page.prototype); +ParticipantConversationPage.prototype.constructor = ParticipantConversationPage; + +/* jshint ignore:start */ +/** + * Build an instance of ParticipantConversationInstance + * + * @function getInstance + * @memberof Twilio.Conversations.V1.ServiceContext.ParticipantConversationPage# + * + * @param {ParticipantConversationPayload} payload - Payload response from the API + * + * @returns ParticipantConversationInstance + */ +/* jshint ignore:end */ +ParticipantConversationPage.prototype.getInstance = function + getInstance(payload) { + return new ParticipantConversationInstance(this._version, payload, this._solution.chatServiceSid); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ServiceContext.ParticipantConversationPage# + * + * @returns Object + */ +/* jshint ignore:end */ +ParticipantConversationPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ParticipantConversationPage.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the ParticipantConversationContext + * + * @constructor Twilio.Conversations.V1.ServiceContext.ParticipantConversationInstance + * + * @property {string} accountSid - + * The unique ID of the Account responsible for this conversation. + * @property {string} chatServiceSid - + * The unique ID of the Conversation Service this conversation belongs to. + * @property {string} participantSid - The unique ID of the Participant. + * @property {string} participantUserSid - + * The unique ID for the conversation participant as Conversation User. + * @property {string} participantIdentity - + * A unique string identifier for the conversation participant as Conversation User. + * @property {object} participantMessagingBinding - + * Information about how this participant exchanges messages with the conversation. + * @property {string} conversationSid - + * The unique ID of the Conversation this Participant belongs to. + * @property {string} conversationUniqueName - + * An application-defined string that uniquely identifies the Conversation resource. + * @property {string} conversationFriendlyName - + * The human-readable name of this conversation. + * @property {string} conversationAttributes - + * An optional string metadata field you can use to store any data you wish. + * @property {Date} conversationDateCreated - + * The date that this conversation was created. + * @property {Date} conversationDateUpdated - + * The date that this conversation was last updated. + * @property {string} conversationCreatedBy - Creator of this conversation. + * @property {participant_conversation.state} conversationState - + * The current state of this User Conversation + * @property {object} conversationTimers - Timer date values for this conversation. + * @property {string} links - + * Absolute URLs to access the participant and conversation of this Participant Conversation. + * + * @param {V1} version - Version of the resource + * @param {ParticipantConversationPayload} payload - The instance payload + * @param {sid} chatServiceSid - + * The unique ID of the Conversation Service this conversation belongs to. + */ +/* jshint ignore:end */ +ParticipantConversationInstance = function + ParticipantConversationInstance(version, payload, chatServiceSid) { + this._version = version; + + // Marshaled Properties + this.accountSid = payload.account_sid; // jshint ignore:line + this.chatServiceSid = payload.chat_service_sid; // jshint ignore:line + this.participantSid = payload.participant_sid; // jshint ignore:line + this.participantUserSid = payload.participant_user_sid; // jshint ignore:line + this.participantIdentity = payload.participant_identity; // jshint ignore:line + this.participantMessagingBinding = payload.participant_messaging_binding; // jshint ignore:line + this.conversationSid = payload.conversation_sid; // jshint ignore:line + this.conversationUniqueName = payload.conversation_unique_name; // jshint ignore:line + this.conversationFriendlyName = payload.conversation_friendly_name; // jshint ignore:line + this.conversationAttributes = payload.conversation_attributes; // jshint ignore:line + this.conversationDateCreated = deserialize.iso8601DateTime(payload.conversation_date_created); // jshint ignore:line + this.conversationDateUpdated = deserialize.iso8601DateTime(payload.conversation_date_updated); // jshint ignore:line + this.conversationCreatedBy = payload.conversation_created_by; // jshint ignore:line + this.conversationState = payload.conversation_state; // jshint ignore:line + this.conversationTimers = payload.conversation_timers; // jshint ignore:line + this.links = payload.links; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {chatServiceSid: chatServiceSid, }; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Conversations.V1.ServiceContext.ParticipantConversationInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +ParticipantConversationInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ParticipantConversationInstance.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + ParticipantConversationList: ParticipantConversationList, + ParticipantConversationPage: ParticipantConversationPage, + ParticipantConversationInstance: ParticipantConversationInstance +}; diff --git a/lib/rest/conversations/v1/service/user/userConversation.js b/lib/rest/conversations/v1/service/user/userConversation.js index 2787ef4eca..2fbda85970 100644 --- a/lib/rest/conversations/v1/service/user/userConversation.js +++ b/lib/rest/conversations/v1/service/user/userConversation.js @@ -424,7 +424,7 @@ UserConversationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {string} chatServiceSid - * The unique ID of the Conversation Service this conversation belongs to. * @property {string} conversationSid - - * The unique ID of the Conversation for this message. + * The unique ID of the Conversation for this User Conversation. * @property {number} unreadMessagesCount - * The number of unread Messages in the Conversation. * @property {number} lastReadMessageIndex - The index of the last read Message . @@ -442,7 +442,7 @@ UserConversationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {user_conversation.notification_level} notificationLevel - * The Notification Level of this User Conversation. * @property {string} uniqueName - - * An application-defined string that uniquely identifies the resource + * An application-defined string that uniquely identifies the Conversation resource. * @property {string} url - The url * @property {string} links - * Absolute URLs to access the participant and conversation of this user conversation. diff --git a/lib/rest/conversations/v1/user/userConversation.js b/lib/rest/conversations/v1/user/userConversation.js index b7bea5389a..dfc5132b71 100644 --- a/lib/rest/conversations/v1/user/userConversation.js +++ b/lib/rest/conversations/v1/user/userConversation.js @@ -410,7 +410,7 @@ UserConversationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {string} chatServiceSid - * The unique ID of the Conversation Service this conversation belongs to. * @property {string} conversationSid - - * The unique ID of the Conversation for this message. + * The unique ID of the Conversation for this User Conversation. * @property {number} unreadMessagesCount - * The number of unread Messages in the Conversation. * @property {number} lastReadMessageIndex - The index of the last read Message . @@ -428,7 +428,7 @@ UserConversationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {user_conversation.notification_level} notificationLevel - * The Notification Level of this User Conversation. * @property {string} uniqueName - - * An application-defined string that uniquely identifies the resource + * An application-defined string that uniquely identifies the Conversation resource. * @property {string} url - The url * @property {string} links - * Absolute URLs to access the participant and conversation of this user conversation. diff --git a/lib/rest/taskrouter/v1/workspace/activity.d.ts b/lib/rest/taskrouter/v1/workspace/activity.d.ts index 14180e32aa..44fa27d8f1 100644 --- a/lib/rest/taskrouter/v1/workspace/activity.d.ts +++ b/lib/rest/taskrouter/v1/workspace/activity.d.ts @@ -236,6 +236,7 @@ interface ActivityResource { date_created: Date; date_updated: Date; friendly_name: string; + links: string; sid: string; url: string; workspace_sid: string; @@ -311,6 +312,7 @@ declare class ActivityInstance extends SerializableClass { */ fetch(callback?: (error: Error | null, items: ActivityInstance) => any): Promise; friendlyName: string; + links: string; /** * remove a ActivityInstance * diff --git a/lib/rest/taskrouter/v1/workspace/activity.js b/lib/rest/taskrouter/v1/workspace/activity.js index 0199ef0ba2..ab3f1a0119 100644 --- a/lib/rest/taskrouter/v1/workspace/activity.js +++ b/lib/rest/taskrouter/v1/workspace/activity.js @@ -482,6 +482,7 @@ ActivityPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {string} workspaceSid - * The SID of the Workspace that contains the Activity * @property {string} url - The absolute URL of the Activity resource + * @property {string} links - The links * * @param {V1} version - Version of the resource * @param {ActivityPayload} payload - The instance payload @@ -502,6 +503,7 @@ ActivityInstance = function ActivityInstance(version, payload, workspaceSid, this.sid = payload.sid; // jshint ignore:line this.workspaceSid = payload.workspace_sid; // jshint ignore:line this.url = payload.url; // jshint ignore:line + this.links = payload.links; // jshint ignore:line // Context this._context = undefined; diff --git a/lib/rest/verify/v2/service/webhook.d.ts b/lib/rest/verify/v2/service/webhook.d.ts index 19ab2776ed..0444c7b13a 100644 --- a/lib/rest/verify/v2/service/webhook.d.ts +++ b/lib/rest/verify/v2/service/webhook.d.ts @@ -14,6 +14,8 @@ type WebhookMethods = 'GET'|'POST'; type WebhookStatus = 'enabled'|'disabled'; +type WebhookVersion = 'v1'|'v2'; + /** * Initialize the WebhookList * @@ -31,12 +33,14 @@ declare function WebhookList(version: V2, serviceSid: string): WebhookListInstan * @property eventTypes - The array of events that this Webhook is subscribed to. * @property friendlyName - The string that you assigned to describe the webhook * @property status - The webhook status + * @property version - The webhook version * @property webhookUrl - The URL associated with this Webhook. */ interface WebhookInstanceUpdateOptions { eventTypes?: string | string[]; friendlyName?: string; status?: WebhookStatus; + version?: WebhookVersion; webhookUrl?: string; } @@ -166,12 +170,14 @@ interface WebhookListInstance { * @property eventTypes - The array of events that this Webhook is subscribed to. * @property friendlyName - The string that you assigned to describe the webhook * @property status - The webhook status + * @property version - The webhook version * @property webhookUrl - The URL associated with this Webhook. */ interface WebhookListInstanceCreateOptions { eventTypes: string | string[]; friendlyName: string; status?: WebhookStatus; + version?: WebhookVersion; webhookUrl: string; } @@ -245,6 +251,7 @@ interface WebhookResource { sid: string; status: WebhookStatus; url: string; + version: WebhookVersion; webhook_method: WebhookMethods; webhook_url: string; } @@ -352,6 +359,7 @@ declare class WebhookInstance extends SerializableClass { */ update(opts?: WebhookInstanceUpdateOptions, callback?: (error: Error | null, items: WebhookInstance) => any): Promise; url: string; + version: WebhookVersion; webhookMethod: WebhookMethods; webhookUrl: string; } @@ -382,4 +390,4 @@ declare class WebhookPage extends Page done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_identity': 'identity', + 'participant_messaging_binding': null, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.participantConversations.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://conversations.twilio.com/v1/ParticipantConversations', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_identity': 'identity', + 'participant_messaging_binding': null, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.participantConversations.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.conversations.v1.participantConversations.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://conversations.twilio.com/v1/ParticipantConversations'; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_empty response', + function(done) { + var body = { + 'conversations': [], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.participantConversations.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full_by_identity response', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_identity': 'identity', + 'participant_messaging_binding': null, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.participantConversations.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full_by_address response', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': null, + 'participant_identity': null, + 'participant_messaging_binding': { + 'address': '+375255555555', + 'proxy_address': '+12345678910', + 'type': 'sms', + 'level': null, + 'name': null, + 'projected_address': null + }, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/ParticipantConversations?Address=%2B375255555555&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/ParticipantConversations?Address=%2B375255555555&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.participantConversations.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/conversations/v1/service.spec.js b/spec/integration/rest/conversations/v1/service.spec.js index 771d76554c..2bd160166d 100644 --- a/spec/integration/rest/conversations/v1/service.spec.js +++ b/spec/integration/rest/conversations/v1/service.spec.js @@ -66,7 +66,8 @@ describe('Service', function() { 'users': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', 'roles': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', 'bindings': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', - 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration' + 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration', + 'participant_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations' } }; @@ -153,7 +154,8 @@ describe('Service', function() { 'users': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', 'roles': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', 'bindings': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', - 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration' + 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration', + 'participant_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations' } }; @@ -184,7 +186,8 @@ describe('Service', function() { 'users': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', 'roles': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', 'bindings': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', - 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration' + 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration', + 'participant_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations' } } ], @@ -218,7 +221,8 @@ describe('Service', function() { 'users': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', 'roles': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', 'bindings': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', - 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration' + 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration', + 'participant_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations' } } ], @@ -257,7 +261,8 @@ describe('Service', function() { 'users': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', 'roles': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', 'bindings': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', - 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration' + 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration', + 'participant_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations' } } ], @@ -311,7 +316,8 @@ describe('Service', function() { 'users': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', 'roles': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', 'bindings': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', - 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration' + 'configuration': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration', + 'participant_conversations': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations' } } ], diff --git a/spec/integration/rest/conversations/v1/service/participantConversation.spec.js b/spec/integration/rest/conversations/v1/service/participantConversation.spec.js new file mode 100644 index 0000000000..e2f22099c5 --- /dev/null +++ b/spec/integration/rest/conversations/v1/service/participantConversation.spec.js @@ -0,0 +1,329 @@ +'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('ParticipantConversation', 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 = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_identity': 'identity', + 'participant_messaging_binding': null, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participantConversations.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_identity': 'identity', + 'participant_messaging_binding': null, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participantConversations.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://conversations.twilio.com/v1/Services/${chatServiceSid}/ParticipantConversations', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_identity': 'identity', + 'participant_messaging_binding': null, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + holodeck.mock(new Response(200, body)); + client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participantConversations.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participantConversations.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var chatServiceSid = 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://conversations.twilio.com/v1/Services/${chatServiceSid}/ParticipantConversations`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_empty response', + function(done) { + var body = { + 'conversations': [], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participantConversations.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full_by_identity response', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': 'USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_identity': 'identity', + 'participant_messaging_binding': null, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Identity=identity&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participantConversations.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full_by_address response', + function(done) { + var body = { + 'conversations': [ + { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'chat_service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_sid': 'CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'participant_sid': 'MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation_friendly_name': 'friendly_name', + 'conversation_state': 'inactive', + 'conversation_timers': { + 'date_inactive': '2015-12-16T22:19:38Z', + 'date_closed': '2015-12-16T22:28:38Z' + }, + 'conversation_attributes': '{}', + 'conversation_date_created': '2015-07-30T20:00:00Z', + 'conversation_date_updated': '2015-07-30T20:00:00Z', + 'conversation_created_by': 'created_by', + 'conversation_unique_name': 'unique_name', + 'participant_user_sid': null, + 'participant_identity': null, + 'participant_messaging_binding': { + 'address': '+375255555555', + 'proxy_address': '+12345678910', + 'type': 'sms', + 'level': null, + 'name': null, + 'projected_address': null + }, + 'links': { + 'participant': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conversation': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Address=%2B375255555555&PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ParticipantConversations?Address=%2B375255555555&PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'conversations' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.conversations.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .participantConversations.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/taskrouter/v1/workspace/activity.spec.js b/spec/integration/rest/taskrouter/v1/workspace/activity.spec.js index effb70070b..3ed93f7f86 100644 --- a/spec/integration/rest/taskrouter/v1/workspace/activity.spec.js +++ b/spec/integration/rest/taskrouter/v1/workspace/activity.spec.js @@ -62,7 +62,10 @@ describe('Activity', function() { 'friendly_name': 'New Activity', 'sid': 'WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } }; holodeck.mock(new Response(200, body)); @@ -110,7 +113,10 @@ describe('Activity', function() { 'friendly_name': 'New Activity', 'sid': 'WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } }; holodeck.mock(new Response(200, body)); @@ -176,18 +182,20 @@ describe('Activity', function() { 'friendly_name': 'New Activity', 'sid': 'WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } } ], 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0', 'key': 'activities', - 'last_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0' } }; holodeck.mock(new Response(200, body)); @@ -207,18 +215,20 @@ describe('Activity', function() { 'friendly_name': 'New Activity', 'sid': 'WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } } ], 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0', 'key': 'activities', - 'last_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0' } }; holodeck.mock(new Response(200, body)); @@ -243,18 +253,20 @@ describe('Activity', function() { 'friendly_name': 'New Activity', 'sid': 'WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } } ], 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0', 'key': 'activities', - 'last_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0' } }; holodeck.mock(new Response(200, body)); @@ -296,18 +308,20 @@ describe('Activity', function() { 'friendly_name': 'New Activity', 'sid': 'WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } } ], 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0', 'key': 'activities', - 'last_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0' } }; @@ -328,14 +342,13 @@ describe('Activity', function() { var body = { 'activities': [], 'meta': { - 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', + 'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0', 'key': 'activities', - 'last_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0', 'next_page_url': null, 'page': 0, 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0' } }; @@ -386,7 +399,10 @@ describe('Activity', function() { 'friendly_name': 'New Activity', 'sid': 'WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'workspace': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } }; holodeck.mock(new Response(201, body)); diff --git a/spec/integration/rest/taskrouter/v1/workspace/worker/workerChannel.spec.js b/spec/integration/rest/taskrouter/v1/workspace/worker/workerChannel.spec.js index bad67b3af0..ec0d3185b1 100644 --- a/spec/integration/rest/taskrouter/v1/workspace/worker/workerChannel.spec.js +++ b/spec/integration/rest/taskrouter/v1/workspace/worker/workerChannel.spec.js @@ -37,9 +37,9 @@ describe('WorkerChannel', function() { 'key': 'channels', 'next_page_url': null, 'page': 0, - 'page_size': 1, + 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0' }, 'channels': [ { @@ -48,12 +48,12 @@ describe('WorkerChannel', function() { 'available': true, 'available_capacity_percentage': 100, 'configured_capacity': 1, - 'date_created': '2014-05-14T10:50:02Z', - 'date_updated': '2014-05-15T16:03:42Z', + 'date_created': '2016-04-14T17:35:54Z', + 'date_updated': '2016-04-14T17:35:54Z', 'sid': 'WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_sid': 'TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_unique_name': 'default', - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'worker_sid': 'WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -73,9 +73,9 @@ describe('WorkerChannel', function() { 'key': 'channels', 'next_page_url': null, 'page': 0, - 'page_size': 1, + 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0' }, 'channels': [ { @@ -84,12 +84,12 @@ describe('WorkerChannel', function() { 'available': true, 'available_capacity_percentage': 100, 'configured_capacity': 1, - 'date_created': '2014-05-14T10:50:02Z', - 'date_updated': '2014-05-15T16:03:42Z', + 'date_created': '2016-04-14T17:35:54Z', + 'date_updated': '2016-04-14T17:35:54Z', 'sid': 'WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_sid': 'TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_unique_name': 'default', - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'worker_sid': 'WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -114,9 +114,9 @@ describe('WorkerChannel', function() { 'key': 'channels', 'next_page_url': null, 'page': 0, - 'page_size': 1, + 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0' }, 'channels': [ { @@ -125,12 +125,12 @@ describe('WorkerChannel', function() { 'available': true, 'available_capacity_percentage': 100, 'configured_capacity': 1, - 'date_created': '2014-05-14T10:50:02Z', - 'date_updated': '2014-05-15T16:03:42Z', + 'date_created': '2016-04-14T17:35:54Z', + 'date_updated': '2016-04-14T17:35:54Z', 'sid': 'WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_sid': 'TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_unique_name': 'default', - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'worker_sid': 'WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -174,9 +174,9 @@ describe('WorkerChannel', function() { 'key': 'channels', 'next_page_url': null, 'page': 0, - 'page_size': 1, + 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0' }, 'channels': [ { @@ -185,12 +185,12 @@ describe('WorkerChannel', function() { 'available': true, 'available_capacity_percentage': 100, 'configured_capacity': 1, - 'date_created': '2014-05-14T10:50:02Z', - 'date_updated': '2014-05-15T16:03:42Z', + 'date_created': '2016-04-14T17:35:54Z', + 'date_updated': '2016-04-14T17:35:54Z', 'sid': 'WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_sid': 'TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_unique_name': 'default', - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'worker_sid': 'WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } @@ -218,9 +218,9 @@ describe('WorkerChannel', function() { 'key': 'channels', 'next_page_url': null, 'page': 0, - 'page_size': 1, + 'page_size': 50, 'previous_page_url': null, - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels' + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0' }, 'channels': [] }; @@ -263,7 +263,7 @@ describe('WorkerChannel', function() { })); } ); - it('should generate valid fetch response', + it('should generate valid fetch_sid response', function(done) { var body = { 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', @@ -271,12 +271,12 @@ describe('WorkerChannel', function() { 'available': true, 'available_capacity_percentage': 100, 'configured_capacity': 1, - 'date_created': '2014-05-14T10:50:02Z', - 'date_updated': '2014-05-15T16:03:42Z', + 'date_created': '2016-04-14T17:35:54Z', + 'date_updated': '2016-04-14T17:35:54Z', 'sid': 'WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_sid': 'TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_unique_name': 'default', - 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'worker_sid': 'WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; @@ -327,8 +327,8 @@ describe('WorkerChannel', function() { 'available': true, 'available_capacity_percentage': 100, 'configured_capacity': 3, - 'date_created': '2014-05-14T10:50:02Z', - 'date_updated': '2014-05-15T16:03:42Z', + 'date_created': '2016-04-14T17:35:54Z', + 'date_updated': '2016-04-14T17:35:54Z', 'sid': 'WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_sid': 'TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'task_channel_unique_name': 'default', diff --git a/spec/integration/rest/verify/v2/service/webhook.spec.js b/spec/integration/rest/verify/v2/service/webhook.spec.js index 11ad6fc5f3..f6e47f4ae6 100644 --- a/spec/integration/rest/verify/v2/service/webhook.spec.js +++ b/spec/integration/rest/verify/v2/service/webhook.spec.js @@ -75,6 +75,7 @@ describe('Webhook', function() { 'webhook_method': 'POST', 'webhook_url': 'https://owlbank.twilio.com', 'status': 'enabled', + 'version': 'v2', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z' }; @@ -130,6 +131,7 @@ describe('Webhook', function() { 'webhook_method': 'POST', 'webhook_url': 'https://owlbank.twilio.com', 'status': 'disabled', + 'version': 'v2', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z' }; @@ -223,6 +225,7 @@ describe('Webhook', function() { 'webhook_method': 'POST', 'webhook_url': 'https://owlbank.twilio.com', 'status': 'enabled', + 'version': 'v2', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z' }; @@ -256,6 +259,7 @@ describe('Webhook', function() { 'webhook_method': 'POST', 'webhook_url': 'https://owlbank.twilio.com', 'status': 'enabled', + 'version': 'v2', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z' } @@ -292,6 +296,7 @@ describe('Webhook', function() { 'webhook_method': 'POST', 'webhook_url': 'https://owlbank.twilio.com', 'status': 'enabled', + 'version': 'v2', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z' } @@ -333,6 +338,7 @@ describe('Webhook', function() { 'webhook_method': 'POST', 'webhook_url': 'https://owlbank.twilio.com', 'status': 'enabled', + 'version': 'v2', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z' } @@ -418,6 +424,7 @@ describe('Webhook', function() { 'webhook_method': 'POST', 'webhook_url': 'https://owlbank.twilio.com', 'status': 'enabled', + 'version': 'v2', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z' } From 51418796670f1b014ad1cb9289a5131990970ddd Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 28 Jul 2021 20:35:16 +0000 Subject: [PATCH 30/30] Release 3.66.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0c7fbd079..0d42ec8e4a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "twilio", "description": "A Twilio helper library", - "version": "3.66.0", + "version": "3.66.1", "author": "API Team ", "contributors": [ {