diff --git a/CHANGES.md b/CHANGES.md index 9cf401d8c5..090337b8f6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,23 @@ twilio-node changelog ===================== +[2022-01-26] Version 3.73.1 +--------------------------- +**Library - Chore** +- [PR #727](https://github.com/twilio/twilio-node/pull/727): run audit only on non dev dependencies. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)! + +**Insights** +- Added new endpoint to fetch Conference Participant Summary +- Added new endpoint to fetch Conference Summary + +**Messaging** +- Add government_entity parameter to brand apis + +**Verify** +- Add Access Token fetch endpoint to retrieve a previously created token. +- Add Access Token payload to the Access Token creation endpoint, including a unique Sid, so it's addressable while it's TTL is valid. + + [2022-01-12] Version 3.73.0 --------------------------- **Library - Chore** diff --git a/lib/rest/Insights.d.ts b/lib/rest/Insights.d.ts index 57304d2a11..d394758022 100644 --- a/lib/rest/Insights.d.ts +++ b/lib/rest/Insights.d.ts @@ -10,6 +10,7 @@ import Twilio = require('./Twilio'); import V1 = require('./insights/V1'); import { CallListInstance } from './insights/v1/call'; import { CallSummariesListInstance } from './insights/v1/callSummaries'; +import { ConferenceListInstance } from './insights/v1/conference'; import { RoomListInstance } from './insights/v1/room'; import { SettingListInstance } from './insights/v1/setting'; @@ -24,6 +25,7 @@ declare class Insights extends Domain { readonly callSummaries: CallSummariesListInstance; readonly calls: CallListInstance; + readonly conferences: ConferenceListInstance; readonly rooms: RoomListInstance; readonly settings: SettingListInstance; readonly v1: V1; diff --git a/lib/rest/Insights.js b/lib/rest/Insights.js index 605922e2ba..61a13ec4e8 100644 --- a/lib/rest/Insights.js +++ b/lib/rest/Insights.js @@ -25,6 +25,7 @@ var V1 = require('./insights/V1'); /* jshint ignore:line */ * @property {Twilio.Insights.V1.CallList} calls - calls resource * @property {Twilio.Insights.V1.CallSummariesList} callSummaries - * callSummaries resource + * @property {Twilio.Insights.V1.ConferenceList} conferences - conferences resource * @property {Twilio.Insights.V1.RoomList} rooms - rooms resource * * @param {Twilio} twilio - The twilio client @@ -69,6 +70,13 @@ Object.defineProperty(Insights.prototype, } }); +Object.defineProperty(Insights.prototype, + 'conferences', { + get: function() { + return this.v1.conferences; + } +}); + Object.defineProperty(Insights.prototype, 'rooms', { get: function() { diff --git a/lib/rest/Supersim.d.ts b/lib/rest/Supersim.d.ts index 750dc6b642..5d9c4a3557 100644 --- a/lib/rest/Supersim.d.ts +++ b/lib/rest/Supersim.d.ts @@ -9,6 +9,7 @@ import Domain = require('../base/Domain'); import Twilio = require('./Twilio'); import V1 = require('./supersim/V1'); import { CommandListInstance } from './supersim/v1/command'; +import { EsimProfileListInstance } from './supersim/v1/esimProfile'; import { FleetListInstance } from './supersim/v1/fleet'; import { IpCommandListInstance } from './supersim/v1/ipCommand'; import { NetworkAccessProfileListInstance } from './supersim/v1/networkAccessProfile'; @@ -27,6 +28,7 @@ declare class Supersim extends Domain { constructor(twilio: Twilio); readonly commands: CommandListInstance; + readonly esimProfiles: EsimProfileListInstance; readonly fleets: FleetListInstance; readonly ipCommands: IpCommandListInstance; readonly networkAccessProfiles: NetworkAccessProfileListInstance; diff --git a/lib/rest/Supersim.js b/lib/rest/Supersim.js index 11cd4adadf..d3e9cf3866 100644 --- a/lib/rest/Supersim.js +++ b/lib/rest/Supersim.js @@ -22,6 +22,8 @@ var V1 = require('./supersim/V1'); /* jshint ignore:line */ * * @property {Twilio.Supersim.V1} v1 - v1 version * @property {Twilio.Supersim.V1.CommandList} commands - commands resource + * @property {Twilio.Supersim.V1.EsimProfileList} esimProfiles - + * esimProfiles resource * @property {Twilio.Supersim.V1.FleetList} fleets - fleets resource * @property {Twilio.Supersim.V1.IpCommandList} ipCommands - ipCommands resource * @property {Twilio.Supersim.V1.NetworkList} networks - networks resource @@ -60,6 +62,13 @@ Object.defineProperty(Supersim.prototype, } }); +Object.defineProperty(Supersim.prototype, + 'esimProfiles', { + get: function() { + return this.v1.esimProfiles; + } +}); + Object.defineProperty(Supersim.prototype, 'fleets', { get: function() { diff --git a/lib/rest/flexApi/v1/flexFlow.d.ts b/lib/rest/flexApi/v1/flexFlow.d.ts index 94a0ec9094..febc710612 100644 --- a/lib/rest/flexApi/v1/flexFlow.d.ts +++ b/lib/rest/flexApi/v1/flexFlow.d.ts @@ -33,7 +33,7 @@ declare function FlexFlowList(version: V1): FlexFlowListInstance; * @property integration.creationOnMessage - Whether to create a Task when the first message arrives * @property integration.flowSid - The SID of the Studio Flow * @property integration.priority - The Task priority of a new Task - * @property integration.retryCount - The number of times to retry the webhook if the first attempt fails + * @property integration.retryCount - The number of times to retry the Studio Flow or webhook in case of failure * @property integration.timeout - The Task timeout in seconds for a new Task * @property integration.url - The External Webhook URL * @property integration.workflowSid - The Workflow SID for a new Task @@ -196,7 +196,7 @@ interface FlexFlowListInstance { * @property integration.creationOnMessage - Whether to create a Task when the first message arrives * @property integration.flowSid - The SID of the Studio Flow * @property integration.priority - The Task priority of a new Task - * @property integration.retryCount - The number of times to retry the webhook if the first attempt fails + * @property integration.retryCount - The number of times to retry the Studio Flow or webhook in case of failure * @property integration.timeout - The Task timeout in seconds for a new Task * @property integration.url - The External Webhook URL * @property integration.workflowSid - The Workflow SID for a new Task diff --git a/lib/rest/flexApi/v1/flexFlow.js b/lib/rest/flexApi/v1/flexFlow.js index 23dfbc7951..602f376ad3 100644 --- a/lib/rest/flexApi/v1/flexFlow.js +++ b/lib/rest/flexApi/v1/flexFlow.js @@ -333,7 +333,7 @@ FlexFlowList = function FlexFlowList(version) { * @param {boolean} [opts.janitorEnabled] - * Remove active Proxy sessions if the corresponding Task is deleted * @param {number} [opts.integration.retryCount] - - * The number of times to retry the webhook if the first attempt fails + * The number of times to retry the Studio Flow or webhook in case of failure * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FlexFlowInstance @@ -608,7 +608,7 @@ FlexFlowInstance.prototype.fetch = function fetch(callback) { * @param {boolean} [opts.janitorEnabled] - * Remove active Proxy sessions if the corresponding Task is deleted * @param {number} [opts.integration.retryCount] - - * The number of times to retry the webhook if the first attempt fails + * The number of times to retry the Studio Flow or webhook in case of failure * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FlexFlowInstance @@ -740,7 +740,7 @@ FlexFlowContext.prototype.fetch = function fetch(callback) { * @param {boolean} [opts.janitorEnabled] - * Remove active Proxy sessions if the corresponding Task is deleted * @param {number} [opts.integration.retryCount] - - * The number of times to retry the webhook if the first attempt fails + * The number of times to retry the Studio Flow or webhook in case of failure * @param {function} [callback] - Callback to handle processed record * * @returns {Promise} Resolves to processed FlexFlowInstance diff --git a/lib/rest/insights/V1.d.ts b/lib/rest/insights/V1.d.ts index 881f2e7989..92592f9dfe 100644 --- a/lib/rest/insights/V1.d.ts +++ b/lib/rest/insights/V1.d.ts @@ -11,6 +11,8 @@ import { CallList } from './v1/call'; import { CallListInstance } from './v1/call'; import { CallSummariesList } from './v1/callSummaries'; import { CallSummariesListInstance } from './v1/callSummaries'; +import { ConferenceList } from './v1/conference'; +import { ConferenceListInstance } from './v1/conference'; import { RoomList } from './v1/room'; import { RoomListInstance } from './v1/room'; import { SettingList } from './v1/setting'; @@ -27,6 +29,7 @@ declare class V1 extends Version { readonly callSummaries: CallSummariesListInstance; readonly calls: CallListInstance; + readonly conferences: ConferenceListInstance; readonly rooms: RoomListInstance; readonly settings: SettingListInstance; } diff --git a/lib/rest/insights/V1.js b/lib/rest/insights/V1.js index 3baee4b677..02b20ed987 100644 --- a/lib/rest/insights/V1.js +++ b/lib/rest/insights/V1.js @@ -12,6 +12,7 @@ var _ = require('lodash'); /* jshint ignore:line */ var CallList = require('./v1/call').CallList; var CallSummariesList = require('./v1/callSummaries').CallSummariesList; +var ConferenceList = require('./v1/conference').ConferenceList; var RoomList = require('./v1/room').RoomList; var SettingList = require('./v1/setting').SettingList; var Version = require('../../base/Version'); /* jshint ignore:line */ @@ -27,6 +28,7 @@ var Version = require('../../base/Version'); /* jshint ignore:line */ * @property {Twilio.Insights.V1.CallList} calls - calls resource * @property {Twilio.Insights.V1.CallSummariesList} callSummaries - * callSummaries resource + * @property {Twilio.Insights.V1.ConferenceList} conferences - conferences resource * @property {Twilio.Insights.V1.RoomList} rooms - rooms resource * * @param {Twilio.Insights} domain - The twilio domain @@ -39,6 +41,7 @@ function V1(domain) { this._settings = undefined; this._calls = undefined; this._callSummaries = undefined; + this._conferences = undefined; this._rooms = undefined; } @@ -69,6 +72,14 @@ Object.defineProperty(V1.prototype, } }); +Object.defineProperty(V1.prototype, + 'conferences', { + get: function() { + this._conferences = this._conferences || new ConferenceList(this); + return this._conferences; + } +}); + Object.defineProperty(V1.prototype, 'rooms', { get: function() { diff --git a/lib/rest/insights/v1/conference.d.ts b/lib/rest/insights/v1/conference.d.ts new file mode 100644 index 0000000000..5104f6a02a --- /dev/null +++ b/lib/rest/insights/v1/conference.d.ts @@ -0,0 +1,387 @@ +/** + * This code was generated by + * \ / _ _ _| _ _ + * | (_)\/(_)(_|\/| |(/_ v1.0.0 + * / / + */ + +import Page = require('../../../base/Page'); +import Response = require('../../../http/response'); +import V1 = require('../V1'); +import { ConferenceParticipantList } from './conference/conferenceParticipant'; +import { ConferenceParticipantListInstance } from './conference/conferenceParticipant'; +import { SerializableClass } from '../../../interfaces'; + +type ConferenceConferenceEndReason = 'last_participant_left'|'conference_ended_via_api'|'participant_with_end_conference_on_exit_left'|'last_participant_kicked'|'participant_with_end_conference_on_exit_kicked'; + +type ConferenceConferenceStatus = 'in_progress'|'not_started'|'completed'|'summary_timeout'; + +type ConferenceRegion = 'us1'|'au1'|'br1'|'ie1'|'jp1'|'sg1'|'de1'; + +type ConferenceTag = 'invalid_requested_region'|'duplicate_identity'|'start_failure'|'region_configuration_issues'|'quality_warnings'|'participant_behavior_issues'|'high_packet_loss'|'high_jitter'|'high_latency'|'low_mos'|'detected_silence'; + +/** + * Initialize the ConferenceList + * + * @param version - Version of the resource + */ +declare function ConferenceList(version: V1): ConferenceListInstance; + +interface ConferenceListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): ConferenceContext; + /** + * Streams ConferenceInstance 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: ConferenceInstance, done: (err?: Error) => void) => void): void; + /** + * Streams ConferenceInstance 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?: ConferenceListInstanceEachOptions, callback?: (item: ConferenceInstance, done: (err?: Error) => void) => void): void; + /** + * Constructs a conference + * + * @param conferenceSid - The conference_sid + */ + get(conferenceSid: string): ConferenceContext; + /** + * Retrieve a single target page of ConferenceInstance 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: ConferencePage) => any): Promise; + /** + * Retrieve a single target page of ConferenceInstance 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: ConferencePage) => any): Promise; + /** + * Lists ConferenceInstance 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: ConferenceInstance[]) => any): Promise; + /** + * Lists ConferenceInstance 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?: ConferenceListInstanceOptions, callback?: (error: Error | null, items: ConferenceInstance[]) => any): Promise; + /** + * Retrieve a single page of ConferenceInstance 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: ConferencePage) => any): Promise; + /** + * Retrieve a single page of ConferenceInstance 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?: ConferenceListInstancePageOptions, callback?: (error: Error | null, items: ConferencePage) => 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 conferenceSid - The conference_sid + * @property createdAfter - The created_after + * @property createdBefore - The created_before + * @property detectedIssues - The detected_issues + * @property done - Function to be called upon completion of streaming + * @property endReason - The end_reason + * @property friendlyName - The friendly_name + * @property limit - + * Upper limit for the number of records to return. + * each() guarantees never to return more than limit. + * Default is no limit + * @property mixerRegion - The mixer_region + * @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) + * @property status - The status + * @property subaccount - The subaccount + * @property tags - The tags + */ +interface ConferenceListInstanceEachOptions { + callback?: (item: ConferenceInstance, done: (err?: Error) => void) => void; + conferenceSid?: string; + createdAfter?: string; + createdBefore?: string; + detectedIssues?: string; + done?: Function; + endReason?: string; + friendlyName?: string; + limit?: number; + mixerRegion?: string; + pageSize?: number; + status?: string; + subaccount?: string; + tags?: string; +} + +/** + * Options to pass to list + * + * @property conferenceSid - The conference_sid + * @property createdAfter - The created_after + * @property createdBefore - The created_before + * @property detectedIssues - The detected_issues + * @property endReason - The end_reason + * @property friendlyName - The friendly_name + * @property limit - + * Upper limit for the number of records to return. + * list() guarantees never to return more than limit. + * Default is no limit + * @property mixerRegion - The mixer_region + * @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) + * @property status - The status + * @property subaccount - The subaccount + * @property tags - The tags + */ +interface ConferenceListInstanceOptions { + conferenceSid?: string; + createdAfter?: string; + createdBefore?: string; + detectedIssues?: string; + endReason?: string; + friendlyName?: string; + limit?: number; + mixerRegion?: string; + pageSize?: number; + status?: string; + subaccount?: string; + tags?: string; +} + +/** + * Options to pass to page + * + * @property conferenceSid - The conference_sid + * @property createdAfter - The created_after + * @property createdBefore - The created_before + * @property detectedIssues - The detected_issues + * @property endReason - The end_reason + * @property friendlyName - The friendly_name + * @property mixerRegion - The mixer_region + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + * @property status - The status + * @property subaccount - The subaccount + * @property tags - The tags + */ +interface ConferenceListInstancePageOptions { + conferenceSid?: string; + createdAfter?: string; + createdBefore?: string; + detectedIssues?: string; + endReason?: string; + friendlyName?: string; + mixerRegion?: string; + pageNumber?: number; + pageSize?: number; + pageToken?: string; + status?: string; + subaccount?: string; + tags?: string; +} + +interface ConferencePayload extends ConferenceResource, Page.TwilioResponsePayload { +} + +interface ConferenceResource { + account_sid: string; + conference_sid: string; + connect_duration_seconds: number; + create_time: Date; + detected_issues: object; + duration_seconds: number; + end_reason: ConferenceConferenceEndReason; + end_time: Date; + ended_by: string; + friendly_name: string; + links: string; + max_concurrent_participants: number; + max_participants: number; + mixer_region: ConferenceRegion; + mixer_region_requested: ConferenceRegion; + recording_enabled: boolean; + start_time: Date; + status: ConferenceConferenceStatus; + tag_info: object; + tags: ConferenceTag[]; + unique_participants: number; + url: string; +} + +interface ConferenceSolution { +} + + +declare class ConferenceContext { + /** + * Initialize the ConferenceContext + * + * @param version - Version of the resource + * @param conferenceSid - The conference_sid + */ + constructor(version: V1, conferenceSid: string); + + conferenceParticipants: ConferenceParticipantListInstance; + /** + * fetch a ConferenceInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: ConferenceInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + +declare class ConferenceInstance extends SerializableClass { + /** + * Initialize the ConferenceContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param conferenceSid - The conference_sid + */ + constructor(version: V1, payload: ConferencePayload, conferenceSid: string); + + private _proxy: ConferenceContext; + accountSid: string; + /** + * Access the conferenceParticipants + */ + conferenceParticipants(): ConferenceParticipantListInstance; + conferenceSid: string; + connectDurationSeconds: number; + createTime: Date; + detectedIssues: any; + durationSeconds: number; + endReason: ConferenceConferenceEndReason; + endTime: Date; + endedBy: string; + /** + * fetch a ConferenceInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: ConferenceInstance) => any): Promise; + friendlyName: string; + links: string; + maxConcurrentParticipants: number; + maxParticipants: number; + mixerRegion: ConferenceRegion; + mixerRegionRequested: ConferenceRegion; + recordingEnabled: boolean; + startTime: Date; + status: ConferenceConferenceStatus; + tagInfo: any; + tags: ConferenceTag[]; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + uniqueParticipants: number; + url: string; +} + + +declare class ConferencePage extends Page { + /** + * Initialize the ConferencePage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: ConferenceSolution); + + /** + * Build an instance of ConferenceInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: ConferencePayload): ConferenceInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { ConferenceConferenceEndReason, ConferenceConferenceStatus, ConferenceContext, ConferenceInstance, ConferenceList, ConferenceListInstance, ConferenceListInstanceEachOptions, ConferenceListInstanceOptions, ConferenceListInstancePageOptions, ConferencePage, ConferencePayload, ConferenceRegion, ConferenceResource, ConferenceSolution, ConferenceTag } diff --git a/lib/rest/insights/v1/conference.js b/lib/rest/insights/v1/conference.js new file mode 100644 index 0000000000..2ddebee966 --- /dev/null +++ b/lib/rest/insights/v1/conference.js @@ -0,0 +1,669 @@ +'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 ConferenceParticipantList = require( + './conference/conferenceParticipant').ConferenceParticipantList; +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 ConferenceList; +var ConferencePage; +var ConferenceInstance; +var ConferenceContext; + +/* jshint ignore:start */ +/** + * Initialize the ConferenceList + * + * @constructor Twilio.Insights.V1.ConferenceList + * + * @param {Twilio.Insights.V1} version - Version of the resource + */ +/* jshint ignore:end */ +ConferenceList = function ConferenceList(version) { + /* jshint ignore:start */ + /** + * @function conferences + * @memberof Twilio.Insights.V1# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Insights.V1.ConferenceContext} + */ + /* jshint ignore:end */ + function ConferenceListInstance(sid) { + return ConferenceListInstance.get(sid); + } + + ConferenceListInstance._version = version; + // Path Solution + ConferenceListInstance._solution = {}; + ConferenceListInstance._uri = `/Conferences`; + /* jshint ignore:start */ + /** + * Streams ConferenceInstance 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.Insights.V1.ConferenceList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.conferenceSid] - The conference_sid + * @param {string} [opts.friendlyName] - The friendly_name + * @param {string} [opts.status] - The status + * @param {string} [opts.createdAfter] - The created_after + * @param {string} [opts.createdBefore] - The created_before + * @param {string} [opts.mixerRegion] - The mixer_region + * @param {string} [opts.tags] - The tags + * @param {string} [opts.subaccount] - The subaccount + * @param {string} [opts.detectedIssues] - The detected_issues + * @param {string} [opts.endReason] - The end_reason + * @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 */ + ConferenceListInstance.each = function each(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + if (opts.callback) { + callback = opts.callback; + } + if (_.isUndefined(callback)) { + throw new Error('Callback function must be provided'); + } + + var done = false; + var currentPage = 1; + var currentResource = 0; + var limits = this._version.readLimits({ + limit: opts.limit, + pageSize: opts.pageSize + }); + + function onComplete(error) { + done = true; + if (_.isFunction(opts.done)) { + opts.done(error); + } + } + + function fetchNextPage(fn) { + var promise = fn(); + if (_.isUndefined(promise)) { + onComplete(); + return; + } + + promise.then(function(page) { + _.each(page.instances, function(instance) { + if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) { + done = true; + return false; + } + + currentResource++; + callback(instance, onComplete); + }); + + if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } else { + onComplete(); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists ConferenceInstance 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.Insights.V1.ConferenceList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.conferenceSid] - The conference_sid + * @param {string} [opts.friendlyName] - The friendly_name + * @param {string} [opts.status] - The status + * @param {string} [opts.createdAfter] - The created_after + * @param {string} [opts.createdBefore] - The created_before + * @param {string} [opts.mixerRegion] - The mixer_region + * @param {string} [opts.tags] - The tags + * @param {string} [opts.subaccount] - The subaccount + * @param {string} [opts.detectedIssues] - The detected_issues + * @param {string} [opts.endReason] - The end_reason + * @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 */ + ConferenceListInstance.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 ConferenceInstance 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.Insights.V1.ConferenceList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.conferenceSid] - The conference_sid + * @param {string} [opts.friendlyName] - The friendly_name + * @param {string} [opts.status] - The status + * @param {string} [opts.createdAfter] - The created_after + * @param {string} [opts.createdBefore] - The created_before + * @param {string} [opts.mixerRegion] - The mixer_region + * @param {string} [opts.tags] - The tags + * @param {string} [opts.subaccount] - The subaccount + * @param {string} [opts.detectedIssues] - The detected_issues + * @param {string} [opts.endReason] - The end_reason + * @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 */ + ConferenceListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'ConferenceSid': _.get(opts, 'conferenceSid'), + 'FriendlyName': _.get(opts, 'friendlyName'), + 'Status': _.get(opts, 'status'), + 'CreatedAfter': _.get(opts, 'createdAfter'), + 'CreatedBefore': _.get(opts, 'createdBefore'), + 'MixerRegion': _.get(opts, 'mixerRegion'), + 'Tags': _.get(opts, 'tags'), + 'Subaccount': _.get(opts, 'subaccount'), + 'DetectedIssues': _.get(opts, 'detectedIssues'), + 'EndReason': _.get(opts, 'endReason'), + '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 ConferencePage(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 ConferenceInstance 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.Insights.V1.ConferenceList# + * + * @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 */ + ConferenceListInstance.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 ConferencePage(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 conference + * + * @function get + * @memberof Twilio.Insights.V1.ConferenceList# + * + * @param {string} conferenceSid - The conference_sid + * + * @returns {Twilio.Insights.V1.ConferenceContext} + */ + /* jshint ignore:end */ + ConferenceListInstance.get = function get(conferenceSid) { + return new ConferenceContext(this._version, conferenceSid); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Insights.V1.ConferenceList# + * + * @returns Object + */ + /* jshint ignore:end */ + ConferenceListInstance.toJSON = function toJSON() { + return this._solution; + }; + + ConferenceListInstance[util.inspect.custom] = function inspect(depth, options) { + return util.inspect(this.toJSON(), options); + }; + + return ConferenceListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the ConferencePage + * + * @constructor Twilio.Insights.V1.ConferencePage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {ConferenceSolution} solution - Path solution + * + * @returns ConferencePage + */ +/* jshint ignore:end */ +ConferencePage = function ConferencePage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(ConferencePage.prototype, Page.prototype); +ConferencePage.prototype.constructor = ConferencePage; + +/* jshint ignore:start */ +/** + * Build an instance of ConferenceInstance + * + * @function getInstance + * @memberof Twilio.Insights.V1.ConferencePage# + * + * @param {ConferencePayload} payload - Payload response from the API + * + * @returns ConferenceInstance + */ +/* jshint ignore:end */ +ConferencePage.prototype.getInstance = function getInstance(payload) { + return new ConferenceInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Insights.V1.ConferencePage# + * + * @returns Object + */ +/* jshint ignore:end */ +ConferencePage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ConferencePage.prototype[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the ConferenceContext + * + * @constructor Twilio.Insights.V1.ConferenceInstance + * + * @property {string} conferenceSid - The conference_sid + * @property {string} accountSid - The account_sid + * @property {string} friendlyName - The friendly_name + * @property {Date} createTime - The create_time + * @property {Date} startTime - The start_time + * @property {Date} endTime - The end_time + * @property {number} durationSeconds - The duration_seconds + * @property {number} connectDurationSeconds - The connect_duration_seconds + * @property {conference.conference_status} status - The status + * @property {number} maxParticipants - The max_participants + * @property {number} maxConcurrentParticipants - The max_concurrent_participants + * @property {number} uniqueParticipants - The unique_participants + * @property {conference.conference_end_reason} endReason - The end_reason + * @property {string} endedBy - The ended_by + * @property {conference.region} mixerRegion - The mixer_region + * @property {conference.region} mixerRegionRequested - The mixer_region_requested + * @property {boolean} recordingEnabled - The recording_enabled + * @property {object} detectedIssues - The detected_issues + * @property {conference.tag} tags - The tags + * @property {object} tagInfo - The tag_info + * @property {string} url - The url + * @property {string} links - The links + * + * @param {V1} version - Version of the resource + * @param {ConferencePayload} payload - The instance payload + * @param {sid} conferenceSid - The conference_sid + */ +/* jshint ignore:end */ +ConferenceInstance = function ConferenceInstance(version, payload, + conferenceSid) { + this._version = version; + + // Marshaled Properties + this.conferenceSid = payload.conference_sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.friendlyName = payload.friendly_name; // jshint ignore:line + this.createTime = deserialize.iso8601DateTime(payload.create_time); // jshint ignore:line + this.startTime = deserialize.iso8601DateTime(payload.start_time); // jshint ignore:line + this.endTime = deserialize.iso8601DateTime(payload.end_time); // jshint ignore:line + this.durationSeconds = deserialize.integer(payload.duration_seconds); // jshint ignore:line + this.connectDurationSeconds = deserialize.integer(payload.connect_duration_seconds); // jshint ignore:line + this.status = payload.status; // jshint ignore:line + this.maxParticipants = deserialize.integer(payload.max_participants); // jshint ignore:line + this.maxConcurrentParticipants = deserialize.integer(payload.max_concurrent_participants); // jshint ignore:line + this.uniqueParticipants = deserialize.integer(payload.unique_participants); // jshint ignore:line + this.endReason = payload.end_reason; // jshint ignore:line + this.endedBy = payload.ended_by; // jshint ignore:line + this.mixerRegion = payload.mixer_region; // jshint ignore:line + this.mixerRegionRequested = payload.mixer_region_requested; // jshint ignore:line + this.recordingEnabled = payload.recording_enabled; // jshint ignore:line + this.detectedIssues = payload.detected_issues; // jshint ignore:line + this.tags = payload.tags; // jshint ignore:line + this.tagInfo = payload.tag_info; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + this.links = payload.links; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {conferenceSid: conferenceSid || this.conferenceSid, }; +}; + +Object.defineProperty(ConferenceInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new ConferenceContext(this._version, this._solution.conferenceSid); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * fetch a ConferenceInstance + * + * @function fetch + * @memberof Twilio.Insights.V1.ConferenceInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed ConferenceInstance + */ +/* jshint ignore:end */ +ConferenceInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * Access the conferenceParticipants + * + * @function conferenceParticipants + * @memberof Twilio.Insights.V1.ConferenceInstance# + * + * @returns {Twilio.Insights.V1.ConferenceContext.ConferenceParticipantList} + */ +/* jshint ignore:end */ +ConferenceInstance.prototype.conferenceParticipants = function + conferenceParticipants() { + return this._proxy.conferenceParticipants; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Insights.V1.ConferenceInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +ConferenceInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ConferenceInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the ConferenceContext + * + * @constructor Twilio.Insights.V1.ConferenceContext + * + * @property {Twilio.Insights.V1.ConferenceContext.ConferenceParticipantList} conferenceParticipants - + * conferenceParticipants resource + * + * @param {V1} version - Version of the resource + * @param {sid} conferenceSid - The conference_sid + */ +/* jshint ignore:end */ +ConferenceContext = function ConferenceContext(version, conferenceSid) { + this._version = version; + + // Path Solution + this._solution = {conferenceSid: conferenceSid, }; + this._uri = `/Conferences/${conferenceSid}`; + + // Dependents + this._conferenceParticipants = undefined; +}; + +/* jshint ignore:start */ +/** + * fetch a ConferenceInstance + * + * @function fetch + * @memberof Twilio.Insights.V1.ConferenceContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed ConferenceInstance + */ +/* jshint ignore:end */ +ConferenceContext.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 ConferenceInstance(this._version, payload, this._solution.conferenceSid)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +Object.defineProperty(ConferenceContext.prototype, + 'conferenceParticipants', { + get: function() { + if (!this._conferenceParticipants) { + this._conferenceParticipants = new ConferenceParticipantList( + this._version, + this._solution.conferenceSid + ); + } + return this._conferenceParticipants; + } +}); + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Insights.V1.ConferenceContext# + * + * @returns Object + */ +/* jshint ignore:end */ +ConferenceContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +ConferenceContext.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + ConferenceList: ConferenceList, + ConferencePage: ConferencePage, + ConferenceInstance: ConferenceInstance, + ConferenceContext: ConferenceContext +}; diff --git a/lib/rest/insights/v1/conference/conferenceParticipant.d.ts b/lib/rest/insights/v1/conference/conferenceParticipant.d.ts new file mode 100644 index 0000000000..69ee522d6b --- /dev/null +++ b/lib/rest/insights/v1/conference/conferenceParticipant.d.ts @@ -0,0 +1,385 @@ +/** + * 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 ConferenceParticipantCallDirection = 'inbound'|'outbound'; + +type ConferenceParticipantCallState = 'answered'|'completed'|'busy'|'fail'|'noanswer'|'ringing'|'canceled'; + +type ConferenceParticipantCallType = 'carrier'|'client'|'sip'; + +type ConferenceParticipantJitterBufferSize = 'large'|'small'|'medium'|'off'; + +type ConferenceParticipantRegion = 'us1'|'us2'|'au1'|'br1'|'ie1'|'jp1'|'sg1'|'de1'; + +/** + * Initialize the ConferenceParticipantList + * + * @param version - Version of the resource + * @param conferenceSid - The conference_sid + */ +declare function ConferenceParticipantList(version: V1, conferenceSid: string): ConferenceParticipantListInstance; + +/** + * Options to pass to fetch + * + * @property events - The events + * @property metrics - The metrics + */ +interface ConferenceParticipantInstanceFetchOptions { + events?: string; + metrics?: string; +} + +interface ConferenceParticipantListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): ConferenceParticipantContext; + /** + * Streams ConferenceParticipantInstance 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: ConferenceParticipantInstance, done: (err?: Error) => void) => void): void; + /** + * Streams ConferenceParticipantInstance 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?: ConferenceParticipantListInstanceEachOptions, callback?: (item: ConferenceParticipantInstance, done: (err?: Error) => void) => void): void; + /** + * Constructs a conference_participant + * + * @param participantSid - The participant_sid + */ + get(participantSid: string): ConferenceParticipantContext; + /** + * Retrieve a single target page of ConferenceParticipantInstance 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: ConferenceParticipantPage) => any): Promise; + /** + * Retrieve a single target page of ConferenceParticipantInstance 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: ConferenceParticipantPage) => any): Promise; + /** + * Lists ConferenceParticipantInstance 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: ConferenceParticipantInstance[]) => any): Promise; + /** + * Lists ConferenceParticipantInstance 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?: ConferenceParticipantListInstanceOptions, callback?: (error: Error | null, items: ConferenceParticipantInstance[]) => any): Promise; + /** + * Retrieve a single page of ConferenceParticipantInstance 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: ConferenceParticipantPage) => any): Promise; + /** + * Retrieve a single page of ConferenceParticipantInstance 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?: ConferenceParticipantListInstancePageOptions, callback?: (error: Error | null, items: ConferenceParticipantPage) => 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 events - The events + * @property label - The label + * @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) + * @property participantSid - The participant_sid + */ +interface ConferenceParticipantListInstanceEachOptions { + callback?: (item: ConferenceParticipantInstance, done: (err?: Error) => void) => void; + done?: Function; + events?: string; + label?: string; + limit?: number; + pageSize?: number; + participantSid?: string; +} + +/** + * Options to pass to list + * + * @property events - The events + * @property label - The label + * @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) + * @property participantSid - The participant_sid + */ +interface ConferenceParticipantListInstanceOptions { + events?: string; + label?: string; + limit?: number; + pageSize?: number; + participantSid?: string; +} + +/** + * Options to pass to page + * + * @property events - The events + * @property label - The label + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + * @property participantSid - The participant_sid + */ +interface ConferenceParticipantListInstancePageOptions { + events?: string; + label?: string; + pageNumber?: number; + pageSize?: number; + pageToken?: string; + participantSid?: string; +} + +interface ConferenceParticipantPayload extends ConferenceParticipantResource, Page.TwilioResponsePayload { +} + +interface ConferenceParticipantResource { + account_sid: string; + agent_audio: boolean; + call_direction: ConferenceParticipantCallDirection; + call_sid: string; + call_state: ConferenceParticipantCallState; + call_type: ConferenceParticipantCallType; + coached_participants: string[]; + conference_region: ConferenceParticipantRegion; + conference_sid: string; + country_code: string; + duration_seconds: number; + events: object; + from: string; + is_coach: boolean; + is_moderator: boolean; + jitter_buffer_size: ConferenceParticipantJitterBufferSize; + join_time: Date; + label: string; + leave_time: Date; + metrics: object; + outbound_queue_length: number; + outbound_time_in_queue: number; + participant_region: ConferenceParticipantRegion; + participant_sid: string; + properties: object; + quality_issues: number; + to: string; + url: string; + whisper: string; +} + +interface ConferenceParticipantSolution { + conferenceSid?: string; +} + + +declare class ConferenceParticipantContext { + /** + * Initialize the ConferenceParticipantContext + * + * @param version - Version of the resource + * @param conferenceSid - The conference_sid + * @param participantSid - The participant_sid + */ + constructor(version: V1, conferenceSid: string, participantSid: string); + + /** + * fetch a ConferenceParticipantInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: ConferenceParticipantInstance) => any): Promise; + /** + * fetch a ConferenceParticipantInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + fetch(opts?: ConferenceParticipantInstanceFetchOptions, callback?: (error: Error | null, items: ConferenceParticipantInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + +declare class ConferenceParticipantInstance extends SerializableClass { + /** + * Initialize the ConferenceParticipantContext + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param conferenceSid - The conference_sid + * @param participantSid - The participant_sid + */ + constructor(version: V1, payload: ConferenceParticipantPayload, conferenceSid: string, participantSid: string); + + private _proxy: ConferenceParticipantContext; + accountSid: string; + agentAudio: boolean; + callDirection: ConferenceParticipantCallDirection; + callSid: string; + callState: ConferenceParticipantCallState; + callType: ConferenceParticipantCallType; + coachedParticipants: string[]; + conferenceRegion: ConferenceParticipantRegion; + conferenceSid: string; + countryCode: string; + durationSeconds: number; + events: any; + /** + * fetch a ConferenceParticipantInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: ConferenceParticipantInstance) => any): Promise; + /** + * fetch a ConferenceParticipantInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + fetch(opts?: ConferenceParticipantInstanceFetchOptions, callback?: (error: Error | null, items: ConferenceParticipantInstance) => any): Promise; + from: string; + isCoach: boolean; + isModerator: boolean; + jitterBufferSize: ConferenceParticipantJitterBufferSize; + joinTime: Date; + label: string; + leaveTime: Date; + metrics: any; + outboundQueueLength: number; + outboundTimeInQueue: number; + participantRegion: ConferenceParticipantRegion; + participantSid: string; + properties: any; + qualityIssues: number; + to: string; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + url: string; + whisper: string; +} + + +declare class ConferenceParticipantPage extends Page { + /** + * Initialize the ConferenceParticipantPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: ConferenceParticipantSolution); + + /** + * Build an instance of ConferenceParticipantInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: ConferenceParticipantPayload): ConferenceParticipantInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { ConferenceParticipantCallDirection, ConferenceParticipantCallState, ConferenceParticipantCallType, ConferenceParticipantContext, ConferenceParticipantInstance, ConferenceParticipantInstanceFetchOptions, ConferenceParticipantJitterBufferSize, ConferenceParticipantList, ConferenceParticipantListInstance, ConferenceParticipantListInstanceEachOptions, ConferenceParticipantListInstanceOptions, ConferenceParticipantListInstancePageOptions, ConferenceParticipantPage, ConferenceParticipantPayload, ConferenceParticipantRegion, ConferenceParticipantResource, ConferenceParticipantSolution } diff --git a/lib/rest/insights/v1/conference/conferenceParticipant.js b/lib/rest/insights/v1/conference/conferenceParticipant.js new file mode 100644 index 0000000000..225635e683 --- /dev/null +++ b/lib/rest/insights/v1/conference/conferenceParticipant.js @@ -0,0 +1,663 @@ +'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 ConferenceParticipantList; +var ConferenceParticipantPage; +var ConferenceParticipantInstance; +var ConferenceParticipantContext; + +/* jshint ignore:start */ +/** + * Initialize the ConferenceParticipantList + * + * @constructor Twilio.Insights.V1.ConferenceContext.ConferenceParticipantList + * + * @param {Twilio.Insights.V1} version - Version of the resource + * @param {string} conferenceSid - The conference_sid + */ +/* jshint ignore:end */ +ConferenceParticipantList = function ConferenceParticipantList(version, + conferenceSid) { + /* jshint ignore:start */ + /** + * @function conferenceParticipants + * @memberof Twilio.Insights.V1.ConferenceContext# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Insights.V1.ConferenceContext.ConferenceParticipantContext} + */ + /* jshint ignore:end */ + function ConferenceParticipantListInstance(sid) { + return ConferenceParticipantListInstance.get(sid); + } + + ConferenceParticipantListInstance._version = version; + // Path Solution + ConferenceParticipantListInstance._solution = {conferenceSid: conferenceSid}; + ConferenceParticipantListInstance._uri = `/Conferences/${conferenceSid}/Participants`; + /* jshint ignore:start */ + /** + * Streams ConferenceParticipantInstance 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.Insights.V1.ConferenceContext.ConferenceParticipantList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.participantSid] - The participant_sid + * @param {string} [opts.label] - The label + * @param {string} [opts.events] - The events + * @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 */ + ConferenceParticipantListInstance.each = function each(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + if (opts.callback) { + callback = opts.callback; + } + if (_.isUndefined(callback)) { + throw new Error('Callback function must be provided'); + } + + var done = false; + var currentPage = 1; + var currentResource = 0; + var limits = this._version.readLimits({ + limit: opts.limit, + pageSize: opts.pageSize + }); + + function onComplete(error) { + done = true; + if (_.isFunction(opts.done)) { + opts.done(error); + } + } + + function fetchNextPage(fn) { + var promise = fn(); + if (_.isUndefined(promise)) { + onComplete(); + return; + } + + promise.then(function(page) { + _.each(page.instances, function(instance) { + if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) { + done = true; + return false; + } + + currentResource++; + callback(instance, onComplete); + }); + + if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } else { + onComplete(); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists ConferenceParticipantInstance 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.Insights.V1.ConferenceContext.ConferenceParticipantList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.participantSid] - The participant_sid + * @param {string} [opts.label] - The label + * @param {string} [opts.events] - The events + * @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 */ + ConferenceParticipantListInstance.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 ConferenceParticipantInstance 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.Insights.V1.ConferenceContext.ConferenceParticipantList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.participantSid] - The participant_sid + * @param {string} [opts.label] - The label + * @param {string} [opts.events] - The events + * @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 */ + ConferenceParticipantListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'ParticipantSid': _.get(opts, 'participantSid'), + 'Label': _.get(opts, 'label'), + 'Events': _.get(opts, 'events'), + '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 ConferenceParticipantPage(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 ConferenceParticipantInstance 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.Insights.V1.ConferenceContext.ConferenceParticipantList# + * + * @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 */ + ConferenceParticipantListInstance.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 ConferenceParticipantPage(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 conference_participant + * + * @function get + * @memberof Twilio.Insights.V1.ConferenceContext.ConferenceParticipantList# + * + * @param {string} participantSid - The participant_sid + * + * @returns {Twilio.Insights.V1.ConferenceContext.ConferenceParticipantContext} + */ + /* jshint ignore:end */ + ConferenceParticipantListInstance.get = function get(participantSid) { + return new ConferenceParticipantContext( + this._version, + this._solution.conferenceSid, + participantSid + ); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Insights.V1.ConferenceContext.ConferenceParticipantList# + * + * @returns Object + */ + /* jshint ignore:end */ + ConferenceParticipantListInstance.toJSON = function toJSON() { + return this._solution; + }; + + ConferenceParticipantListInstance[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); + }; + + return ConferenceParticipantListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the ConferenceParticipantPage + * + * @constructor Twilio.Insights.V1.ConferenceContext.ConferenceParticipantPage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {ConferenceParticipantSolution} solution - Path solution + * + * @returns ConferenceParticipantPage + */ +/* jshint ignore:end */ +ConferenceParticipantPage = function ConferenceParticipantPage(version, + response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(ConferenceParticipantPage.prototype, Page.prototype); +ConferenceParticipantPage.prototype.constructor = ConferenceParticipantPage; + +/* jshint ignore:start */ +/** + * Build an instance of ConferenceParticipantInstance + * + * @function getInstance + * @memberof Twilio.Insights.V1.ConferenceContext.ConferenceParticipantPage# + * + * @param {ConferenceParticipantPayload} payload - Payload response from the API + * + * @returns ConferenceParticipantInstance + */ +/* jshint ignore:end */ +ConferenceParticipantPage.prototype.getInstance = function getInstance(payload) + { + return new ConferenceParticipantInstance(this._version, payload, this._solution.conferenceSid); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Insights.V1.ConferenceContext.ConferenceParticipantPage# + * + * @returns Object + */ +/* jshint ignore:end */ +ConferenceParticipantPage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ConferenceParticipantPage.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the ConferenceParticipantContext + * + * @constructor Twilio.Insights.V1.ConferenceContext.ConferenceParticipantInstance + * + * @property {string} participantSid - The participant_sid + * @property {string} label - The label + * @property {string} conferenceSid - The conference_sid + * @property {string} callSid - The call_sid + * @property {string} accountSid - The account_sid + * @property {conference_participant.call_direction} callDirection - + * The call_direction + * @property {string} from - The from + * @property {string} to - The to + * @property {conference_participant.call_state} callState - The call_state + * @property {string} countryCode - The country_code + * @property {boolean} isModerator - The is_moderator + * @property {Date} joinTime - The join_time + * @property {Date} leaveTime - The leave_time + * @property {number} durationSeconds - The duration_seconds + * @property {string} whisper - The whisper + * @property {boolean} agentAudio - The agent_audio + * @property {number} outboundQueueLength - The outbound_queue_length + * @property {number} outboundTimeInQueue - The outbound_time_in_queue + * @property {conference_participant.jitter_buffer_size} jitterBufferSize - + * The jitter_buffer_size + * @property {boolean} isCoach - The is_coach + * @property {string} coachedParticipants - The coached_participants + * @property {conference_participant.region} participantRegion - + * The participant_region + * @property {conference_participant.region} conferenceRegion - + * The conference_region + * @property {conference_participant.call_type} callType - The call_type + * @property {number} qualityIssues - The quality_issues + * @property {object} properties - The properties + * @property {object} events - The events + * @property {object} metrics - The metrics + * @property {string} url - The url + * + * @param {V1} version - Version of the resource + * @param {ConferenceParticipantPayload} payload - The instance payload + * @param {sid} conferenceSid - The conference_sid + * @param {sid} participantSid - The participant_sid + */ +/* jshint ignore:end */ +ConferenceParticipantInstance = function ConferenceParticipantInstance(version, + payload, conferenceSid, participantSid) { + this._version = version; + + // Marshaled Properties + this.participantSid = payload.participant_sid; // jshint ignore:line + this.label = payload.label; // jshint ignore:line + this.conferenceSid = payload.conference_sid; // jshint ignore:line + this.callSid = payload.call_sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.callDirection = payload.call_direction; // jshint ignore:line + this.from = payload.from; // jshint ignore:line + this.to = payload.to; // jshint ignore:line + this.callState = payload.call_state; // jshint ignore:line + this.countryCode = payload.country_code; // jshint ignore:line + this.isModerator = payload.is_moderator; // jshint ignore:line + this.joinTime = deserialize.iso8601DateTime(payload.join_time); // jshint ignore:line + this.leaveTime = deserialize.iso8601DateTime(payload.leave_time); // jshint ignore:line + this.durationSeconds = deserialize.integer(payload.duration_seconds); // jshint ignore:line + this.whisper = payload.whisper; // jshint ignore:line + this.agentAudio = payload.agent_audio; // jshint ignore:line + this.outboundQueueLength = deserialize.integer(payload.outbound_queue_length); // jshint ignore:line + this.outboundTimeInQueue = deserialize.integer(payload.outbound_time_in_queue); // jshint ignore:line + this.jitterBufferSize = payload.jitter_buffer_size; // jshint ignore:line + this.isCoach = payload.is_coach; // jshint ignore:line + this.coachedParticipants = payload.coached_participants; // jshint ignore:line + this.participantRegion = payload.participant_region; // jshint ignore:line + this.conferenceRegion = payload.conference_region; // jshint ignore:line + this.callType = payload.call_type; // jshint ignore:line + this.qualityIssues = deserialize.integer(payload.quality_issues); // jshint ignore:line + this.properties = payload.properties; // jshint ignore:line + this.events = payload.events; // jshint ignore:line + this.metrics = payload.metrics; // jshint ignore:line + this.url = payload.url; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = { + conferenceSid: conferenceSid, + participantSid: participantSid || this.participantSid, + }; +}; + +Object.defineProperty(ConferenceParticipantInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new ConferenceParticipantContext( + this._version, + this._solution.conferenceSid, + this._solution.participantSid + ); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * fetch a ConferenceParticipantInstance + * + * @function fetch + * @memberof Twilio.Insights.V1.ConferenceContext.ConferenceParticipantInstance# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.events] - The events + * @param {string} [opts.metrics] - The metrics + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed ConferenceParticipantInstance + */ +/* jshint ignore:end */ +ConferenceParticipantInstance.prototype.fetch = function fetch(opts, callback) { + return this._proxy.fetch(opts, callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Insights.V1.ConferenceContext.ConferenceParticipantInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +ConferenceParticipantInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +ConferenceParticipantInstance.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the ConferenceParticipantContext + * + * @constructor Twilio.Insights.V1.ConferenceContext.ConferenceParticipantContext + * + * @param {V1} version - Version of the resource + * @param {sid} conferenceSid - The conference_sid + * @param {sid} participantSid - The participant_sid + */ +/* jshint ignore:end */ +ConferenceParticipantContext = function ConferenceParticipantContext(version, + conferenceSid, participantSid) { + this._version = version; + + // Path Solution + this._solution = {conferenceSid: conferenceSid, participantSid: participantSid, }; + this._uri = `/Conferences/${conferenceSid}/Participants/${participantSid}`; +}; + +/* jshint ignore:start */ +/** + * fetch a ConferenceParticipantInstance + * + * @function fetch + * @memberof Twilio.Insights.V1.ConferenceContext.ConferenceParticipantContext# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.events] - The events + * @param {string} [opts.metrics] - The metrics + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed ConferenceParticipantInstance + */ +/* jshint ignore:end */ +ConferenceParticipantContext.prototype.fetch = function fetch(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({'Events': _.get(opts, 'events'), 'Metrics': _.get(opts, 'metrics')}); + + var promise = this._version.fetch({uri: this._uri, method: 'GET', params: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new ConferenceParticipantInstance( + this._version, + payload, + this._solution.conferenceSid, + this._solution.participantSid + )); + }.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.Insights.V1.ConferenceContext.ConferenceParticipantContext# + * + * @returns Object + */ +/* jshint ignore:end */ +ConferenceParticipantContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +ConferenceParticipantContext.prototype[util.inspect.custom] = function + inspect(depth, options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + ConferenceParticipantList: ConferenceParticipantList, + ConferenceParticipantPage: ConferenceParticipantPage, + ConferenceParticipantInstance: ConferenceParticipantInstance, + ConferenceParticipantContext: ConferenceParticipantContext +}; diff --git a/lib/rest/messaging/v1/brandRegistration.d.ts b/lib/rest/messaging/v1/brandRegistration.d.ts index 8c03b889e9..74280cff3c 100644 --- a/lib/rest/messaging/v1/brandRegistration.d.ts +++ b/lib/rest/messaging/v1/brandRegistration.d.ts @@ -235,6 +235,7 @@ interface BrandRegistrationResource { date_created: Date; date_updated: Date; failure_reason: string; + government_entity: boolean; identity_status: BrandRegistrationIdentityStatus; links: string; mock: boolean; @@ -316,6 +317,7 @@ declare class BrandRegistrationInstance extends SerializableClass { * @param callback - Callback to handle processed record */ fetch(callback?: (error: Error | null, items: BrandRegistrationInstance) => any): Promise; + governmentEntity: boolean; identityStatus: BrandRegistrationIdentityStatus; links: string; mock: boolean; diff --git a/lib/rest/messaging/v1/brandRegistration.js b/lib/rest/messaging/v1/brandRegistration.js index 9f786b06b3..77400cf182 100644 --- a/lib/rest/messaging/v1/brandRegistration.js +++ b/lib/rest/messaging/v1/brandRegistration.js @@ -492,6 +492,7 @@ BrandRegistrationPage.prototype[util.inspect.custom] = function inspect(depth, * @property {brand_registration.brand_feedback} brandFeedback - Brand feedback * @property {brand_registration.identity_status} identityStatus - Identity Status * @property {boolean} russell3000 - Russell 3000 + * @property {boolean} governmentEntity - Government Entity * @property {string} taxExemptStatus - Tax Exempt Status * @property {boolean} skipAutomaticSecVet - Skip Automatic Secondary Vetting * @property {boolean} mock - @@ -523,6 +524,7 @@ BrandRegistrationInstance = function BrandRegistrationInstance(version, payload, this.brandFeedback = payload.brand_feedback; // jshint ignore:line this.identityStatus = payload.identity_status; // jshint ignore:line this.russell3000 = payload.russell_3000; // jshint ignore:line + this.governmentEntity = payload.government_entity; // jshint ignore:line this.taxExemptStatus = payload.tax_exempt_status; // jshint ignore:line this.skipAutomaticSecVet = payload.skip_automatic_sec_vet; // jshint ignore:line this.mock = payload.mock; // jshint ignore:line diff --git a/lib/rest/supersim/V1.d.ts b/lib/rest/supersim/V1.d.ts index 0a9d8fe03c..1595f7d43b 100644 --- a/lib/rest/supersim/V1.d.ts +++ b/lib/rest/supersim/V1.d.ts @@ -9,6 +9,8 @@ import Supersim = require('../Supersim'); import Version = require('../../base/Version'); import { CommandList } from './v1/command'; import { CommandListInstance } from './v1/command'; +import { EsimProfileList } from './v1/esimProfile'; +import { EsimProfileListInstance } from './v1/esimProfile'; import { FleetList } from './v1/fleet'; import { FleetListInstance } from './v1/fleet'; import { IpCommandList } from './v1/ipCommand'; @@ -34,6 +36,7 @@ declare class V1 extends Version { constructor(domain: Supersim); readonly commands: CommandListInstance; + readonly esimProfiles: EsimProfileListInstance; readonly fleets: FleetListInstance; readonly ipCommands: IpCommandListInstance; readonly networkAccessProfiles: NetworkAccessProfileListInstance; diff --git a/lib/rest/supersim/V1.js b/lib/rest/supersim/V1.js index e7e7cd4525..bf8f70d29e 100644 --- a/lib/rest/supersim/V1.js +++ b/lib/rest/supersim/V1.js @@ -11,6 +11,7 @@ var _ = require('lodash'); /* jshint ignore:line */ var CommandList = require('./v1/command').CommandList; +var EsimProfileList = require('./v1/esimProfile').EsimProfileList; var FleetList = require('./v1/fleet').FleetList; var IpCommandList = require('./v1/ipCommand').IpCommandList; var NetworkAccessProfileList = require( @@ -29,6 +30,8 @@ var Version = require('../../base/Version'); /* jshint ignore:line */ * @constructor Twilio.Supersim.V1 * * @property {Twilio.Supersim.V1.CommandList} commands - commands resource + * @property {Twilio.Supersim.V1.EsimProfileList} esimProfiles - + * esimProfiles resource * @property {Twilio.Supersim.V1.FleetList} fleets - fleets resource * @property {Twilio.Supersim.V1.IpCommandList} ipCommands - ipCommands resource * @property {Twilio.Supersim.V1.NetworkList} networks - networks resource @@ -47,6 +50,7 @@ function V1(domain) { // Resources this._commands = undefined; + this._esimProfiles = undefined; this._fleets = undefined; this._ipCommands = undefined; this._networks = undefined; @@ -67,6 +71,14 @@ Object.defineProperty(V1.prototype, } }); +Object.defineProperty(V1.prototype, + 'esimProfiles', { + get: function() { + this._esimProfiles = this._esimProfiles || new EsimProfileList(this); + return this._esimProfiles; + } +}); + Object.defineProperty(V1.prototype, 'fleets', { get: function() { diff --git a/lib/rest/supersim/v1/esimProfile.d.ts b/lib/rest/supersim/v1/esimProfile.d.ts new file mode 100644 index 0000000000..30a1e9d37e --- /dev/null +++ b/lib/rest/supersim/v1/esimProfile.d.ts @@ -0,0 +1,344 @@ +/** + * 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 EsimProfileStatus = 'new'|'reserving'|'available'|'downloaded'|'installed'|'failed'; + +/** + * Initialize the EsimProfileList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + */ +declare function EsimProfileList(version: V1): EsimProfileListInstance; + +interface EsimProfileListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): EsimProfileContext; + /** + * create a EsimProfileInstance + * + * @param opts - Options for request + * @param callback - Callback to handle processed record + */ + create(opts: EsimProfileListInstanceCreateOptions, callback?: (error: Error | null, item: EsimProfileInstance) => any): Promise; + /** + * Streams EsimProfileInstance 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: EsimProfileInstance, done: (err?: Error) => void) => void): void; + /** + * Streams EsimProfileInstance 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?: EsimProfileListInstanceEachOptions, callback?: (item: EsimProfileInstance, done: (err?: Error) => void) => void): void; + /** + * Constructs a esim_profile + * + * @param sid - The SID of the eSIM Profile resource to fetch + */ + get(sid: string): EsimProfileContext; + /** + * Retrieve a single target page of EsimProfileInstance 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: EsimProfilePage) => any): Promise; + /** + * Retrieve a single target page of EsimProfileInstance 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: EsimProfilePage) => any): Promise; + /** + * Lists EsimProfileInstance 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: EsimProfileInstance[]) => any): Promise; + /** + * Lists EsimProfileInstance 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?: EsimProfileListInstanceOptions, callback?: (error: Error | null, items: EsimProfileInstance[]) => any): Promise; + /** + * Retrieve a single page of EsimProfileInstance 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: EsimProfilePage) => any): Promise; + /** + * Retrieve a single page of EsimProfileInstance 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?: EsimProfileListInstancePageOptions, callback?: (error: Error | null, items: EsimProfilePage) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +/** + * Options to pass to create + * + * @property callbackMethod - The HTTP method we should use to call callback_url + * @property callbackUrl - The URL we should call after we have sent when the status of the eSIM Profile changes + * @property eid - Identifier of the eUICC that will claim the eSIM Profile + */ +interface EsimProfileListInstanceCreateOptions { + callbackMethod?: string; + callbackUrl?: string; + eid: 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 eid - List the eSIM Profiles that have been associated with an EId + * @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) + * @property simSid - Find the eSIM Profile resource related to a Sim resource by providing the SIM SID + * @property status - List the eSIM Profiles that are in a given status + */ +interface EsimProfileListInstanceEachOptions { + callback?: (item: EsimProfileInstance, done: (err?: Error) => void) => void; + done?: Function; + eid?: string; + limit?: number; + pageSize?: number; + simSid?: string; + status?: EsimProfileStatus; +} + +/** + * Options to pass to list + * + * @property eid - List the eSIM Profiles that have been associated with an EId + * @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) + * @property simSid - Find the eSIM Profile resource related to a Sim resource by providing the SIM SID + * @property status - List the eSIM Profiles that are in a given status + */ +interface EsimProfileListInstanceOptions { + eid?: string; + limit?: number; + pageSize?: number; + simSid?: string; + status?: EsimProfileStatus; +} + +/** + * Options to pass to page + * + * @property eid - List the eSIM Profiles that have been associated with an EId + * @property pageNumber - Page Number, this value is simply for client state + * @property pageSize - Number of records to return, defaults to 50 + * @property pageToken - PageToken provided by the API + * @property simSid - Find the eSIM Profile resource related to a Sim resource by providing the SIM SID + * @property status - List the eSIM Profiles that are in a given status + */ +interface EsimProfileListInstancePageOptions { + eid?: string; + pageNumber?: number; + pageSize?: number; + pageToken?: string; + simSid?: string; + status?: EsimProfileStatus; +} + +interface EsimProfilePayload extends EsimProfileResource, Page.TwilioResponsePayload { +} + +interface EsimProfileResource { + account_sid: string; + date_created: Date; + date_updated: Date; + eid: string; + error_code: string; + error_message: string; + iccid: string; + sid: string; + sim_sid: string; + smdp_plus_address: string; + status: EsimProfileStatus; + url: string; +} + +interface EsimProfileSolution { +} + + +declare class EsimProfileContext { + /** + * Initialize the EsimProfileContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param sid - The SID of the eSIM Profile resource to fetch + */ + constructor(version: V1, sid: string); + + /** + * fetch a EsimProfileInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: EsimProfileInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + +declare class EsimProfileInstance extends SerializableClass { + /** + * Initialize the EsimProfileContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param payload - The instance payload + * @param sid - The SID of the eSIM Profile resource to fetch + */ + constructor(version: V1, payload: EsimProfilePayload, sid: string); + + private _proxy: EsimProfileContext; + accountSid: string; + dateCreated: Date; + dateUpdated: Date; + eid: string; + errorCode: string; + errorMessage: string; + /** + * fetch a EsimProfileInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: EsimProfileInstance) => any): Promise; + iccid: string; + sid: string; + simSid: string; + smdpPlusAddress: string; + status: EsimProfileStatus; + /** + * Provide a user-friendly representation + */ + toJSON(): any; + url: string; +} + + +declare class EsimProfilePage extends Page { + /** + * Initialize the EsimProfilePage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor(version: V1, response: Response, solution: EsimProfileSolution); + + /** + * Build an instance of EsimProfileInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: EsimProfilePayload): EsimProfileInstance; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + +export { EsimProfileContext, EsimProfileInstance, EsimProfileList, EsimProfileListInstance, EsimProfileListInstanceCreateOptions, EsimProfileListInstanceEachOptions, EsimProfileListInstanceOptions, EsimProfileListInstancePageOptions, EsimProfilePage, EsimProfilePayload, EsimProfileResource, EsimProfileSolution, EsimProfileStatus } diff --git a/lib/rest/supersim/v1/esimProfile.js b/lib/rest/supersim/v1/esimProfile.js new file mode 100644 index 0000000000..5d44313a4e --- /dev/null +++ b/lib/rest/supersim/v1/esimProfile.js @@ -0,0 +1,664 @@ +'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 EsimProfileList; +var EsimProfilePage; +var EsimProfileInstance; +var EsimProfileContext; + +/* jshint ignore:start */ +/** + * Initialize the EsimProfileList + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Supersim.V1.EsimProfileList + * + * @param {Twilio.Supersim.V1} version - Version of the resource + */ +/* jshint ignore:end */ +EsimProfileList = function EsimProfileList(version) { + /* jshint ignore:start */ + /** + * @function esimProfiles + * @memberof Twilio.Supersim.V1# + * + * @param {string} sid - sid of instance + * + * @returns {Twilio.Supersim.V1.EsimProfileContext} + */ + /* jshint ignore:end */ + function EsimProfileListInstance(sid) { + return EsimProfileListInstance.get(sid); + } + + EsimProfileListInstance._version = version; + // Path Solution + EsimProfileListInstance._solution = {}; + EsimProfileListInstance._uri = `/ESimProfiles`; + /* jshint ignore:start */ + /** + * create a EsimProfileInstance + * + * @function create + * @memberof Twilio.Supersim.V1.EsimProfileList# + * + * @param {object} opts - Options for request + * @param {string} opts.eid - + * Identifier of the eUICC that will claim the eSIM Profile + * @param {string} [opts.callbackUrl] - + * The URL we should call after we have sent when the status of the eSIM Profile changes + * @param {string} [opts.callbackMethod] - + * The HTTP method we should use to call callback_url + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed EsimProfileInstance + */ + /* jshint ignore:end */ + EsimProfileListInstance.create = function create(opts, callback) { + if (_.isUndefined(opts)) { + throw new Error('Required parameter "opts" missing.'); + } + if (_.isUndefined(opts.eid)) { + throw new Error('Required parameter "opts.eid" missing.'); + } + + var deferred = Q.defer(); + var data = values.of({ + 'Eid': _.get(opts, 'eid'), + 'CallbackUrl': _.get(opts, 'callbackUrl'), + 'CallbackMethod': _.get(opts, 'callbackMethod') + }); + + var promise = this._version.create({uri: this._uri, method: 'POST', data: data}); + + promise = promise.then(function(payload) { + deferred.resolve(new EsimProfileInstance(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 EsimProfileInstance 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.EsimProfileList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.eid] - + * List the eSIM Profiles that have been associated with an EId + * @param {string} [opts.simSid] - + * Find the eSIM Profile resource related to a Sim resource by providing the SIM SID + * @param {esim_profile.status} [opts.status] - + * List the eSIM Profiles that are in a given status + * @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 */ + EsimProfileListInstance.each = function each(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + if (opts.callback) { + callback = opts.callback; + } + if (_.isUndefined(callback)) { + throw new Error('Callback function must be provided'); + } + + var done = false; + var currentPage = 1; + var currentResource = 0; + var limits = this._version.readLimits({ + limit: opts.limit, + pageSize: opts.pageSize + }); + + function onComplete(error) { + done = true; + if (_.isFunction(opts.done)) { + opts.done(error); + } + } + + function fetchNextPage(fn) { + var promise = fn(); + if (_.isUndefined(promise)) { + onComplete(); + return; + } + + promise.then(function(page) { + _.each(page.instances, function(instance) { + if (done || (!_.isUndefined(opts.limit) && currentResource >= opts.limit)) { + done = true; + return false; + } + + currentResource++; + callback(instance, onComplete); + }); + + if (!done) { + currentPage++; + fetchNextPage(_.bind(page.nextPage, page)); + } else { + onComplete(); + } + }); + + promise.catch(onComplete); + } + + fetchNextPage(_.bind(this.page, this, _.merge(opts, limits))); + }; + + /* jshint ignore:start */ + /** + * Lists EsimProfileInstance 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.EsimProfileList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.eid] - + * List the eSIM Profiles that have been associated with an EId + * @param {string} [opts.simSid] - + * Find the eSIM Profile resource related to a Sim resource by providing the SIM SID + * @param {esim_profile.status} [opts.status] - + * List the eSIM Profiles that are in a given status + * @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 */ + EsimProfileListInstance.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 EsimProfileInstance 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.EsimProfileList# + * + * @param {object} [opts] - Options for request + * @param {string} [opts.eid] - + * List the eSIM Profiles that have been associated with an EId + * @param {string} [opts.simSid] - + * Find the eSIM Profile resource related to a Sim resource by providing the SIM SID + * @param {esim_profile.status} [opts.status] - + * List the eSIM Profiles that are in a given status + * @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 */ + EsimProfileListInstance.page = function page(opts, callback) { + if (_.isFunction(opts)) { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var deferred = Q.defer(); + var data = values.of({ + 'Eid': _.get(opts, 'eid'), + 'SimSid': _.get(opts, 'simSid'), + 'Status': _.get(opts, 'status'), + '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 EsimProfilePage(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 EsimProfileInstance 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.EsimProfileList# + * + * @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 */ + EsimProfileListInstance.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 EsimProfilePage(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 esim_profile + * + * @function get + * @memberof Twilio.Supersim.V1.EsimProfileList# + * + * @param {string} sid - The SID of the eSIM Profile resource to fetch + * + * @returns {Twilio.Supersim.V1.EsimProfileContext} + */ + /* jshint ignore:end */ + EsimProfileListInstance.get = function get(sid) { + return new EsimProfileContext(this._version, sid); + }; + + /* jshint ignore:start */ + /** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.EsimProfileList# + * + * @returns Object + */ + /* jshint ignore:end */ + EsimProfileListInstance.toJSON = function toJSON() { + return this._solution; + }; + + EsimProfileListInstance[util.inspect.custom] = function inspect(depth, options) + { + return util.inspect(this.toJSON(), options); + }; + + return EsimProfileListInstance; +}; + + +/* jshint ignore:start */ +/** + * Initialize the EsimProfilePage + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Supersim.V1.EsimProfilePage + * + * @param {V1} version - Version of the resource + * @param {Response} response - Response from the API + * @param {EsimProfileSolution} solution - Path solution + * + * @returns EsimProfilePage + */ +/* jshint ignore:end */ +EsimProfilePage = function EsimProfilePage(version, response, solution) { + // Path Solution + this._solution = solution; + + Page.prototype.constructor.call(this, version, response, this._solution); +}; + +_.extend(EsimProfilePage.prototype, Page.prototype); +EsimProfilePage.prototype.constructor = EsimProfilePage; + +/* jshint ignore:start */ +/** + * Build an instance of EsimProfileInstance + * + * @function getInstance + * @memberof Twilio.Supersim.V1.EsimProfilePage# + * + * @param {EsimProfilePayload} payload - Payload response from the API + * + * @returns EsimProfileInstance + */ +/* jshint ignore:end */ +EsimProfilePage.prototype.getInstance = function getInstance(payload) { + return new EsimProfileInstance(this._version, payload); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.EsimProfilePage# + * + * @returns Object + */ +/* jshint ignore:end */ +EsimProfilePage.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +EsimProfilePage.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the EsimProfileContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Supersim.V1.EsimProfileInstance + * + * @property {string} sid - The unique string that identifies the resource + * @property {string} accountSid - + * The SID of the Account to which the eSIM Profile resource belongs + * @property {string} iccid - The ICCID associated with the Sim resource + * @property {string} simSid - + * The SID of the Sim resource that this eSIM Profile controls + * @property {esim_profile.status} status - The status of the eSIM Profile + * @property {string} eid - Identifier of the eUICC that can claim the eSIM Profile + * @property {string} smdpPlusAddress - + * Address of the SM-DP+ server from which the Profile will be downloaded + * @property {string} errorCode - + * Code indicating the failure if the download of the SIM Profile failed and the eSIM Profile is in `failed` state + * @property {string} errorMessage - + * Error message describing the failure if the download of the SIM Profile failed and the eSIM Profile is in `failed` state + * @property {Date} dateCreated - + * The ISO 8601 date and time in GMT when the resource was created + * @property {Date} dateUpdated - + * The ISO 8601 date and time in GMT when the resource was last updated + * @property {string} url - The absolute URL of the eSIM Profile resource + * + * @param {V1} version - Version of the resource + * @param {EsimProfilePayload} payload - The instance payload + * @param {sid_like} sid - The SID of the eSIM Profile resource to fetch + */ +/* jshint ignore:end */ +EsimProfileInstance = function EsimProfileInstance(version, payload, sid) { + this._version = version; + + // Marshaled Properties + this.sid = payload.sid; // jshint ignore:line + this.accountSid = payload.account_sid; // jshint ignore:line + this.iccid = payload.iccid; // jshint ignore:line + this.simSid = payload.sim_sid; // jshint ignore:line + this.status = payload.status; // jshint ignore:line + this.eid = payload.eid; // jshint ignore:line + this.smdpPlusAddress = payload.smdp_plus_address; // jshint ignore:line + this.errorCode = payload.error_code; // jshint ignore:line + this.errorMessage = payload.error_message; // jshint ignore:line + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line + this.url = payload.url; // jshint ignore:line + + // Context + this._context = undefined; + this._solution = {sid: sid || this.sid, }; +}; + +Object.defineProperty(EsimProfileInstance.prototype, + '_proxy', { + get: function() { + if (!this._context) { + this._context = new EsimProfileContext(this._version, this._solution.sid); + } + + return this._context; + } +}); + +/* jshint ignore:start */ +/** + * fetch a EsimProfileInstance + * + * @function fetch + * @memberof Twilio.Supersim.V1.EsimProfileInstance# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed EsimProfileInstance + */ +/* jshint ignore:end */ +EsimProfileInstance.prototype.fetch = function fetch(callback) { + return this._proxy.fetch(callback); +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.EsimProfileInstance# + * + * @returns Object + */ +/* jshint ignore:end */ +EsimProfileInstance.prototype.toJSON = function toJSON() { + let clone = {}; + _.forOwn(this, function(value, key) { + if (!_.startsWith(key, '_') && ! _.isFunction(value)) { + clone[key] = value; + } + }); + return clone; +}; + +EsimProfileInstance.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + + +/* jshint ignore:start */ +/** + * Initialize the EsimProfileContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @constructor Twilio.Supersim.V1.EsimProfileContext + * + * @param {V1} version - Version of the resource + * @param {sid_like} sid - The SID of the eSIM Profile resource to fetch + */ +/* jshint ignore:end */ +EsimProfileContext = function EsimProfileContext(version, sid) { + this._version = version; + + // Path Solution + this._solution = {sid: sid, }; + this._uri = `/ESimProfiles/${sid}`; +}; + +/* jshint ignore:start */ +/** + * fetch a EsimProfileInstance + * + * @function fetch + * @memberof Twilio.Supersim.V1.EsimProfileContext# + * + * @param {function} [callback] - Callback to handle processed record + * + * @returns {Promise} Resolves to processed EsimProfileInstance + */ +/* jshint ignore:end */ +EsimProfileContext.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 EsimProfileInstance(this._version, payload, this._solution.sid)); + }.bind(this)); + + promise.catch(function(error) { + deferred.reject(error); + }); + + if (_.isFunction(callback)) { + deferred.promise.nodeify(callback); + } + + return deferred.promise; +}; + +/* jshint ignore:start */ +/** + * Provide a user-friendly representation + * + * @function toJSON + * @memberof Twilio.Supersim.V1.EsimProfileContext# + * + * @returns Object + */ +/* jshint ignore:end */ +EsimProfileContext.prototype.toJSON = function toJSON() { + return this._solution; +}; + +EsimProfileContext.prototype[util.inspect.custom] = function inspect(depth, + options) { + return util.inspect(this.toJSON(), options); +}; + +module.exports = { + EsimProfileList: EsimProfileList, + EsimProfilePage: EsimProfilePage, + EsimProfileInstance: EsimProfileInstance, + EsimProfileContext: EsimProfileContext +}; diff --git a/lib/rest/verify/v2/service/accessToken.d.ts b/lib/rest/verify/v2/service/accessToken.d.ts index 36a0f4b8cd..29f270cb6c 100644 --- a/lib/rest/verify/v2/service/accessToken.d.ts +++ b/lib/rest/verify/v2/service/accessToken.d.ts @@ -19,11 +19,15 @@ type AccessTokenFactorTypes = 'push'; * Use them with caution. * * @param version - Version of the resource - * @param serviceSid - The unique string that identifies the resource + * @param serviceSid - Verify Service Sid. */ declare function AccessTokenList(version: V2, serviceSid: string): AccessTokenListInstance; interface AccessTokenListInstance { + /** + * @param sid - sid of instance + */ + (sid: string): AccessTokenContext; /** * create a AccessTokenInstance * @@ -31,6 +35,12 @@ interface AccessTokenListInstance { * @param callback - Callback to handle processed record */ create(opts: AccessTokenListInstanceCreateOptions, callback?: (error: Error | null, item: AccessTokenInstance) => any): Promise; + /** + * Constructs a access_token + * + * @param sid - A string that uniquely identifies this Access Token. + */ + get(sid: string): AccessTokenContext; /** * Provide a user-friendly representation */ @@ -54,7 +64,14 @@ interface AccessTokenPayload extends AccessTokenResource, Page.TwilioResponsePay } interface AccessTokenResource { + account_sid: string; + entity_identity: string; + factor_friendly_name: string; + factor_type: AccessTokenFactorTypes; + service_sid: string; + sid: string; token: string; + url: string; } interface AccessTokenSolution { @@ -62,6 +79,32 @@ interface AccessTokenSolution { } +declare class AccessTokenContext { + /** + * Initialize the AccessTokenContext + * + * PLEASE NOTE that this class contains beta products that are subject to change. + * Use them with caution. + * + * @param version - Version of the resource + * @param serviceSid - Service Sid. + * @param sid - A string that uniquely identifies this Access Token. + */ + constructor(version: V2, serviceSid: string, sid: string); + + /** + * fetch a AccessTokenInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: AccessTokenInstance) => any): Promise; + /** + * Provide a user-friendly representation + */ + toJSON(): any; +} + + declare class AccessTokenInstance extends SerializableClass { /** * Initialize the AccessTokenContext @@ -71,15 +114,30 @@ declare class AccessTokenInstance extends SerializableClass { * * @param version - Version of the resource * @param payload - The instance payload - * @param serviceSid - The unique string that identifies the resource + * @param serviceSid - Verify Service Sid. + * @param sid - A string that uniquely identifies this Access Token. */ - constructor(version: V2, payload: AccessTokenPayload, serviceSid: string); + constructor(version: V2, payload: AccessTokenPayload, serviceSid: string, sid: string); + private _proxy: AccessTokenContext; + accountSid: string; + entityIdentity: string; + factorFriendlyName: string; + factorType: AccessTokenFactorTypes; + /** + * fetch a AccessTokenInstance + * + * @param callback - Callback to handle processed record + */ + fetch(callback?: (error: Error | null, items: AccessTokenInstance) => any): Promise; + serviceSid: string; + sid: string; /** * Provide a user-friendly representation */ toJSON(): any; token: string; + url: string; } @@ -108,4 +166,4 @@ declare class AccessTokenPage extends Page done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences?CreatedAfter=2021-10-09T17%3A20%3A53Z&CreatedBefore=2021-10-12T18%3A37%3A53Z&PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences?CreatedAfter=2021-10-09T17%3A20%3A53Z&CreatedBefore=2021-10-12T18%3A37%3A53Z&PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'conferences' + }, + 'conferences': [ + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 1', + 'start_time': '2021-10-12T18:11:10Z', + 'create_time': '2021-10-12T18:11:09Z', + 'end_time': '2021-10-12T18:11:15Z', + 'duration_seconds': 7, + 'connect_duration_seconds': 5, + 'status': 'completed', + 'max_participants': 250, + 'max_concurrent_participants': 2, + 'unique_participants': 2, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'mixer_region': 'us1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 1, + 'region_configuration': 0, + 'participant_behavior': 0 + }, + 'tags': null, + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants' + } + }, + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 2', + 'start_time': null, + 'create_time': '2021-10-12T18:09:21Z', + 'end_time': '2021-10-12T18:09:21Z', + 'duration_seconds': 1, + 'connect_duration_seconds': 0, + 'status': 'completed', + 'max_participants': 250, + 'max_concurrent_participants': 2, + 'unique_participants': 3, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'mixer_region': 'us1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 1, + 'region_configuration': 0, + 'participant_behavior': 0 + }, + 'tags': [ + 'detected_silence', + 'participant_behavior_issues' + ], + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Participants' + } + } + ] + }; + holodeck.mock(new Response(200, body)); + client.insights.v1.conferences.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://insights.twilio.com/v1/Conferences', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences?CreatedAfter=2021-10-09T17%3A20%3A53Z&CreatedBefore=2021-10-12T18%3A37%3A53Z&PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences?CreatedAfter=2021-10-09T17%3A20%3A53Z&CreatedBefore=2021-10-12T18%3A37%3A53Z&PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'conferences' + }, + 'conferences': [ + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 1', + 'start_time': '2021-10-12T18:11:10Z', + 'create_time': '2021-10-12T18:11:09Z', + 'end_time': '2021-10-12T18:11:15Z', + 'duration_seconds': 7, + 'connect_duration_seconds': 5, + 'status': 'completed', + 'max_participants': 250, + 'max_concurrent_participants': 2, + 'unique_participants': 2, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'mixer_region': 'us1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 1, + 'region_configuration': 0, + 'participant_behavior': 0 + }, + 'tags': null, + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants' + } + }, + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 2', + 'start_time': null, + 'create_time': '2021-10-12T18:09:21Z', + 'end_time': '2021-10-12T18:09:21Z', + 'duration_seconds': 1, + 'connect_duration_seconds': 0, + 'status': 'completed', + 'max_participants': 250, + 'max_concurrent_participants': 2, + 'unique_participants': 3, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'mixer_region': 'us1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 1, + 'region_configuration': 0, + 'participant_behavior': 0 + }, + 'tags': [ + 'detected_silence', + 'participant_behavior_issues' + ], + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Participants' + } + } + ] + }; + holodeck.mock(new Response(200, body)); + client.insights.v1.conferences.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.insights.v1.conferences.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://insights.twilio.com/v1/Conferences'; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_full response', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences?CreatedAfter=2021-10-09T17%3A20%3A53Z&CreatedBefore=2021-10-12T18%3A37%3A53Z&PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences?CreatedAfter=2021-10-09T17%3A20%3A53Z&CreatedBefore=2021-10-12T18%3A37%3A53Z&PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'conferences' + }, + 'conferences': [ + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 1', + 'start_time': '2021-10-12T18:11:10Z', + 'create_time': '2021-10-12T18:11:09Z', + 'end_time': '2021-10-12T18:11:15Z', + 'duration_seconds': 7, + 'connect_duration_seconds': 5, + 'status': 'completed', + 'max_participants': 250, + 'max_concurrent_participants': 2, + 'unique_participants': 2, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'mixer_region': 'us1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 1, + 'region_configuration': 0, + 'participant_behavior': 0 + }, + 'tags': null, + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants' + } + }, + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 2', + 'start_time': null, + 'create_time': '2021-10-12T18:09:21Z', + 'end_time': '2021-10-12T18:09:21Z', + 'duration_seconds': 1, + 'connect_duration_seconds': 0, + 'status': 'completed', + 'max_participants': 250, + 'max_concurrent_participants': 2, + 'unique_participants': 3, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'mixer_region': 'us1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 1, + 'region_configuration': 0, + 'participant_behavior': 0 + }, + 'tags': [ + 'detected_silence', + 'participant_behavior_issues' + ], + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Participants' + } + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.insights.v1.conferences.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_with_region response', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences?MixerRegion=au1&Status=completed&PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences?MixerRegion=au1&Status=completed&PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'conferences' + }, + 'conferences': [ + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 1', + 'start_time': '2021-10-12T18:19:10Z', + 'create_time': '2021-10-12T18:19:09Z', + 'end_time': '2021-10-12T18:20:17Z', + 'duration_seconds': 7, + 'connect_duration_seconds': 5, + 'status': 'completed', + 'max_participants': 250, + 'max_concurrent_participants': 2, + 'unique_participants': 2, + 'end_reason': 'participant_with_end_conference_on_exit_kicked', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'mixer_region': 'au1', + 'mixer_region_requested': 'au1', + 'recording_enabled': true, + 'detected_issues': { + 'call_quality': 0, + 'region_configuration': 2, + 'participant_behavior': 0 + }, + 'tags': [ + 'region_configuration_issues' + ], + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants' + } + }, + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 2', + 'start_time': '2021-10-12T18:16:53Z', + 'create_time': '2021-10-12T18:16:51Z', + 'end_time': '2021-10-12T18:17:20Z', + 'duration_seconds': 30, + 'connect_duration_seconds': 27, + 'status': 'completed', + 'max_participants': 250, + 'max_concurrent_participants': 2, + 'unique_participants': 2, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'mixer_region': 'au1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 0, + 'region_configuration': 2, + 'participant_behavior': 3 + }, + 'tags': [ + 'detected_silence', + 'region_configuration_issues', + 'participant_behavior_issues' + ], + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab/Participants' + } + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.insights.v1.conferences.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_with_friendlyname_startfailure response', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences?FriendlyName=outboundConfCallTransferThrice_1&Status=not_started&PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences?FriendlyName=outboundConfCallTransferThrice_1&Status=not_started&PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'conferences' + }, + 'conferences': [ + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'outboundConfCallTransferThrice_1', + 'start_time': null, + 'create_time': '2021-11-18T00:09:09Z', + 'end_time': '2021-11-18T00:09:52Z', + 'duration_seconds': 7, + 'connect_duration_seconds': 0, + 'status': 'not_started', + 'max_participants': 250, + 'max_concurrent_participants': 1, + 'unique_participants': 1, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'mixer_region': null, + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 0, + 'region_configuration': 0, + 'participant_behavior': 0 + }, + 'tags': [ + 'participant_behavior_issues', + 'start_failure' + ], + 'tag_info': { + 'start_failure': { + 'reason': 'no_concurrent_participants' + } + }, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants' + } + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.insights.v1.conferences.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_with_duplicate_identity response', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences?Tags=duplicate_identity&PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences?Tags=duplicate_identity&PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'conferences' + }, + 'conferences': [ + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 1', + 'start_time': '2021-11-17T16:21:45Z', + 'create_time': '2021-11-17T16:21:40Z', + 'end_time': '2021-11-17T16:22:11Z', + 'duration_seconds': 32, + 'connect_duration_seconds': 27, + 'status': 'not_started', + 'max_participants': 250, + 'max_concurrent_participants': 3, + 'unique_participants': 4, + 'end_reason': 'last_participant_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'mixer_region': 'us1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 0, + 'region_configuration': 0, + 'participant_behavior': 0 + }, + 'tags': [ + 'duplicate_identity', + 'detected_silence', + 'participant_behavior_issues' + ], + 'tag_info': { + 'duplicate_identity': [ + { + 'participant_identity': 'client:+10000000000', + 'participant_sids': [ + 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab' + ] + } + ] + }, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants' + } + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.insights.v1.conferences.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_with_detected_issue_endreason response', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences?DetectedIssues=call_quality&EndReason=participant_with_end_conference_on_exit_left&PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences?DetectedIssues=call_quality&EndReason=participant_with_end_conference_on_exit_left&PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'conferences' + }, + 'conferences': [ + { + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'friendly_name': 'conference 1', + 'start_time': '2021-11-17T16:21:45Z', + 'create_time': '2021-11-17T16:21:40Z', + 'end_time': '2021-11-17T16:22:11Z', + 'duration_seconds': 32, + 'connect_duration_seconds': 27, + 'status': 'not_started', + 'max_participants': 250, + 'max_concurrent_participants': 3, + 'unique_participants': 3, + 'end_reason': 'participant_with_end_conference_on_exit_left', + 'ended_by': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'mixer_region': 'us1', + 'mixer_region_requested': null, + 'recording_enabled': false, + 'detected_issues': { + 'call_quality': 3, + 'region_configuration': 0, + 'participant_behavior': 1 + }, + 'tags': [ + 'high_packet_loss', + 'low_mos', + 'participant_behavior_issues', + 'quality_warnings', + 'high_jitter', + 'detected_silence' + ], + 'tag_info': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'links': { + 'conference_participants': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants' + } + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.insights.v1.conferences.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/insights/v1/conference/conferenceParticipant.spec.js b/spec/integration/rest/insights/v1/conference/conferenceParticipant.spec.js new file mode 100644 index 0000000000..88002f7293 --- /dev/null +++ b/spec/integration/rest/insights/v1/conference/conferenceParticipant.spec.js @@ -0,0 +1,937 @@ +'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('ConferenceParticipant', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferenceParticipants('CPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var conferenceSid = 'CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var participantSid = 'CPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://insights.twilio.com/v1/Conferences/${conferenceSid}/Participants/${participantSid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+1000000001', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:59Z', + 'leave_time': '2021-10-08T03:00:02Z', + 'duration_seconds': 64, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 965, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': true, + 'end_conference_on_exit': false, + 'play_early_media': true, + 'enter_muted': false, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 49, + 'packet_loss_percentage': 0.0, + 'jitter': { + 'avg': 0.34, + 'max': 0.53 + }, + 'latency': { + 'avg': 0.0, + 'max': 0.0 + }, + 'mos': 4.4 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 126, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.01, + 'max': 0.01 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferenceParticipants('CPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should treat the first each arg as a callback', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'participants' + }, + 'participants': [ + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000001', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:51Z', + 'leave_time': '2021-10-08T02:59:55Z', + 'duration_seconds': 65, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 3361, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': true, + 'end_conference_on_exit': false, + 'play_early_media': true, + 'enter_muted': false, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 70, + 'packet_loss_percentage': 0.0, + 'jitter': { + 'avg': 0.41, + 'max': 0.84 + }, + 'latency': { + 'avg': 0.0, + 'max': 0.0 + }, + 'mos': 4.4 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 126, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.01, + 'max': 0.01 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }, + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000002', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:52Z', + 'leave_time': '2021-10-08T02:59:54Z', + 'duration_seconds': 63, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 321, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': false, + 'end_conference_on_exit': false, + 'early_media': false, + 'enter_muted': true, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 16, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.26, + 'max': 0.45 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 42, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.03, + 'max': 0.08 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'tags': [ + 'silent' + ], + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': { + 'mute': [ + 1636007397844 + ] + }, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab' + } + ] + }; + holodeck.mock(new Response(200, body)); + client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferenceParticipants.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'participants' + }, + 'participants': [ + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000001', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:51Z', + 'leave_time': '2021-10-08T02:59:55Z', + 'duration_seconds': 65, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 3361, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': true, + 'end_conference_on_exit': false, + 'play_early_media': true, + 'enter_muted': false, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 70, + 'packet_loss_percentage': 0.0, + 'jitter': { + 'avg': 0.41, + 'max': 0.84 + }, + 'latency': { + 'avg': 0.0, + 'max': 0.0 + }, + 'mos': 4.4 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 126, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.01, + 'max': 0.01 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }, + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000002', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:52Z', + 'leave_time': '2021-10-08T02:59:54Z', + 'duration_seconds': 63, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 321, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': false, + 'end_conference_on_exit': false, + 'early_media': false, + 'enter_muted': true, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 16, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.26, + 'max': 0.45 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 42, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.03, + 'max': 0.08 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'tags': [ + 'silent' + ], + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': { + 'mute': [ + 1636007397844 + ] + }, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab' + } + ] + }; + holodeck.mock(new Response(200, body)); + client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferenceParticipants.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://insights.twilio.com/v1/Conferences/${conferenceSid}/Participants', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'participants' + }, + 'participants': [ + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000001', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:51Z', + 'leave_time': '2021-10-08T02:59:55Z', + 'duration_seconds': 65, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 3361, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': true, + 'end_conference_on_exit': false, + 'play_early_media': true, + 'enter_muted': false, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 70, + 'packet_loss_percentage': 0.0, + 'jitter': { + 'avg': 0.41, + 'max': 0.84 + }, + 'latency': { + 'avg': 0.0, + 'max': 0.0 + }, + 'mos': 4.4 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 126, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.01, + 'max': 0.01 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }, + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000002', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:52Z', + 'leave_time': '2021-10-08T02:59:54Z', + 'duration_seconds': 63, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 321, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': false, + 'end_conference_on_exit': false, + 'early_media': false, + 'enter_muted': true, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 16, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.26, + 'max': 0.45 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 42, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.03, + 'max': 0.08 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'tags': [ + 'silent' + ], + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': { + 'mute': [ + 1636007397844 + ] + }, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab' + } + ] + }; + holodeck.mock(new Response(200, body)); + client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferenceParticipants.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferenceParticipants.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var conferenceSid = 'CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://insights.twilio.com/v1/Conferences/${conferenceSid}/Participants`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_full response', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'participants' + }, + 'participants': [ + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000001', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:51Z', + 'leave_time': '2021-10-08T02:59:55Z', + 'duration_seconds': 65, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 3361, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': true, + 'end_conference_on_exit': false, + 'play_early_media': true, + 'enter_muted': false, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 70, + 'packet_loss_percentage': 0.0, + 'jitter': { + 'avg': 0.41, + 'max': 0.84 + }, + 'latency': { + 'avg': 0.0, + 'max': 0.0 + }, + 'mos': 4.4 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 126, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.01, + 'max': 0.01 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }, + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'label': null, + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000002', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:52Z', + 'leave_time': '2021-10-08T02:59:54Z', + 'duration_seconds': 63, + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 321, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': false, + 'end_conference_on_exit': false, + 'early_media': false, + 'enter_muted': true, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 16, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.26, + 'max': 0.45 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 42, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.03, + 'max': 0.08 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4, + 'tags': [ + 'silent' + ], + 'last_rtp_count': 1, + 'unique_ssrc_count': 1 + } + }, + 'events': { + 'mute': [ + 1636007397844 + ] + }, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab' + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferenceParticipants.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_with_label response', + function(done) { + var body = { + 'meta': { + 'page': 0, + 'page_size': 25, + 'first_page_url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?Label=client&PageSize=25&Page=0', + 'previous_page_url': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?Label=client&PageSize=25&Page=0', + 'next_page_url': null, + 'key': 'participants' + }, + 'participants': [ + { + 'participant_sid': 'CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'conference_sid': 'CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_sid': 'CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'call_direction': 'outbound', + 'from': '+10000000000', + 'to': '+10000000001', + 'call_state': 'completed', + 'country_code': 'US', + 'is_moderator': true, + 'join_time': '2021-10-08T02:58:51Z', + 'leave_time': '2021-10-08T02:59:55Z', + 'duration_seconds': 65, + 'label': 'client', + 'whisper': null, + 'agent_audio': null, + 'outbound_queue_length': 0, + 'outbound_time_in_queue': 3361, + 'jitter_buffer_size': null, + 'is_coach': false, + 'coached_participants': null, + 'participant_region': 'us1', + 'conference_region': 'us1', + 'call_type': 'carrier', + 'quality_issues': 0, + 'properties': { + 'start_conference_on_enter': true, + 'end_conference_on_exit': false, + 'play_early_media': true, + 'enter_muted': false, + 'beep_on_enter': false, + 'beep_on_exit': false + }, + 'metrics': { + 'inbound': { + 'total_packets_lost': 0, + 'total_packets_received': 70, + 'packet_loss_percentage': 0.0, + 'jitter': { + 'avg': 0.41, + 'max': 0.84 + }, + 'latency': { + 'avg': 0.0, + 'max': 0.0 + }, + 'mos': 4.4 + }, + 'outbound': { + 'total_packets_lost': 0, + 'total_packets_received': 96, + 'packet_loss_percentage': 0, + 'jitter': { + 'avg': 0.01, + 'max': 0.01 + }, + 'latency': { + 'avg': 0, + 'max': 0 + }, + 'mos': 4.4 + } + }, + 'events': null, + 'url': 'https://insights.twilio.com/v1/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ] + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.insights.v1.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .conferenceParticipants.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/messaging/v1/brandRegistration.spec.js b/spec/integration/rest/messaging/v1/brandRegistration.spec.js index ac7d6c27a8..3b5f63c924 100644 --- a/spec/integration/rest/messaging/v1/brandRegistration.spec.js +++ b/spec/integration/rest/messaging/v1/brandRegistration.spec.js @@ -71,6 +71,7 @@ describe('BrandRegistration', function() { ], 'identity_status': 'VERIFIED', 'russell_3000': true, + 'government_entity': false, 'tax_exempt_status': '501c3', 'skip_automatic_sec_vet': false, 'mock': false, @@ -123,6 +124,7 @@ describe('BrandRegistration', function() { 'identity_status': 'VERIFIED', 'russell_3000': true, 'tax_exempt_status': '501c3', + 'government_entity': false, 'skip_automatic_sec_vet': false, 'mock': false, 'links': { @@ -168,6 +170,7 @@ describe('BrandRegistration', function() { 'identity_status': 'VERIFIED', 'russell_3000': true, 'tax_exempt_status': '501c3', + 'government_entity': false, 'skip_automatic_sec_vet': false, 'mock': false, 'links': { @@ -218,6 +221,7 @@ describe('BrandRegistration', function() { 'identity_status': 'VERIFIED', 'russell_3000': true, 'tax_exempt_status': '501c3', + 'government_entity': false, 'skip_automatic_sec_vet': false, 'mock': false, 'links': { @@ -283,6 +287,7 @@ describe('BrandRegistration', function() { 'identity_status': 'VERIFIED', 'russell_3000': true, 'tax_exempt_status': '501c3', + 'government_entity': false, 'skip_automatic_sec_vet': false, 'mock': false, 'links': { @@ -353,6 +358,7 @@ describe('BrandRegistration', function() { ], 'identity_status': 'VERIFIED', 'russell_3000': true, + 'government_entity': false, 'tax_exempt_status': '501c3', 'skip_automatic_sec_vet': false, 'mock': false, @@ -418,6 +424,7 @@ describe('BrandRegistration', function() { ], 'identity_status': 'VERIFIED', 'russell_3000': false, + 'government_entity': false, 'tax_exempt_status': '501c3', 'skip_automatic_sec_vet': false, 'mock': false, diff --git a/spec/integration/rest/supersim/v1/esimProfile.spec.js b/spec/integration/rest/supersim/v1/esimProfile.spec.js new file mode 100644 index 0000000000..9015f44ae1 --- /dev/null +++ b/spec/integration/rest/supersim/v1/esimProfile.spec.js @@ -0,0 +1,450 @@ +'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('EsimProfile', function() { + beforeEach(function() { + holodeck = new Holodeck(); + client = new Twilio('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'AUTHTOKEN', { + httpClient: holodeck + }); + }); + it('should generate valid create request', + function(done) { + holodeck.mock(new Response(500, {})); + + var opts = {eid: 'eid'}; + var promise = client.supersim.v1.esimProfiles.create(opts); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://supersim.twilio.com/v1/ESimProfiles'; + + var values = {Eid: 'eid', }; + holodeck.assertHasRequest(new Request({ + method: 'POST', + url: url, + data: values + })); + } + ); + it('should generate valid create_default_smdp response', + function(done) { + var body = { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': null, + 'sim_sid': null, + 'status': 'reserving', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': null, + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {eid: 'eid'}; + var promise = client.supersim.v1.esimProfiles.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid create_with_callback response', + function(done) { + var body = { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': null, + 'sim_sid': null, + 'status': 'reserving', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': null, + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(201, body)); + + var opts = {eid: 'eid'}; + var promise = client.supersim.v1.esimProfiles.create(opts); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.supersim.v1.esimProfiles('HPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var sid = 'HPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://supersim.twilio.com/v1/ESimProfiles/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': '8988307aaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'available', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': 'https://sm-dp-plus.twilio.com', + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.esimProfiles('HPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should treat the first each arg as a callback', + function(done) { + var body = { + 'esim_profiles': [ + { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': '8988307aaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'available', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': 'https://sm-dp-plus.twilio.com', + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'first_page_url': 'https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0', + 'key': 'esim_profiles', + 'next_page_url': null, + 'page': 0, + 'page_size': 50, + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.esimProfiles.each(() => done()); + } + ); + it('should treat the second arg as a callback', + function(done) { + var body = { + 'esim_profiles': [ + { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': '8988307aaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'available', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': 'https://sm-dp-plus.twilio.com', + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'first_page_url': 'https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0', + 'key': 'esim_profiles', + 'next_page_url': null, + 'page': 0, + 'page_size': 50, + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.esimProfiles.each({pageSize: 20}, () => done()); + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: 'https://supersim.twilio.com/v1/ESimProfiles', + params: {PageSize: 20}, + })); + } + ); + it('should find the callback in the opts object', + function(done) { + var body = { + 'esim_profiles': [ + { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': '8988307aaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'available', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': 'https://sm-dp-plus.twilio.com', + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'first_page_url': 'https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0', + 'key': 'esim_profiles', + 'next_page_url': null, + 'page': 0, + 'page_size': 50, + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0' + } + }; + holodeck.mock(new Response(200, body)); + client.supersim.v1.esimProfiles.each({callback: () => done()}, () => fail('wrong callback!')); + } + ); + it('should generate valid list request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.supersim.v1.esimProfiles.list(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var url = 'https://supersim.twilio.com/v1/ESimProfiles'; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid read_all response', + function(done) { + var body = { + 'esim_profiles': [ + { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': '8988307aaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'available', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': 'https://sm-dp-plus.twilio.com', + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'first_page_url': 'https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0', + 'key': 'esim_profiles', + 'next_page_url': null, + 'page': 0, + 'page_size': 50, + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/ESimProfiles?PageSize=50&Page=0' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.esimProfiles.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_by_eid response', + function(done) { + var body = { + 'esim_profiles': [ + { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': '8988307aaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'available', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': 'https://sm-dp-plus.twilio.com', + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'first_page_url': 'https://supersim.twilio.com/v1/ESimProfiles?Eid=89049032005008882600033489aaaaaa&PageSize=50&Page=0', + 'key': 'esim_profiles', + 'next_page_url': null, + 'page': 0, + 'page_size': 50, + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/ESimProfiles?Eid=89049032005008882600033489aaaaaa&PageSize=50&Page=0' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.esimProfiles.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_by_sim_sid response', + function(done) { + var body = { + 'esim_profiles': [ + { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': '8988307aaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'available', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': 'https://sm-dp-plus.twilio.com', + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'first_page_url': 'https://supersim.twilio.com/v1/ESimProfiles?SimSid=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0', + 'key': 'esim_profiles', + 'next_page_url': null, + 'page': 0, + 'page_size': 50, + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/ESimProfiles?SimSid=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.esimProfiles.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); + it('should generate valid read_by_status response', + function(done) { + var body = { + 'esim_profiles': [ + { + 'sid': 'HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'iccid': '8988307aaaaaaaaaaaaa', + 'sim_sid': 'HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'status': 'downloaded', + 'eid': '89049032005008882600033489aaaaaa', + 'smdp_plus_address': 'https://sm-dp-plus.twilio.com', + 'error_code': null, + 'error_message': null, + 'date_created': '2020-09-01T20:00:00Z', + 'date_updated': '2020-09-01T20:00:00Z', + 'url': 'https://supersim.twilio.com/v1/ESimProfiles/HPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + } + ], + 'meta': { + 'first_page_url': 'https://supersim.twilio.com/v1/ESimProfiles?Status=downloaded&PageSize=50&Page=0', + 'key': 'esim_profiles', + 'next_page_url': null, + 'page': 0, + 'page_size': 50, + 'previous_page_url': null, + 'url': 'https://supersim.twilio.com/v1/ESimProfiles?Status=downloaded&PageSize=50&Page=0' + } + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.supersim.v1.esimProfiles.list(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); +}); diff --git a/spec/integration/rest/verify/v2/service/accessToken.spec.js b/spec/integration/rest/verify/v2/service/accessToken.spec.js index 8ef55055a8..08597600cf 100644 --- a/spec/integration/rest/verify/v2/service/accessToken.spec.js +++ b/spec/integration/rest/verify/v2/service/accessToken.spec.js @@ -57,7 +57,14 @@ describe('AccessToken', function() { it('should generate valid create response', function(done) { var body = { - 'token': 'eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ' + 'sid': 'YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_type': 'push', + 'factor_friendly_name': 'John Doe iPhone', + 'token': 'eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }; holodeck.mock(new Response(201, body)); @@ -73,4 +80,52 @@ describe('AccessToken', function() { }).done(); } ); + it('should generate valid fetch request', + function(done) { + holodeck.mock(new Response(500, {})); + + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .accessTokens('YKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function() { + throw new Error('failed'); + }, function(error) { + expect(error.constructor).toBe(RestException.prototype.constructor); + done(); + }).done(); + + var serviceSid = 'VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var sid = 'YKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; + var url = `https://verify.twilio.com/v2/Services/${serviceSid}/AccessTokens/${sid}`; + + holodeck.assertHasRequest(new Request({ + method: 'GET', + url: url + })); + } + ); + it('should generate valid fetch response', + function(done) { + var body = { + 'sid': 'YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'service_sid': 'VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'entity_identity': 'ff483d1ff591898a9942916050d2ca3f', + 'factor_type': 'push', + 'factor_friendly_name': 'John Doe iPhone', + 'token': 'eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ', + 'url': 'https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + }; + + holodeck.mock(new Response(200, body)); + + var promise = client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') + .accessTokens('YKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch(); + promise.then(function(response) { + expect(response).toBeDefined(); + done(); + }, function() { + throw new Error('failed'); + }).done(); + } + ); });