diff --git a/CHANGES.md b/CHANGES.md index 8a7965d3b8..21fbaae980 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,24 @@ twilio-node changelog ===================== +[2021-06-30] Version 3.65.0 +--------------------------- +**Conversations** +- Read-only Conversation Email Binding property `binding` + +**Supersim** +- Add Billing Period resource for the Super Sim Pilot +- Add List endpoint to Billing Period resource for Super Sim Pilot +- Add Fetch endpoint to Billing Period resource for Super Sim Pilot + +**Taskrouter** +- Update `transcribe` & `transcription_configuration` form params in Reservation update endpoint to have private visibility **(breaking change)** +- Add `transcribe` & `transcription_configuration` form params to Reservation update endpoint + +**Twiml** +- Add `modify` event to `statusCallbackEvent` for ``. + + [2021-06-16] Version 3.64.0 --------------------------- **Library - Chore** diff --git a/lib/rest/api/v2010/account/message.d.ts b/lib/rest/api/v2010/account/message.d.ts index 60bce552d2..96a9a386a7 100644 --- a/lib/rest/api/v2010/account/message.d.ts +++ b/lib/rest/api/v2010/account/message.d.ts @@ -42,7 +42,7 @@ declare function MessageList(version: V2010, accountSid: string): MessageListIns * @property body - The text of the message you want to send */ interface MessageInstanceUpdateOptions { - body: string; + body?: string; } interface MessageListInstance { @@ -350,13 +350,19 @@ declare class MessageContext { * Provide a user-friendly representation */ toJSON(): any; + /** + * update a MessageInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: MessageInstance) => any): Promise; /** * update a MessageInstance * * @param opts - Options for request * @param callback - Callback to handle processed record */ - update(opts: MessageInstanceUpdateOptions, callback?: (error: Error | null, items: MessageInstance) => any): Promise; + update(opts?: MessageInstanceUpdateOptions, callback?: (error: Error | null, items: MessageInstance) => any): Promise; } @@ -415,13 +421,19 @@ declare class MessageInstance extends SerializableClass { * Provide a user-friendly representation */ toJSON(): any; + /** + * update a MessageInstance + * + * @param callback - Callback to handle processed record + */ + update(callback?: (error: Error | null, items: MessageInstance) => any): Promise; /** * update a MessageInstance * * @param opts - Options for request * @param callback - Callback to handle processed record */ - update(opts: MessageInstanceUpdateOptions, callback?: (error: Error | null, items: MessageInstance) => any): Promise; + update(opts?: MessageInstanceUpdateOptions, callback?: (error: Error | null, items: MessageInstance) => any): Promise; uri: string; } diff --git a/lib/rest/api/v2010/account/message.js b/lib/rest/api/v2010/account/message.js index 0bdf4f7bcf..df66f241e4 100644 --- a/lib/rest/api/v2010/account/message.js +++ b/lib/rest/api/v2010/account/message.js @@ -630,8 +630,8 @@ MessageInstance.prototype.fetch = function fetch(callback) { * @function update * @memberof Twilio.Api.V2010.AccountContext.MessageInstance# * - * @param {object} opts - Options for request - * @param {string} opts.body - The text of the message you want to send + * @param {object} [opts] - Options for request + * @param {string} [opts.body] - The text of the message you want to send * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MessageInstance @@ -798,20 +798,19 @@ MessageContext.prototype.fetch = function fetch(callback) { * @function update * @memberof Twilio.Api.V2010.AccountContext.MessageContext# * - * @param {object} opts - Options for request - * @param {string} opts.body - The text of the message you want to send + * @param {object} [opts] - Options for request + * @param {string} [opts.body] - The text of the message you want to send * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed MessageInstance */ /* jshint ignore:end */ MessageContext.prototype.update = function update(opts, callback) { - if (_.isUndefined(opts)) { - throw new Error('Required parameter "opts" missing.'); - } - if (_.isUndefined(opts.body)) { - throw new Error('Required parameter "opts.body" missing.'); + if (_.isFunction(opts)) { + callback = opts; + opts = {}; } + opts = opts || {}; var deferred = Q.defer(); var data = values.of({'Body': _.get(opts, 'body')}); diff --git a/lib/rest/conversations/v1/conversation.d.ts b/lib/rest/conversations/v1/conversation.d.ts index 749f951484..cd8faf6d97 100644 --- a/lib/rest/conversations/v1/conversation.d.ts +++ b/lib/rest/conversations/v1/conversation.d.ts @@ -283,6 +283,7 @@ interface ConversationPayload extends ConversationResource, Page.TwilioResponseP interface ConversationResource { account_sid: string; attributes: string; + bindings: object; chat_service_sid: string; date_created: Date; date_updated: Date; @@ -364,6 +365,7 @@ declare class ConversationInstance extends SerializableClass { private _proxy: ConversationContext; accountSid: string; attributes: string; + bindings: any; chatServiceSid: string; dateCreated: Date; dateUpdated: Date; diff --git a/lib/rest/conversations/v1/conversation.js b/lib/rest/conversations/v1/conversation.js index 25c678ef5e..c71f5d71dd 100644 --- a/lib/rest/conversations/v1/conversation.js +++ b/lib/rest/conversations/v1/conversation.js @@ -495,6 +495,7 @@ ConversationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {string} url - An absolute URL for this conversation. * @property {string} links - * Absolute URLs to access the participants, messages and webhooks of this conversation. + * @property {object} bindings - The bindings * * @param {V1} version - Version of the resource * @param {ConversationPayload} payload - The instance payload @@ -519,6 +520,7 @@ ConversationInstance = function ConversationInstance(version, payload, sid) { this.timers = payload.timers; // jshint ignore:line this.url = payload.url; // jshint ignore:line this.links = payload.links; // jshint ignore:line + this.bindings = payload.bindings; // jshint ignore:line // Context this._context = undefined; diff --git a/lib/rest/conversations/v1/service/conversation.d.ts b/lib/rest/conversations/v1/service/conversation.d.ts index 853f9b498e..405358b385 100644 --- a/lib/rest/conversations/v1/service/conversation.d.ts +++ b/lib/rest/conversations/v1/service/conversation.d.ts @@ -284,6 +284,7 @@ interface ConversationPayload extends ConversationResource, Page.TwilioResponseP interface ConversationResource { account_sid: string; attributes: string; + bindings: object; chat_service_sid: string; date_created: Date; date_updated: Date; @@ -368,6 +369,7 @@ declare class ConversationInstance extends SerializableClass { private _proxy: ConversationContext; accountSid: string; attributes: string; + bindings: any; chatServiceSid: string; dateCreated: Date; dateUpdated: Date; diff --git a/lib/rest/conversations/v1/service/conversation.js b/lib/rest/conversations/v1/service/conversation.js index a3097be89b..41a97e7967 100644 --- a/lib/rest/conversations/v1/service/conversation.js +++ b/lib/rest/conversations/v1/service/conversation.js @@ -502,6 +502,7 @@ ConversationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {string} url - An absolute URL for this conversation. * @property {string} links - * Absolute URLs to access the participants, messages and webhooks of this conversation. + * @property {object} bindings - The bindings * * @param {V1} version - Version of the resource * @param {ConversationPayload} payload - The instance payload @@ -529,6 +530,7 @@ ConversationInstance = function ConversationInstance(version, payload, this.timers = payload.timers; // jshint ignore:line this.url = payload.url; // jshint ignore:line this.links = payload.links; // jshint ignore:line + this.bindings = payload.bindings; // jshint ignore:line // Context this._context = undefined; diff --git a/lib/rest/supersim/v1/sim.d.ts b/lib/rest/supersim/v1/sim.d.ts index 3b244fe34c..e7927a6728 100644 --- a/lib/rest/supersim/v1/sim.d.ts +++ b/lib/rest/supersim/v1/sim.d.ts @@ -8,6 +8,8 @@ import Page = require('../../../base/Page'); import Response = require('../../../http/response'); import V1 = require('../V1'); +import { BillingPeriodList } from './sim/billingPeriod'; +import { BillingPeriodListInstance } from './sim/billingPeriod'; import { SerializableClass } from '../../../interfaces'; type SimStatus = 'new'|'ready'|'active'|'inactive'|'scheduled'; @@ -258,6 +260,7 @@ interface SimResource { date_updated: Date; fleet_sid: string; iccid: string; + links: string; sid: string; status: SimStatus; unique_name: string; @@ -280,6 +283,7 @@ declare class SimContext { */ constructor(version: V1, sid: string); + billingPeriods: BillingPeriodListInstance; /** * fetch a SimInstance * @@ -321,6 +325,10 @@ declare class SimInstance extends SerializableClass { private _proxy: SimContext; accountSid: string; + /** + * Access the billingPeriods + */ + billingPeriods(): BillingPeriodListInstance; dateCreated: Date; dateUpdated: Date; /** @@ -331,6 +339,7 @@ declare class SimInstance extends SerializableClass { fetch(callback?: (error: Error | null, items: SimInstance) => any): Promise; fleetSid: string; iccid: string; + links: string; sid: string; status: SimStatus; /** diff --git a/lib/rest/supersim/v1/sim.js b/lib/rest/supersim/v1/sim.js index ee7131270c..3f8c43fbdd 100644 --- a/lib/rest/supersim/v1/sim.js +++ b/lib/rest/supersim/v1/sim.js @@ -12,6 +12,7 @@ var Q = require('q'); /* jshint ignore:line */ var _ = require('lodash'); /* jshint ignore:line */ var util = require('util'); /* jshint ignore:line */ +var BillingPeriodList = require('./sim/billingPeriod').BillingPeriodList; var Page = require('../../../base/Page'); /* jshint ignore:line */ var deserialize = require( '../../../base/deserialize'); /* jshint ignore:line */ @@ -491,6 +492,7 @@ SimPage.prototype[util.inspect.custom] = function inspect(depth, options) { * @property {Date} dateUpdated - * The ISO 8601 date and time in GMT when the resource was last updated * @property {string} url - The absolute URL of the Sim Resource + * @property {string} links - The links * * @param {V1} version - Version of the resource * @param {SimPayload} payload - The instance payload @@ -510,6 +512,7 @@ SimInstance = function SimInstance(version, payload, sid) { this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line this.url = payload.url; // jshint ignore:line + this.links = payload.links; // jshint ignore:line // Context this._context = undefined; @@ -571,6 +574,20 @@ SimInstance.prototype.update = function update(opts, callback) { return this._proxy.update(opts, callback); }; +/* jshint ignore:start */ +/** + * Access the billingPeriods + * + * @function billingPeriods + * @memberof Twilio.Supersim.V1.SimInstance# + * + * @returns {Twilio.Supersim.V1.SimContext.BillingPeriodList} + */ +/* jshint ignore:end */ +SimInstance.prototype.billingPeriods = function billingPeriods() { + return this._proxy.billingPeriods; +}; + /* jshint ignore:start */ /** * Provide a user-friendly representation @@ -605,6 +622,9 @@ SimInstance.prototype[util.inspect.custom] = function inspect(depth, options) { * * @constructor Twilio.Supersim.V1.SimContext * + * @property {Twilio.Supersim.V1.SimContext.BillingPeriodList} billingPeriods - + * billingPeriods resource + * * @param {V1} version - Version of the resource * @param {sid_like} sid - The SID that identifies the resource to fetch */ @@ -615,6 +635,9 @@ SimContext = function SimContext(version, sid) { // Path Solution this._solution = {sid: sid, }; this._uri = `/Sims/${sid}`; + + // Dependents + this._billingPeriods = undefined; }; /* jshint ignore:start */ @@ -706,6 +729,16 @@ SimContext.prototype.update = function update(opts, callback) { return deferred.promise; }; +Object.defineProperty(SimContext.prototype, + 'billingPeriods', { + get: function() { + if (!this._billingPeriods) { + this._billingPeriods = new BillingPeriodList(this._version, this._solution.sid); + } + return this._billingPeriods; + } +}); + /* jshint ignore:start */ /** * Provide a user-friendly representation diff --git a/lib/rest/supersim/v1/sim/billingPeriod.d.ts b/lib/rest/supersim/v1/sim/billingPeriod.d.ts new file mode 100644 index 0000000000..d7890ccdfe --- /dev/null +++ b/lib/rest/supersim/v1/sim/billingPeriod.d.ts @@ -0,0 +1,249 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../../base/Page'); +import Response = require('../../../../http/response'); +import V1 = require('../../V1'); +import { SerializableClass } from '../../../../interfaces'; + +type BillingPeriodBpType = 'ready'|'active'; + +/** + * Initialize the BillingPeriodList + * + * @param version - Version of the resource + * @param simSid - The SID of the Super SIM the Billing Period belongs to + */ +declare function BillingPeriodList(version: V1, simSid: string): BillingPeriodListInstance; + +interface BillingPeriodListInstance { + /** + * Streams BillingPeriodInstance records from the API. + * + * This operation lazily loads records as efficiently as possible until the limit + * is reached. + * + * The results are passed into the callback function, so this operation is memory + * efficient. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @param callback - Function to process each record + */ + each(callback?: (item: BillingPeriodInstance, done: (err?: Error) => void) => void): void; + /** + * Streams BillingPeriodInstance records from the API. + * + * This operation lazily loads records as efficiently as possible until the limit + * is reached. + * + * The results are passed into the callback function, so this operation is memory + * efficient. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @param opts - Options for request + * @param callback - Function to process each record + */ + each(opts?: BillingPeriodListInstanceEachOptions, callback?: (item: BillingPeriodInstance, done: (err?: Error) => void) => void): void; + /** + * Retrieve a single target page of BillingPeriodInstance records from the API. + * + * The request is executed immediately. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @param callback - Callback to handle list of records + */ + getPage(callback?: (error: Error | null, items: BillingPeriodPage) => any): Promise; + /** + * Retrieve a single target page of BillingPeriodInstance records from the API. + * + * The request is executed immediately. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @param targetUrl - API-generated URL for the requested results page + * @param callback - Callback to handle list of records + */ + getPage(targetUrl?: string, callback?: (error: Error | null, items: BillingPeriodPage) => any): Promise; + /** + * Lists BillingPeriodInstance records from the API as a list. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @param callback - Callback to handle list of records + */ + list(callback?: (error: Error | null, items: BillingPeriodInstance[]) => any): Promise; + /** + * Lists BillingPeriodInstance records from the API as a list. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @param opts - Options for request + * @param callback - Callback to handle list of records + */ + list(opts?: BillingPeriodListInstanceOptions, callback?: (error: Error | null, items: BillingPeriodInstance[]) => any): Promise; + /** + * Retrieve a single page of BillingPeriodInstance records from the API. + * + * The request is executed immediately. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @param callback - Callback to handle list of records + */ + page(callback?: (error: Error | null, items: BillingPeriodPage) => any): Promise; + /** + * Retrieve a single page of BillingPeriodInstance records from the API. + * + * The request is executed immediately. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @param opts - Options for request + * @param callback - Callback to handle list of records + */ + page(opts?: BillingPeriodListInstancePageOptions, callback?: (error: Error | null, items: BillingPeriodPage) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to each + * + * @property callback - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @property done - Function to be called upon completion of streaming + * @property limit - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @property pageSize - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no pageSize is defined but a limit is defined, + * each() will attempt to read the limit with the most efficient + * page size, i.e. min(limit, 1000) + */ +interface BillingPeriodListInstanceEachOptions { + callback?: (item: BillingPeriodInstance, done: (err?: Error) => void) => void; + done?: Function; + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to list + * + * @property limit - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @property pageSize - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no page_size is defined but a limit is defined, + * list() will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + */ +interface BillingPeriodListInstanceOptions { + limit?: number; + pageSize?: number; +} + +/** + * Options to pass to page + * + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + */ +interface BillingPeriodListInstancePageOptions { + pageNumber?: number; + pageSize?: number; + pageToken?: string; +} + +interface BillingPeriodPayload extends BillingPeriodResource, Page.TwilioResponsePayload { +} + +interface BillingPeriodResource { + account_sid: string; + date_created: Date; + date_updated: Date; + end_time: Date; + period_type: BillingPeriodBpType; + sid: string; + sim_sid: string; + start_time: Date; +} + +interface BillingPeriodSolution { + simSid?: string; +} + + +declare class BillingPeriodInstance extends SerializableClass { + /** + * Initialize the BillingPeriodContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param simSid - The SID of the Super SIM the Billing Period belongs to + */ + constructor(version: V1, payload: BillingPeriodPayload, simSid: string); + + accountSid: string; + dateCreated: Date; + dateUpdated: Date; + endTime: Date; + periodType: BillingPeriodBpType; + sid: string; + simSid: string; + startTime: Date; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + +declare class BillingPeriodPage extends Page { + /** + * Initialize the BillingPeriodPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: BillingPeriodSolution); + + /** + * Build an instance of BillingPeriodInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: BillingPeriodPayload): BillingPeriodInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { BillingPeriodBpType, BillingPeriodInstance, BillingPeriodList, BillingPeriodListInstance, BillingPeriodListInstanceEachOptions, BillingPeriodListInstanceOptions, BillingPeriodListInstancePageOptions, BillingPeriodPage, BillingPeriodPayload, BillingPeriodResource, BillingPeriodSolution } diff --git a/lib/rest/supersim/v1/sim/billingPeriod.js b/lib/rest/supersim/v1/sim/billingPeriod.js new file mode 100644 index 0000000000..2a512d1dd6 --- /dev/null +++ b/lib/rest/supersim/v1/sim/billingPeriod.js @@ -0,0 +1,454 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var Q = require('q'); /* jshint ignore:line */ +var _ = require('lodash'); /* jshint ignore:line */ +var util = require('util'); /* jshint ignore:line */ +var Page = require('../../../../base/Page'); /* jshint ignore:line */ +var deserialize = require( + '../../../../base/deserialize'); /* jshint ignore:line */ +var values = require('../../../../base/values'); /* jshint ignore:line */ + +var BillingPeriodList; +var BillingPeriodPage; +var BillingPeriodInstance; + +/* jshint ignore:start */ +/** + * Initialize the BillingPeriodList + * + * @constructor Twilio.Supersim.V1.SimContext.BillingPeriodList + * + * @param {Twilio.Supersim.V1} version - Version of the resource + * @param {string} simSid - The SID of the Super SIM the Billing Period belongs to + */ +/* jshint ignore:end */ +BillingPeriodList = function BillingPeriodList(version, simSid) { + /* jshint ignore:start */ + /** + * @function billingPeriods + * @memberof Twilio.Supersim.V1.SimContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Supersim.V1.SimContext.BillingPeriodContext} + */ + /* jshint ignore:end */ + function BillingPeriodListInstance(sid) { + return BillingPeriodListInstance.get(sid); + } + + BillingPeriodListInstance._version = version; + // Path Solution + BillingPeriodListInstance._solution = {simSid: simSid}; + BillingPeriodListInstance._uri = `/Sims/${simSid}/BillingPeriods`; + /* jshint ignore:start */ + /** + * Streams BillingPeriodInstance records from the API. + * + * This operation lazily loads records as efficiently as possible until the limit + * is reached. + * + * The results are passed into the callback function, so this operation is memory + * efficient. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @function each + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodList# + * + * @param {object} [opts] - Options for request + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no pageSize is defined but a limit is defined, + * each() will attempt to read the limit with the most efficient + * page size, i.e. min(limit, 1000) + * @param {Function} [opts.callback] - + * Function to process each record. If this and a positional + * callback are passed, this one will be used + * @param {Function} [opts.done] - + * Function to be called upon completion of streaming + * @param {Function} [callback] - Function to process each record + */ + /* jshint ignore:end */ + BillingPeriodListInstance.each = function each(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + if (opts.callback) { + callback = opts.callback; + } + if (_.isUndefined(callback)) { + throw new Error('Callback function must be provided'); + } + + var done = false; + var currentPage = 1; + var currentResource = 0; + var limits = this._version.readLimits({ + limit: opts.limit, + pageSize: opts.pageSize + }); + + function onComplete(error) { + done = true; + if (_.isFunction(opts.done)) { + opts.done(error); + } + } + + function fetchNextPage(fn) { + var promise = fn(); + if (_.isUndefined(promise)) { + onComplete(); + return; + } + + promise.then(function(page) { + _.each(page.instances, function(instance) { + if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) { + done = true; + return false; + } + + currentResource++; + callback(instance, onComplete); + }); + + if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists BillingPeriodInstance records from the API as a list. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @function list + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodList# + * + * @param {object} [opts] - Options for request + * @param {number} [opts.limit] - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @param {number} [opts.pageSize] - + * Number of records to fetch per request, + * when not set will use the default value of 50 records. + * If no page_size is defined but a limit is defined, + * list() will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + BillingPeriodListInstance.list = function list(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + var deferred = Q.defer(); + var allResources = []; + opts.callback = function(resource, done) { + allResources.push(resource); + + if (!_.isUndefined(opts.limit) && allResources.length === opts.limit) { + done(); + } + }; + + opts.done = function(error) { + if (_.isUndefined(error)) { + deferred.resolve(allResources); + } else { + deferred.reject(error); + } + }; + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + this.each(opts); + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single page of BillingPeriodInstance records from the API. + * + * The request is executed immediately. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @function page + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.pageToken] - PageToken provided by the API + * @param {number} [opts.pageNumber] - + * Page Number, this value is simply for client state + * @param {number} [opts.pageSize] - Number of records to return, defaults to 50 + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + BillingPeriodListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'PageToken': opts.pageToken, + 'Page': opts.pageNumber, + 'PageSize': opts.pageSize + }); + + var promise = this._version.page({uri: this._uri, method: 'GET', params: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new BillingPeriodPage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Retrieve a single target page of BillingPeriodInstance records from the API. + * + * The request is executed immediately. + * + * If a function is passed as the first argument, it will be used as the callback + * function. + * + * @function getPage + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodList# + * + * @param {string} [targetUrl] - API-generated URL for the requested results page + * @param {function} [callback] - Callback to handle list of records + * + * @returns {Promise} Resolves to a list of records + */ + /* jshint ignore:end */ + BillingPeriodListInstance.getPage = function getPage(targetUrl, callback) { + var deferred = Q.defer(); + + var promise = this._version._domain.twilio.request({method: 'GET', uri: targetUrl}); + + promise = promise.then(function(payload) { + deferred.resolve(new BillingPeriodPage(this._version, payload, this._solution)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodList# + * + * @returns Object + */ + /* jshint ignore:end */ + BillingPeriodListInstance.toJSON = function toJSON() { + return this._solution; + }; + + BillingPeriodListInstance[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); + }; + + return BillingPeriodListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the BillingPeriodPage + * + * @constructor Twilio.Supersim.V1.SimContext.BillingPeriodPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {BillingPeriodSolution} solution - Path solution + * + * @returns BillingPeriodPage + */ +/* jshint ignore:end */ +BillingPeriodPage = function BillingPeriodPage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(BillingPeriodPage.prototype, Page.prototype); +BillingPeriodPage.prototype.constructor = BillingPeriodPage; + +/* jshint ignore:start */ +/** + * Build an instance of BillingPeriodInstance + * + * @function getInstance + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodPage# + * + * @param {BillingPeriodPayload} payload - Payload response from the API + * + * @returns BillingPeriodInstance + */ +/* jshint ignore:end */ +BillingPeriodPage.prototype.getInstance = function getInstance(payload) { + return new BillingPeriodInstance(this._version, payload, this._solution.simSid); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodPage# + * + * @returns Object + */ +/* jshint ignore:end */ +BillingPeriodPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +BillingPeriodPage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the BillingPeriodContext + * + * @constructor Twilio.Supersim.V1.SimContext.BillingPeriodInstance + * + * @property {string} sid - The SID of the Billing Period + * @property {string} accountSid - The SID of the Account the Super SIM belongs to + * @property {string} simSid - + * The SID of the Super SIM the Billing Period belongs to + * @property {Date} startTime - The start time of the Billing Period + * @property {Date} endTime - The end time of the Billing Period + * @property {billing_period.bp_type} periodType - The type of the Billing Period + * @property {Date} dateCreated - + * The ISO 8601 date and time in GMT when the resource was created + * @property {Date} dateUpdated - + * The ISO 8601 date and time in GMT when the resource was last updated + * + * @param {V1} version - Version of the resource + * @param {BillingPeriodPayload} payload - The instance payload + * @param {sid} simSid - The SID of the Super SIM the Billing Period belongs to + */ +/* jshint ignore:end */ +BillingPeriodInstance = function BillingPeriodInstance(version, payload, simSid) + { + this._version = version; + + // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.simSid = payload.sim_sid; // jshint ignore:line + this.startTime = deserialize.iso8601DateTime(payload.start_time); // jshint ignore:line + this.endTime = deserialize.iso8601DateTime(payload.end_time); // jshint ignore:line + this.periodType = payload.period_type; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {simSid: simSid, }; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.SimContext.BillingPeriodInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +BillingPeriodInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +BillingPeriodInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + BillingPeriodList: BillingPeriodList, + BillingPeriodPage: BillingPeriodPage, + BillingPeriodInstance: BillingPeriodInstance +}; diff --git a/lib/twiml/VoiceResponse.d.ts b/lib/twiml/VoiceResponse.d.ts index 923e04c729..9c9d0dc8e4 100644 --- a/lib/twiml/VoiceResponse.d.ts +++ b/lib/twiml/VoiceResponse.d.ts @@ -193,7 +193,7 @@ declare namespace VoiceResponse { type ConferenceBeep = 'true'|'false'|'onEnter'|'onExit'; - type ConferenceEvent = 'start'|'end'|'join'|'leave'|'mute'|'hold'|'speaker'|'announcement'; + type ConferenceEvent = 'start'|'end'|'join'|'leave'|'mute'|'hold'|'modify'|'speaker'|'announcement'; type ConferenceJitterBufferSize = 'large'|'medium'|'small'|'off'; diff --git a/spec/integration/rest/api/v2010/account/message.spec.js b/spec/integration/rest/api/v2010/account/message.spec.js index 4ccfb606a2..7bbeab25b6 100644 --- a/spec/integration/rest/api/v2010/account/message.spec.js +++ b/spec/integration/rest/api/v2010/account/message.spec.js @@ -787,9 +787,8 @@ describe('Message', function() { function(done) { holodeck.mock(new Response(500, {})); - var opts = {body: 'body'}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(opts); + .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); promise.then(function() { throw new Error('failed'); }, function(error) { @@ -801,11 +800,9 @@ describe('Message', function() { var sid = 'MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; var url = `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages/${sid}.json`; - var values = {Body: 'body', }; holodeck.assertHasRequest(new Request({ - method: 'POST', - url: url, - data: values + method: 'POST', + url: url })); } ); @@ -839,9 +836,48 @@ describe('Message', function() { holodeck.mock(new Response(200, body)); - var opts = {body: 'body'}; var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') - .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(opts); + .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid cancel_message response', + function(done) { + var body = { + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'api_version': '2010-04-01', + 'body': '', + 'date_created': 'Fri, 24 May 2019 17:18:27 +0000', + 'date_sent': 'Fri, 24 May 2019 17:18:28 +0000', + 'date_updated': 'Fri, 24 May 2019 17:18:28 +0000', + 'direction': 'outbound-api', + 'error_code': 30007, + 'error_message': 'Carrier violation', + 'from': '+12019235161', + 'messaging_service_sid': 'MGdeadbeefdeadbeefdeadbeefdeadbeef', + 'num_media': '0', + 'num_segments': '1', + 'price': '-0.00750', + 'price_unit': 'USD', + 'sid': 'SMb7c0a2ce80504485a6f653a7110836f5', + 'status': 'canceled', + 'subresource_uris': { + 'media': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Media.json', + 'feedback': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5/Feedback.json' + }, + 'to': '+18182008801', + 'uri': '/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMb7c0a2ce80504485a6f653a7110836f5.json' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.api.v2010.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update(); promise.then(function(response) { expect(response).toBeDefined(); done(); diff --git a/spec/integration/rest/conversations/v1/conversation.spec.js b/spec/integration/rest/conversations/v1/conversation.spec.js index 7ec1baef06..882bc4a4a0 100644 --- a/spec/integration/rest/conversations/v1/conversation.spec.js +++ b/spec/integration/rest/conversations/v1/conversation.spec.js @@ -69,6 +69,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -102,6 +103,7 @@ describe('Conversation', function() { 'date_updated': '2020-07-01T22:18:37Z', 'state': 'active', 'timers': {}, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -162,6 +164,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -258,6 +261,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -296,6 +300,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -337,6 +342,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -383,6 +389,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -444,6 +451,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', diff --git a/spec/integration/rest/conversations/v1/service/conversation.spec.js b/spec/integration/rest/conversations/v1/service/conversation.spec.js index 102ee45453..0b0770a6fb 100644 --- a/spec/integration/rest/conversations/v1/service/conversation.spec.js +++ b/spec/integration/rest/conversations/v1/service/conversation.spec.js @@ -71,6 +71,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -105,6 +106,7 @@ describe('Conversation', function() { 'date_updated': '2020-07-01T22:18:37Z', 'state': 'active', 'timers': {}, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -168,6 +170,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -270,6 +273,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -309,6 +313,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -351,6 +356,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -398,6 +404,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', @@ -462,6 +469,7 @@ describe('Conversation', function() { 'date_inactive': '2015-12-16T22:19:38Z', 'date_closed': '2015-12-16T22:28:38Z' }, + 'bindings': {}, 'url': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'links': { 'participants': 'https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', diff --git a/spec/integration/rest/supersim/v1/sim.spec.js b/spec/integration/rest/supersim/v1/sim.spec.js index 455d8f63c9..8e00859cac 100644 --- a/spec/integration/rest/supersim/v1/sim.spec.js +++ b/spec/integration/rest/supersim/v1/sim.spec.js @@ -63,7 +63,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(201, body)); @@ -110,7 +113,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -156,7 +162,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -181,7 +190,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -206,7 +218,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -231,7 +246,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -256,7 +274,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } }; holodeck.mock(new Response(200, body)); @@ -292,7 +313,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -322,7 +346,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -357,7 +384,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -433,7 +463,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -471,7 +504,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; @@ -509,7 +545,10 @@ describe('Sim', function() { 'iccid': '89883070000123456789', 'date_created': '2015-07-30T20:00:00Z', 'date_updated': '2015-07-30T20:00:00Z', - 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'billing_periods': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods' + } } ] }; diff --git a/spec/integration/rest/supersim/v1/sim/billingPeriod.spec.js b/spec/integration/rest/supersim/v1/sim/billingPeriod.spec.js new file mode 100644 index 0000000000..68d79899f3 --- /dev/null +++ b/spec/integration/rest/supersim/v1/sim/billingPeriod.spec.js @@ -0,0 +1,252 @@ +'use strict'; + +/* jshint ignore:start */ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ +/* jshint ignore:end */ + +var Holodeck = require('../../../../holodeck'); /* jshint ignore:line */ +var Request = require( + '../../../../../../lib/http/request'); /* jshint ignore:line */ +var Response = require( + '../../../../../../lib/http/response'); /* jshint ignore:line */ +var RestException = require( + '../../../../../../lib/base/RestException'); /* jshint ignore:line */ +var Twilio = require('../../../../../../lib'); /* jshint ignore:line */ + + +var client; +var holodeck; + +describe('BillingPeriod', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should treat the first each arg as a callback', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'active', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'active', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://supersim.twilio.com/v1/Sims/${simSid}/BillingPeriods', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'active', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var simSid = 'HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://supersim.twilio.com/v1/Sims/${simSid}/BillingPeriods`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_empty response', + function(done) { + var body = { + 'billing_periods': [], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full_active_period response', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'active', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_full_ready_period response', + function(done) { + var body = { + 'billing_periods': [ + { + 'sid': 'HBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'period_type': 'ready', + 'start_time': '2021-06-09T13:18:15Z', + 'end_time': '2021-07-09T13:18:15Z', + 'date_created': '2021-06-09T13:18:16Z', + 'date_updated': '2021-06-09T13:18:16Z' + } + ], + 'meta': { + 'page': 0, + 'page_size': 50, + 'first_page_url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/Sims/HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/BillingPeriods?PageSize=50&Page=0', + 'next_page_url': null, + 'key': 'billing_periods' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.sims('HSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .billingPeriods.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/video/v1/room.spec.js b/spec/integration/rest/video/v1/room.spec.js index dc4a9a9908..e39cc8b6a4 100644 --- a/spec/integration/rest/video/v1/room.spec.js +++ b/spec/integration/rest/video/v1/room.spec.js @@ -65,7 +65,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 0, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -126,7 +126,7 @@ describe('Room', function() { 'max_participants': 10, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -167,7 +167,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 0, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -208,7 +208,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 170, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -249,7 +249,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 170, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -290,7 +290,7 @@ describe('Room', function() { 'max_concurrent_published_tracks': 16, 'duration': 0, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8' @@ -597,7 +597,7 @@ describe('Room', function() { 'max_participants': 10, 'max_concurrent_published_tracks': 10, 'status_callback_method': 'POST', - 'status_callback': '', + 'status_callback': null, 'record_participants_on_connect': false, 'video_codecs': [ 'VP8'