diff --git a/CHANGES.md b/CHANGES.md index b89e7a41ca..1a233409db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,38 @@ twilio-node changelog ===================== +[2023-01-25] Version 4.0.0 +-------------------------- +**Note:** This release contains breaking changes, check our [upgrade guide](./UPGRADE.md###-2023-01-25-3xx-to-4xx) for detailed migration notes. + +**Library - Fix** +- [PR #902](https://github.com/twilio/twilio-node/pull/902): remove Flex shortcuts for removed APIs. Thanks to [@childish-sambino](https://github.com/childish-sambino)! +- [PR #897](https://github.com/twilio/twilio-node/pull/897): use break() for method names rather than break_(). Thanks to [@mattcole19](https://github.com/mattcole19)! + +**Library - Docs** +- [PR #901](https://github.com/twilio/twilio-node/pull/901): update README link to exceptions example for 4.x release. Thanks to [@stern-shawn](https://github.com/stern-shawn)! +- [PR #899](https://github.com/twilio/twilio-node/pull/899): use long property descriptions if available. Thanks to [@childish-sambino](https://github.com/childish-sambino)! +- [PR #895](https://github.com/twilio/twilio-node/pull/895): add relevant Refer/Say/ssml links to upgrade guide; formatting. Thanks to [@stern-shawn](https://github.com/stern-shawn)! + +**Library - Chore** +- [PR #888](https://github.com/twilio/twilio-node/pull/888): re-add test:typescript to test rule. Thanks to [@beebzz](https://github.com/beebzz)! + +**Library - Feature** +- [PR #883](https://github.com/twilio/twilio-node/pull/883): Merge branch '4.0.0-rc' to main. Thanks to [@childish-sambino](https://github.com/childish-sambino)! **(breaking change)** + +**Api** +- Add `public_application_connect_enabled` param to Application resource + +**Messaging** +- Add new tollfree verification API property (ExternalReferenceId)] + +**Verify** +- Add `device_ip` parameter and channel `auto` for sna/sms orchestration + +**Twiml** +- Add support for `` noun and `` noun, nested `` to `` and `` verb + + [2023-01-11] Version 3.84.1 --------------------------- **Library - Test** diff --git a/lib/rest/api/v2010/account/application.ts b/lib/rest/api/v2010/account/application.ts index cc59a06816..52290d2e0f 100644 --- a/lib/rest/api/v2010/account/application.ts +++ b/lib/rest/api/v2010/account/application.ts @@ -54,6 +54,8 @@ export interface ApplicationContextUpdateOptions { smsStatusCallback?: string; /** The URL we should call using a POST method to send message status information to your application. */ messageStatusCallback?: string; + /** Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`. */ + publicApplicationConnectEnabled?: boolean; } /** @@ -90,6 +92,8 @@ export interface ApplicationListInstanceCreateOptions { messageStatusCallback?: string; /** A descriptive string that you create to describe the new application. It can be up to 64 characters long. */ friendlyName?: string; + /** Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`. */ + publicApplicationConnectEnabled?: boolean; } /** * Options to pass to each @@ -297,6 +301,10 @@ export class ApplicationContextImpl implements ApplicationContext { data["SmsStatusCallback"] = params["smsStatusCallback"]; if (params["messageStatusCallback"] !== undefined) data["MessageStatusCallback"] = params["messageStatusCallback"]; + if (params["publicApplicationConnectEnabled"] !== undefined) + data["PublicApplicationConnectEnabled"] = serialize.bool( + params["publicApplicationConnectEnabled"] + ); const headers: any = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; @@ -402,6 +410,7 @@ interface ApplicationResource { voice_fallback_url: string; voice_method: ApplicationVoiceMethod; voice_url: string; + public_application_connect_enabled: boolean; } export class ApplicationInstance { @@ -434,6 +443,8 @@ export class ApplicationInstance { this.voiceFallbackUrl = payload.voice_fallback_url; this.voiceMethod = payload.voice_method; this.voiceUrl = payload.voice_url; + this.publicApplicationConnectEnabled = + payload.public_application_connect_enabled; this._solution = { accountSid, sid: sid || this.sid }; } @@ -518,6 +529,10 @@ export class ApplicationInstance { * The URL we call when the phone number assigned to this application receives a call. */ voiceUrl: string; + /** + * Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`. + */ + publicApplicationConnectEnabled: boolean; private get _proxy(): ApplicationContext { this._context = @@ -613,6 +628,7 @@ export class ApplicationInstance { voiceFallbackUrl: this.voiceFallbackUrl, voiceMethod: this.voiceMethod, voiceUrl: this.voiceUrl, + publicApplicationConnectEnabled: this.publicApplicationConnectEnabled, }; } @@ -795,6 +811,10 @@ export function ApplicationListInstance( data["MessageStatusCallback"] = params["messageStatusCallback"]; if (params["friendlyName"] !== undefined) data["FriendlyName"] = params["friendlyName"]; + if (params["publicApplicationConnectEnabled"] !== undefined) + data["PublicApplicationConnectEnabled"] = serialize.bool( + params["publicApplicationConnectEnabled"] + ); const headers: any = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; diff --git a/lib/rest/api/v2010/account/call/userDefinedMessageSubscription.ts b/lib/rest/api/v2010/account/call/userDefinedMessageSubscription.ts index 9b49d6daa2..eb58a2d2cc 100644 --- a/lib/rest/api/v2010/account/call/userDefinedMessageSubscription.ts +++ b/lib/rest/api/v2010/account/call/userDefinedMessageSubscription.ts @@ -26,7 +26,7 @@ export interface UserDefinedMessageSubscriptionListInstanceCreateOptions { callback: string; /** A unique string value to identify API call. This should be a unique string value per API call and can be a randomly generated. */ idempotencyKey?: string; - /** The HTTP method Twilio will use when requesting the above `Url`. Either `GET` or `POST`. */ + /** The HTTP method Twilio will use when requesting the above `Url`. Either `GET` or `POST`. Default is `POST`. */ method?: string; } diff --git a/lib/rest/flexApi/V1.ts b/lib/rest/flexApi/V1.ts index 73dd81a0ed..352e7b1bb7 100644 --- a/lib/rest/flexApi/V1.ts +++ b/lib/rest/flexApi/V1.ts @@ -18,9 +18,13 @@ import { AssessmentsListInstance } from "./v1/assessments"; import { ChannelListInstance } from "./v1/channel"; import { ConfigurationListInstance } from "./v1/configuration"; import { FlexFlowListInstance } from "./v1/flexFlow"; -import { GoodDataListInstance } from "./v1/goodData"; +import { InsightsQuestionnairesCategoryListInstance } from "./v1/insightsQuestionnairesCategory"; +import { InsightsQuestionnairesQuestionListInstance } from "./v1/insightsQuestionnairesQuestion"; +import { InsightsSessionListInstance } from "./v1/insightsSession"; +import { InsightsSettingsAnswerSetsListInstance } from "./v1/insightsSettingsAnswerSets"; +import { InsightsSettingsCommentListInstance } from "./v1/insightsSettingsComment"; +import { InsightsUserRolesListInstance } from "./v1/insightsUserRoles"; import { InteractionListInstance } from "./v1/interaction"; -import { UserRolesListInstance } from "./v1/userRoles"; import { WebChannelListInstance } from "./v1/webChannel"; export default class V1 extends Version { @@ -41,12 +45,20 @@ export default class V1 extends Version { protected _configuration?: ConfigurationListInstance; /** flexFlow - { Twilio.FlexApi.V1.FlexFlowListInstance } resource */ protected _flexFlow?: FlexFlowListInstance; - /** goodData - { Twilio.FlexApi.V1.GoodDataListInstance } resource */ - protected _goodData?: GoodDataListInstance; + /** insightsQuestionnairesCategory - { Twilio.FlexApi.V1.InsightsQuestionnairesCategoryListInstance } resource */ + protected _insightsQuestionnairesCategory?: InsightsQuestionnairesCategoryListInstance; + /** insightsQuestionnairesQuestion - { Twilio.FlexApi.V1.InsightsQuestionnairesQuestionListInstance } resource */ + protected _insightsQuestionnairesQuestion?: InsightsQuestionnairesQuestionListInstance; + /** insightsSession - { Twilio.FlexApi.V1.InsightsSessionListInstance } resource */ + protected _insightsSession?: InsightsSessionListInstance; + /** insightsSettingsAnswerSets - { Twilio.FlexApi.V1.InsightsSettingsAnswerSetsListInstance } resource */ + protected _insightsSettingsAnswerSets?: InsightsSettingsAnswerSetsListInstance; + /** insightsSettingsComment - { Twilio.FlexApi.V1.InsightsSettingsCommentListInstance } resource */ + protected _insightsSettingsComment?: InsightsSettingsCommentListInstance; + /** insightsUserRoles - { Twilio.FlexApi.V1.InsightsUserRolesListInstance } resource */ + protected _insightsUserRoles?: InsightsUserRolesListInstance; /** interaction - { Twilio.FlexApi.V1.InteractionListInstance } resource */ protected _interaction?: InteractionListInstance; - /** userRoles - { Twilio.FlexApi.V1.UserRolesListInstance } resource */ - protected _userRoles?: UserRolesListInstance; /** webChannel - { Twilio.FlexApi.V1.WebChannelListInstance } resource */ protected _webChannel?: WebChannelListInstance; @@ -75,10 +87,50 @@ export default class V1 extends Version { return this._flexFlow; } - /** Getter for goodData resource */ - get goodData(): GoodDataListInstance { - this._goodData = this._goodData || GoodDataListInstance(this); - return this._goodData; + /** Getter for insightsQuestionnairesCategory resource */ + get insightsQuestionnairesCategory(): InsightsQuestionnairesCategoryListInstance { + this._insightsQuestionnairesCategory = + this._insightsQuestionnairesCategory || + InsightsQuestionnairesCategoryListInstance(this); + return this._insightsQuestionnairesCategory; + } + + /** Getter for insightsQuestionnairesQuestion resource */ + get insightsQuestionnairesQuestion(): InsightsQuestionnairesQuestionListInstance { + this._insightsQuestionnairesQuestion = + this._insightsQuestionnairesQuestion || + InsightsQuestionnairesQuestionListInstance(this); + return this._insightsQuestionnairesQuestion; + } + + /** Getter for insightsSession resource */ + get insightsSession(): InsightsSessionListInstance { + this._insightsSession = + this._insightsSession || InsightsSessionListInstance(this); + return this._insightsSession; + } + + /** Getter for insightsSettingsAnswerSets resource */ + get insightsSettingsAnswerSets(): InsightsSettingsAnswerSetsListInstance { + this._insightsSettingsAnswerSets = + this._insightsSettingsAnswerSets || + InsightsSettingsAnswerSetsListInstance(this); + return this._insightsSettingsAnswerSets; + } + + /** Getter for insightsSettingsComment resource */ + get insightsSettingsComment(): InsightsSettingsCommentListInstance { + this._insightsSettingsComment = + this._insightsSettingsComment || + InsightsSettingsCommentListInstance(this); + return this._insightsSettingsComment; + } + + /** Getter for insightsUserRoles resource */ + get insightsUserRoles(): InsightsUserRolesListInstance { + this._insightsUserRoles = + this._insightsUserRoles || InsightsUserRolesListInstance(this); + return this._insightsUserRoles; } /** Getter for interaction resource */ @@ -87,12 +139,6 @@ export default class V1 extends Version { return this._interaction; } - /** Getter for userRoles resource */ - get userRoles(): UserRolesListInstance { - this._userRoles = this._userRoles || UserRolesListInstance(this); - return this._userRoles; - } - /** Getter for webChannel resource */ get webChannel(): WebChannelListInstance { this._webChannel = this._webChannel || WebChannelListInstance(this); diff --git a/lib/rest/flexApi/v1/insightsQuestionnairesCategory.ts b/lib/rest/flexApi/v1/insightsQuestionnairesCategory.ts new file mode 100644 index 0000000000..6a053cd5bb --- /dev/null +++ b/lib/rest/flexApi/v1/insightsQuestionnairesCategory.ts @@ -0,0 +1,441 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Flex + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { inspect, InspectOptions } from "util"; +import V1 from "../V1"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +/** + * Options to pass to remove a InsightsQuestionnairesCategoryInstance + */ +export interface InsightsQuestionnairesCategoryContextRemoveOptions { + /** The Token HTTP request header */ + token?: string; +} + +/** + * Options to pass to update a InsightsQuestionnairesCategoryInstance + */ +export interface InsightsQuestionnairesCategoryContextUpdateOptions { + /** The name of this category. */ + name: string; + /** The Token HTTP request header */ + token?: string; +} + +/** + * Options to pass to create a InsightsQuestionnairesCategoryInstance + */ +export interface InsightsQuestionnairesCategoryListInstanceCreateOptions { + /** The name of this category. */ + name: string; + /** The Token HTTP request header */ + token?: string; +} + +export interface InsightsQuestionnairesCategoryContext { + /** + * Remove a InsightsQuestionnairesCategoryInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + /** + * Remove a InsightsQuestionnairesCategoryInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesCategoryInstance + */ + remove( + params: InsightsQuestionnairesCategoryContextRemoveOptions, + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + + /** + * Update a InsightsQuestionnairesCategoryInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesCategoryInstance + */ + update( + params: InsightsQuestionnairesCategoryContextUpdateOptions, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesCategoryInstance + ) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface InsightsQuestionnairesCategoryContextSolution { + categoryId: string; +} + +export class InsightsQuestionnairesCategoryContextImpl + implements InsightsQuestionnairesCategoryContext +{ + protected _solution: InsightsQuestionnairesCategoryContextSolution; + protected _uri: string; + + constructor(protected _version: V1, categoryId: string) { + if (!isValidPathParam(categoryId)) { + throw new Error("Parameter 'categoryId' is not valid."); + } + + this._solution = { categoryId }; + this._uri = `/Insights/QM/Categories/${categoryId}`; + } + + remove( + params?: + | InsightsQuestionnairesCategoryContextRemoveOptions + | ((error: Error | null, item?: boolean) => any), + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + const headers: any = {}; + if (params["token"] !== undefined) headers["Token"] = params["token"]; + + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.remove({ + uri: instance._uri, + method: "delete", + params: data, + headers, + }); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + + update( + params: InsightsQuestionnairesCategoryContextUpdateOptions, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesCategoryInstance + ) => any + ): Promise { + if (params === null || params === undefined) { + throw new Error('Required parameter "params" missing.'); + } + + if (params["name"] === null || params["name"] === undefined) { + throw new Error("Required parameter \"params['name']\" missing."); + } + + let data: any = {}; + + data["Name"] = params["name"]; + + const headers: any = {}; + headers["Content-Type"] = "application/x-www-form-urlencoded"; + if (params["token"] !== undefined) headers["Token"] = params["token"]; + + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.update({ + uri: instance._uri, + method: "post", + data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new InsightsQuestionnairesCategoryInstance( + operationVersion, + payload, + instance._solution.categoryId + ) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return this._solution; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +interface InsightsQuestionnairesCategoryPayload + extends InsightsQuestionnairesCategoryResource {} + +interface InsightsQuestionnairesCategoryResource { + account_sid: string; + category_id: string; + name: string; + url: string; +} + +export class InsightsQuestionnairesCategoryInstance { + protected _solution: InsightsQuestionnairesCategoryContextSolution; + protected _context?: InsightsQuestionnairesCategoryContext; + + constructor( + protected _version: V1, + payload: InsightsQuestionnairesCategoryResource, + categoryId?: string + ) { + this.accountSid = payload.account_sid; + this.categoryId = payload.category_id; + this.name = payload.name; + this.url = payload.url; + + this._solution = { categoryId: categoryId || this.categoryId }; + } + + /** + * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. + */ + accountSid: string; + /** + * The unique ID for the category + */ + categoryId: string; + /** + * The name of this category. + */ + name: string; + url: string; + + private get _proxy(): InsightsQuestionnairesCategoryContext { + this._context = + this._context || + new InsightsQuestionnairesCategoryContextImpl( + this._version, + this._solution.categoryId + ); + return this._context; + } + + /** + * Remove a InsightsQuestionnairesCategoryInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + /** + * Remove a InsightsQuestionnairesCategoryInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesCategoryInstance + */ + remove( + params: InsightsQuestionnairesCategoryContextRemoveOptions, + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + + remove( + params?: any, + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + return this._proxy.remove(params, callback); + } + + /** + * Update a InsightsQuestionnairesCategoryInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesCategoryInstance + */ + update( + params: InsightsQuestionnairesCategoryContextUpdateOptions, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesCategoryInstance + ) => any + ): Promise; + + update( + params?: any, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesCategoryInstance + ) => any + ): Promise { + return this._proxy.update(params, callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + accountSid: this.accountSid, + categoryId: this.categoryId, + name: this.name, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export interface InsightsQuestionnairesCategorySolution {} + +export interface InsightsQuestionnairesCategoryListInstance { + _version: V1; + _solution: InsightsQuestionnairesCategorySolution; + _uri: string; + + (categoryId: string): InsightsQuestionnairesCategoryContext; + get(categoryId: string): InsightsQuestionnairesCategoryContext; + + /** + * Create a InsightsQuestionnairesCategoryInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesCategoryInstance + */ + create( + params: InsightsQuestionnairesCategoryListInstanceCreateOptions, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesCategoryInstance + ) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function InsightsQuestionnairesCategoryListInstance( + version: V1 +): InsightsQuestionnairesCategoryListInstance { + const instance = ((categoryId) => + instance.get(categoryId)) as InsightsQuestionnairesCategoryListInstance; + + instance.get = function get( + categoryId + ): InsightsQuestionnairesCategoryContext { + return new InsightsQuestionnairesCategoryContextImpl(version, categoryId); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Insights/QM/Categories`; + + instance.create = function create( + params: InsightsQuestionnairesCategoryListInstanceCreateOptions, + callback?: ( + error: Error | null, + items: InsightsQuestionnairesCategoryInstance + ) => any + ): Promise { + if (params === null || params === undefined) { + throw new Error('Required parameter "params" missing.'); + } + + if (params["name"] === null || params["name"] === undefined) { + throw new Error("Required parameter \"params['name']\" missing."); + } + + let data: any = {}; + + data["Name"] = params["name"]; + + const headers: any = {}; + headers["Content-Type"] = "application/x-www-form-urlencoded"; + if (params["token"] !== undefined) headers["Token"] = params["token"]; + + let operationVersion = version, + operationPromise = operationVersion.create({ + uri: instance._uri, + method: "post", + data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new InsightsQuestionnairesCategoryInstance(operationVersion, payload) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} diff --git a/lib/rest/flexApi/v1/insightsQuestionnairesQuestion.ts b/lib/rest/flexApi/v1/insightsQuestionnairesQuestion.ts new file mode 100644 index 0000000000..16fdc3b722 --- /dev/null +++ b/lib/rest/flexApi/v1/insightsQuestionnairesQuestion.ts @@ -0,0 +1,529 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Flex + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { inspect, InspectOptions } from "util"; +import V1 from "../V1"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +/** + * Options to pass to remove a InsightsQuestionnairesQuestionInstance + */ +export interface InsightsQuestionnairesQuestionContextRemoveOptions { + /** The Token HTTP request header */ + token?: string; +} + +/** + * Options to pass to update a InsightsQuestionnairesQuestionInstance + */ +export interface InsightsQuestionnairesQuestionContextUpdateOptions { + /** The question. */ + question: string; + /** The description for the question. */ + description: string; + /** The answer_set for the question. */ + answerSetId: string; + /** The flag to enable for disable NA for answer. */ + allowNa: boolean; + /** The Token HTTP request header */ + token?: string; + /** The ID of the category */ + categoryId?: string; +} + +/** + * Options to pass to create a InsightsQuestionnairesQuestionInstance + */ +export interface InsightsQuestionnairesQuestionListInstanceCreateOptions { + /** The ID of the category */ + categoryId: string; + /** The question. */ + question: string; + /** The description for the question. */ + description: string; + /** The answer_set for the question. */ + answerSetId: string; + /** The flag to enable for disable NA for answer. */ + allowNa: boolean; + /** The Token HTTP request header */ + token?: string; +} + +export interface InsightsQuestionnairesQuestionContext { + /** + * Remove a InsightsQuestionnairesQuestionInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + /** + * Remove a InsightsQuestionnairesQuestionInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesQuestionInstance + */ + remove( + params: InsightsQuestionnairesQuestionContextRemoveOptions, + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + + /** + * Update a InsightsQuestionnairesQuestionInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesQuestionInstance + */ + update( + params: InsightsQuestionnairesQuestionContextUpdateOptions, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesQuestionInstance + ) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface InsightsQuestionnairesQuestionContextSolution { + questionId: string; +} + +export class InsightsQuestionnairesQuestionContextImpl + implements InsightsQuestionnairesQuestionContext +{ + protected _solution: InsightsQuestionnairesQuestionContextSolution; + protected _uri: string; + + constructor(protected _version: V1, questionId: string) { + if (!isValidPathParam(questionId)) { + throw new Error("Parameter 'questionId' is not valid."); + } + + this._solution = { questionId }; + this._uri = `/Insights/QM/Questions/${questionId}`; + } + + remove( + params?: + | InsightsQuestionnairesQuestionContextRemoveOptions + | ((error: Error | null, item?: boolean) => any), + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + const headers: any = {}; + if (params["token"] !== undefined) headers["Token"] = params["token"]; + + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.remove({ + uri: instance._uri, + method: "delete", + params: data, + headers, + }); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + + update( + params: InsightsQuestionnairesQuestionContextUpdateOptions, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesQuestionInstance + ) => any + ): Promise { + if (params === null || params === undefined) { + throw new Error('Required parameter "params" missing.'); + } + + if (params["question"] === null || params["question"] === undefined) { + throw new Error("Required parameter \"params['question']\" missing."); + } + + if (params["description"] === null || params["description"] === undefined) { + throw new Error("Required parameter \"params['description']\" missing."); + } + + if (params["answerSetId"] === null || params["answerSetId"] === undefined) { + throw new Error("Required parameter \"params['answerSetId']\" missing."); + } + + if (params["allowNa"] === null || params["allowNa"] === undefined) { + throw new Error("Required parameter \"params['allowNa']\" missing."); + } + + let data: any = {}; + + data["Question"] = params["question"]; + + data["Description"] = params["description"]; + + data["AnswerSetId"] = params["answerSetId"]; + + data["AllowNa"] = serialize.bool(params["allowNa"]); + if (params["categoryId"] !== undefined) + data["CategoryId"] = params["categoryId"]; + + const headers: any = {}; + headers["Content-Type"] = "application/x-www-form-urlencoded"; + if (params["token"] !== undefined) headers["Token"] = params["token"]; + + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.update({ + uri: instance._uri, + method: "post", + data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new InsightsQuestionnairesQuestionInstance( + operationVersion, + payload, + instance._solution.questionId + ) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return this._solution; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +interface InsightsQuestionnairesQuestionPayload + extends InsightsQuestionnairesQuestionResource {} + +interface InsightsQuestionnairesQuestionResource { + account_sid: string; + question_id: string; + question: string; + description: string; + category: any; + answer_set_id: string; + allow_na: boolean; + url: string; +} + +export class InsightsQuestionnairesQuestionInstance { + protected _solution: InsightsQuestionnairesQuestionContextSolution; + protected _context?: InsightsQuestionnairesQuestionContext; + + constructor( + protected _version: V1, + payload: InsightsQuestionnairesQuestionResource, + questionId?: string + ) { + this.accountSid = payload.account_sid; + this.questionId = payload.question_id; + this.question = payload.question; + this.description = payload.description; + this.category = payload.category; + this.answerSetId = payload.answer_set_id; + this.allowNa = payload.allow_na; + this.url = payload.url; + + this._solution = { questionId: questionId || this.questionId }; + } + + /** + * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. + */ + accountSid: string; + /** + * The unique ID of the question + */ + questionId: string; + /** + * The question. + */ + question: string; + /** + * The description for the question. + */ + description: string; + /** + * The Category for the question. + */ + category: any; + /** + * The answer_set for the question. + */ + answerSetId: string; + /** + * The flag to enable for disable NA for answer. + */ + allowNa: boolean; + url: string; + + private get _proxy(): InsightsQuestionnairesQuestionContext { + this._context = + this._context || + new InsightsQuestionnairesQuestionContextImpl( + this._version, + this._solution.questionId + ); + return this._context; + } + + /** + * Remove a InsightsQuestionnairesQuestionInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + /** + * Remove a InsightsQuestionnairesQuestionInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesQuestionInstance + */ + remove( + params: InsightsQuestionnairesQuestionContextRemoveOptions, + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + + remove( + params?: any, + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + return this._proxy.remove(params, callback); + } + + /** + * Update a InsightsQuestionnairesQuestionInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesQuestionInstance + */ + update( + params: InsightsQuestionnairesQuestionContextUpdateOptions, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesQuestionInstance + ) => any + ): Promise; + + update( + params?: any, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesQuestionInstance + ) => any + ): Promise { + return this._proxy.update(params, callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + accountSid: this.accountSid, + questionId: this.questionId, + question: this.question, + description: this.description, + category: this.category, + answerSetId: this.answerSetId, + allowNa: this.allowNa, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export interface InsightsQuestionnairesQuestionSolution {} + +export interface InsightsQuestionnairesQuestionListInstance { + _version: V1; + _solution: InsightsQuestionnairesQuestionSolution; + _uri: string; + + (questionId: string): InsightsQuestionnairesQuestionContext; + get(questionId: string): InsightsQuestionnairesQuestionContext; + + /** + * Create a InsightsQuestionnairesQuestionInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsQuestionnairesQuestionInstance + */ + create( + params: InsightsQuestionnairesQuestionListInstanceCreateOptions, + callback?: ( + error: Error | null, + item?: InsightsQuestionnairesQuestionInstance + ) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function InsightsQuestionnairesQuestionListInstance( + version: V1 +): InsightsQuestionnairesQuestionListInstance { + const instance = ((questionId) => + instance.get(questionId)) as InsightsQuestionnairesQuestionListInstance; + + instance.get = function get( + questionId + ): InsightsQuestionnairesQuestionContext { + return new InsightsQuestionnairesQuestionContextImpl(version, questionId); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Insights/QM/Questions`; + + instance.create = function create( + params: InsightsQuestionnairesQuestionListInstanceCreateOptions, + callback?: ( + error: Error | null, + items: InsightsQuestionnairesQuestionInstance + ) => any + ): Promise { + if (params === null || params === undefined) { + throw new Error('Required parameter "params" missing.'); + } + + if (params["categoryId"] === null || params["categoryId"] === undefined) { + throw new Error("Required parameter \"params['categoryId']\" missing."); + } + + if (params["question"] === null || params["question"] === undefined) { + throw new Error("Required parameter \"params['question']\" missing."); + } + + if (params["description"] === null || params["description"] === undefined) { + throw new Error("Required parameter \"params['description']\" missing."); + } + + if (params["answerSetId"] === null || params["answerSetId"] === undefined) { + throw new Error("Required parameter \"params['answerSetId']\" missing."); + } + + if (params["allowNa"] === null || params["allowNa"] === undefined) { + throw new Error("Required parameter \"params['allowNa']\" missing."); + } + + let data: any = {}; + + data["CategoryId"] = params["categoryId"]; + + data["Question"] = params["question"]; + + data["Description"] = params["description"]; + + data["AnswerSetId"] = params["answerSetId"]; + + data["AllowNa"] = serialize.bool(params["allowNa"]); + + const headers: any = {}; + headers["Content-Type"] = "application/x-www-form-urlencoded"; + if (params["token"] !== undefined) headers["Token"] = params["token"]; + + let operationVersion = version, + operationPromise = operationVersion.create({ + uri: instance._uri, + method: "post", + data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new InsightsQuestionnairesQuestionInstance(operationVersion, payload) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} diff --git a/lib/rest/flexApi/v1/goodData.ts b/lib/rest/flexApi/v1/insightsSession.ts similarity index 61% rename from lib/rest/flexApi/v1/goodData.ts rename to lib/rest/flexApi/v1/insightsSession.ts index 3552fe000d..b7aa46eb8c 100644 --- a/lib/rest/flexApi/v1/goodData.ts +++ b/lib/rest/flexApi/v1/insightsSession.ts @@ -19,36 +19,36 @@ const serialize = require("../../../base/serialize"); import { isValidPathParam } from "../../../base/utility"; /** - * Options to pass to create a GoodDataInstance + * Options to pass to create a InsightsSessionInstance */ -export interface GoodDataContextCreateOptions { +export interface InsightsSessionContextCreateOptions { /** The Token HTTP request header */ token?: string; } -export interface GoodDataContext { +export interface InsightsSessionContext { /** - * Create a GoodDataInstance + * Create a InsightsSessionInstance * * @param callback - Callback to handle processed record * - * @returns Resolves to processed GoodDataInstance + * @returns Resolves to processed InsightsSessionInstance */ create( - callback?: (error: Error | null, item?: GoodDataInstance) => any - ): Promise; + callback?: (error: Error | null, item?: InsightsSessionInstance) => any + ): Promise; /** - * Create a GoodDataInstance + * Create a InsightsSessionInstance * * @param params - Parameter for request * @param callback - Callback to handle processed record * - * @returns Resolves to processed GoodDataInstance + * @returns Resolves to processed InsightsSessionInstance */ create( - params: GoodDataContextCreateOptions, - callback?: (error: Error | null, item?: GoodDataInstance) => any - ): Promise; + params: InsightsSessionContextCreateOptions, + callback?: (error: Error | null, item?: InsightsSessionInstance) => any + ): Promise; /** * Provide a user-friendly representation @@ -57,10 +57,10 @@ export interface GoodDataContext { [inspect.custom](_depth: any, options: InspectOptions): any; } -export interface GoodDataContextSolution {} +export interface InsightsSessionContextSolution {} -export class GoodDataContextImpl implements GoodDataContext { - protected _solution: GoodDataContextSolution; +export class InsightsSessionContextImpl implements InsightsSessionContext { + protected _solution: InsightsSessionContextSolution; protected _uri: string; constructor(protected _version: V1) { @@ -70,10 +70,10 @@ export class GoodDataContextImpl implements GoodDataContext { create( params?: - | GoodDataContextCreateOptions - | ((error: Error | null, item?: GoodDataInstance) => any), - callback?: (error: Error | null, item?: GoodDataInstance) => any - ): Promise { + | InsightsSessionContextCreateOptions + | ((error: Error | null, item?: InsightsSessionInstance) => any), + callback?: (error: Error | null, item?: InsightsSessionInstance) => any + ): Promise { if (params instanceof Function) { callback = params; params = {}; @@ -96,7 +96,7 @@ export class GoodDataContextImpl implements GoodDataContext { }); operationPromise = operationPromise.then( - (payload) => new GoodDataInstance(operationVersion, payload) + (payload) => new InsightsSessionInstance(operationVersion, payload) ); operationPromise = instance._version.setPromiseCallback( @@ -120,9 +120,9 @@ export class GoodDataContextImpl implements GoodDataContext { } } -interface GoodDataPayload extends GoodDataResource {} +interface InsightsSessionPayload extends InsightsSessionResource {} -interface GoodDataResource { +interface InsightsSessionResource { workspace_id: string; session_expiry: string; session_id: string; @@ -130,11 +130,11 @@ interface GoodDataResource { url: string; } -export class GoodDataInstance { - protected _solution: GoodDataContextSolution; - protected _context?: GoodDataContext; +export class InsightsSessionInstance { + protected _solution: InsightsSessionContextSolution; + protected _context?: InsightsSessionContext; - constructor(protected _version: V1, payload: GoodDataResource) { + constructor(protected _version: V1, payload: InsightsSessionResource) { this.workspaceId = payload.workspace_id; this.sessionExpiry = payload.session_expiry; this.sessionId = payload.session_id; @@ -165,38 +165,39 @@ export class GoodDataInstance { */ url: string; - private get _proxy(): GoodDataContext { - this._context = this._context || new GoodDataContextImpl(this._version); + private get _proxy(): InsightsSessionContext { + this._context = + this._context || new InsightsSessionContextImpl(this._version); return this._context; } /** - * Create a GoodDataInstance + * Create a InsightsSessionInstance * * @param callback - Callback to handle processed record * - * @returns Resolves to processed GoodDataInstance + * @returns Resolves to processed InsightsSessionInstance */ create( - callback?: (error: Error | null, item?: GoodDataInstance) => any - ): Promise; + callback?: (error: Error | null, item?: InsightsSessionInstance) => any + ): Promise; /** - * Create a GoodDataInstance + * Create a InsightsSessionInstance * * @param params - Parameter for request * @param callback - Callback to handle processed record * - * @returns Resolves to processed GoodDataInstance + * @returns Resolves to processed InsightsSessionInstance */ create( - params: GoodDataContextCreateOptions, - callback?: (error: Error | null, item?: GoodDataInstance) => any - ): Promise; + params: InsightsSessionContextCreateOptions, + callback?: (error: Error | null, item?: InsightsSessionInstance) => any + ): Promise; create( params?: any, - callback?: (error: Error | null, item?: GoodDataInstance) => any - ): Promise { + callback?: (error: Error | null, item?: InsightsSessionInstance) => any + ): Promise { return this._proxy.create(params, callback); } @@ -220,15 +221,15 @@ export class GoodDataInstance { } } -export interface GoodDataSolution {} +export interface InsightsSessionSolution {} -export interface GoodDataListInstance { +export interface InsightsSessionListInstance { _version: V1; - _solution: GoodDataSolution; + _solution: InsightsSessionSolution; _uri: string; - (): GoodDataContext; - get(): GoodDataContext; + (): InsightsSessionContext; + get(): InsightsSessionContext; /** * Provide a user-friendly representation @@ -237,11 +238,13 @@ export interface GoodDataListInstance { [inspect.custom](_depth: any, options: InspectOptions): any; } -export function GoodDataListInstance(version: V1): GoodDataListInstance { - const instance = (() => instance.get()) as GoodDataListInstance; +export function InsightsSessionListInstance( + version: V1 +): InsightsSessionListInstance { + const instance = (() => instance.get()) as InsightsSessionListInstance; - instance.get = function get(): GoodDataContext { - return new GoodDataContextImpl(version); + instance.get = function get(): InsightsSessionContext { + return new InsightsSessionContextImpl(version); }; instance._version = version; diff --git a/lib/rest/flexApi/v1/insightsSettingsAnswerSets.ts b/lib/rest/flexApi/v1/insightsSettingsAnswerSets.ts new file mode 100644 index 0000000000..c03e9a09d7 --- /dev/null +++ b/lib/rest/flexApi/v1/insightsSettingsAnswerSets.ts @@ -0,0 +1,198 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Flex + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { inspect, InspectOptions } from "util"; +import V1 from "../V1"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +/** + * Options to pass to fetch a InsightsSettingsAnswerSetsInstance + */ +export interface InsightsSettingsAnswerSetsListInstanceFetchOptions { + /** The Token HTTP request header */ + token?: string; +} + +export interface InsightsSettingsAnswerSetsSolution {} + +export interface InsightsSettingsAnswerSetsListInstance { + _version: V1; + _solution: InsightsSettingsAnswerSetsSolution; + _uri: string; + + /** + * Fetch a InsightsSettingsAnswerSetsInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsSettingsAnswerSetsInstance + */ + fetch( + callback?: ( + error: Error | null, + item?: InsightsSettingsAnswerSetsInstance + ) => any + ): Promise; + /** + * Fetch a InsightsSettingsAnswerSetsInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsSettingsAnswerSetsInstance + */ + fetch( + params: InsightsSettingsAnswerSetsListInstanceFetchOptions, + callback?: ( + error: Error | null, + item?: InsightsSettingsAnswerSetsInstance + ) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function InsightsSettingsAnswerSetsListInstance( + version: V1 +): InsightsSettingsAnswerSetsListInstance { + const instance = {} as InsightsSettingsAnswerSetsListInstance; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Insights/QM/Settings/AnswerSets`; + + instance.fetch = function fetch( + params?: + | InsightsSettingsAnswerSetsListInstanceFetchOptions + | (( + error: Error | null, + items: InsightsSettingsAnswerSetsInstance + ) => any), + callback?: ( + error: Error | null, + items: InsightsSettingsAnswerSetsInstance + ) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + const headers: any = {}; + if (params["token"] !== undefined) headers["Token"] = params["token"]; + + let operationVersion = version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + params: data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new InsightsSettingsAnswerSetsInstance(operationVersion, payload) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +interface InsightsSettingsAnswerSetsPayload + extends InsightsSettingsAnswerSetsResource {} + +interface InsightsSettingsAnswerSetsResource { + account_sid: string; + answer_sets: any; + answer_set_categories: any; + not_applicable: any; + url: string; +} + +export class InsightsSettingsAnswerSetsInstance { + constructor( + protected _version: V1, + payload: InsightsSettingsAnswerSetsResource + ) { + this.accountSid = payload.account_sid; + this.answerSets = payload.answer_sets; + this.answerSetCategories = payload.answer_set_categories; + this.notApplicable = payload.not_applicable; + this.url = payload.url; + } + + /** + * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. + */ + accountSid: string; + /** + * The lis of answer sets + */ + answerSets: any; + /** + * The list of answer set categories + */ + answerSetCategories: any; + /** + * The details for not applicable answer set + */ + notApplicable: any; + url: string; + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + accountSid: this.accountSid, + answerSets: this.answerSets, + answerSetCategories: this.answerSetCategories, + notApplicable: this.notApplicable, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/lib/rest/flexApi/v1/insightsSettingsComment.ts b/lib/rest/flexApi/v1/insightsSettingsComment.ts new file mode 100644 index 0000000000..bce1904e6d --- /dev/null +++ b/lib/rest/flexApi/v1/insightsSettingsComment.ts @@ -0,0 +1,178 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Flex + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { inspect, InspectOptions } from "util"; +import V1 from "../V1"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +/** + * Options to pass to fetch a InsightsSettingsCommentInstance + */ +export interface InsightsSettingsCommentListInstanceFetchOptions { + /** The Token HTTP request header */ + token?: string; +} + +export interface InsightsSettingsCommentSolution {} + +export interface InsightsSettingsCommentListInstance { + _version: V1; + _solution: InsightsSettingsCommentSolution; + _uri: string; + + /** + * Fetch a InsightsSettingsCommentInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsSettingsCommentInstance + */ + fetch( + callback?: ( + error: Error | null, + item?: InsightsSettingsCommentInstance + ) => any + ): Promise; + /** + * Fetch a InsightsSettingsCommentInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed InsightsSettingsCommentInstance + */ + fetch( + params: InsightsSettingsCommentListInstanceFetchOptions, + callback?: ( + error: Error | null, + item?: InsightsSettingsCommentInstance + ) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function InsightsSettingsCommentListInstance( + version: V1 +): InsightsSettingsCommentListInstance { + const instance = {} as InsightsSettingsCommentListInstance; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Insights/QM/Settings/CommentTags`; + + instance.fetch = function fetch( + params?: + | InsightsSettingsCommentListInstanceFetchOptions + | ((error: Error | null, items: InsightsSettingsCommentInstance) => any), + callback?: ( + error: Error | null, + items: InsightsSettingsCommentInstance + ) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + const headers: any = {}; + if (params["token"] !== undefined) headers["Token"] = params["token"]; + + let operationVersion = version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + params: data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new InsightsSettingsCommentInstance(operationVersion, payload) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +interface InsightsSettingsCommentPayload + extends InsightsSettingsCommentResource {} + +interface InsightsSettingsCommentResource { + account_sid: string; + comments: any; + url: string; +} + +export class InsightsSettingsCommentInstance { + constructor( + protected _version: V1, + payload: InsightsSettingsCommentResource + ) { + this.accountSid = payload.account_sid; + this.comments = payload.comments; + this.url = payload.url; + } + + /** + * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. + */ + accountSid: string; + comments: any; + url: string; + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + accountSid: this.accountSid, + comments: this.comments, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/lib/rest/flexApi/v1/userRoles.ts b/lib/rest/flexApi/v1/insightsUserRoles.ts similarity index 56% rename from lib/rest/flexApi/v1/userRoles.ts rename to lib/rest/flexApi/v1/insightsUserRoles.ts index f0f339d9a3..00fc26bd12 100644 --- a/lib/rest/flexApi/v1/userRoles.ts +++ b/lib/rest/flexApi/v1/insightsUserRoles.ts @@ -19,36 +19,36 @@ const serialize = require("../../../base/serialize"); import { isValidPathParam } from "../../../base/utility"; /** - * Options to pass to fetch a UserRolesInstance + * Options to pass to fetch a InsightsUserRolesInstance */ -export interface UserRolesContextFetchOptions { +export interface InsightsUserRolesContextFetchOptions { /** The Token HTTP request header */ token?: string; } -export interface UserRolesContext { +export interface InsightsUserRolesContext { /** - * Fetch a UserRolesInstance + * Fetch a InsightsUserRolesInstance * * @param callback - Callback to handle processed record * - * @returns Resolves to processed UserRolesInstance + * @returns Resolves to processed InsightsUserRolesInstance */ fetch( - callback?: (error: Error | null, item?: UserRolesInstance) => any - ): Promise; + callback?: (error: Error | null, item?: InsightsUserRolesInstance) => any + ): Promise; /** - * Fetch a UserRolesInstance + * Fetch a InsightsUserRolesInstance * * @param params - Parameter for request * @param callback - Callback to handle processed record * - * @returns Resolves to processed UserRolesInstance + * @returns Resolves to processed InsightsUserRolesInstance */ fetch( - params: UserRolesContextFetchOptions, - callback?: (error: Error | null, item?: UserRolesInstance) => any - ): Promise; + params: InsightsUserRolesContextFetchOptions, + callback?: (error: Error | null, item?: InsightsUserRolesInstance) => any + ): Promise; /** * Provide a user-friendly representation @@ -57,10 +57,10 @@ export interface UserRolesContext { [inspect.custom](_depth: any, options: InspectOptions): any; } -export interface UserRolesContextSolution {} +export interface InsightsUserRolesContextSolution {} -export class UserRolesContextImpl implements UserRolesContext { - protected _solution: UserRolesContextSolution; +export class InsightsUserRolesContextImpl implements InsightsUserRolesContext { + protected _solution: InsightsUserRolesContextSolution; protected _uri: string; constructor(protected _version: V1) { @@ -70,10 +70,10 @@ export class UserRolesContextImpl implements UserRolesContext { fetch( params?: - | UserRolesContextFetchOptions - | ((error: Error | null, item?: UserRolesInstance) => any), - callback?: (error: Error | null, item?: UserRolesInstance) => any - ): Promise { + | InsightsUserRolesContextFetchOptions + | ((error: Error | null, item?: InsightsUserRolesInstance) => any), + callback?: (error: Error | null, item?: InsightsUserRolesInstance) => any + ): Promise { if (params instanceof Function) { callback = params; params = {}; @@ -96,7 +96,7 @@ export class UserRolesContextImpl implements UserRolesContext { }); operationPromise = operationPromise.then( - (payload) => new UserRolesInstance(operationVersion, payload) + (payload) => new InsightsUserRolesInstance(operationVersion, payload) ); operationPromise = instance._version.setPromiseCallback( @@ -120,18 +120,18 @@ export class UserRolesContextImpl implements UserRolesContext { } } -interface UserRolesPayload extends UserRolesResource {} +interface InsightsUserRolesPayload extends InsightsUserRolesResource {} -interface UserRolesResource { +interface InsightsUserRolesResource { roles: Array; url: string; } -export class UserRolesInstance { - protected _solution: UserRolesContextSolution; - protected _context?: UserRolesContext; +export class InsightsUserRolesInstance { + protected _solution: InsightsUserRolesContextSolution; + protected _context?: InsightsUserRolesContext; - constructor(protected _version: V1, payload: UserRolesResource) { + constructor(protected _version: V1, payload: InsightsUserRolesResource) { this.roles = payload.roles; this.url = payload.url; @@ -144,38 +144,39 @@ export class UserRolesInstance { roles: Array; url: string; - private get _proxy(): UserRolesContext { - this._context = this._context || new UserRolesContextImpl(this._version); + private get _proxy(): InsightsUserRolesContext { + this._context = + this._context || new InsightsUserRolesContextImpl(this._version); return this._context; } /** - * Fetch a UserRolesInstance + * Fetch a InsightsUserRolesInstance * * @param callback - Callback to handle processed record * - * @returns Resolves to processed UserRolesInstance + * @returns Resolves to processed InsightsUserRolesInstance */ fetch( - callback?: (error: Error | null, item?: UserRolesInstance) => any - ): Promise; + callback?: (error: Error | null, item?: InsightsUserRolesInstance) => any + ): Promise; /** - * Fetch a UserRolesInstance + * Fetch a InsightsUserRolesInstance * * @param params - Parameter for request * @param callback - Callback to handle processed record * - * @returns Resolves to processed UserRolesInstance + * @returns Resolves to processed InsightsUserRolesInstance */ fetch( - params: UserRolesContextFetchOptions, - callback?: (error: Error | null, item?: UserRolesInstance) => any - ): Promise; + params: InsightsUserRolesContextFetchOptions, + callback?: (error: Error | null, item?: InsightsUserRolesInstance) => any + ): Promise; fetch( params?: any, - callback?: (error: Error | null, item?: UserRolesInstance) => any - ): Promise { + callback?: (error: Error | null, item?: InsightsUserRolesInstance) => any + ): Promise { return this._proxy.fetch(params, callback); } @@ -196,15 +197,15 @@ export class UserRolesInstance { } } -export interface UserRolesSolution {} +export interface InsightsUserRolesSolution {} -export interface UserRolesListInstance { +export interface InsightsUserRolesListInstance { _version: V1; - _solution: UserRolesSolution; + _solution: InsightsUserRolesSolution; _uri: string; - (): UserRolesContext; - get(): UserRolesContext; + (): InsightsUserRolesContext; + get(): InsightsUserRolesContext; /** * Provide a user-friendly representation @@ -213,11 +214,13 @@ export interface UserRolesListInstance { [inspect.custom](_depth: any, options: InspectOptions): any; } -export function UserRolesListInstance(version: V1): UserRolesListInstance { - const instance = (() => instance.get()) as UserRolesListInstance; +export function InsightsUserRolesListInstance( + version: V1 +): InsightsUserRolesListInstance { + const instance = (() => instance.get()) as InsightsUserRolesListInstance; - instance.get = function get(): UserRolesContext { - return new UserRolesContextImpl(version); + instance.get = function get(): InsightsUserRolesContext { + return new InsightsUserRolesContextImpl(version); }; instance._version = version; diff --git a/lib/rest/messaging/v1/tollfreeVerification.ts b/lib/rest/messaging/v1/tollfreeVerification.ts index 018dcadbe4..32cf56f35b 100644 --- a/lib/rest/messaging/v1/tollfreeVerification.ts +++ b/lib/rest/messaging/v1/tollfreeVerification.ts @@ -127,6 +127,8 @@ export interface TollfreeVerificationListInstanceCreateOptions { businessContactEmail?: string; /** The phone number of the contact for the business or organization using the Tollfree number. */ businessContactPhone?: string; + /** An optional external reference ID supplied by customer and echoed back on status retrieval. */ + externalReferenceId?: string; } /** * Options to pass to each @@ -407,6 +409,7 @@ interface TollfreeVerificationResource { status: TollfreeVerificationStatus; url: string; resource_links: any; + external_reference_id: string; } export class TollfreeVerificationInstance { @@ -449,6 +452,7 @@ export class TollfreeVerificationInstance { this.status = payload.status; this.url = payload.url; this.resourceLinks = payload.resource_links; + this.externalReferenceId = payload.external_reference_id; this._solution = { sid: sid || this.sid }; } @@ -571,6 +575,10 @@ export class TollfreeVerificationInstance { * The URLs of the documents associated with the Tollfree Verification resource. */ resourceLinks: any; + /** + * An optional external reference ID supplied by customer and echoed back on status retrieval. + */ + externalReferenceId: string; private get _proxy(): TollfreeVerificationContext { this._context = @@ -660,6 +668,7 @@ export class TollfreeVerificationInstance { status: this.status, url: this.url, resourceLinks: this.resourceLinks, + externalReferenceId: this.externalReferenceId, }; } @@ -936,6 +945,8 @@ export function TollfreeVerificationListInstance( data["BusinessContactEmail"] = params["businessContactEmail"]; if (params["businessContactPhone"] !== undefined) data["BusinessContactPhone"] = params["businessContactPhone"]; + if (params["externalReferenceId"] !== undefined) + data["ExternalReferenceId"] = params["externalReferenceId"]; const headers: any = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; diff --git a/lib/rest/verify/v2/service/verification.ts b/lib/rest/verify/v2/service/verification.ts index a548c2571d..b481165678 100644 --- a/lib/rest/verify/v2/service/verification.ts +++ b/lib/rest/verify/v2/service/verification.ts @@ -36,7 +36,7 @@ export interface VerificationContextUpdateOptions { export interface VerificationListInstanceCreateOptions { /** The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). */ to: string; - /** The verification method to use. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, or `sna`. */ + /** The verification method to use. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, `sna` or `auto`. */ channel: string; /** A custom user defined friendly name that overwrites the existing one in the verification message */ customFriendlyName?: string; @@ -62,6 +62,8 @@ export interface VerificationListInstanceCreateOptions { templateSid?: string; /** A stringified JSON object in which the keys are the template\\\'s special variables and the values are the variables substitutions. */ templateCustomSubstitutions?: string; + /** The IP address of the client\\\'s device. If provided, it has to be a valid IPv4 or IPv6 address. */ + deviceIp?: string; } export interface VerificationContext { @@ -479,6 +481,7 @@ export function VerificationListInstance( if (params["templateCustomSubstitutions"] !== undefined) data["TemplateCustomSubstitutions"] = params["templateCustomSubstitutions"]; + if (params["deviceIp"] !== undefined) data["DeviceIp"] = params["deviceIp"]; const headers: any = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; diff --git a/lib/twiml/VoiceResponse.ts b/lib/twiml/VoiceResponse.ts index 5f97357f04..c5a2f0de00 100644 --- a/lib/twiml/VoiceResponse.ts +++ b/lib/twiml/VoiceResponse.ts @@ -302,6 +302,8 @@ class VoiceResponse extends TwiML { } namespace VoiceResponse { + type ApplicationEvent = "initiated" | "ringing" | "answered" | "completed"; + type ClientEvent = "initiated" | "ringing" | "answered" | "completed"; type ConferenceBeep = "true" | "false" | "onEnter" | "onExit"; @@ -1791,6 +1793,26 @@ namespace VoiceResponse { value?: string; } + /** + * Attributes to pass to parameter + */ + export interface ParameterAttributes { + /** name - The name of the custom parameter */ + name?: string; + /** value - The value of the custom parameter */ + value?: string; + } + + /** + * Attributes to pass to parameter + */ + export interface ParameterAttributes { + /** name - The name of the custom parameter */ + name?: string; + /** value - The value of the custom parameter */ + value?: string; + } + /** * Attributes to pass to say */ @@ -1975,6 +1997,36 @@ namespace VoiceResponse { username?: string; } + /** + * Attributes to pass to application + */ + export interface ApplicationAttributes { + /** copyParentTo - Copy parent call To field to called application side, otherwise use the application sid as To field */ + copyParentTo?: boolean; + /** customerId - Identity of the customer calling application */ + customerId?: string; + /** method - TwiML URL Method */ + method?: string; + /** statusCallback - Status Callback URL */ + statusCallback?: string; + /** statusCallbackEvent - Events to trigger status callback */ + statusCallbackEvent?: ApplicationEvent[]; + /** statusCallbackMethod - Status Callback URL Method */ + statusCallbackMethod?: string; + /** url - TwiML URL */ + url?: string; + } + + /** + * Attributes to pass to parameter + */ + export interface ParameterAttributes { + /** name - The name of the custom parameter */ + name?: string; + /** value - The value of the custom parameter */ + value?: string; + } + /** * Attributes to pass to parameter */ @@ -2081,6 +2133,65 @@ namespace VoiceResponse { value?: string; } + export class Application extends TwiML { + application: XMLElement; + /** + * TwiML Noun + */ + constructor(application: XMLElement) { + super(); + this.application = application; + this._propertyName = "application"; + } + /** + * TwiML Noun + * + * @param attributes - TwiML attributes + * @param sid - Application sid to dial + */ + applicationSid(sid: string): VoiceResponse.ApplicationSid; + applicationSid( + attributes: object, + sid: string + ): VoiceResponse.ApplicationSid; + applicationSid( + attributes: object | string, + sid?: string + ): VoiceResponse.ApplicationSid { + if (typeof attributes === "string") { + sid = attributes; + attributes = {}; + } + return new VoiceResponse.ApplicationSid( + this.application.ele("ApplicationSid", attributes, sid) + ); + } + /** + * TwiML Noun + * + * @param attributes - TwiML attributes + */ + parameter( + attributes?: VoiceResponse.ParameterAttributes + ): VoiceResponse.Parameter { + return new VoiceResponse.Parameter( + this.application.ele("Parameter", attributes) + ); + } + } + + export class ApplicationSid extends TwiML { + applicationSid: XMLElement; + /** + * TwiML Noun + */ + constructor(applicationSid: XMLElement) { + super(); + this.applicationSid = applicationSid; + this._propertyName = "applicationSid"; + } + } + export class Autopilot extends TwiML { autopilot: XMLElement; /** @@ -2271,6 +2382,29 @@ namespace VoiceResponse { this.dial = dial; this._propertyName = "dial"; } + /** + * TwiML Noun + * + * @param attributes - TwiML attributes + * @param applicationSid - Application sid + */ + application(applicationSid?: string): VoiceResponse.Application; + application( + attributes?: VoiceResponse.ApplicationAttributes, + applicationSid?: string + ): VoiceResponse.Application; + application( + attributes?: VoiceResponse.ApplicationAttributes | string, + applicationSid?: string + ): VoiceResponse.Application { + if (typeof attributes === "string") { + applicationSid = attributes; + attributes = {}; + } + return new VoiceResponse.Application( + this.dial.ele("Application", attributes, applicationSid) + ); + } /** * TwiML Noun * @@ -2516,6 +2650,18 @@ namespace VoiceResponse { this.hangup = hangup; this._propertyName = "hangup"; } + /** + * TwiML Noun + * + * @param attributes - TwiML attributes + */ + parameter( + attributes?: VoiceResponse.ParameterAttributes + ): VoiceResponse.Parameter { + return new VoiceResponse.Parameter( + this.hangup.ele("Parameter", attributes) + ); + } } export class Identity extends TwiML { @@ -2769,6 +2915,18 @@ namespace VoiceResponse { this.reject = reject; this._propertyName = "reject"; } + /** + * TwiML Noun + * + * @param attributes - TwiML attributes + */ + parameter( + attributes?: VoiceResponse.ParameterAttributes + ): VoiceResponse.Parameter { + return new VoiceResponse.Parameter( + this.reject.ele("Parameter", attributes) + ); + } } export class Room extends TwiML {