diff --git a/CHANGES.md b/CHANGES.md index 288631eb79..92b1eb7e7d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,28 @@ twilio-node changelog ===================== +[2018-11-30] Version 3.25.0 +---------------------------- +**Api** +- Add `interactive_data` optional param to Messages create request + +**Authy** +- Required authentication for `/v1/Forms/{type}` endpoint **(breaking change)** +- Removed `Challenge.reason` to `Challenge.responded_reason` +- Removed `verification_sid` from Challenge responses +- Removed `config` param from the Factor creation +- Replaced all occurrences of `FactorType` and `FormType` in favor of a unified `Type` **(breaking change)** + +**Chat** +- Add Member attributes + +**Preview** +- Removed `Authy` version from `preview` subdomain in favor to `authy` subdomain. **(breaking change)** + +**Verify** +- Add `CustomCode` optional parameter on Verication creation. + + [2018-11-16] Version 3.24.0 ---------------------------- **Messaging** diff --git a/lib/rest/Authy.js b/lib/rest/Authy.js index 0be0027df1..7817c08afb 100644 --- a/lib/rest/Authy.js +++ b/lib/rest/Authy.js @@ -21,8 +21,8 @@ var V1 = require('./authy/V1'); /* jshint ignore:line */ * @constructor * * @property {Twilio.Authy.V1} v1 - v1 version - * @property {Twilio.Authy.V1.ServiceList} services - services resource * @property {Twilio.Authy.V1.FormList} forms - forms resource + * @property {Twilio.Authy.V1.ServiceList} services - services resource * * @param {Twilio} twilio - The twilio client */ @@ -46,16 +46,16 @@ Object.defineProperty(Authy.prototype, }); Object.defineProperty(Authy.prototype, - 'services', { + 'forms', { get: function() { - return this.v1.services; + return this.v1.forms; } }); Object.defineProperty(Authy.prototype, - 'forms', { + 'services', { get: function() { - return this.v1.forms; + return this.v1.services; } }); diff --git a/lib/rest/Preview.d.ts b/lib/rest/Preview.d.ts index fbbccb7c68..4756ed772b 100644 --- a/lib/rest/Preview.d.ts +++ b/lib/rest/Preview.d.ts @@ -6,7 +6,6 @@ */ import AccSecurity = require('./preview/AccSecurity'); -import Authy = require('./preview/Authy'); import BulkExports = require('./preview/BulkExports'); import DeployedDevices = require('./preview/DeployedDevices'); import Domain = require('../base/Domain'); @@ -41,7 +40,6 @@ declare class Preview extends Domain { readonly acc_security: AccSecurity; readonly assistants: AssistantListInstance; readonly authorizationDocuments: AuthorizationDocumentListInstance; - readonly authy: Authy; readonly availableAddOns: AvailableAddOnListInstance; readonly bulk_exports: BulkExports; readonly commands: CommandListInstance; diff --git a/lib/rest/Preview.js b/lib/rest/Preview.js index 2fb76a6faa..6e6e933fe0 100644 --- a/lib/rest/Preview.js +++ b/lib/rest/Preview.js @@ -11,7 +11,6 @@ var _ = require('lodash'); /* jshint ignore:line */ var AccSecurity = require('./preview/AccSecurity'); /* jshint ignore:line */ -var Authy = require('./preview/Authy'); /* jshint ignore:line */ var BulkExports = require('./preview/BulkExports'); /* jshint ignore:line */ var DeployedDevices = require( './preview/DeployedDevices'); /* jshint ignore:line */ @@ -30,7 +29,6 @@ var Wireless = require('./preview/Wireless'); /* jshint ignore:line */ * * @constructor * - * @property {Twilio.Preview.Authy} authy - authy version * @property {Twilio.Preview.BulkExports} bulk_exports - bulk_exports version * @property {Twilio.Preview.DeployedDevices} deployed_devices - * deployed_devices version @@ -40,7 +38,6 @@ var Wireless = require('./preview/Wireless'); /* jshint ignore:line */ * @property {Twilio.Preview.Sync} sync - sync version * @property {Twilio.Preview.Understand} understand - understand version * @property {Twilio.Preview.Wireless} wireless - wireless version - * @property {Twilio.Preview.Sync.ServiceList} services - services resource * @property {Twilio.Preview.BulkExports.ExportList} exports - exports resource * @property {Twilio.Preview.BulkExports.ExportConfigurationList} exportConfiguration - * exportConfiguration resource @@ -49,10 +46,11 @@ var Wireless = require('./preview/Wireless'); /* jshint ignore:line */ * authorizationDocuments resource * @property {Twilio.Preview.HostedNumbers.HostedNumberOrderList} hostedNumberOrders - * hostedNumberOrders resource - * @property {Twilio.Preview.Marketplace.InstalledAddOnList} installedAddOns - - * installedAddOns resource * @property {Twilio.Preview.Marketplace.AvailableAddOnList} availableAddOns - * availableAddOns resource + * @property {Twilio.Preview.Marketplace.InstalledAddOnList} installedAddOns - + * installedAddOns resource + * @property {Twilio.Preview.Sync.ServiceList} services - services resource * @property {Twilio.Preview.Understand.AssistantList} assistants - * assistants resource * @property {Twilio.Preview.Wireless.CommandList} commands - commands resource @@ -66,7 +64,6 @@ function Preview(twilio) { Domain.prototype.constructor.call(this, twilio, 'https://preview.twilio.com'); // Versions - this._authy = undefined; this._bulk_exports = undefined; this._deployed_devices = undefined; this._hosted_numbers = undefined; @@ -80,14 +77,6 @@ function Preview(twilio) { _.extend(Preview.prototype, Domain.prototype); Preview.prototype.constructor = Preview; -Object.defineProperty(Preview.prototype, - 'authy', { - get: function() { - this._authy = this._authy || new Authy(this); - return this._authy; - } -}); - Object.defineProperty(Preview.prototype, 'bulk_exports', { get: function() { @@ -152,13 +141,6 @@ Object.defineProperty(Preview.prototype, } }); -Object.defineProperty(Preview.prototype, - 'services', { - get: function() { - return this.sync.services; - } -}); - Object.defineProperty(Preview.prototype, 'exports', { get: function() { @@ -194,6 +176,13 @@ Object.defineProperty(Preview.prototype, } }); +Object.defineProperty(Preview.prototype, + 'availableAddOns', { + get: function() { + return this.marketplace.availableAddOns; + } +}); + Object.defineProperty(Preview.prototype, 'installedAddOns', { get: function() { @@ -202,9 +191,9 @@ Object.defineProperty(Preview.prototype, }); Object.defineProperty(Preview.prototype, - 'availableAddOns', { + 'services', { get: function() { - return this.marketplace.availableAddOns; + return this.sync.services; } }); diff --git a/lib/rest/Video.js b/lib/rest/Video.js index 79d294d8f2..467f0806d8 100644 --- a/lib/rest/Video.js +++ b/lib/rest/Video.js @@ -21,6 +21,7 @@ var V1 = require('./video/V1'); /* jshint ignore:line */ * @constructor * * @property {Twilio.Video.V1} v1 - v1 version + * @property {Twilio.Video.V1.CompositionList} compositions - compositions resource * @property {Twilio.Video.V1.CompositionHookList} compositionHooks - * compositionHooks resource * @property {Twilio.Video.V1.CompositionSettingsList} compositionSettings - @@ -28,7 +29,6 @@ var V1 = require('./video/V1'); /* jshint ignore:line */ * @property {Twilio.Video.V1.RecordingList} recordings - recordings resource * @property {Twilio.Video.V1.RecordingSettingsList} recordingSettings - * recordingSettings resource - * @property {Twilio.Video.V1.CompositionList} compositions - compositions resource * @property {Twilio.Video.V1.RoomList} rooms - rooms resource * * @param {Twilio} twilio - The twilio client @@ -52,6 +52,13 @@ Object.defineProperty(Video.prototype, } }); +Object.defineProperty(Video.prototype, + 'compositions', { + get: function() { + return this.v1.compositions; + } +}); + Object.defineProperty(Video.prototype, 'compositionHooks', { get: function() { @@ -80,13 +87,6 @@ Object.defineProperty(Video.prototype, } }); -Object.defineProperty(Video.prototype, - 'compositions', { - get: function() { - return this.v1.compositions; - } -}); - Object.defineProperty(Video.prototype, 'rooms', { get: function() { diff --git a/lib/rest/api/v2010/account/message.d.ts b/lib/rest/api/v2010/account/message.d.ts index 33555e514d..96c524f511 100644 --- a/lib/rest/api/v2010/account/message.d.ts +++ b/lib/rest/api/v2010/account/message.d.ts @@ -112,6 +112,7 @@ interface MessageListInstance { * @property contentRetention - The content_retention * @property forceDelivery - The force_delivery * @property from - The phone number that initiated the message + * @property interactiveData - JSON string representing interactive data message. * @property maxPrice - The total maximum price up to the fourth decimal in US dollars acceptable for the message to be delivered. * @property maxRate - The max_rate * @property mediaUrl - The URL of the media you wish to send out with the message. @@ -130,6 +131,7 @@ interface MessageListInstanceCreateOptions { contentRetention?: MessageContentRetention; forceDelivery?: boolean; from?: string; + interactiveData?: string; maxPrice?: number; maxRate?: string; mediaUrl?: string[]; diff --git a/lib/rest/api/v2010/account/message.js b/lib/rest/api/v2010/account/message.js index ac0ccc9540..f9b48004bb 100644 --- a/lib/rest/api/v2010/account/message.js +++ b/lib/rest/api/v2010/account/message.js @@ -73,6 +73,8 @@ MessageList = function MessageList(version, accountSid) { * @param {message.address_retention} [opts.addressRetention] - * The address_retention * @param {boolean} [opts.smartEncoded] - The smart_encoded + * @param {string} [opts.interactiveData] - + * JSON string representing interactive data message. * @param {string} [opts.from] - The phone number that initiated the message * @param {string} [opts.messagingServiceSid] - * The 34 character unique id of the Messaging Service you want to associate with this Message. @@ -110,7 +112,8 @@ MessageList = function MessageList(version, accountSid) { 'ProviderSid': _.get(opts, 'providerSid'), 'ContentRetention': _.get(opts, 'contentRetention'), 'AddressRetention': _.get(opts, 'addressRetention'), - 'SmartEncoded': serialize.bool(_.get(opts, 'smartEncoded')) + 'SmartEncoded': serialize.bool(_.get(opts, 'smartEncoded')), + 'InteractiveData': _.get(opts, 'interactiveData') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/api/v2010/account/sip/ipAccessControlList.d.ts b/lib/rest/api/v2010/account/sip/ipAccessControlList.d.ts index 2f40e4e19a..b438b6731e 100644 --- a/lib/rest/api/v2010/account/sip/ipAccessControlList.d.ts +++ b/lib/rest/api/v2010/account/sip/ipAccessControlList.d.ts @@ -58,7 +58,7 @@ interface IpAccessControlListListInstance { /** * Constructs a ip_access_control_list * - * @param sid - Fetch by unique ip-access-control-list Sid + * @param sid - Fetch by unique IpAccessControlList Sid */ get(sid: string): IpAccessControlListContext; /** @@ -184,7 +184,7 @@ declare class IpAccessControlListContext { * * @param version - Version of the resource * @param accountSid - The account_sid - * @param sid - Fetch by unique ip-access-control-list Sid + * @param sid - Fetch by unique IpAccessControlList Sid */ constructor(version: V2010, accountSid: string, sid: string); @@ -226,7 +226,7 @@ declare class IpAccessControlListInstance extends SerializableClass { * @param version - Version of the resource * @param payload - The instance payload * @param accountSid - A 34 character string that uniquely identifies this resource. - * @param sid - Fetch by unique ip-access-control-list Sid + * @param sid - Fetch by unique IpAccessControlList Sid */ constructor(version: V2010, payload: IpAccessControlListPayload, accountSid: string, sid: string); diff --git a/lib/rest/api/v2010/account/sip/ipAccessControlList.js b/lib/rest/api/v2010/account/sip/ipAccessControlList.js index 2a22386a77..bbba8e2842 100644 --- a/lib/rest/api/v2010/account/sip/ipAccessControlList.js +++ b/lib/rest/api/v2010/account/sip/ipAccessControlList.js @@ -325,7 +325,7 @@ IpAccessControlListList = function IpAccessControlListList(version, accountSid) /** * Constructs a ip_access_control_list * - * @param {string} sid - Fetch by unique ip-access-control-list Sid + * @param {string} sid - Fetch by unique IpAccessControlList Sid * * @returns {Twilio.Api.V2010.AccountContext.SipContext.IpAccessControlListContext} */ @@ -390,7 +390,7 @@ IpAccessControlListPage.prototype.getInstance = function getInstance(payload) { * @param {IpAccessControlListPayload} payload - The instance payload * @param {sid} accountSid - * A 34 character string that uniquely identifies this resource. - * @param {sid} sid - Fetch by unique ip-access-control-list Sid + * @param {sid} sid - Fetch by unique IpAccessControlList Sid */ /* jshint ignore:end */ IpAccessControlListInstance = function IpAccessControlListInstance(version, @@ -507,7 +507,7 @@ IpAccessControlListInstance.prototype.toJSON = function toJSON() { * * @param {V2010} version - Version of the resource * @param {sid} accountSid - The account_sid - * @param {sid} sid - Fetch by unique ip-access-control-list Sid + * @param {sid} sid - Fetch by unique IpAccessControlList Sid */ /* jshint ignore:end */ IpAccessControlListContext = function IpAccessControlListContext(version, diff --git a/lib/rest/authy/V1.d.ts b/lib/rest/authy/V1.d.ts index ec8e6d31c0..f50f4f07bc 100644 --- a/lib/rest/authy/V1.d.ts +++ b/lib/rest/authy/V1.d.ts @@ -17,8 +17,8 @@ declare class V1 extends Version { /** * Initialize the V1 version of Authy * - * @property services - services resource * @property forms - forms resource + * @property services - services resource * * @param domain - The twilio domain */ diff --git a/lib/rest/authy/V1.js b/lib/rest/authy/V1.js index b76ed4cd97..33ceb83f11 100644 --- a/lib/rest/authy/V1.js +++ b/lib/rest/authy/V1.js @@ -19,8 +19,8 @@ var Version = require('../../base/Version'); /* jshint ignore:line */ /** * Initialize the V1 version of Authy * - * @property {Twilio.Authy.V1.ServiceList} services - services resource * @property {Twilio.Authy.V1.FormList} forms - forms resource + * @property {Twilio.Authy.V1.ServiceList} services - services resource * * @param {Twilio.Authy} domain - The twilio domain */ @@ -29,26 +29,26 @@ function V1(domain) { Version.prototype.constructor.call(this, domain, 'v1'); // Resources - this._services = undefined; this._forms = undefined; + this._services = undefined; } _.extend(V1.prototype, Version.prototype); V1.prototype.constructor = V1; Object.defineProperty(V1.prototype, - 'services', { + 'forms', { get: function() { - this._services = this._services || new ServiceList(this); - return this._services; + this._forms = this._forms || new FormList(this); + return this._forms; } }); Object.defineProperty(V1.prototype, - 'forms', { + 'services', { get: function() { - this._forms = this._forms || new FormList(this); - return this._forms; + this._services = this._services || new ServiceList(this); + return this._services; } }); diff --git a/lib/rest/authy/v1/form.d.ts b/lib/rest/authy/v1/form.d.ts index 456c246222..f397b6f165 100644 --- a/lib/rest/authy/v1/form.d.ts +++ b/lib/rest/authy/v1/form.d.ts @@ -10,7 +10,7 @@ import Response = require('../../../http/response'); import V1 = require('../V1'); import { SerializableClass } from '../../../interfaces'; -type FormFormType = 'form-app-push'|'form-sms'|'form-totp'; +type FormFormTypes = 'form-app-push'|'form-sms'|'form-totp'; /** * @description Initialize the FormList @@ -28,9 +28,9 @@ interface FormListInstance { /** * Constructs a form * - * @param formType - The Form Type of this Form + * @param type - The Type of this Form */ - get(formType: string): FormContext; + get(type: string): FormContext; } interface FormPayload extends FormResource, Page.TwilioResponsePayload { @@ -38,8 +38,8 @@ interface FormPayload extends FormResource, Page.TwilioResponsePayload { interface FormResource { form_meta: string; - form_type: FormFormType; forms: string; + type: FormFormTypes; url: string; } @@ -52,9 +52,9 @@ declare class FormContext { * Initialize the FormContextPLEASE 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 formType - The Form Type of this Form + * @param type - The Type of this Form */ - constructor(version: V1, formType: FormFormType); + constructor(version: V1, type: FormFormTypes); /** * fetch a FormInstance @@ -69,16 +69,16 @@ declare class FormInstance extends SerializableClass { /** * Initialize the FormContextPLEASE 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. * - * @property formType - The Form Type of this Form - * @property forms - Object that contains the available forms for this form type. - * @property formMeta - Additional information for the available forms for this form type. - * @property url - The URL to access the forms for this form type. + * @property type - The Type of this Form + * @property forms - Object that contains the available forms for this type. + * @property formMeta - Additional information for the available forms for this type. + * @property url - The URL to access the forms for this type. * * @param version - Version of the resource * @param payload - The instance payload - * @param formType - The Form Type of this Form + * @param type - The Type of this Form */ - constructor(version: V1, payload: FormPayload, formType: FormFormType); + constructor(version: V1, payload: FormPayload, type: FormFormTypes); private _proxy: FormContext; /** @@ -88,13 +88,13 @@ declare class FormInstance extends SerializableClass { */ fetch(callback?: (error: Error | null, items: FormInstance) => any): void; formMeta: string; - formType: FormFormType; forms: string; /** * Produce a plain JSON object version of the FormInstance for serialization. * Removes any circular references in the object. */ toJSON(): any; + type: FormFormTypes; url: string; } diff --git a/lib/rest/authy/v1/form.js b/lib/rest/authy/v1/form.js index eeb5d2ac5a..bbac77ebb5 100644 --- a/lib/rest/authy/v1/form.js +++ b/lib/rest/authy/v1/form.js @@ -46,13 +46,13 @@ FormList = function FormList(version) { /** * Constructs a form * - * @param {string} formType - The Form Type of this Form + * @param {string} type - The Type of this Form * * @returns {Twilio.Authy.V1.FormContext} */ /* jshint ignore:end */ - FormListInstance.get = function get(formType) { - return new FormContext(this._version, formType); + FormListInstance.get = function get(type) { + return new FormContext(this._version, type); }; return FormListInstance; @@ -98,37 +98,37 @@ FormPage.prototype.getInstance = function getInstance(payload) { /** * Initialize the FormContextPLEASE 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. * - * @property {form.form_type} formType - The Form Type of this Form + * @property {form.form_types} type - The Type of this Form * @property {string} forms - - * Object that contains the available forms for this form type. + * Object that contains the available forms for this type. * @property {string} formMeta - - * Additional information for the available forms for this form type. - * @property {string} url - The URL to access the forms for this form type. + * Additional information for the available forms for this type. + * @property {string} url - The URL to access the forms for this type. * * @param {V1} version - Version of the resource * @param {FormPayload} payload - The instance payload - * @param {form:enum:form_type} formType - The Form Type of this Form + * @param {form:enum:form_types} type - The Type of this Form */ /* jshint ignore:end */ -FormInstance = function FormInstance(version, payload, formType) { +FormInstance = function FormInstance(version, payload, type) { this._version = version; // Marshaled Properties - this.formType = payload.form_type; // jshint ignore:line + this.type = payload.type; // jshint ignore:line this.forms = payload.forms; // jshint ignore:line this.formMeta = payload.form_meta; // jshint ignore:line this.url = payload.url; // jshint ignore:line // Context this._context = undefined; - this._solution = {formType: formType || this.formType, }; + this._solution = {type: type || this.type, }; }; Object.defineProperty(FormInstance.prototype, '_proxy', { get: function() { if (!this._context) { - this._context = new FormContext(this._version, this._solution.formType); + this._context = new FormContext(this._version, this._solution.type); } return this._context; @@ -172,16 +172,16 @@ FormInstance.prototype.toJSON = function toJSON() { * Initialize the FormContextPLEASE 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 {V1} version - Version of the resource - * @param {form:enum:form_type} formType - The Form Type of this Form + * @param {form:enum:form_types} type - The Type of this Form */ /* jshint ignore:end */ -FormContext = function FormContext(version, formType) { +FormContext = function FormContext(version, type) { this._version = version; // Path Solution - this._solution = {formType: formType, }; + this._solution = {type: type, }; this._uri = _.template( - '/Forms/<%= formType %>' // jshint ignore:line + '/Forms/<%= type %>' // jshint ignore:line )(this._solution); }; @@ -199,7 +199,7 @@ FormContext.prototype.fetch = function fetch(callback) { var promise = this._version.fetch({uri: this._uri, method: 'GET'}); promise = promise.then(function(payload) { - deferred.resolve(new FormInstance(this._version, payload, this._solution.formType)); + deferred.resolve(new FormInstance(this._version, payload, this._solution.type)); }.bind(this)); promise.catch(function(error) { diff --git a/lib/rest/authy/v1/service/entity/factor.d.ts b/lib/rest/authy/v1/service/entity/factor.d.ts index bc6ddebbe0..162c9d7c3f 100644 --- a/lib/rest/authy/v1/service/entity/factor.d.ts +++ b/lib/rest/authy/v1/service/entity/factor.d.ts @@ -12,7 +12,9 @@ import { ChallengeList } from './factor/challenge'; import { ChallengeListInstance } from './factor/challenge'; import { SerializableClass } from '../../../../../interfaces'; -type FactorFactorStatus = 'unverified'|'verified'; +type FactorFactorStatuses = 'unverified'|'verified'; + +type FactorFactorTypes = 'app-push'|'sms'|'totp'; /** * @description Initialize the FactorList @@ -100,15 +102,13 @@ interface FactorListInstance { * Options to pass to create * * @property binding - A unique binding for this Factor - * @property config - Factor configuration - * @property factorType - The Type of this Factor * @property friendlyName - The friendly name of this Factor + * @property type - The Type of this Factor */ interface FactorListInstanceCreateOptions { binding: string; - config?: string; - factorType: string; friendlyName: string; + type: FactorFactorTypes; } /** @@ -181,8 +181,8 @@ interface FactorResource { links: string; service_sid: string; sid: string; - status: FactorFactorStatus; - type: string; + status: FactorFactorStatuses; + type: FactorFactorTypes; url: string; } @@ -279,13 +279,13 @@ declare class FactorInstance extends SerializableClass { remove(callback?: (error: Error | null, items: FactorInstance) => any): void; serviceSid: string; sid: string; - status: FactorFactorStatus; + status: FactorFactorStatuses; /** * Produce a plain JSON object version of the FactorInstance for serialization. * Removes any circular references in the object. */ toJSON(): any; - type: string; + type: FactorFactorTypes; /** * update a FactorInstance * diff --git a/lib/rest/authy/v1/service/entity/factor.js b/lib/rest/authy/v1/service/entity/factor.js index 5c6fdcdc88..937b5f2ac3 100644 --- a/lib/rest/authy/v1/service/entity/factor.js +++ b/lib/rest/authy/v1/service/entity/factor.js @@ -56,9 +56,8 @@ FactorList = function FactorList(version, serviceSid, identity) { * * @param {object} opts - Options for request * @param {string} opts.binding - A unique binding for this Factor - * @param {string} opts.factorType - The Type of this Factor * @param {string} opts.friendlyName - The friendly name of this Factor - * @param {string} [opts.config] - Factor configuration + * @param {factor.factor_types} opts.type - The Type of this Factor * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FactorInstance @@ -71,19 +70,18 @@ FactorList = function FactorList(version, serviceSid, identity) { if (_.isUndefined(opts.binding)) { throw new Error('Required parameter "opts.binding" missing.'); } - if (_.isUndefined(opts.factorType)) { - throw new Error('Required parameter "opts.factorType" missing.'); - } if (_.isUndefined(opts.friendlyName)) { throw new Error('Required parameter "opts.friendlyName" missing.'); } + if (_.isUndefined(opts.type)) { + throw new Error('Required parameter "opts.type" missing.'); + } var deferred = Q.defer(); var data = values.of({ 'Binding': _.get(opts, 'binding'), - 'FactorType': _.get(opts, 'factorType'), 'FriendlyName': _.get(opts, 'friendlyName'), - 'Config': _.get(opts, 'config') + 'Type': _.get(opts, 'type') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); @@ -403,8 +401,8 @@ FactorPage.prototype.getInstance = function getInstance(payload) { * @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 {factor.factor_status} status - The Status of this Factor - * @property {string} type - The Type of this Factor + * @property {factor.factor_statuses} status - The Status of this Factor + * @property {factor.factor_types} type - The Type of this Factor * @property {string} url - The URL of this resource. * @property {string} links - Nested resource URLs. * diff --git a/lib/rest/authy/v1/service/entity/factor/challenge.d.ts b/lib/rest/authy/v1/service/entity/factor/challenge.d.ts index e300f87a77..75e8b02c2f 100644 --- a/lib/rest/authy/v1/service/entity/factor/challenge.d.ts +++ b/lib/rest/authy/v1/service/entity/factor/challenge.d.ts @@ -11,9 +11,11 @@ import V1 = require('../../../../V1'); import serialize = require('../../../../../../base/serialize'); import { SerializableClass } from '../../../../../../interfaces'; -type ChallengeChallengeReason = 'none'|'not_needed'|'not_requested'; +type ChallengeChallengeReasons = 'none'|'not_needed'|'not_requested'; -type ChallengeChallengeStatus = 'pending'|'expired'|'approved'|'denied'; +type ChallengeChallengeStatuses = 'pending'|'expired'|'approved'|'denied'; + +type ChallengeFactorTypes = 'app-push'|'sms'|'totp'; /** * @description Initialize the ChallengeList @@ -82,13 +84,12 @@ interface ChallengeResource { factor_sid: string; hidden_details: string; identity: string; - reason: ChallengeChallengeReason; + responded_reason: ChallengeChallengeReasons; service_sid: string; sid: string; - status: ChallengeChallengeStatus; - type: string; + status: ChallengeChallengeStatuses; + type: ChallengeFactorTypes; url: string; - verification_sid: string; } interface ChallengeSolution { @@ -146,12 +147,11 @@ declare class ChallengeInstance extends SerializableClass { * @property dateUpdated - The date this Challenge was updated * @property dateResponded - The date this Challenge was responded * @property expirationDate - The date this Challenge is expired - * @property verificationSid - Verification Sid. * @property status - The Status of this Challenge - * @property reason - The Reason of this Challenge `status` + * @property respondedReason - The Reason of this Challenge `status` * @property details - Public details provided to contextualize the Challenge * @property hiddenDetails - Hidden details provided to contextualize the Challenge - * @property type - The Factor Type of this Challenge + * @property type - The Type of this Challenge * @property url - The URL of this resource. * * @param version - Version of the resource @@ -180,22 +180,22 @@ declare class ChallengeInstance extends SerializableClass { fetch(callback?: (error: Error | null, items: ChallengeInstance) => any): void; hiddenDetails: string; identity: string; - reason: ChallengeChallengeReason; /** * remove a ChallengeInstance * * @param callback - Callback to handle processed record */ remove(callback?: (error: Error | null, items: ChallengeInstance) => any): void; + respondedReason: ChallengeChallengeReasons; serviceSid: string; sid: string; - status: ChallengeChallengeStatus; + status: ChallengeChallengeStatuses; /** * Produce a plain JSON object version of the ChallengeInstance for serialization. * Removes any circular references in the object. */ toJSON(): any; - type: string; + type: ChallengeFactorTypes; /** * update a ChallengeInstance * @@ -204,7 +204,6 @@ declare class ChallengeInstance extends SerializableClass { */ update(opts?: ChallengeInstanceUpdateOptions, callback?: (error: Error | null, items: ChallengeInstance) => any): void; url: string; - verificationSid: string; } diff --git a/lib/rest/authy/v1/service/entity/factor/challenge.js b/lib/rest/authy/v1/service/entity/factor/challenge.js index db2145a845..938c825add 100644 --- a/lib/rest/authy/v1/service/entity/factor/challenge.js +++ b/lib/rest/authy/v1/service/entity/factor/challenge.js @@ -190,15 +190,14 @@ ChallengePage.prototype.getInstance = function getInstance(payload) { * @property {Date} dateUpdated - The date this Challenge was updated * @property {Date} dateResponded - The date this Challenge was responded * @property {Date} expirationDate - The date this Challenge is expired - * @property {string} verificationSid - Verification Sid. - * @property {challenge.challenge_status} status - The Status of this Challenge - * @property {challenge.challenge_reason} reason - + * @property {challenge.challenge_statuses} status - The Status of this Challenge + * @property {challenge.challenge_reasons} respondedReason - * The Reason of this Challenge `status` * @property {string} details - * Public details provided to contextualize the Challenge * @property {string} hiddenDetails - * Hidden details provided to contextualize the Challenge - * @property {string} type - The Factor Type of this Challenge + * @property {challenge.factor_types} type - The Type of this Challenge * @property {string} url - The URL of this resource. * * @param {V1} version - Version of the resource @@ -225,9 +224,8 @@ ChallengeInstance = function ChallengeInstance(version, payload, serviceSid, this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line this.dateResponded = deserialize.iso8601DateTime(payload.date_responded); // jshint ignore:line this.expirationDate = deserialize.iso8601DateTime(payload.expiration_date); // jshint ignore:line - this.verificationSid = payload.verification_sid; // jshint ignore:line this.status = payload.status; // jshint ignore:line - this.reason = payload.reason; // jshint ignore:line + this.respondedReason = payload.responded_reason; // jshint ignore:line this.details = payload.details; // jshint ignore:line this.hiddenDetails = payload.hidden_details; // jshint ignore:line this.type = payload.type; // jshint ignore:line diff --git a/lib/rest/chat/v2/service/channel/member.d.ts b/lib/rest/chat/v2/service/channel/member.d.ts index 84419d76dc..30739a1e6a 100644 --- a/lib/rest/chat/v2/service/channel/member.d.ts +++ b/lib/rest/chat/v2/service/channel/member.d.ts @@ -25,6 +25,7 @@ declare function MemberList(version: V2, serviceSid: string, channelSid: string) /** * Options to pass to update * + * @property attributes - An optional string metadata field you can use to store any data you wish. * @property dateCreated - The ISO8601 time specifying the datetime the Members should be set as being created. * @property dateUpdated - The ISO8601 time specifying the datetime the Member should be set as having been last updated. * @property lastConsumedMessageIndex - Field used to specify the last consumed Message index for the Channel for this Member. @@ -32,6 +33,7 @@ declare function MemberList(version: V2, serviceSid: string, channelSid: string) * @property roleSid - The role to be assigned to this member. */ interface MemberInstanceUpdateOptions { + attributes?: string; dateCreated?: Date; dateUpdated?: Date; lastConsumedMessageIndex?: number; @@ -105,6 +107,7 @@ interface MemberListInstance { /** * Options to pass to create * + * @property attributes - An optional string metadata field you can use to store any data you wish. * @property dateCreated - The ISO8601 time specifying the datetime the Members should be set as being created. Will be set to the current time by the Chat service if not specified. Note that this should only be used in cases where a Member is being recreated from a backup/separate source * @property dateUpdated - The ISO8601 time specifying the datetime the Member should be set as having been last updated. Will be set to the null by the Chat service if not specified. Note that this should only be used in cases where a Member is being recreated from a backup/separate source and where a Member was previously updated. * @property identity - A unique string identifier for this User in this Service. See the access tokens docs for more details. @@ -113,6 +116,7 @@ interface MemberListInstance { * @property roleSid - The role to be assigned to this member. Defaults to the roles specified on the Service. */ interface MemberListInstanceCreateOptions { + attributes?: string; dateCreated?: Date; dateUpdated?: Date; identity: string; @@ -189,6 +193,7 @@ interface MemberPayload extends MemberResource, Page.TwilioResponsePayload { interface MemberResource { account_sid: string; + attributes: string; channel_sid: string; date_created: Date; date_updated: Date; @@ -255,6 +260,7 @@ declare class MemberInstance extends SerializableClass { * @property lastConsumedMessageIndex - An Integer representing index of the last Message this Member has read within this Channel * @property lastConsumptionTimestamp - An ISO8601 based timestamp string representing the datetime of the last Message read event for this Member within this Channel * @property url - An absolute URL for this member. + * @property attributes - An optional string metadata field you can use to store any data you wish. * * @param version - Version of the resource * @param payload - The instance payload @@ -266,6 +272,7 @@ declare class MemberInstance extends SerializableClass { private _proxy: MemberContext; accountSid: string; + attributes: string; channelSid: string; dateCreated: Date; dateUpdated: Date; diff --git a/lib/rest/chat/v2/service/channel/member.js b/lib/rest/chat/v2/service/channel/member.js index b5c84dfe08..c84528c0af 100644 --- a/lib/rest/chat/v2/service/channel/member.js +++ b/lib/rest/chat/v2/service/channel/member.js @@ -68,6 +68,8 @@ MemberList = function MemberList(version, serviceSid, channelSid) { * The ISO8601 time specifying the datetime the Members should be set as being created. Will be set to the current time by the Chat service if not specified. Note that this should only be used in cases where a Member is being recreated from a backup/separate source * @param {Date} [opts.dateUpdated] - * The ISO8601 time specifying the datetime the Member should be set as having been last updated. Will be set to the null by the Chat service if not specified. Note that this should only be used in cases where a Member is being recreated from a backup/separate source and where a Member was previously updated. + * @param {string} [opts.attributes] - + * An optional string metadata field you can use to store any data you wish. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MemberInstance @@ -88,7 +90,8 @@ MemberList = function MemberList(version, serviceSid, channelSid) { 'LastConsumedMessageIndex': _.get(opts, 'lastConsumedMessageIndex'), 'LastConsumptionTimestamp': serialize.iso8601DateTime(_.get(opts, 'lastConsumptionTimestamp')), 'DateCreated': serialize.iso8601DateTime(_.get(opts, 'dateCreated')), - 'DateUpdated': serialize.iso8601DateTime(_.get(opts, 'dateUpdated')) + 'DateUpdated': serialize.iso8601DateTime(_.get(opts, 'dateUpdated')), + 'Attributes': _.get(opts, 'attributes') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); @@ -424,6 +427,8 @@ MemberPage.prototype.getInstance = function getInstance(payload) { * @property {Date} lastConsumptionTimestamp - * An ISO8601 based timestamp string representing the datetime of the last Message read event for this Member within this Channel * @property {string} url - An absolute URL for this member. + * @property {string} attributes - + * An optional string metadata field you can use to store any data you wish. * * @param {V2} version - Version of the resource * @param {MemberPayload} payload - The instance payload @@ -448,6 +453,7 @@ MemberInstance = function MemberInstance(version, payload, serviceSid, this.lastConsumedMessageIndex = deserialize.integer(payload.last_consumed_message_index); // jshint ignore:line this.lastConsumptionTimestamp = deserialize.iso8601DateTime(payload.last_consumption_timestamp); // jshint ignore:line this.url = payload.url; // jshint ignore:line + this.attributes = payload.attributes; // jshint ignore:line // Context this._context = undefined; @@ -510,6 +516,8 @@ MemberInstance.prototype.remove = function remove(callback) { * The ISO8601 time specifying the datetime the Members should be set as being created. * @param {Date} [opts.dateUpdated] - * The ISO8601 time specifying the datetime the Member should be set as having been last updated. + * @param {string} [opts.attributes] - + * An optional string metadata field you can use to store any data you wish. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MemberInstance @@ -635,6 +643,8 @@ MemberContext.prototype.remove = function remove(callback) { * The ISO8601 time specifying the datetime the Members should be set as being created. * @param {Date} [opts.dateUpdated] - * The ISO8601 time specifying the datetime the Member should be set as having been last updated. + * @param {string} [opts.attributes] - + * An optional string metadata field you can use to store any data you wish. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MemberInstance @@ -653,7 +663,8 @@ MemberContext.prototype.update = function update(opts, callback) { 'LastConsumedMessageIndex': _.get(opts, 'lastConsumedMessageIndex'), 'LastConsumptionTimestamp': serialize.iso8601DateTime(_.get(opts, 'lastConsumptionTimestamp')), 'DateCreated': serialize.iso8601DateTime(_.get(opts, 'dateCreated')), - 'DateUpdated': serialize.iso8601DateTime(_.get(opts, 'dateUpdated')) + 'DateUpdated': serialize.iso8601DateTime(_.get(opts, 'dateUpdated')), + 'Attributes': _.get(opts, 'attributes') }); var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/ipMessaging/v2/service/channel/member.d.ts b/lib/rest/ipMessaging/v2/service/channel/member.d.ts index 84419d76dc..30739a1e6a 100644 --- a/lib/rest/ipMessaging/v2/service/channel/member.d.ts +++ b/lib/rest/ipMessaging/v2/service/channel/member.d.ts @@ -25,6 +25,7 @@ declare function MemberList(version: V2, serviceSid: string, channelSid: string) /** * Options to pass to update * + * @property attributes - An optional string metadata field you can use to store any data you wish. * @property dateCreated - The ISO8601 time specifying the datetime the Members should be set as being created. * @property dateUpdated - The ISO8601 time specifying the datetime the Member should be set as having been last updated. * @property lastConsumedMessageIndex - Field used to specify the last consumed Message index for the Channel for this Member. @@ -32,6 +33,7 @@ declare function MemberList(version: V2, serviceSid: string, channelSid: string) * @property roleSid - The role to be assigned to this member. */ interface MemberInstanceUpdateOptions { + attributes?: string; dateCreated?: Date; dateUpdated?: Date; lastConsumedMessageIndex?: number; @@ -105,6 +107,7 @@ interface MemberListInstance { /** * Options to pass to create * + * @property attributes - An optional string metadata field you can use to store any data you wish. * @property dateCreated - The ISO8601 time specifying the datetime the Members should be set as being created. Will be set to the current time by the Chat service if not specified. Note that this should only be used in cases where a Member is being recreated from a backup/separate source * @property dateUpdated - The ISO8601 time specifying the datetime the Member should be set as having been last updated. Will be set to the null by the Chat service if not specified. Note that this should only be used in cases where a Member is being recreated from a backup/separate source and where a Member was previously updated. * @property identity - A unique string identifier for this User in this Service. See the access tokens docs for more details. @@ -113,6 +116,7 @@ interface MemberListInstance { * @property roleSid - The role to be assigned to this member. Defaults to the roles specified on the Service. */ interface MemberListInstanceCreateOptions { + attributes?: string; dateCreated?: Date; dateUpdated?: Date; identity: string; @@ -189,6 +193,7 @@ interface MemberPayload extends MemberResource, Page.TwilioResponsePayload { interface MemberResource { account_sid: string; + attributes: string; channel_sid: string; date_created: Date; date_updated: Date; @@ -255,6 +260,7 @@ declare class MemberInstance extends SerializableClass { * @property lastConsumedMessageIndex - An Integer representing index of the last Message this Member has read within this Channel * @property lastConsumptionTimestamp - An ISO8601 based timestamp string representing the datetime of the last Message read event for this Member within this Channel * @property url - An absolute URL for this member. + * @property attributes - An optional string metadata field you can use to store any data you wish. * * @param version - Version of the resource * @param payload - The instance payload @@ -266,6 +272,7 @@ declare class MemberInstance extends SerializableClass { private _proxy: MemberContext; accountSid: string; + attributes: string; channelSid: string; dateCreated: Date; dateUpdated: Date; diff --git a/lib/rest/ipMessaging/v2/service/channel/member.js b/lib/rest/ipMessaging/v2/service/channel/member.js index 0bcd871f2b..d81717cc3a 100644 --- a/lib/rest/ipMessaging/v2/service/channel/member.js +++ b/lib/rest/ipMessaging/v2/service/channel/member.js @@ -68,6 +68,8 @@ MemberList = function MemberList(version, serviceSid, channelSid) { * The ISO8601 time specifying the datetime the Members should be set as being created. Will be set to the current time by the Chat service if not specified. Note that this should only be used in cases where a Member is being recreated from a backup/separate source * @param {Date} [opts.dateUpdated] - * The ISO8601 time specifying the datetime the Member should be set as having been last updated. Will be set to the null by the Chat service if not specified. Note that this should only be used in cases where a Member is being recreated from a backup/separate source and where a Member was previously updated. + * @param {string} [opts.attributes] - + * An optional string metadata field you can use to store any data you wish. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MemberInstance @@ -88,7 +90,8 @@ MemberList = function MemberList(version, serviceSid, channelSid) { 'LastConsumedMessageIndex': _.get(opts, 'lastConsumedMessageIndex'), 'LastConsumptionTimestamp': serialize.iso8601DateTime(_.get(opts, 'lastConsumptionTimestamp')), 'DateCreated': serialize.iso8601DateTime(_.get(opts, 'dateCreated')), - 'DateUpdated': serialize.iso8601DateTime(_.get(opts, 'dateUpdated')) + 'DateUpdated': serialize.iso8601DateTime(_.get(opts, 'dateUpdated')), + 'Attributes': _.get(opts, 'attributes') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); @@ -424,6 +427,8 @@ MemberPage.prototype.getInstance = function getInstance(payload) { * @property {Date} lastConsumptionTimestamp - * An ISO8601 based timestamp string representing the datetime of the last Message read event for this Member within this Channel * @property {string} url - An absolute URL for this member. + * @property {string} attributes - + * An optional string metadata field you can use to store any data you wish. * * @param {V2} version - Version of the resource * @param {MemberPayload} payload - The instance payload @@ -448,6 +453,7 @@ MemberInstance = function MemberInstance(version, payload, serviceSid, this.lastConsumedMessageIndex = deserialize.integer(payload.last_consumed_message_index); // jshint ignore:line this.lastConsumptionTimestamp = deserialize.iso8601DateTime(payload.last_consumption_timestamp); // jshint ignore:line this.url = payload.url; // jshint ignore:line + this.attributes = payload.attributes; // jshint ignore:line // Context this._context = undefined; @@ -510,6 +516,8 @@ MemberInstance.prototype.remove = function remove(callback) { * The ISO8601 time specifying the datetime the Members should be set as being created. * @param {Date} [opts.dateUpdated] - * The ISO8601 time specifying the datetime the Member should be set as having been last updated. + * @param {string} [opts.attributes] - + * An optional string metadata field you can use to store any data you wish. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MemberInstance @@ -635,6 +643,8 @@ MemberContext.prototype.remove = function remove(callback) { * The ISO8601 time specifying the datetime the Members should be set as being created. * @param {Date} [opts.dateUpdated] - * The ISO8601 time specifying the datetime the Member should be set as having been last updated. + * @param {string} [opts.attributes] - + * An optional string metadata field you can use to store any data you wish. * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MemberInstance @@ -653,7 +663,8 @@ MemberContext.prototype.update = function update(opts, callback) { 'LastConsumedMessageIndex': _.get(opts, 'lastConsumedMessageIndex'), 'LastConsumptionTimestamp': serialize.iso8601DateTime(_.get(opts, 'lastConsumptionTimestamp')), 'DateCreated': serialize.iso8601DateTime(_.get(opts, 'dateCreated')), - 'DateUpdated': serialize.iso8601DateTime(_.get(opts, 'dateUpdated')) + 'DateUpdated': serialize.iso8601DateTime(_.get(opts, 'dateUpdated')), + 'Attributes': _.get(opts, 'attributes') }); var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/preview/Authy.d.ts b/lib/rest/preview/Authy.d.ts deleted file mode 100644 index 7d57e4128b..0000000000 --- a/lib/rest/preview/Authy.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ - -import Preview = require('../Preview'); -import Version = require('../../base/Version'); -import { ServiceList } from './authy/service'; -import { ServiceListInstance } from './authy/service'; - - -declare class Authy extends Version { - /** - * Initialize the Authy version of Preview - * - * @property services - services resource - * - * @param domain - The twilio domain - */ - constructor(domain: Preview); - - readonly services: ServiceListInstance; -} - -export = Authy; diff --git a/lib/rest/preview/Authy.js b/lib/rest/preview/Authy.js deleted file mode 100644 index 395778fb0d..0000000000 --- a/lib/rest/preview/Authy.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -var _ = require('lodash'); /* jshint ignore:line */ -var ServiceList = require('./authy/service').ServiceList; -var Version = require('../../base/Version'); /* jshint ignore:line */ - - -/* jshint ignore:start */ -/** - * Initialize the Authy version of Preview - * - * @property {Twilio.Preview.Authy.ServiceList} services - services resource - * - * @param {Twilio.Preview} domain - The twilio domain - */ -/* jshint ignore:end */ -function Authy(domain) { - Version.prototype.constructor.call(this, domain, 'Authy'); - - // Resources - this._services = undefined; -} - -_.extend(Authy.prototype, Version.prototype); -Authy.prototype.constructor = Authy; - -Object.defineProperty(Authy.prototype, - 'services', { - get: function() { - this._services = this._services || new ServiceList(this); - return this._services; - } -}); - -module.exports = Authy; diff --git a/lib/rest/preview/Marketplace.d.ts b/lib/rest/preview/Marketplace.d.ts index 977a747a7c..ede7c28c2f 100644 --- a/lib/rest/preview/Marketplace.d.ts +++ b/lib/rest/preview/Marketplace.d.ts @@ -17,8 +17,8 @@ declare class Marketplace extends Version { /** * Initialize the Marketplace version of Preview * - * @property installedAddOns - installedAddOns resource * @property availableAddOns - availableAddOns resource + * @property installedAddOns - installedAddOns resource * * @param domain - The twilio domain */ diff --git a/lib/rest/preview/Marketplace.js b/lib/rest/preview/Marketplace.js index 85eedd00eb..d03b08836d 100644 --- a/lib/rest/preview/Marketplace.js +++ b/lib/rest/preview/Marketplace.js @@ -21,10 +21,10 @@ var Version = require('../../base/Version'); /* jshint ignore:line */ /** * Initialize the Marketplace version of Preview * - * @property {Twilio.Preview.Marketplace.InstalledAddOnList} installedAddOns - - * installedAddOns resource * @property {Twilio.Preview.Marketplace.AvailableAddOnList} availableAddOns - * availableAddOns resource + * @property {Twilio.Preview.Marketplace.InstalledAddOnList} installedAddOns - + * installedAddOns resource * * @param {Twilio.Preview} domain - The twilio domain */ @@ -33,26 +33,26 @@ function Marketplace(domain) { Version.prototype.constructor.call(this, domain, 'marketplace'); // Resources - this._installedAddOns = undefined; this._availableAddOns = undefined; + this._installedAddOns = undefined; } _.extend(Marketplace.prototype, Version.prototype); Marketplace.prototype.constructor = Marketplace; Object.defineProperty(Marketplace.prototype, - 'installedAddOns', { + 'availableAddOns', { get: function() { - this._installedAddOns = this._installedAddOns || new InstalledAddOnList(this); - return this._installedAddOns; + this._availableAddOns = this._availableAddOns || new AvailableAddOnList(this); + return this._availableAddOns; } }); Object.defineProperty(Marketplace.prototype, - 'availableAddOns', { + 'installedAddOns', { get: function() { - this._availableAddOns = this._availableAddOns || new AvailableAddOnList(this); - return this._availableAddOns; + this._installedAddOns = this._installedAddOns || new InstalledAddOnList(this); + return this._installedAddOns; } }); diff --git a/lib/rest/preview/authy/service.d.ts b/lib/rest/preview/authy/service.d.ts deleted file mode 100644 index 110eb32f61..0000000000 --- a/lib/rest/preview/authy/service.d.ts +++ /dev/null @@ -1,275 +0,0 @@ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ - -import Authy = require('../Authy'); -import Page = require('../../../base/Page'); -import Response = require('../../../http/response'); -import { EntityList } from './service/entity'; -import { EntityListInstance } from './service/entity'; -import { SerializableClass } from '../../../interfaces'; - -/** - * @description Initialize the ServiceList - * 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 ServiceList(version: Authy): ServiceListInstance; - -/** - * Options to pass to update - * - * @property friendlyName - A human readable description of this resource. - */ -interface ServiceInstanceUpdateOptions { - friendlyName?: string; -} - -interface ServiceListInstance { - /** - * @param sid - sid of instance - */ - (sid: string): ServiceContext; - /** - * create a ServiceInstance - * - * @param opts - Options for request - * @param callback - Callback to handle processed record - */ - create(opts: ServiceListInstanceCreateOptions, callback?: (error: Error | null, item: ServiceInstance) => any): Promise; - /** - * Streams ServiceInstance 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?: ServiceListInstanceEachOptions, callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void; - /** - * Constructs a service - * - * @param sid - A string that uniquely identifies this Service. - */ - get(sid: string): ServiceContext; - /** - * Retrieve a single target page of ServiceInstance records from the API. - * Request is executed immediately - * - * If a function is passed as the first argument, it will be used as the callback function. - * - * @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: ServicePage) => any): Promise; - /** - * Lists ServiceInstance 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?: ServiceListInstanceOptions, callback?: (error: Error | null, items: ServiceInstance[]) => any): Promise; - /** - * Retrieve a single page of ServiceInstance records from the API. - * Request is executed immediately - * - * If a function is passed as the first argument, it will be used as the callback function. - * - * @param opts - Options for request - * @param callback - Callback to handle list of records - */ - page(opts?: ServiceListInstancePageOptions, callback?: (error: Error | null, items: ServicePage) => any): Promise; -} - -/** - * Options to pass to create - * - * @property friendlyName - A human readable description of this resource. - */ -interface ServiceListInstanceCreateOptions { - friendlyName: 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 ServiceListInstanceEachOptions { - callback?: (item: ServiceInstance, 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 ServiceListInstanceOptions { - 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 ServiceListInstancePageOptions { - pageNumber?: number; - pageSize?: number; - pageToken?: string; -} - -interface ServicePayload extends ServiceResource, Page.TwilioResponsePayload { -} - -interface ServiceResource { - account_sid: string; - date_created: Date; - date_updated: Date; - friendly_name: string; - links: string; - sid: string; - url: string; -} - -interface ServiceSolution { -} - - -declare class ServiceContext { - /** - * Initialize the ServiceContextPLEASE 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. - * - * @property entities - entities resource - * - * @param version - Version of the resource - * @param sid - A string that uniquely identifies this Service. - */ - constructor(version: Authy, sid: string); - - entities: EntityListInstance; - /** - * fetch a ServiceInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: ServiceInstance) => any): Promise; - /** - * update a ServiceInstance - * - * @param opts - Options for request - * @param callback - Callback to handle processed record - */ - update(opts?: ServiceInstanceUpdateOptions, callback?: (error: Error | null, items: ServiceInstance) => any): Promise; -} - - -declare class ServiceInstance extends SerializableClass { - /** - * Initialize the ServiceContextPLEASE 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. - * - * @property sid - A string that uniquely identifies this Service. - * @property friendlyName - A human readable description of this resource. - * @property accountSid - Account Sid. - * @property dateCreated - The date this Service was created - * @property dateUpdated - The date this Service was updated - * @property url - The URL of this resource. - * @property links - Nested resource URLs. - * - * @param version - Version of the resource - * @param payload - The instance payload - * @param sid - A string that uniquely identifies this Service. - */ - constructor(version: Authy, payload: ServicePayload, sid: string); - - private _proxy: ServiceContext; - accountSid: string; - dateCreated: Date; - dateUpdated: Date; - /** - * Access the entities - */ - entities(): EntityListInstance; - /** - * fetch a ServiceInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: ServiceInstance) => any): void; - friendlyName: string; - links: string; - sid: string; - /** - * Produce a plain JSON object version of the ServiceInstance for serialization. - * Removes any circular references in the object. - */ - toJSON(): any; - /** - * update a ServiceInstance - * - * @param opts - Options for request - * @param callback - Callback to handle processed record - */ - update(opts?: ServiceInstanceUpdateOptions, callback?: (error: Error | null, items: ServiceInstance) => any): void; - url: string; -} - - -declare class ServicePage extends Page { - /** - * Initialize the ServicePagePLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor(version: Authy, response: Response, solution: ServiceSolution); - - /** - * Build an instance of ServiceInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: ServicePayload): ServiceInstance; -} - -export { ServiceContext, ServiceInstance, ServiceList, ServiceListInstance, ServiceListInstanceCreateOptions, ServiceListInstanceEachOptions, ServiceListInstanceOptions, ServiceListInstancePageOptions, ServicePage, ServicePayload, ServiceResource, ServiceSolution } diff --git a/lib/rest/preview/authy/service.js b/lib/rest/preview/authy/service.js deleted file mode 100644 index ead346cf4d..0000000000 --- a/lib/rest/preview/authy/service.js +++ /dev/null @@ -1,578 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -var Q = require('q'); /* jshint ignore:line */ -var _ = require('lodash'); /* jshint ignore:line */ -var EntityList = require('./service/entity').EntityList; -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 ServiceList; -var ServicePage; -var ServiceInstance; -var ServiceContext; - -/* jshint ignore:start */ -/** - * @description Initialize the ServiceList - * 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 {Twilio.Preview.Authy} version - Version of the resource - */ -/* jshint ignore:end */ -ServiceList = function ServiceList(version) { - /* jshint ignore:start */ - /** - * @param {string} sid - sid of instance - * - * @returns {Twilio.Preview.Authy.ServiceContext} - */ - /* jshint ignore:end */ - function ServiceListInstance(sid) { - return ServiceListInstance.get(sid); - } - - ServiceListInstance._version = version; - // Path Solution - ServiceListInstance._solution = {}; - ServiceListInstance._uri = _.template( - '/Services' // jshint ignore:line - )(ServiceListInstance._solution); - /* jshint ignore:start */ - /** - * create a ServiceInstance - * - * @param {object} opts - Options for request - * @param {string} opts.friendlyName - - * A human readable description of this resource. - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ServiceInstance - */ - /* jshint ignore:end */ - ServiceListInstance.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.'); - } - - var deferred = Q.defer(); - var data = values.of({'FriendlyName': _.get(opts, 'friendlyName')}); - - var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); - - promise = promise.then(function(payload) { - deferred.resolve(new ServiceInstance(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 ServiceInstance 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 {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 */ - ServiceListInstance.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 ((limits.pageLimit && limits.pageLimit <= currentPage)) { - onComplete(); - } else if (!done) { - currentPage++; - fetchNextPage(_.bind(page.nextPage, page)); - } - }); - - promise.catch(onComplete); - } - - fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); - }; - - /* jshint ignore:start */ - /** - * Lists ServiceInstance 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 {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 */ - ServiceListInstance.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 ServiceInstance records from the API. - * Request is executed immediately - * - * If a function is passed as the first argument, it will be used as the callback function. - * - * @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 */ - ServiceListInstance.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 ServicePage(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 ServiceInstance records from the API. - * Request is executed immediately - * - * If a function is passed as the first argument, it will be used as the callback function. - * - * @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 */ - ServiceListInstance.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 ServicePage(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 service - * - * @param {string} sid - A string that uniquely identifies this Service. - * - * @returns {Twilio.Preview.Authy.ServiceContext} - */ - /* jshint ignore:end */ - ServiceListInstance.get = function get(sid) { - return new ServiceContext(this._version, sid); - }; - - return ServiceListInstance; -}; - - -/* jshint ignore:start */ -/** - * Initialize the ServicePagePLEASE 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 {Authy} version - Version of the resource - * @param {Response} response - Response from the API - * @param {ServiceSolution} solution - Path solution - * - * @returns ServicePage - */ -/* jshint ignore:end */ -ServicePage = function ServicePage(version, response, solution) { - // Path Solution - this._solution = solution; - - Page.prototype.constructor.call(this, version, response, this._solution); -}; - -_.extend(ServicePage.prototype, Page.prototype); -ServicePage.prototype.constructor = ServicePage; - -/* jshint ignore:start */ -/** - * Build an instance of ServiceInstance - * - * @param {ServicePayload} payload - Payload response from the API - * - * @returns ServiceInstance - */ -/* jshint ignore:end */ -ServicePage.prototype.getInstance = function getInstance(payload) { - return new ServiceInstance(this._version, payload); -}; - - -/* jshint ignore:start */ -/** - * Initialize the ServiceContextPLEASE 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. - * - * @property {string} sid - A string that uniquely identifies this Service. - * @property {string} friendlyName - A human readable description of this resource. - * @property {string} accountSid - Account Sid. - * @property {Date} dateCreated - The date this Service was created - * @property {Date} dateUpdated - The date this Service was updated - * @property {string} url - The URL of this resource. - * @property {string} links - Nested resource URLs. - * - * @param {Authy} version - Version of the resource - * @param {ServicePayload} payload - The instance payload - * @param {sid} sid - A string that uniquely identifies this Service. - */ -/* jshint ignore:end */ -ServiceInstance = function ServiceInstance(version, payload, sid) { - this._version = version; - - // Marshaled Properties - this.sid = payload.sid; // jshint ignore:line - this.friendlyName = payload.friendly_name; // jshint ignore:line - this.accountSid = payload.account_sid; // 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 - this.links = payload.links; // jshint ignore:line - - // Context - this._context = undefined; - this._solution = {sid: sid || this.sid, }; -}; - -Object.defineProperty(ServiceInstance.prototype, - '_proxy', { - get: function() { - if (!this._context) { - this._context = new ServiceContext(this._version, this._solution.sid); - } - - return this._context; - } -}); - -/* jshint ignore:start */ -/** - * fetch a ServiceInstance - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ServiceInstance - */ -/* jshint ignore:end */ -ServiceInstance.prototype.fetch = function fetch(callback) { - return this._proxy.fetch(callback); -}; - -/* jshint ignore:start */ -/** - * update a ServiceInstance - * - * @param {object} [opts] - Options for request - * @param {string} [opts.friendlyName] - - * A human readable description of this resource. - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ServiceInstance - */ -/* jshint ignore:end */ -ServiceInstance.prototype.update = function update(opts, callback) { - return this._proxy.update(opts, callback); -}; - -/* jshint ignore:start */ -/** - * Access the entities - * - * @returns {Twilio.Preview.Authy.ServiceContext.EntityList} - */ -/* jshint ignore:end */ -ServiceInstance.prototype.entities = function entities() { - return this._proxy.entities; -}; - -/* jshint ignore:start */ -/** - * Produce a plain JSON object version of the ServiceInstance for serialization. - * Removes any circular references in the object. - * - * @returns Object - */ -/* jshint ignore:end */ -ServiceInstance.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - - -/* jshint ignore:start */ -/** - * Initialize the ServiceContextPLEASE 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. - * - * @property {Twilio.Preview.Authy.ServiceContext.EntityList} entities - - * entities resource - * - * @param {Authy} version - Version of the resource - * @param {sid} sid - A string that uniquely identifies this Service. - */ -/* jshint ignore:end */ -ServiceContext = function ServiceContext(version, sid) { - this._version = version; - - // Path Solution - this._solution = {sid: sid, }; - this._uri = _.template( - '/Services/<%= sid %>' // jshint ignore:line - )(this._solution); - - // Dependents - this._entities = undefined; -}; - -/* jshint ignore:start */ -/** - * fetch a ServiceInstance - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ServiceInstance - */ -/* jshint ignore:end */ -ServiceContext.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 ServiceInstance(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 ServiceInstance - * - * @param {object} [opts] - Options for request - * @param {string} [opts.friendlyName] - - * A human readable description of this resource. - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed ServiceInstance - */ -/* jshint ignore:end */ -ServiceContext.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')}); - - var promise = this._version.update({uri: this._uri, method: 'POST', data: data}); - - promise = promise.then(function(payload) { - deferred.resolve(new ServiceInstance(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(ServiceContext.prototype, - 'entities', { - get: function() { - if (!this._entities) { - this._entities = new EntityList(this._version, this._solution.sid); - } - return this._entities; - } -}); - -module.exports = { - ServiceList: ServiceList, - ServicePage: ServicePage, - ServiceInstance: ServiceInstance, - ServiceContext: ServiceContext -}; diff --git a/lib/rest/preview/authy/service/entity.d.ts b/lib/rest/preview/authy/service/entity.d.ts deleted file mode 100644 index aa63298367..0000000000 --- a/lib/rest/preview/authy/service/entity.d.ts +++ /dev/null @@ -1,250 +0,0 @@ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ - -import Authy = require('../../Authy'); -import Page = require('../../../../base/Page'); -import Response = require('../../../../http/response'); -import { SerializableClass } from '../../../../interfaces'; - -/** - * @description Initialize the EntityList - * 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 serviceSid - Service Sid. - */ -declare function EntityList(version: Authy, serviceSid: string): EntityListInstance; - -interface EntityListInstance { - /** - * @param sid - sid of instance - */ - (sid: string): EntityContext; - /** - * create a EntityInstance - * - * @param opts - Options for request - * @param callback - Callback to handle processed record - */ - create(opts: EntityListInstanceCreateOptions, callback?: (error: Error | null, item: EntityInstance) => any): Promise; - /** - * Streams EntityInstance 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?: EntityListInstanceEachOptions, callback?: (item: EntityInstance, done: (err?: Error) => void) => void): void; - /** - * Constructs a entity - * - * @param identity - Unique identity of the Entity - */ - get(identity: string): EntityContext; - /** - * Retrieve a single target page of EntityInstance records from the API. - * Request is executed immediately - * - * If a function is passed as the first argument, it will be used as the callback function. - * - * @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: EntityPage) => any): Promise; - /** - * Lists EntityInstance 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?: EntityListInstanceOptions, callback?: (error: Error | null, items: EntityInstance[]) => any): Promise; - /** - * Retrieve a single page of EntityInstance records from the API. - * Request is executed immediately - * - * If a function is passed as the first argument, it will be used as the callback function. - * - * @param opts - Options for request - * @param callback - Callback to handle list of records - */ - page(opts?: EntityListInstancePageOptions, callback?: (error: Error | null, items: EntityPage) => any): Promise; -} - -/** - * Options to pass to create - * - * @property identity - Unique identity of the Entity - */ -interface EntityListInstanceCreateOptions { - identity: 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 EntityListInstanceEachOptions { - callback?: (item: EntityInstance, 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 EntityListInstanceOptions { - 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 EntityListInstancePageOptions { - pageNumber?: number; - pageSize?: number; - pageToken?: string; -} - -interface EntityPayload extends EntityResource, Page.TwilioResponsePayload { -} - -interface EntityResource { - account_sid: string; - date_created: Date; - date_updated: Date; - identity: string; - links: string; - service_sid: string; - sid: string; - url: string; -} - -interface EntitySolution { - serviceSid?: string; -} - - -declare class EntityContext { - /** - * Initialize the EntityContextPLEASE 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 serviceSid - Service Sid. - * @param identity - Unique identity of the Entity - */ - constructor(version: Authy, serviceSid: string, identity: string); - - /** - * fetch a EntityInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: EntityInstance) => any): Promise; -} - - -declare class EntityInstance extends SerializableClass { - /** - * Initialize the EntityContextPLEASE 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. - * - * @property sid - A string that uniquely identifies this Entity. - * @property identity - Unique identity of the Entity - * @property accountSid - Account Sid. - * @property serviceSid - Service Sid. - * @property dateCreated - The date this Entity was created - * @property dateUpdated - The date this Entity was updated - * @property url - The URL of this resource. - * @property links - Nested resource URLs. - * - * @param version - Version of the resource - * @param payload - The instance payload - * @param serviceSid - Service Sid. - * @param identity - Unique identity of the Entity - */ - constructor(version: Authy, payload: EntityPayload, serviceSid: string, identity: string); - - private _proxy: EntityContext; - accountSid: string; - dateCreated: Date; - dateUpdated: Date; - /** - * fetch a EntityInstance - * - * @param callback - Callback to handle processed record - */ - fetch(callback?: (error: Error | null, items: EntityInstance) => any): void; - identity: string; - links: string; - serviceSid: string; - sid: string; - /** - * Produce a plain JSON object version of the EntityInstance for serialization. - * Removes any circular references in the object. - */ - toJSON(): any; - url: string; -} - - -declare class EntityPage extends Page { - /** - * Initialize the EntityPagePLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor(version: Authy, response: Response, solution: EntitySolution); - - /** - * Build an instance of EntityInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: EntityPayload): EntityInstance; -} - -export { EntityContext, EntityInstance, EntityList, EntityListInstance, EntityListInstanceCreateOptions, EntityListInstanceEachOptions, EntityListInstanceOptions, EntityListInstancePageOptions, EntityPage, EntityPayload, EntityResource, EntitySolution } diff --git a/lib/rest/preview/authy/service/entity.js b/lib/rest/preview/authy/service/entity.js deleted file mode 100644 index 8c2e62439e..0000000000 --- a/lib/rest/preview/authy/service/entity.js +++ /dev/null @@ -1,514 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -var Q = require('q'); /* jshint ignore:line */ -var _ = require('lodash'); /* jshint ignore:line */ -var Page = require('../../../../base/Page'); /* jshint ignore:line */ -var deserialize = require( - '../../../../base/deserialize'); /* jshint ignore:line */ -var values = require('../../../../base/values'); /* jshint ignore:line */ - -var EntityList; -var EntityPage; -var EntityInstance; -var EntityContext; - -/* jshint ignore:start */ -/** - * @description Initialize the EntityList - * 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 {Twilio.Preview.Authy} version - Version of the resource - * @param {string} serviceSid - Service Sid. - */ -/* jshint ignore:end */ -EntityList = function EntityList(version, serviceSid) { - /* jshint ignore:start */ - /** - * @param {string} sid - sid of instance - * - * @returns {Twilio.Preview.Authy.ServiceContext.EntityContext} - */ - /* jshint ignore:end */ - function EntityListInstance(sid) { - return EntityListInstance.get(sid); - } - - EntityListInstance._version = version; - // Path Solution - EntityListInstance._solution = {serviceSid: serviceSid}; - EntityListInstance._uri = _.template( - '/Services/<%= serviceSid %>/Entities' // jshint ignore:line - )(EntityListInstance._solution); - /* jshint ignore:start */ - /** - * create a EntityInstance - * - * @param {object} opts - Options for request - * @param {string} opts.identity - Unique identity of the Entity - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed EntityInstance - */ - /* jshint ignore:end */ - EntityListInstance.create = function create(opts, callback) { - if (_.isUndefined(opts)) { - throw new Error('Required parameter "opts" missing.'); - } - if (_.isUndefined(opts.identity)) { - throw new Error('Required parameter "opts.identity" missing.'); - } - - var deferred = Q.defer(); - var data = values.of({'Identity': _.get(opts, 'identity')}); - - var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); - - promise = promise.then(function(payload) { - deferred.resolve(new EntityInstance( - this._version, - payload, - this._solution.serviceSid, - this._solution.identity - )); - }.bind(this)); - - promise.catch(function(error) { - deferred.reject(error); - }); - - if (_.isFunction(callback)) { - deferred.promise.nodeify(callback); - } - - return deferred.promise; - }; - - /* jshint ignore:start */ - /** - * Streams EntityInstance 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 {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 */ - EntityListInstance.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 ((limits.pageLimit && limits.pageLimit <= currentPage)) { - onComplete(); - } else if (!done) { - currentPage++; - fetchNextPage(_.bind(page.nextPage, page)); - } - }); - - promise.catch(onComplete); - } - - fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); - }; - - /* jshint ignore:start */ - /** - * Lists EntityInstance 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 {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 */ - EntityListInstance.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 EntityInstance records from the API. - * Request is executed immediately - * - * If a function is passed as the first argument, it will be used as the callback function. - * - * @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 */ - EntityListInstance.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 EntityPage(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 EntityInstance records from the API. - * Request is executed immediately - * - * If a function is passed as the first argument, it will be used as the callback function. - * - * @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 */ - EntityListInstance.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 EntityPage(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 entity - * - * @param {string} identity - Unique identity of the Entity - * - * @returns {Twilio.Preview.Authy.ServiceContext.EntityContext} - */ - /* jshint ignore:end */ - EntityListInstance.get = function get(identity) { - return new EntityContext(this._version, this._solution.serviceSid, identity); - }; - - return EntityListInstance; -}; - - -/* jshint ignore:start */ -/** - * Initialize the EntityPagePLEASE 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 {Authy} version - Version of the resource - * @param {Response} response - Response from the API - * @param {EntitySolution} solution - Path solution - * - * @returns EntityPage - */ -/* jshint ignore:end */ -EntityPage = function EntityPage(version, response, solution) { - // Path Solution - this._solution = solution; - - Page.prototype.constructor.call(this, version, response, this._solution); -}; - -_.extend(EntityPage.prototype, Page.prototype); -EntityPage.prototype.constructor = EntityPage; - -/* jshint ignore:start */ -/** - * Build an instance of EntityInstance - * - * @param {EntityPayload} payload - Payload response from the API - * - * @returns EntityInstance - */ -/* jshint ignore:end */ -EntityPage.prototype.getInstance = function getInstance(payload) { - return new EntityInstance(this._version, payload, this._solution.serviceSid); -}; - - -/* jshint ignore:start */ -/** - * Initialize the EntityContextPLEASE 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. - * - * @property {string} sid - A string that uniquely identifies this Entity. - * @property {string} identity - Unique identity of the Entity - * @property {string} accountSid - Account Sid. - * @property {string} serviceSid - Service Sid. - * @property {Date} dateCreated - The date this Entity was created - * @property {Date} dateUpdated - The date this Entity was updated - * @property {string} url - The URL of this resource. - * @property {string} links - Nested resource URLs. - * - * @param {Authy} version - Version of the resource - * @param {EntityPayload} payload - The instance payload - * @param {sid} serviceSid - Service Sid. - * @param {string} identity - Unique identity of the Entity - */ -/* jshint ignore:end */ -EntityInstance = function EntityInstance(version, payload, serviceSid, identity) - { - this._version = version; - - // Marshaled Properties - this.sid = payload.sid; // jshint ignore:line - this.identity = payload.identity; // jshint ignore:line - this.accountSid = payload.account_sid; // jshint ignore:line - this.serviceSid = payload.service_sid; // 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 - this.links = payload.links; // jshint ignore:line - - // Context - this._context = undefined; - this._solution = {serviceSid: serviceSid, identity: identity || this.identity, }; -}; - -Object.defineProperty(EntityInstance.prototype, - '_proxy', { - get: function() { - if (!this._context) { - this._context = new EntityContext( - this._version, - this._solution.serviceSid, - this._solution.identity - ); - } - - return this._context; - } -}); - -/* jshint ignore:start */ -/** - * fetch a EntityInstance - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed EntityInstance - */ -/* jshint ignore:end */ -EntityInstance.prototype.fetch = function fetch(callback) { - return this._proxy.fetch(callback); -}; - -/* jshint ignore:start */ -/** - * Produce a plain JSON object version of the EntityInstance for serialization. - * Removes any circular references in the object. - * - * @returns Object - */ -/* jshint ignore:end */ -EntityInstance.prototype.toJSON = function toJSON() { - let clone = {}; - _.forOwn(this, function(value, key) { - if (!_.startsWith(key, '_') && ! _.isFunction(value)) { - clone[key] = value; - } - }); - return clone; -}; - - -/* jshint ignore:start */ -/** - * Initialize the EntityContextPLEASE 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 {Authy} version - Version of the resource - * @param {sid} serviceSid - Service Sid. - * @param {string} identity - Unique identity of the Entity - */ -/* jshint ignore:end */ -EntityContext = function EntityContext(version, serviceSid, identity) { - this._version = version; - - // Path Solution - this._solution = {serviceSid: serviceSid, identity: identity, }; - this._uri = _.template( - '/Services/<%= serviceSid %>/Entities/<%= identity %>' // jshint ignore:line - )(this._solution); -}; - -/* jshint ignore:start */ -/** - * fetch a EntityInstance - * - * @param {function} [callback] - Callback to handle processed record - * - * @returns {Promise} Resolves to processed EntityInstance - */ -/* jshint ignore:end */ -EntityContext.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 EntityInstance( - this._version, - payload, - this._solution.serviceSid, - this._solution.identity - )); - }.bind(this)); - - promise.catch(function(error) { - deferred.reject(error); - }); - - if (_.isFunction(callback)) { - deferred.promise.nodeify(callback); - } - - return deferred.promise; -}; - -module.exports = { - EntityList: EntityList, - EntityPage: EntityPage, - EntityInstance: EntityInstance, - EntityContext: EntityContext -}; diff --git a/lib/rest/verify/v1/service/verification.d.ts b/lib/rest/verify/v1/service/verification.d.ts index 2ccc07ba40..e3875161e4 100644 --- a/lib/rest/verify/v1/service/verification.d.ts +++ b/lib/rest/verify/v1/service/verification.d.ts @@ -35,6 +35,7 @@ interface VerificationListInstance { * Options to pass to create * * @property channel - sms or call + * @property customCode - A pre-generated code * @property customMessage - A custom message for this verification * @property locale - Locale used in the sms or call. * @property sendDigits - Digits to send when a phone call is started @@ -42,6 +43,7 @@ interface VerificationListInstance { */ interface VerificationListInstanceCreateOptions { channel: string; + customCode?: string; customMessage?: string; locale?: string; sendDigits?: string; diff --git a/lib/rest/verify/v1/service/verification.js b/lib/rest/verify/v1/service/verification.js index 3090bc888c..2c2b516c6d 100644 --- a/lib/rest/verify/v1/service/verification.js +++ b/lib/rest/verify/v1/service/verification.js @@ -57,6 +57,7 @@ VerificationList = function VerificationList(version, serviceSid) { * @param {string} [opts.customMessage] - A custom message for this verification * @param {string} [opts.sendDigits] - Digits to send when a phone call is started * @param {string} [opts.locale] - Locale used in the sms or call. + * @param {string} [opts.customCode] - A pre-generated code * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed VerificationInstance @@ -79,7 +80,8 @@ VerificationList = function VerificationList(version, serviceSid) { 'Channel': _.get(opts, 'channel'), 'CustomMessage': _.get(opts, 'customMessage'), 'SendDigits': _.get(opts, 'sendDigits'), - 'Locale': _.get(opts, 'locale') + 'Locale': _.get(opts, 'locale'), + 'CustomCode': _.get(opts, 'customCode') }); var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); diff --git a/lib/rest/video/V1.d.ts b/lib/rest/video/V1.d.ts index 89bd1f48c6..6c3f63588d 100644 --- a/lib/rest/video/V1.d.ts +++ b/lib/rest/video/V1.d.ts @@ -25,11 +25,11 @@ declare class V1 extends Version { /** * Initialize the V1 version of Video * + * @property compositions - compositions resource * @property compositionHooks - compositionHooks resource * @property compositionSettings - compositionSettings resource * @property recordings - recordings resource * @property recordingSettings - recordingSettings resource - * @property compositions - compositions resource * @property rooms - rooms resource * * @param domain - The twilio domain diff --git a/lib/rest/video/V1.js b/lib/rest/video/V1.js index cd187e7865..d8ac8855a7 100644 --- a/lib/rest/video/V1.js +++ b/lib/rest/video/V1.js @@ -25,6 +25,7 @@ var Version = require('../../base/Version'); /* jshint ignore:line */ /** * Initialize the V1 version of Video * + * @property {Twilio.Video.V1.CompositionList} compositions - compositions resource * @property {Twilio.Video.V1.CompositionHookList} compositionHooks - * compositionHooks resource * @property {Twilio.Video.V1.CompositionSettingsList} compositionSettings - @@ -32,7 +33,6 @@ var Version = require('../../base/Version'); /* jshint ignore:line */ * @property {Twilio.Video.V1.RecordingList} recordings - recordings resource * @property {Twilio.Video.V1.RecordingSettingsList} recordingSettings - * recordingSettings resource - * @property {Twilio.Video.V1.CompositionList} compositions - compositions resource * @property {Twilio.Video.V1.RoomList} rooms - rooms resource * * @param {Twilio.Video} domain - The twilio domain @@ -42,17 +42,25 @@ function V1(domain) { Version.prototype.constructor.call(this, domain, 'v1'); // Resources + this._compositions = undefined; this._compositionHooks = undefined; this._compositionSettings = undefined; this._recordings = undefined; this._recordingSettings = undefined; - this._compositions = undefined; this._rooms = undefined; } _.extend(V1.prototype, Version.prototype); V1.prototype.constructor = V1; +Object.defineProperty(V1.prototype, + 'compositions', { + get: function() { + this._compositions = this._compositions || new CompositionList(this); + return this._compositions; + } +}); + Object.defineProperty(V1.prototype, 'compositionHooks', { get: function() { @@ -85,14 +93,6 @@ Object.defineProperty(V1.prototype, } }); -Object.defineProperty(V1.prototype, - 'compositions', { - get: function() { - this._compositions = this._compositions || new CompositionList(this); - return this._compositions; - } -}); - Object.defineProperty(V1.prototype, 'rooms', { get: function() { diff --git a/spec/integration/rest/authy/v1/form.spec.js b/spec/integration/rest/authy/v1/form.spec.js index d40f3bbbf2..ab61a956a0 100644 --- a/spec/integration/rest/authy/v1/form.spec.js +++ b/spec/integration/rest/authy/v1/form.spec.js @@ -42,8 +42,8 @@ describe('Form', function() { }); promise.done(); - var solution = {formType: 'form-app-push'}; - var url = _.template('https://authy.twilio.com/v1/Forms/<%= formType %>')(solution); + var solution = {type: 'form-app-push'}; + var url = _.template('https://authy.twilio.com/v1/Forms/<%= type %>')(solution); holodeck.assertHasRequest(new Request({ method: 'GET', @@ -54,7 +54,7 @@ describe('Form', function() { it('should generate valid fetch response', function() { var body = JSON.stringify({ - 'form_type': 'form-sms', + 'type': 'form-sms', 'forms': { 'create_factor': {}, 'verify_factor': {}, diff --git a/spec/integration/rest/authy/v1/service/entity/factor.spec.js b/spec/integration/rest/authy/v1/service/entity/factor.spec.js index b27b8ad675..6cdad497e7 100644 --- a/spec/integration/rest/authy/v1/service/entity/factor.spec.js +++ b/spec/integration/rest/authy/v1/service/entity/factor.spec.js @@ -34,7 +34,7 @@ describe('Factor', function() { function() { holodeck.mock(new Response(500, '{}')); - var opts = {binding: 'binding', factorType: 'factorType', friendlyName: 'friendlyName'}; + var opts = {binding: 'binding', friendlyName: 'friendlyName', type: 'app-push'}; var promise = client.authy.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .entities('identity') .factors.create(opts); @@ -48,7 +48,7 @@ describe('Factor', function() { var solution = {serviceSid: 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', identity: 'identity'}; var url = _.template('https://authy.twilio.com/v1/Services/<%= serviceSid %>/Entities/<%= identity %>/Factors')(solution); - var values = {Binding: 'binding', FactorType: 'factorType', FriendlyName: 'friendlyName', }; + var values = {Binding: 'binding', FriendlyName: 'friendlyName', Type: 'app-push', }; holodeck.assertHasRequest(new Request({ method: 'POST', url: url, @@ -77,7 +77,7 @@ describe('Factor', function() { holodeck.mock(new Response(201, body)); - var opts = {binding: 'binding', factorType: 'factorType', friendlyName: 'friendlyName'}; + var opts = {binding: 'binding', friendlyName: 'friendlyName', type: 'app-push'}; var promise = client.authy.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .entities('identity') .factors.create(opts); diff --git a/spec/integration/rest/authy/v1/service/entity/factor/challenge.spec.js b/spec/integration/rest/authy/v1/service/entity/factor/challenge.spec.js index 74e059d381..3532c38dd2 100644 --- a/spec/integration/rest/authy/v1/service/entity/factor/challenge.spec.js +++ b/spec/integration/rest/authy/v1/service/entity/factor/challenge.spec.js @@ -71,9 +71,8 @@ describe('Challenge', function() { 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', 'expiration_date': '2015-07-30T20:00:00Z', - 'verification_sid': 'VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'status': 'pending', - 'reason': 'none', + 'responded_reason': 'none', 'details': 'Hi! Mr. John Doe, would you like to sign up?', 'hidden_details': 'Hidden details about the sign up', 'type': 'sms', @@ -185,9 +184,8 @@ describe('Challenge', function() { 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', 'expiration_date': '2015-07-30T20:00:00Z', - 'verification_sid': 'VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'status': 'pending', - 'reason': 'none', + 'responded_reason': 'none', 'details': 'details', 'hidden_details': 'hidden_details', 'type': 'sms', @@ -222,9 +220,8 @@ describe('Challenge', function() { 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', 'expiration_date': '2015-07-30T20:00:00Z', - 'verification_sid': 'VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'status': 'pending', - 'reason': 'none', + 'responded_reason': 'none', 'details': 'details', 'hidden_details': 'hidden_details', 'type': 'sms', @@ -288,9 +285,8 @@ describe('Challenge', function() { 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', 'expiration_date': '2015-07-30T20:00:00Z', - 'verification_sid': 'VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'status': 'approved', - 'reason': 'none', + 'responded_reason': 'none', 'details': 'Hi! Mr. John Doe, would you like to sign up?', 'hidden_details': 'Hidden details about the sign up', 'type': 'sms', @@ -325,9 +321,8 @@ describe('Challenge', function() { 'date_updated': '2015-07-30T20:00:00Z', 'date_responded': '2015-07-30T20:00:00Z', 'expiration_date': '2015-07-30T20:00:00Z', - 'verification_sid': 'VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'status': 'approved', - 'reason': 'none', + 'responded_reason': 'none', 'details': 'Hi! Mr. John Doe, would you like to sign up?', 'hidden_details': 'Hidden details about the sign up', 'type': 'sms', diff --git a/spec/integration/rest/chat/v2/service/channel/member.spec.js b/spec/integration/rest/chat/v2/service/channel/member.spec.js index cbc4635f7b..846b709d2e 100644 --- a/spec/integration/rest/chat/v2/service/channel/member.spec.js +++ b/spec/integration/rest/chat/v2/service/channel/member.spec.js @@ -70,6 +70,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }); @@ -129,6 +130,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }); @@ -171,6 +173,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] @@ -205,6 +208,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] @@ -244,6 +248,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] @@ -304,6 +309,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] @@ -437,6 +443,7 @@ describe('Member', function() { 'last_consumption_timestamp': '2016-03-24T21:05:52Z', 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:51Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }); diff --git a/spec/integration/rest/ipMessaging/v2/service/channel/member.spec.js b/spec/integration/rest/ipMessaging/v2/service/channel/member.spec.js index 056fd0eb83..943aadfe80 100644 --- a/spec/integration/rest/ipMessaging/v2/service/channel/member.spec.js +++ b/spec/integration/rest/ipMessaging/v2/service/channel/member.spec.js @@ -70,6 +70,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }); @@ -129,6 +130,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }); @@ -171,6 +173,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] @@ -205,6 +208,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] @@ -244,6 +248,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] @@ -304,6 +309,7 @@ describe('Member', function() { 'last_consumption_timestamp': null, 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:50Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] @@ -437,6 +443,7 @@ describe('Member', function() { 'last_consumption_timestamp': '2016-03-24T21:05:52Z', 'date_created': '2016-03-24T21:05:50Z', 'date_updated': '2016-03-24T21:05:51Z', + 'attributes': '{}', 'url': 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }); diff --git a/spec/integration/rest/preview/authy/service.spec.js b/spec/integration/rest/preview/authy/service.spec.js deleted file mode 100644 index c7afc9629c..0000000000 --- a/spec/integration/rest/preview/authy/service.spec.js +++ /dev/null @@ -1,358 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -var _ = require('lodash'); /* jshint ignore:line */ -var 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('Service', function() { - beforeEach(function() { - holodeck = new Holodeck(); - client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { - httpClient: holodeck - }); - }); - it('should generate valid create request', - function() { - holodeck.mock(new Response(500, '{}')); - - var opts = {friendlyName: 'friendlyName'}; - var promise = client.preview.authy.services.create(opts); - promise = promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - }); - promise.done(); - - var url = 'https://preview.twilio.com/Authy/Services'; - - var values = {FriendlyName: 'friendlyName', }; - holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url, - data: values - })); - } - ); - it('should generate valid create response', - function() { - var body = JSON.stringify({ - 'sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'links': { - 'entities': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities' - } - }); - - holodeck.mock(new Response(201, body)); - - var opts = {friendlyName: 'friendlyName'}; - var promise = client.preview.authy.services.create(opts); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); - it('should generate valid fetch request', - function() { - holodeck.mock(new Response(500, '{}')); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); - promise = promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - }); - promise.done(); - - var solution = {sid: 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; - var url = _.template('https://preview.twilio.com/Authy/Services/<%= sid %>')(solution); - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid fetch response', - function() { - var body = JSON.stringify({ - 'sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'links': { - 'entities': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities' - } - }); - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); - it('should treat the first each arg as a callback', - function(done) { - var body = JSON.stringify({ - 'services': [ - { - 'sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'links': { - 'entities': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities' - } - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'services' - } - }); - holodeck.mock(new Response(200, body)); - client.preview.authy.services.each(() => done()); - } - ); - it('should treat the second arg as a callback', - function(done) { - var body = JSON.stringify({ - 'services': [ - { - 'sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'links': { - 'entities': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities' - } - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'services' - } - }); - holodeck.mock(new Response(200, body)); - client.preview.authy.services.each({pageSize: 20}, () => done()); - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: 'https://preview.twilio.com/Authy/Services', - params: {PageSize: 20}, - })); - } - ); - it('should find the callback in the opts object', - function(done) { - var body = JSON.stringify({ - 'services': [ - { - 'sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'links': { - 'entities': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities' - } - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'services' - } - }); - holodeck.mock(new Response(200, body)); - client.preview.authy.services.each({callback: () => done()}, () => fail('wrong callback!')); - } - ); - it('should generate valid list request', - function() { - holodeck.mock(new Response(500, '{}')); - - var promise = client.preview.authy.services.list(); - promise = promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - }); - promise.done(); - - var url = 'https://preview.twilio.com/Authy/Services'; - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid read_empty response', - function() { - var body = JSON.stringify({ - 'services': [], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'services' - } - }); - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.authy.services.list(); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); - it('should generate valid read_full response', - function() { - var body = JSON.stringify({ - 'services': [ - { - 'sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'links': { - 'entities': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities' - } - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'services' - } - }); - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.authy.services.list(); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); - it('should generate valid update request', - function() { - holodeck.mock(new Response(500, '{}')); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); - promise = promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - }); - promise.done(); - - var solution = {sid: 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; - var url = _.template('https://preview.twilio.com/Authy/Services/<%= sid %>')(solution); - - holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url - })); - } - ); - it('should generate valid update response', - function() { - var body = JSON.stringify({ - 'sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'friendly_name': 'friendly_name', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'links': { - 'entities': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities' - } - }); - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); -}); diff --git a/spec/integration/rest/preview/authy/service/entity.spec.js b/spec/integration/rest/preview/authy/service/entity.spec.js deleted file mode 100644 index 1c927efea8..0000000000 --- a/spec/integration/rest/preview/authy/service/entity.spec.js +++ /dev/null @@ -1,329 +0,0 @@ -'use strict'; - -/* jshint ignore:start */ -/** - * This code was generated by - * \ / _ _ _| _ _ - * | (_)\/(_)(_|\/| |(/_ v1.0.0 - * / / - */ -/* jshint ignore:end */ - -var _ = require('lodash'); /* jshint ignore:line */ -var 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('Entity', function() { - beforeEach(function() { - holodeck = new Holodeck(); - client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { - httpClient: holodeck - }); - }); - it('should generate valid create request', - function() { - holodeck.mock(new Response(500, '{}')); - - var opts = {identity: 'identity'}; - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities.create(opts); - promise = promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - }); - promise.done(); - - var solution = {serviceSid: 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; - var url = _.template('https://preview.twilio.com/Authy/Services/<%= serviceSid %>/Entities')(solution); - - var values = {Identity: 'identity', }; - holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url, - data: values - })); - } - ); - it('should generate valid create response', - function() { - var body = JSON.stringify({ - 'sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', - 'links': { - 'factors': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors' - } - }); - - holodeck.mock(new Response(201, body)); - - var opts = {identity: 'identity'}; - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities.create(opts); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); - it('should treat the first each arg as a callback', - function(done) { - var body = JSON.stringify({ - 'entities': [ - { - 'sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', - 'links': { - 'factors': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors' - } - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'entities' - } - }); - holodeck.mock(new Response(200, body)); - client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities.each(() => done()); - } - ); - it('should treat the second arg as a callback', - function(done) { - var body = JSON.stringify({ - 'entities': [ - { - 'sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', - 'links': { - 'factors': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors' - } - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'entities' - } - }); - holodeck.mock(new Response(200, body)); - client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities.each({pageSize: 20}, () => done()); - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: 'https://preview.twilio.com/Authy/Services/<%= serviceSid %>/Entities', - params: {PageSize: 20}, - })); - } - ); - it('should find the callback in the opts object', - function(done) { - var body = JSON.stringify({ - 'entities': [ - { - 'sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', - 'links': { - 'factors': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors' - } - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'entities' - } - }); - holodeck.mock(new Response(200, body)); - client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities.each({callback: () => done()}, () => fail('wrong callback!')); - } - ); - it('should generate valid list request', - function() { - holodeck.mock(new Response(500, '{}')); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities.list(); - promise = promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - }); - promise.done(); - - var solution = {serviceSid: 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}; - var url = _.template('https://preview.twilio.com/Authy/Services/<%= serviceSid %>/Entities')(solution); - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid read_empty response', - function() { - var body = JSON.stringify({ - 'entities': [], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'entities' - } - }); - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities.list(); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); - it('should generate valid read_full response', - function() { - var body = JSON.stringify({ - 'entities': [ - { - 'sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', - 'links': { - 'factors': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors' - } - } - ], - 'meta': { - 'page': 0, - 'page_size': 50, - 'first_page_url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'previous_page_url': null, - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities?PageSize=50&Page=0', - 'next_page_url': null, - 'key': 'entities' - } - }); - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities.list(); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); - it('should generate valid fetch request', - function() { - holodeck.mock(new Response(500, '{}')); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities('identity').fetch(); - promise = promise.then(function() { - throw new Error('failed'); - }, function(error) { - expect(error.constructor).toBe(RestException.prototype.constructor); - }); - promise.done(); - - var solution = {serviceSid: 'ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', identity: 'identity'}; - var url = _.template('https://preview.twilio.com/Authy/Services/<%= serviceSid %>/Entities/<%= identity %>')(solution); - - holodeck.assertHasRequest(new Request({ - method: 'GET', - url: url - })); - } - ); - it('should generate valid fetch response', - function() { - var body = JSON.stringify({ - 'sid': 'YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'identity': 'ff483d1ff591898a9942916050d2ca3f', - 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'service_sid': 'ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'date_created': '2015-07-30T20:00:00Z', - 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f', - 'links': { - 'factors': 'https://preview.twilio.com/Authy/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Factors' - } - }); - - holodeck.mock(new Response(200, body)); - - var promise = client.preview.authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .entities('identity').fetch(); - promise = promise.then(function(response) { - expect(response).toBeDefined(); - }, function() { - throw new Error('failed'); - }); - - promise.done(); - } - ); -});