From 4e65af4402c53d90bede0d1ff1d1dc5542feeb26 Mon Sep 17 00:00:00 2001 From: Twilio Date: Fri, 24 May 2024 11:02:59 +0000 Subject: [PATCH] [Librarian] Regenerated @ 1baa147fbfa3bf2798f86ec43796ef1df42570d4 a3170b07f36450c6d179edf9b044cbf5f6b94e3a --- CHANGES.md | 46 ++ src/rest/ContentBase.ts | 6 + src/rest/api/v2010/account/message.ts | 2 +- src/rest/content/V2.ts | 47 ++ src/rest/content/v2/content.ts | 354 +++++++++ src/rest/content/v2/contentAndApprovals.ts | 374 +++++++++ src/rest/flexApi/v1/interaction.ts | 10 +- src/rest/flexApi/v1/plugin/pluginVersions.ts | 6 +- src/rest/intelligence/V2.ts | 58 ++ src/rest/intelligence/v2/customOperator.ts | 731 ++++++++++++++++++ src/rest/intelligence/v2/operator.ts | 487 ++++++++++++ .../intelligence/v2/operatorAttachment.ts | 275 +++++++ .../intelligence/v2/operatorAttachments.ts | 220 ++++++ src/rest/intelligence/v2/operatorType.ts | 501 ++++++++++++ src/rest/intelligence/v2/prebuiltOperator.ts | 510 ++++++++++++ src/rest/intelligence/v2/service.ts | 16 +- src/rest/messaging/v1/service.ts | 7 - src/rest/numbers/V1.ts | 54 +- src/rest/numbers/v1/portingBulkPortability.ts | 316 -------- src/rest/numbers/v1/portingPortIn.ts | 118 +++ src/rest/numbers/v1/portingPortInFetch.ts | 280 ------- .../numbers/v1/portingPortInPhoneNumber.ts | 220 ++++++ .../numbers/v1/portingWebhookConfiguration.ts | 196 +++++ .../v1/portingWebhookConfigurationDelete.ts | 149 ++++ .../v1/portingWebhookConfigurationFetch.ts | 169 ++++ src/rest/taskrouter/v1/workspace/task.ts | 34 + .../v1/complianceTollfreeInquiries.ts | 4 + src/rest/trusthub/v1/customerProfiles.ts | 7 + src/rest/trusthub/v1/trustProducts.ts | 7 + src/rest/verify/v2/service.ts | 2 +- src/rest/verify/v2/service/verification.ts | 2 +- .../verify/v2/service/verificationCheck.ts | 2 +- 32 files changed, 4568 insertions(+), 642 deletions(-) create mode 100644 src/rest/content/V2.ts create mode 100644 src/rest/content/v2/content.ts create mode 100644 src/rest/content/v2/contentAndApprovals.ts create mode 100644 src/rest/intelligence/v2/customOperator.ts create mode 100644 src/rest/intelligence/v2/operator.ts create mode 100644 src/rest/intelligence/v2/operatorAttachment.ts create mode 100644 src/rest/intelligence/v2/operatorAttachments.ts create mode 100644 src/rest/intelligence/v2/operatorType.ts create mode 100644 src/rest/intelligence/v2/prebuiltOperator.ts delete mode 100644 src/rest/numbers/v1/portingBulkPortability.ts delete mode 100644 src/rest/numbers/v1/portingPortInFetch.ts create mode 100644 src/rest/numbers/v1/portingWebhookConfiguration.ts create mode 100644 src/rest/numbers/v1/portingWebhookConfigurationDelete.ts create mode 100644 src/rest/numbers/v1/portingWebhookConfigurationFetch.ts diff --git a/CHANGES.md b/CHANGES.md index ffd1e9460f..3a772d87f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,52 @@ twilio-node changelog ===================== +[2024-05-24] Version 5.1.0 +-------------------------- +**Library - Fix** +- [PR #1022](https://github.com/twilio/twilio-node/pull/1022): corrected options.validate to default true. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Library - Chore** +- [PR #1020](https://github.com/twilio/twilio-node/pull/1020): removing previewMessaging reference. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Api** +- Add ie1 as supported region for UserDefinedMessage and UserDefinedMessageSubscription. + +**Flex** +- Adding validated field to `plugin_versions` +- Corrected the data type for `runtime_domain`, `call_recording_webhook_url`, `crm_callback_url`, `crm_fallback_url`, `flex_url` in Flex Configuration +- Making `routing` optional in Create Interactions endpoint + +**Intelligence** +- Expose operator authoring apis to public visibility +- Deleted `language_code` parameter from updating service in v2 **(breaking change)** +- Add read_only_attached_operator_sids to v2 services + +**Numbers** +- Add API endpoint for GET Porting Webhook Configurations By Account SID +- Remove bulk portability api under version `/v1`. **(breaking change)** +- Removed porting_port_in_fetch.json files and move the content into porting_port_in.json files +- Add API endpoint to deleting Webhook Configurations +- Add Get Phone Number by Port in request SID and Phone Number SID api +- Add Create Porting webhook configuration API +- Added bundle_sid and losing_carrier_information fields to Create PortInRequest api to support Japan porting + +**Taskrouter** +- Add back `routing_target` property to tasks +- Add back `ignore_capacity` property to tasks +- Removing `routing_target` property to tasks due to revert +- Removing `ignore_capacity` property to tasks due to revert +- Add `routing_target` property to tasks +- Add `ignore_capacity` property to tasks + +**Trusthub** +- Add new field errors to bundle as part of public API response in customer_profile.json and trust_product.json **(breaking change)** +- Add themeSetId field in compliance_tollfree_inquiry. + +**Verify** +- Update `friendly_name` description on service docs + + [2024-04-18] Version 5.0.4 -------------------------- **Library - Chore** diff --git a/src/rest/ContentBase.ts b/src/rest/ContentBase.ts index 8cf4ff81cd..b979a174a1 100644 --- a/src/rest/ContentBase.ts +++ b/src/rest/ContentBase.ts @@ -11,9 +11,11 @@ import Domain from "../base/Domain"; import V1 from "./content/V1"; +import V2 from "./content/V2"; class ContentBase extends Domain { _v1?: V1; + _v2?: V2; /** * Initialize content domain @@ -28,6 +30,10 @@ class ContentBase extends Domain { this._v1 = this._v1 || new V1(this); return this._v1; } + get v2(): V2 { + this._v2 = this._v2 || new V2(this); + return this._v2; + } } export = ContentBase; diff --git a/src/rest/api/v2010/account/message.ts b/src/rest/api/v2010/account/message.ts index 8cdd876d1e..40d73c7de6 100644 --- a/src/rest/api/v2010/account/message.ts +++ b/src/rest/api/v2010/account/message.ts @@ -492,7 +492,7 @@ export class MessageInstance { numMedia: string; status: MessageStatus; /** - * The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource. The value is `null` if a Messaging Service was not used. + * The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource. A unique default value is assigned if a Messaging Service is not used. */ messagingServiceSid: string; /** diff --git a/src/rest/content/V2.ts b/src/rest/content/V2.ts new file mode 100644 index 0000000000..78a7e71594 --- /dev/null +++ b/src/rest/content/V2.ts @@ -0,0 +1,47 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Content + * 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 ContentBase from "../ContentBase"; +import Version from "../../base/Version"; +import { ContentListInstance } from "./v2/content"; +import { ContentAndApprovalsListInstance } from "./v2/contentAndApprovals"; + +export default class V2 extends Version { + /** + * Initialize the V2 version of Content + * + * @param domain - The Twilio (Twilio.Content) domain + */ + constructor(domain: ContentBase) { + super(domain, "v2"); + } + + /** contents - { Twilio.Content.V2.ContentListInstance } resource */ + protected _contents?: ContentListInstance; + /** contentAndApprovals - { Twilio.Content.V2.ContentAndApprovalsListInstance } resource */ + protected _contentAndApprovals?: ContentAndApprovalsListInstance; + + /** Getter for contents resource */ + get contents(): ContentListInstance { + this._contents = this._contents || ContentListInstance(this); + return this._contents; + } + + /** Getter for contentAndApprovals resource */ + get contentAndApprovals(): ContentAndApprovalsListInstance { + this._contentAndApprovals = + this._contentAndApprovals || ContentAndApprovalsListInstance(this); + return this._contentAndApprovals; + } +} diff --git a/src/rest/content/v2/content.ts b/src/rest/content/v2/content.ts new file mode 100644 index 0000000000..aa32bcfe8f --- /dev/null +++ b/src/rest/content/v2/content.ts @@ -0,0 +1,354 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Content + * 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 Page, { TwilioResponsePayload } from "../../../base/Page"; +import Response from "../../../http/response"; +import V2 from "../V2"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +/** + * Options to pass to each + */ +export interface ContentListInstanceEachOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Function to process each record. If this and a positional callback are passed, this one will be used */ + callback?: (item: ContentInstance, done: (err?: Error) => void) => void; + /** Function to be called upon completion of streaming */ + done?: Function; + /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to list + */ +export interface ContentListInstanceOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to page + */ +export interface ContentListInstancePageOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Page Number, this value is simply for client state */ + pageNumber?: number; + /** PageToken provided by the API */ + pageToken?: string; +} + +export interface ContentSolution {} + +export interface ContentListInstance { + _version: V2; + _solution: ContentSolution; + _uri: string; + + /** + * Streams ContentInstance 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 { ContentListInstanceEachOptions } [params] - Options for request + * @param { function } [callback] - Function to process each record + */ + each( + callback?: (item: ContentInstance, done: (err?: Error) => void) => void + ): void; + each( + params: ContentListInstanceEachOptions, + callback?: (item: ContentInstance, done: (err?: Error) => void) => void + ): void; + /** + * Retrieve a single target page of ContentInstance records from the API. + * + * The request is executed immediately. + * + * @param { string } [targetUrl] - API-generated URL for the requested results page + * @param { function } [callback] - Callback to handle list of records + */ + getPage( + targetUrl: string, + callback?: (error: Error | null, items: ContentPage) => any + ): Promise; + /** + * Lists ContentInstance 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 { ContentListInstanceOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + list( + callback?: (error: Error | null, items: ContentInstance[]) => any + ): Promise; + list( + params: ContentListInstanceOptions, + callback?: (error: Error | null, items: ContentInstance[]) => any + ): Promise; + /** + * Retrieve a single page of ContentInstance 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 { ContentListInstancePageOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + page( + callback?: (error: Error | null, items: ContentPage) => any + ): Promise; + page( + params: ContentListInstancePageOptions, + callback?: (error: Error | null, items: ContentPage) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function ContentListInstance(version: V2): ContentListInstance { + const instance = {} as ContentListInstance; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Content`; + + instance.page = function page( + params?: + | ContentListInstancePageOptions + | ((error: Error | null, items: ContentPage) => any), + callback?: (error: Error | null, items: ContentPage) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; + + if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; + if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; + + const headers: any = {}; + + let operationVersion = version, + operationPromise = operationVersion.page({ + uri: instance._uri, + method: "get", + params: data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new ContentPage(operationVersion, payload, instance._solution) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + instance.each = instance._version.each; + instance.list = instance._version.list; + + instance.getPage = function getPage( + targetUrl: string, + callback?: (error: Error | null, items: ContentPage) => any + ): Promise { + const operationPromise = instance._version._domain.twilio.request({ + method: "get", + uri: targetUrl, + }); + + let pagePromise = operationPromise.then( + (payload) => + new ContentPage(instance._version, payload, instance._solution) + ); + pagePromise = instance._version.setPromiseCallback(pagePromise, callback); + return pagePromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +interface ContentPayload extends TwilioResponsePayload { + contents: ContentResource[]; +} + +interface ContentResource { + date_created: Date; + date_updated: Date; + sid: string; + account_sid: string; + friendly_name: string; + language: string; + variables: any; + types: any; + url: string; + links: Record; +} + +export class ContentInstance { + constructor(protected _version: V2, payload: ContentResource) { + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); + this.sid = payload.sid; + this.accountSid = payload.account_sid; + this.friendlyName = payload.friendly_name; + this.language = payload.language; + this.variables = payload.variables; + this.types = payload.types; + this.url = payload.url; + this.links = payload.links; + } + + /** + * The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + */ + dateCreated: Date; + /** + * The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + */ + dateUpdated: Date; + /** + * The unique string that that we created to identify the Content resource. + */ + sid: string; + /** + * The SID of the [Account](https://www.twilio.com/docs/usage/api/account) that created Content resource. + */ + accountSid: string; + /** + * A string name used to describe the Content resource. Not visible to the end recipient. + */ + friendlyName: string; + /** + * Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in. + */ + language: string; + /** + * Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}. + */ + variables: any; + /** + * The [Content types](https://www.twilio.com/docs/content/content-types-overview) (e.g. twilio/text) for this Content resource. + */ + types: any; + /** + * The URL of the resource, relative to `https://content.twilio.com`. + */ + url: string; + /** + * A list of links related to the Content resource, such as approval_fetch and approval_create + */ + links: Record; + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + dateCreated: this.dateCreated, + dateUpdated: this.dateUpdated, + sid: this.sid, + accountSid: this.accountSid, + friendlyName: this.friendlyName, + language: this.language, + variables: this.variables, + types: this.types, + url: this.url, + links: this.links, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export class ContentPage extends Page< + V2, + ContentPayload, + ContentResource, + ContentInstance +> { + /** + * Initialize the ContentPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor( + version: V2, + response: Response, + solution: ContentSolution + ) { + super(version, response, solution); + } + + /** + * Build an instance of ContentInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: ContentResource): ContentInstance { + return new ContentInstance(this._version, payload); + } + + [inspect.custom](depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/content/v2/contentAndApprovals.ts b/src/rest/content/v2/contentAndApprovals.ts new file mode 100644 index 0000000000..d848cd4727 --- /dev/null +++ b/src/rest/content/v2/contentAndApprovals.ts @@ -0,0 +1,374 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Content + * 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 Page, { TwilioResponsePayload } from "../../../base/Page"; +import Response from "../../../http/response"; +import V2 from "../V2"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +/** + * Options to pass to each + */ +export interface ContentAndApprovalsListInstanceEachOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Function to process each record. If this and a positional callback are passed, this one will be used */ + callback?: ( + item: ContentAndApprovalsInstance, + done: (err?: Error) => void + ) => void; + /** Function to be called upon completion of streaming */ + done?: Function; + /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to list + */ +export interface ContentAndApprovalsListInstanceOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to page + */ +export interface ContentAndApprovalsListInstancePageOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Page Number, this value is simply for client state */ + pageNumber?: number; + /** PageToken provided by the API */ + pageToken?: string; +} + +export interface ContentAndApprovalsSolution {} + +export interface ContentAndApprovalsListInstance { + _version: V2; + _solution: ContentAndApprovalsSolution; + _uri: string; + + /** + * Streams ContentAndApprovalsInstance 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 { ContentAndApprovalsListInstanceEachOptions } [params] - Options for request + * @param { function } [callback] - Function to process each record + */ + each( + callback?: ( + item: ContentAndApprovalsInstance, + done: (err?: Error) => void + ) => void + ): void; + each( + params: ContentAndApprovalsListInstanceEachOptions, + callback?: ( + item: ContentAndApprovalsInstance, + done: (err?: Error) => void + ) => void + ): void; + /** + * Retrieve a single target page of ContentAndApprovalsInstance records from the API. + * + * The request is executed immediately. + * + * @param { string } [targetUrl] - API-generated URL for the requested results page + * @param { function } [callback] - Callback to handle list of records + */ + getPage( + targetUrl: string, + callback?: (error: Error | null, items: ContentAndApprovalsPage) => any + ): Promise; + /** + * Lists ContentAndApprovalsInstance 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 { ContentAndApprovalsListInstanceOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + list( + callback?: ( + error: Error | null, + items: ContentAndApprovalsInstance[] + ) => any + ): Promise; + list( + params: ContentAndApprovalsListInstanceOptions, + callback?: ( + error: Error | null, + items: ContentAndApprovalsInstance[] + ) => any + ): Promise; + /** + * Retrieve a single page of ContentAndApprovalsInstance 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 { ContentAndApprovalsListInstancePageOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + page( + callback?: (error: Error | null, items: ContentAndApprovalsPage) => any + ): Promise; + page( + params: ContentAndApprovalsListInstancePageOptions, + callback?: (error: Error | null, items: ContentAndApprovalsPage) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function ContentAndApprovalsListInstance( + version: V2 +): ContentAndApprovalsListInstance { + const instance = {} as ContentAndApprovalsListInstance; + + instance._version = version; + instance._solution = {}; + instance._uri = `/ContentAndApprovals`; + + instance.page = function page( + params?: + | ContentAndApprovalsListInstancePageOptions + | ((error: Error | null, items: ContentAndApprovalsPage) => any), + callback?: (error: Error | null, items: ContentAndApprovalsPage) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; + + if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; + if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; + + const headers: any = {}; + + let operationVersion = version, + operationPromise = operationVersion.page({ + uri: instance._uri, + method: "get", + params: data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new ContentAndApprovalsPage( + operationVersion, + payload, + instance._solution + ) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + instance.each = instance._version.each; + instance.list = instance._version.list; + + instance.getPage = function getPage( + targetUrl: string, + callback?: (error: Error | null, items: ContentAndApprovalsPage) => any + ): Promise { + const operationPromise = instance._version._domain.twilio.request({ + method: "get", + uri: targetUrl, + }); + + let pagePromise = operationPromise.then( + (payload) => + new ContentAndApprovalsPage( + instance._version, + payload, + instance._solution + ) + ); + pagePromise = instance._version.setPromiseCallback(pagePromise, callback); + return pagePromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +interface ContentAndApprovalsPayload extends TwilioResponsePayload { + contents: ContentAndApprovalsResource[]; +} + +interface ContentAndApprovalsResource { + date_created: Date; + date_updated: Date; + sid: string; + account_sid: string; + friendly_name: string; + language: string; + variables: any; + types: any; + approval_requests: any; +} + +export class ContentAndApprovalsInstance { + constructor(protected _version: V2, payload: ContentAndApprovalsResource) { + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); + this.sid = payload.sid; + this.accountSid = payload.account_sid; + this.friendlyName = payload.friendly_name; + this.language = payload.language; + this.variables = payload.variables; + this.types = payload.types; + this.approvalRequests = payload.approval_requests; + } + + /** + * The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + */ + dateCreated: Date; + /** + * The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + */ + dateUpdated: Date; + /** + * The unique string that that we created to identify the Content resource. + */ + sid: string; + /** + * The SID of the [Account](https://www.twilio.com/docs/usage/api/account) that created Content resource. + */ + accountSid: string; + /** + * A string name used to describe the Content resource. Not visible to the end recipient. + */ + friendlyName: string; + /** + * Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in. + */ + language: string; + /** + * Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}. + */ + variables: any; + /** + * The [Content types](https://www.twilio.com/docs/content/content-types-overview) (e.g. twilio/text) for this Content resource. + */ + types: any; + /** + * The submitted information and approval request status of the Content resource. + */ + approvalRequests: any; + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + dateCreated: this.dateCreated, + dateUpdated: this.dateUpdated, + sid: this.sid, + accountSid: this.accountSid, + friendlyName: this.friendlyName, + language: this.language, + variables: this.variables, + types: this.types, + approvalRequests: this.approvalRequests, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export class ContentAndApprovalsPage extends Page< + V2, + ContentAndApprovalsPayload, + ContentAndApprovalsResource, + ContentAndApprovalsInstance +> { + /** + * Initialize the ContentAndApprovalsPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor( + version: V2, + response: Response, + solution: ContentAndApprovalsSolution + ) { + super(version, response, solution); + } + + /** + * Build an instance of ContentAndApprovalsInstance + * + * @param payload - Payload response from the API + */ + getInstance( + payload: ContentAndApprovalsResource + ): ContentAndApprovalsInstance { + return new ContentAndApprovalsInstance(this._version, payload); + } + + [inspect.custom](depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/flexApi/v1/interaction.ts b/src/rest/flexApi/v1/interaction.ts index fa11cff61a..797a21f953 100644 --- a/src/rest/flexApi/v1/interaction.ts +++ b/src/rest/flexApi/v1/interaction.ts @@ -26,7 +26,7 @@ export interface InteractionListInstanceCreateOptions { /** The Interaction\\\'s channel. */ channel: any; /** The Interaction\\\'s routing logic. */ - routing: any; + routing?: any; /** The Interaction context sid is used for adding a context lookup sid */ interactionContextSid?: string; } @@ -265,15 +265,11 @@ export function InteractionListInstance(version: V1): InteractionListInstance { throw new Error("Required parameter \"params['channel']\" missing."); } - if (params["routing"] === null || params["routing"] === undefined) { - throw new Error("Required parameter \"params['routing']\" missing."); - } - let data: any = {}; data["Channel"] = serialize.object(params["channel"]); - - data["Routing"] = serialize.object(params["routing"]); + if (params["routing"] !== undefined) + data["Routing"] = serialize.object(params["routing"]); if (params["interactionContextSid"] !== undefined) data["InteractionContextSid"] = params["interactionContextSid"]; diff --git a/src/rest/flexApi/v1/plugin/pluginVersions.ts b/src/rest/flexApi/v1/plugin/pluginVersions.ts index 38c37a5198..ad1fa1a8af 100644 --- a/src/rest/flexApi/v1/plugin/pluginVersions.ts +++ b/src/rest/flexApi/v1/plugin/pluginVersions.ts @@ -217,6 +217,7 @@ interface PluginVersionsResource { changelog: string; private: boolean; archived: boolean; + validated: boolean; date_created: Date; url: string; } @@ -239,6 +240,7 @@ export class PluginVersionsInstance { this.changelog = payload.changelog; this._private = payload.private; this.archived = payload.archived; + this.validated = payload.validated; this.dateCreated = deserialize.iso8601DateTime(payload.date_created); this.url = payload.url; @@ -270,13 +272,14 @@ export class PluginVersionsInstance { */ changelog: string; /** - * Whether to inject credentials while accessing this Plugin Version. The default value is false. + * Whether the Flex Plugin Version is validated. The default value is false. */ _private: boolean; /** * Whether the Flex Plugin Version is archived. The default value is false. */ archived: boolean; + validated: boolean; /** * The date and time in GMT when the Flex Plugin Version was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ @@ -342,6 +345,7 @@ export class PluginVersionsInstance { changelog: this.changelog, _private: this._private, archived: this.archived, + validated: this.validated, dateCreated: this.dateCreated, url: this.url, }; diff --git a/src/rest/intelligence/V2.ts b/src/rest/intelligence/V2.ts index b826266df9..3b7c033ae6 100644 --- a/src/rest/intelligence/V2.ts +++ b/src/rest/intelligence/V2.ts @@ -14,6 +14,12 @@ import IntelligenceBase from "../IntelligenceBase"; import Version from "../../base/Version"; +import { CustomOperatorListInstance } from "./v2/customOperator"; +import { OperatorListInstance } from "./v2/operator"; +import { OperatorAttachmentListInstance } from "./v2/operatorAttachment"; +import { OperatorAttachmentsListInstance } from "./v2/operatorAttachments"; +import { OperatorTypeListInstance } from "./v2/operatorType"; +import { PrebuiltOperatorListInstance } from "./v2/prebuiltOperator"; import { ServiceListInstance } from "./v2/service"; import { TranscriptListInstance } from "./v2/transcript"; @@ -27,11 +33,63 @@ export default class V2 extends Version { super(domain, "v2"); } + /** customOperators - { Twilio.Intelligence.V2.CustomOperatorListInstance } resource */ + protected _customOperators?: CustomOperatorListInstance; + /** operators - { Twilio.Intelligence.V2.OperatorListInstance } resource */ + protected _operators?: OperatorListInstance; + /** operatorAttachment - { Twilio.Intelligence.V2.OperatorAttachmentListInstance } resource */ + protected _operatorAttachment?: OperatorAttachmentListInstance; + /** operatorAttachments - { Twilio.Intelligence.V2.OperatorAttachmentsListInstance } resource */ + protected _operatorAttachments?: OperatorAttachmentsListInstance; + /** operatorType - { Twilio.Intelligence.V2.OperatorTypeListInstance } resource */ + protected _operatorType?: OperatorTypeListInstance; + /** prebuiltOperators - { Twilio.Intelligence.V2.PrebuiltOperatorListInstance } resource */ + protected _prebuiltOperators?: PrebuiltOperatorListInstance; /** services - { Twilio.Intelligence.V2.ServiceListInstance } resource */ protected _services?: ServiceListInstance; /** transcripts - { Twilio.Intelligence.V2.TranscriptListInstance } resource */ protected _transcripts?: TranscriptListInstance; + /** Getter for customOperators resource */ + get customOperators(): CustomOperatorListInstance { + this._customOperators = + this._customOperators || CustomOperatorListInstance(this); + return this._customOperators; + } + + /** Getter for operators resource */ + get operators(): OperatorListInstance { + this._operators = this._operators || OperatorListInstance(this); + return this._operators; + } + + /** Getter for operatorAttachment resource */ + get operatorAttachment(): OperatorAttachmentListInstance { + this._operatorAttachment = + this._operatorAttachment || OperatorAttachmentListInstance(this); + return this._operatorAttachment; + } + + /** Getter for operatorAttachments resource */ + get operatorAttachments(): OperatorAttachmentsListInstance { + this._operatorAttachments = + this._operatorAttachments || OperatorAttachmentsListInstance(this); + return this._operatorAttachments; + } + + /** Getter for operatorType resource */ + get operatorType(): OperatorTypeListInstance { + this._operatorType = this._operatorType || OperatorTypeListInstance(this); + return this._operatorType; + } + + /** Getter for prebuiltOperators resource */ + get prebuiltOperators(): PrebuiltOperatorListInstance { + this._prebuiltOperators = + this._prebuiltOperators || PrebuiltOperatorListInstance(this); + return this._prebuiltOperators; + } + /** Getter for services resource */ get services(): ServiceListInstance { this._services = this._services || ServiceListInstance(this); diff --git a/src/rest/intelligence/v2/customOperator.ts b/src/rest/intelligence/v2/customOperator.ts new file mode 100644 index 0000000000..bc11812bc1 --- /dev/null +++ b/src/rest/intelligence/v2/customOperator.ts @@ -0,0 +1,731 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Intelligence + * 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 Page, { TwilioResponsePayload } from "../../../base/Page"; +import Response from "../../../http/response"; +import V2 from "../V2"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +export type CustomOperatorAvailability = + | "internal" + | "beta" + | "public" + | "retired"; + +/** + * Options to pass to update a CustomOperatorInstance + */ +export interface CustomOperatorContextUpdateOptions { + /** A human-readable name of this resource, up to 64 characters. */ + friendlyName: string; + /** Operator configuration, following the schema defined by the Operator Type. */ + config: any; + /** The If-Match HTTP request header */ + ifMatch?: string; +} + +/** + * Options to pass to create a CustomOperatorInstance + */ +export interface CustomOperatorListInstanceCreateOptions { + /** A human readable description of the new Operator, up to 64 characters. */ + friendlyName: string; + /** Operator Type for this Operator. References an existing Operator Type resource. */ + operatorType: string; + /** Operator configuration, following the schema defined by the Operator Type. */ + config: any; +} +/** + * Options to pass to each + */ +export interface CustomOperatorListInstanceEachOptions { + /** Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: CustomOperatorAvailability; + /** Returns Custom Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Function to process each record. If this and a positional callback are passed, this one will be used */ + callback?: ( + item: CustomOperatorInstance, + done: (err?: Error) => void + ) => void; + /** Function to be called upon completion of streaming */ + done?: Function; + /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to list + */ +export interface CustomOperatorListInstanceOptions { + /** Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: CustomOperatorAvailability; + /** Returns Custom Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to page + */ +export interface CustomOperatorListInstancePageOptions { + /** Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: CustomOperatorAvailability; + /** Returns Custom Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Page Number, this value is simply for client state */ + pageNumber?: number; + /** PageToken provided by the API */ + pageToken?: string; +} + +export interface CustomOperatorContext { + /** + * Remove a CustomOperatorInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + + /** + * Fetch a CustomOperatorInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed CustomOperatorInstance + */ + fetch( + callback?: (error: Error | null, item?: CustomOperatorInstance) => any + ): Promise; + + /** + * Update a CustomOperatorInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed CustomOperatorInstance + */ + update( + params: CustomOperatorContextUpdateOptions, + callback?: (error: Error | null, item?: CustomOperatorInstance) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface CustomOperatorContextSolution { + sid: string; +} + +export class CustomOperatorContextImpl implements CustomOperatorContext { + protected _solution: CustomOperatorContextSolution; + protected _uri: string; + + constructor(protected _version: V2, sid: string) { + if (!isValidPathParam(sid)) { + throw new Error("Parameter 'sid' is not valid."); + } + + this._solution = { sid }; + this._uri = `/Operators/Custom/${sid}`; + } + + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.remove({ + uri: instance._uri, + method: "delete", + }); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + + fetch( + callback?: (error: Error | null, item?: CustomOperatorInstance) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + }); + + operationPromise = operationPromise.then( + (payload) => + new CustomOperatorInstance( + operationVersion, + payload, + instance._solution.sid + ) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + + update( + params: CustomOperatorContextUpdateOptions, + callback?: (error: Error | null, item?: CustomOperatorInstance) => any + ): Promise { + if (params === null || params === undefined) { + throw new Error('Required parameter "params" missing.'); + } + + if ( + params["friendlyName"] === null || + params["friendlyName"] === undefined + ) { + throw new Error("Required parameter \"params['friendlyName']\" missing."); + } + + if (params["config"] === null || params["config"] === undefined) { + throw new Error("Required parameter \"params['config']\" missing."); + } + + let data: any = {}; + + data["FriendlyName"] = params["friendlyName"]; + + data["Config"] = serialize.object(params["config"]); + + const headers: any = {}; + headers["Content-Type"] = "application/x-www-form-urlencoded"; + if (params["ifMatch"] !== undefined) + headers["If-Match"] = params["ifMatch"]; + + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.update({ + uri: instance._uri, + method: "post", + data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new CustomOperatorInstance( + operationVersion, + payload, + instance._solution.sid + ) + ); + + 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 CustomOperatorPayload extends TwilioResponsePayload { + operators: CustomOperatorResource[]; +} + +interface CustomOperatorResource { + account_sid: string; + sid: string; + friendly_name: string; + description: string; + author: string; + operator_type: string; + version: number; + availability: CustomOperatorAvailability; + config: any; + date_created: Date; + date_updated: Date; + url: string; +} + +export class CustomOperatorInstance { + protected _solution: CustomOperatorContextSolution; + protected _context?: CustomOperatorContext; + + constructor( + protected _version: V2, + payload: CustomOperatorResource, + sid?: string + ) { + this.accountSid = payload.account_sid; + this.sid = payload.sid; + this.friendlyName = payload.friendly_name; + this.description = payload.description; + this.author = payload.author; + this.operatorType = payload.operator_type; + this.version = deserialize.integer(payload.version); + this.availability = payload.availability; + this.config = payload.config; + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); + this.url = payload.url; + + this._solution = { sid: sid || this.sid }; + } + + /** + * The unique SID identifier of the Account the Custom Operator belongs to. + */ + accountSid: string; + /** + * A 34 character string that uniquely identifies this Custom Operator. + */ + sid: string; + /** + * A human-readable name of this resource, up to 64 characters. + */ + friendlyName: string; + /** + * A human-readable description of this resource, longer than the friendly name. + */ + description: string; + /** + * The creator of the Custom Operator. Custom Operators can only be created by a Twilio Account. + */ + author: string; + /** + * Operator Type for this Operator. References an existing Operator Type resource. + */ + operatorType: string; + /** + * Numeric Custom Operator version. Incremented with each update on the resource, used to ensure integrity when updating the Custom Operator. + */ + version: number; + availability: CustomOperatorAvailability; + /** + * Operator configuration, following the schema defined by the Operator Type. Only available on Operators created by the Account. + */ + config: any; + /** + * The date that this Custom Operator was created, given in ISO 8601 format. + */ + dateCreated: Date; + /** + * The date that this Custom Operator was updated, given in ISO 8601 format. + */ + dateUpdated: Date; + /** + * The URL of this resource. + */ + url: string; + + private get _proxy(): CustomOperatorContext { + this._context = + this._context || + new CustomOperatorContextImpl(this._version, this._solution.sid); + return this._context; + } + + /** + * Remove a CustomOperatorInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + return this._proxy.remove(callback); + } + + /** + * Fetch a CustomOperatorInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed CustomOperatorInstance + */ + fetch( + callback?: (error: Error | null, item?: CustomOperatorInstance) => any + ): Promise { + return this._proxy.fetch(callback); + } + + /** + * Update a CustomOperatorInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed CustomOperatorInstance + */ + update( + params: CustomOperatorContextUpdateOptions, + callback?: (error: Error | null, item?: CustomOperatorInstance) => any + ): Promise; + + update( + params?: any, + callback?: (error: Error | null, item?: CustomOperatorInstance) => any + ): Promise { + return this._proxy.update(params, callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + accountSid: this.accountSid, + sid: this.sid, + friendlyName: this.friendlyName, + description: this.description, + author: this.author, + operatorType: this.operatorType, + version: this.version, + availability: this.availability, + config: this.config, + dateCreated: this.dateCreated, + dateUpdated: this.dateUpdated, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export interface CustomOperatorSolution {} + +export interface CustomOperatorListInstance { + _version: V2; + _solution: CustomOperatorSolution; + _uri: string; + + (sid: string): CustomOperatorContext; + get(sid: string): CustomOperatorContext; + + /** + * Create a CustomOperatorInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed CustomOperatorInstance + */ + create( + params: CustomOperatorListInstanceCreateOptions, + callback?: (error: Error | null, item?: CustomOperatorInstance) => any + ): Promise; + + /** + * Streams CustomOperatorInstance 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 { CustomOperatorListInstanceEachOptions } [params] - Options for request + * @param { function } [callback] - Function to process each record + */ + each( + callback?: ( + item: CustomOperatorInstance, + done: (err?: Error) => void + ) => void + ): void; + each( + params: CustomOperatorListInstanceEachOptions, + callback?: ( + item: CustomOperatorInstance, + done: (err?: Error) => void + ) => void + ): void; + /** + * Retrieve a single target page of CustomOperatorInstance records from the API. + * + * The request is executed immediately. + * + * @param { string } [targetUrl] - API-generated URL for the requested results page + * @param { function } [callback] - Callback to handle list of records + */ + getPage( + targetUrl: string, + callback?: (error: Error | null, items: CustomOperatorPage) => any + ): Promise; + /** + * Lists CustomOperatorInstance 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 { CustomOperatorListInstanceOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + list( + callback?: (error: Error | null, items: CustomOperatorInstance[]) => any + ): Promise; + list( + params: CustomOperatorListInstanceOptions, + callback?: (error: Error | null, items: CustomOperatorInstance[]) => any + ): Promise; + /** + * Retrieve a single page of CustomOperatorInstance 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 { CustomOperatorListInstancePageOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + page( + callback?: (error: Error | null, items: CustomOperatorPage) => any + ): Promise; + page( + params: CustomOperatorListInstancePageOptions, + callback?: (error: Error | null, items: CustomOperatorPage) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function CustomOperatorListInstance( + version: V2 +): CustomOperatorListInstance { + const instance = ((sid) => instance.get(sid)) as CustomOperatorListInstance; + + instance.get = function get(sid): CustomOperatorContext { + return new CustomOperatorContextImpl(version, sid); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Operators/Custom`; + + instance.create = function create( + params: CustomOperatorListInstanceCreateOptions, + callback?: (error: Error | null, items: CustomOperatorInstance) => any + ): Promise { + if (params === null || params === undefined) { + throw new Error('Required parameter "params" missing.'); + } + + if ( + params["friendlyName"] === null || + params["friendlyName"] === undefined + ) { + throw new Error("Required parameter \"params['friendlyName']\" missing."); + } + + if ( + params["operatorType"] === null || + params["operatorType"] === undefined + ) { + throw new Error("Required parameter \"params['operatorType']\" missing."); + } + + if (params["config"] === null || params["config"] === undefined) { + throw new Error("Required parameter \"params['config']\" missing."); + } + + let data: any = {}; + + data["FriendlyName"] = params["friendlyName"]; + + data["OperatorType"] = params["operatorType"]; + + data["Config"] = serialize.object(params["config"]); + + const headers: any = {}; + headers["Content-Type"] = "application/x-www-form-urlencoded"; + + let operationVersion = version, + operationPromise = operationVersion.create({ + uri: instance._uri, + method: "post", + data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => new CustomOperatorInstance(operationVersion, payload) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + + instance.page = function page( + params?: + | CustomOperatorListInstancePageOptions + | ((error: Error | null, items: CustomOperatorPage) => any), + callback?: (error: Error | null, items: CustomOperatorPage) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + if (params["availability"] !== undefined) + data["Availability"] = params["availability"]; + if (params["languageCode"] !== undefined) + data["LanguageCode"] = params["languageCode"]; + if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; + + if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; + if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; + + const headers: any = {}; + + let operationVersion = version, + operationPromise = operationVersion.page({ + uri: instance._uri, + method: "get", + params: data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new CustomOperatorPage(operationVersion, payload, instance._solution) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + instance.each = instance._version.each; + instance.list = instance._version.list; + + instance.getPage = function getPage( + targetUrl: string, + callback?: (error: Error | null, items: CustomOperatorPage) => any + ): Promise { + const operationPromise = instance._version._domain.twilio.request({ + method: "get", + uri: targetUrl, + }); + + let pagePromise = operationPromise.then( + (payload) => + new CustomOperatorPage(instance._version, payload, instance._solution) + ); + pagePromise = instance._version.setPromiseCallback(pagePromise, callback); + return pagePromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +export class CustomOperatorPage extends Page< + V2, + CustomOperatorPayload, + CustomOperatorResource, + CustomOperatorInstance +> { + /** + * Initialize the CustomOperatorPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor( + version: V2, + response: Response, + solution: CustomOperatorSolution + ) { + super(version, response, solution); + } + + /** + * Build an instance of CustomOperatorInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: CustomOperatorResource): CustomOperatorInstance { + return new CustomOperatorInstance(this._version, payload); + } + + [inspect.custom](depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/intelligence/v2/operator.ts b/src/rest/intelligence/v2/operator.ts new file mode 100644 index 0000000000..2a221d5cc6 --- /dev/null +++ b/src/rest/intelligence/v2/operator.ts @@ -0,0 +1,487 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Intelligence + * 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 Page, { TwilioResponsePayload } from "../../../base/Page"; +import Response from "../../../http/response"; +import V2 from "../V2"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +export type OperatorAvailability = "internal" | "beta" | "public" | "retired"; + +/** + * Options to pass to each + */ +export interface OperatorListInstanceEachOptions { + /** Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: OperatorAvailability; + /** Returns Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Function to process each record. If this and a positional callback are passed, this one will be used */ + callback?: (item: OperatorInstance, done: (err?: Error) => void) => void; + /** Function to be called upon completion of streaming */ + done?: Function; + /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to list + */ +export interface OperatorListInstanceOptions { + /** Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: OperatorAvailability; + /** Returns Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to page + */ +export interface OperatorListInstancePageOptions { + /** Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: OperatorAvailability; + /** Returns Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Page Number, this value is simply for client state */ + pageNumber?: number; + /** PageToken provided by the API */ + pageToken?: string; +} + +export interface OperatorContext { + /** + * Fetch a OperatorInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed OperatorInstance + */ + fetch( + callback?: (error: Error | null, item?: OperatorInstance) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface OperatorContextSolution { + sid: string; +} + +export class OperatorContextImpl implements OperatorContext { + protected _solution: OperatorContextSolution; + protected _uri: string; + + constructor(protected _version: V2, sid: string) { + if (!isValidPathParam(sid)) { + throw new Error("Parameter 'sid' is not valid."); + } + + this._solution = { sid }; + this._uri = `/Operators/${sid}`; + } + + fetch( + callback?: (error: Error | null, item?: OperatorInstance) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + }); + + operationPromise = operationPromise.then( + (payload) => + new OperatorInstance(operationVersion, payload, instance._solution.sid) + ); + + 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 OperatorPayload extends TwilioResponsePayload { + operators: OperatorResource[]; +} + +interface OperatorResource { + account_sid: string; + sid: string; + friendly_name: string; + description: string; + author: string; + operator_type: string; + version: number; + availability: OperatorAvailability; + config: any; + date_created: Date; + date_updated: Date; + url: string; +} + +export class OperatorInstance { + protected _solution: OperatorContextSolution; + protected _context?: OperatorContext; + + constructor(protected _version: V2, payload: OperatorResource, sid?: string) { + this.accountSid = payload.account_sid; + this.sid = payload.sid; + this.friendlyName = payload.friendly_name; + this.description = payload.description; + this.author = payload.author; + this.operatorType = payload.operator_type; + this.version = deserialize.integer(payload.version); + this.availability = payload.availability; + this.config = payload.config; + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); + this.url = payload.url; + + this._solution = { sid: sid || this.sid }; + } + + /** + * The unique SID identifier of the Account the Operator belongs to. + */ + accountSid: string; + /** + * A 34 character string that uniquely identifies this Operator. + */ + sid: string; + /** + * A human-readable name of this resource, up to 64 characters. + */ + friendlyName: string; + /** + * A human-readable description of this resource, longer than the friendly name. + */ + description: string; + /** + * The creator of the Operator. Either Twilio or the creating Account. + */ + author: string; + /** + * Operator Type for this Operator. References an existing Operator Type resource. + */ + operatorType: string; + /** + * Numeric Operator version. Incremented with each update on the resource, used to ensure integrity when updating the Operator. + */ + version: number; + availability: OperatorAvailability; + /** + * Operator configuration, following the schema defined by the Operator Type. Only available on Custom Operators created by the Account. + */ + config: any; + /** + * The date that this Operator was created, given in ISO 8601 format. + */ + dateCreated: Date; + /** + * The date that this Operator was updated, given in ISO 8601 format. + */ + dateUpdated: Date; + /** + * The URL of this resource. + */ + url: string; + + private get _proxy(): OperatorContext { + this._context = + this._context || + new OperatorContextImpl(this._version, this._solution.sid); + return this._context; + } + + /** + * Fetch a OperatorInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed OperatorInstance + */ + fetch( + callback?: (error: Error | null, item?: OperatorInstance) => any + ): Promise { + return this._proxy.fetch(callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + accountSid: this.accountSid, + sid: this.sid, + friendlyName: this.friendlyName, + description: this.description, + author: this.author, + operatorType: this.operatorType, + version: this.version, + availability: this.availability, + config: this.config, + dateCreated: this.dateCreated, + dateUpdated: this.dateUpdated, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export interface OperatorSolution {} + +export interface OperatorListInstance { + _version: V2; + _solution: OperatorSolution; + _uri: string; + + (sid: string): OperatorContext; + get(sid: string): OperatorContext; + + /** + * Streams OperatorInstance 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 { OperatorListInstanceEachOptions } [params] - Options for request + * @param { function } [callback] - Function to process each record + */ + each( + callback?: (item: OperatorInstance, done: (err?: Error) => void) => void + ): void; + each( + params: OperatorListInstanceEachOptions, + callback?: (item: OperatorInstance, done: (err?: Error) => void) => void + ): void; + /** + * Retrieve a single target page of OperatorInstance records from the API. + * + * The request is executed immediately. + * + * @param { string } [targetUrl] - API-generated URL for the requested results page + * @param { function } [callback] - Callback to handle list of records + */ + getPage( + targetUrl: string, + callback?: (error: Error | null, items: OperatorPage) => any + ): Promise; + /** + * Lists OperatorInstance 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 { OperatorListInstanceOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + list( + callback?: (error: Error | null, items: OperatorInstance[]) => any + ): Promise; + list( + params: OperatorListInstanceOptions, + callback?: (error: Error | null, items: OperatorInstance[]) => any + ): Promise; + /** + * Retrieve a single page of OperatorInstance 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 { OperatorListInstancePageOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + page( + callback?: (error: Error | null, items: OperatorPage) => any + ): Promise; + page( + params: OperatorListInstancePageOptions, + callback?: (error: Error | null, items: OperatorPage) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function OperatorListInstance(version: V2): OperatorListInstance { + const instance = ((sid) => instance.get(sid)) as OperatorListInstance; + + instance.get = function get(sid): OperatorContext { + return new OperatorContextImpl(version, sid); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Operators`; + + instance.page = function page( + params?: + | OperatorListInstancePageOptions + | ((error: Error | null, items: OperatorPage) => any), + callback?: (error: Error | null, items: OperatorPage) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + if (params["availability"] !== undefined) + data["Availability"] = params["availability"]; + if (params["languageCode"] !== undefined) + data["LanguageCode"] = params["languageCode"]; + if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; + + if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; + if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; + + const headers: any = {}; + + let operationVersion = version, + operationPromise = operationVersion.page({ + uri: instance._uri, + method: "get", + params: data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new OperatorPage(operationVersion, payload, instance._solution) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + instance.each = instance._version.each; + instance.list = instance._version.list; + + instance.getPage = function getPage( + targetUrl: string, + callback?: (error: Error | null, items: OperatorPage) => any + ): Promise { + const operationPromise = instance._version._domain.twilio.request({ + method: "get", + uri: targetUrl, + }); + + let pagePromise = operationPromise.then( + (payload) => + new OperatorPage(instance._version, payload, instance._solution) + ); + pagePromise = instance._version.setPromiseCallback(pagePromise, callback); + return pagePromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +export class OperatorPage extends Page< + V2, + OperatorPayload, + OperatorResource, + OperatorInstance +> { + /** + * Initialize the OperatorPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor( + version: V2, + response: Response, + solution: OperatorSolution + ) { + super(version, response, solution); + } + + /** + * Build an instance of OperatorInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: OperatorResource): OperatorInstance { + return new OperatorInstance(this._version, payload); + } + + [inspect.custom](depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/intelligence/v2/operatorAttachment.ts b/src/rest/intelligence/v2/operatorAttachment.ts new file mode 100644 index 0000000000..09d27622b9 --- /dev/null +++ b/src/rest/intelligence/v2/operatorAttachment.ts @@ -0,0 +1,275 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Intelligence + * 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 V2 from "../V2"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +export interface OperatorAttachmentContext { + /** + * Create a OperatorAttachmentInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed OperatorAttachmentInstance + */ + create( + callback?: (error: Error | null, item?: OperatorAttachmentInstance) => any + ): Promise; + + /** + * Remove a OperatorAttachmentInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface OperatorAttachmentContextSolution { + serviceSid: string; + operatorSid: string; +} + +export class OperatorAttachmentContextImpl + implements OperatorAttachmentContext +{ + protected _solution: OperatorAttachmentContextSolution; + protected _uri: string; + + constructor(protected _version: V2, serviceSid: string, operatorSid: string) { + if (!isValidPathParam(serviceSid)) { + throw new Error("Parameter 'serviceSid' is not valid."); + } + + if (!isValidPathParam(operatorSid)) { + throw new Error("Parameter 'operatorSid' is not valid."); + } + + this._solution = { serviceSid, operatorSid }; + this._uri = `/Services/${serviceSid}/Operators/${operatorSid}`; + } + + create( + callback?: (error: Error | null, item?: OperatorAttachmentInstance) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.create({ + uri: instance._uri, + method: "post", + }); + + operationPromise = operationPromise.then( + (payload) => + new OperatorAttachmentInstance( + operationVersion, + payload, + instance._solution.serviceSid, + instance._solution.operatorSid + ) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.remove({ + uri: instance._uri, + method: "delete", + }); + + 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 OperatorAttachmentPayload extends OperatorAttachmentResource {} + +interface OperatorAttachmentResource { + service_sid: string; + operator_sid: string; + url: string; +} + +export class OperatorAttachmentInstance { + protected _solution: OperatorAttachmentContextSolution; + protected _context?: OperatorAttachmentContext; + + constructor( + protected _version: V2, + payload: OperatorAttachmentResource, + serviceSid?: string, + operatorSid?: string + ) { + this.serviceSid = payload.service_sid; + this.operatorSid = payload.operator_sid; + this.url = payload.url; + + this._solution = { + serviceSid: serviceSid || this.serviceSid, + operatorSid: operatorSid || this.operatorSid, + }; + } + + /** + * The unique SID identifier of the Service. + */ + serviceSid: string; + /** + * The unique SID identifier of the Operator. + */ + operatorSid: string; + /** + * The URL of this resource. + */ + url: string; + + private get _proxy(): OperatorAttachmentContext { + this._context = + this._context || + new OperatorAttachmentContextImpl( + this._version, + this._solution.serviceSid, + this._solution.operatorSid + ); + return this._context; + } + + /** + * Create a OperatorAttachmentInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed OperatorAttachmentInstance + */ + create( + callback?: (error: Error | null, item?: OperatorAttachmentInstance) => any + ): Promise { + return this._proxy.create(callback); + } + + /** + * Remove a OperatorAttachmentInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + return this._proxy.remove(callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + serviceSid: this.serviceSid, + operatorSid: this.operatorSid, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export interface OperatorAttachmentSolution {} + +export interface OperatorAttachmentListInstance { + _version: V2; + _solution: OperatorAttachmentSolution; + _uri: string; + + (serviceSid: string, operatorSid: string): OperatorAttachmentContext; + get(serviceSid: string, operatorSid: string): OperatorAttachmentContext; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function OperatorAttachmentListInstance( + version: V2 +): OperatorAttachmentListInstance { + const instance = ((serviceSid, operatorSid) => + instance.get(serviceSid, operatorSid)) as OperatorAttachmentListInstance; + + instance.get = function get( + serviceSid, + operatorSid + ): OperatorAttachmentContext { + return new OperatorAttachmentContextImpl(version, serviceSid, operatorSid); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = ``; + + 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/src/rest/intelligence/v2/operatorAttachments.ts b/src/rest/intelligence/v2/operatorAttachments.ts new file mode 100644 index 0000000000..d96afeca3c --- /dev/null +++ b/src/rest/intelligence/v2/operatorAttachments.ts @@ -0,0 +1,220 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Intelligence + * 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 V2 from "../V2"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +export interface OperatorAttachmentsContext { + /** + * Fetch a OperatorAttachmentsInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed OperatorAttachmentsInstance + */ + fetch( + callback?: (error: Error | null, item?: OperatorAttachmentsInstance) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface OperatorAttachmentsContextSolution { + serviceSid: string; +} + +export class OperatorAttachmentsContextImpl + implements OperatorAttachmentsContext +{ + protected _solution: OperatorAttachmentsContextSolution; + protected _uri: string; + + constructor(protected _version: V2, serviceSid: string) { + if (!isValidPathParam(serviceSid)) { + throw new Error("Parameter 'serviceSid' is not valid."); + } + + this._solution = { serviceSid }; + this._uri = `/Services/${serviceSid}/Operators`; + } + + fetch( + callback?: (error: Error | null, item?: OperatorAttachmentsInstance) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + }); + + operationPromise = operationPromise.then( + (payload) => + new OperatorAttachmentsInstance( + operationVersion, + payload, + instance._solution.serviceSid + ) + ); + + 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 OperatorAttachmentsPayload extends OperatorAttachmentsResource {} + +interface OperatorAttachmentsResource { + service_sid: string; + operator_sids: Array; + url: string; +} + +export class OperatorAttachmentsInstance { + protected _solution: OperatorAttachmentsContextSolution; + protected _context?: OperatorAttachmentsContext; + + constructor( + protected _version: V2, + payload: OperatorAttachmentsResource, + serviceSid?: string + ) { + this.serviceSid = payload.service_sid; + this.operatorSids = payload.operator_sids; + this.url = payload.url; + + this._solution = { serviceSid: serviceSid || this.serviceSid }; + } + + /** + * The unique SID identifier of the Service. + */ + serviceSid: string; + /** + * List of Operator SIDs attached to the service. Includes both Custom and Pre-built Operators. + */ + operatorSids: Array; + /** + * The URL of this resource. + */ + url: string; + + private get _proxy(): OperatorAttachmentsContext { + this._context = + this._context || + new OperatorAttachmentsContextImpl( + this._version, + this._solution.serviceSid + ); + return this._context; + } + + /** + * Fetch a OperatorAttachmentsInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed OperatorAttachmentsInstance + */ + fetch( + callback?: (error: Error | null, item?: OperatorAttachmentsInstance) => any + ): Promise { + return this._proxy.fetch(callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + serviceSid: this.serviceSid, + operatorSids: this.operatorSids, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export interface OperatorAttachmentsSolution {} + +export interface OperatorAttachmentsListInstance { + _version: V2; + _solution: OperatorAttachmentsSolution; + _uri: string; + + (serviceSid: string): OperatorAttachmentsContext; + get(serviceSid: string): OperatorAttachmentsContext; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function OperatorAttachmentsListInstance( + version: V2 +): OperatorAttachmentsListInstance { + const instance = ((serviceSid) => + instance.get(serviceSid)) as OperatorAttachmentsListInstance; + + instance.get = function get(serviceSid): OperatorAttachmentsContext { + return new OperatorAttachmentsContextImpl(version, serviceSid); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = ``; + + 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/src/rest/intelligence/v2/operatorType.ts b/src/rest/intelligence/v2/operatorType.ts new file mode 100644 index 0000000000..e96e8e42a0 --- /dev/null +++ b/src/rest/intelligence/v2/operatorType.ts @@ -0,0 +1,501 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Intelligence + * 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 Page, { TwilioResponsePayload } from "../../../base/Page"; +import Response from "../../../http/response"; +import V2 from "../V2"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +export type OperatorTypeAvailability = + | "internal" + | "beta" + | "public" + | "retired"; + +export type OperatorTypeOutputType = + | "text-classification" + | "text-extraction" + | "text-extraction-normalized" + | "text-generation"; + +export type OperatorTypeProvider = "twilio" | "amazon" | "openai"; + +/** + * Options to pass to each + */ +export interface OperatorTypeListInstanceEachOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Function to process each record. If this and a positional callback are passed, this one will be used */ + callback?: (item: OperatorTypeInstance, done: (err?: Error) => void) => void; + /** Function to be called upon completion of streaming */ + done?: Function; + /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to list + */ +export interface OperatorTypeListInstanceOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to page + */ +export interface OperatorTypeListInstancePageOptions { + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Page Number, this value is simply for client state */ + pageNumber?: number; + /** PageToken provided by the API */ + pageToken?: string; +} + +export interface OperatorTypeContext { + /** + * Fetch a OperatorTypeInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed OperatorTypeInstance + */ + fetch( + callback?: (error: Error | null, item?: OperatorTypeInstance) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface OperatorTypeContextSolution { + sid: string; +} + +export class OperatorTypeContextImpl implements OperatorTypeContext { + protected _solution: OperatorTypeContextSolution; + protected _uri: string; + + constructor(protected _version: V2, sid: string) { + if (!isValidPathParam(sid)) { + throw new Error("Parameter 'sid' is not valid."); + } + + this._solution = { sid }; + this._uri = `/OperatorTypes/${sid}`; + } + + fetch( + callback?: (error: Error | null, item?: OperatorTypeInstance) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + }); + + operationPromise = operationPromise.then( + (payload) => + new OperatorTypeInstance( + operationVersion, + payload, + instance._solution.sid + ) + ); + + 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 OperatorTypePayload extends TwilioResponsePayload { + operator_types: OperatorTypeResource[]; +} + +interface OperatorTypeResource { + name: string; + sid: string; + friendly_name: string; + description: string; + docs_link: string; + output_type: OperatorTypeOutputType; + supported_languages: Array; + provider: OperatorTypeProvider; + availability: OperatorTypeAvailability; + configurable: boolean; + config_schema: any; + date_created: Date; + date_updated: Date; + url: string; +} + +export class OperatorTypeInstance { + protected _solution: OperatorTypeContextSolution; + protected _context?: OperatorTypeContext; + + constructor( + protected _version: V2, + payload: OperatorTypeResource, + sid?: string + ) { + this.name = payload.name; + this.sid = payload.sid; + this.friendlyName = payload.friendly_name; + this.description = payload.description; + this.docsLink = payload.docs_link; + this.outputType = payload.output_type; + this.supportedLanguages = payload.supported_languages; + this.provider = payload.provider; + this.availability = payload.availability; + this.configurable = payload.configurable; + this.configSchema = payload.config_schema; + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); + this.url = payload.url; + + this._solution = { sid: sid || this.sid }; + } + + /** + * A unique name that references an Operator\'s Operator Type. + */ + name: string; + /** + * A 34 character string that uniquely identifies this Operator Type. + */ + sid: string; + /** + * A human-readable name of this resource, up to 64 characters. + */ + friendlyName: string; + /** + * A human-readable description of this resource, longer than the friendly name. + */ + description: string; + /** + * Additional documentation for the Operator Type. + */ + docsLink: string; + outputType: OperatorTypeOutputType; + /** + * List of languages this Operator Type supports. + */ + supportedLanguages: Array; + provider: OperatorTypeProvider; + availability: OperatorTypeAvailability; + /** + * Operators can be created from configurable Operator Types. + */ + configurable: boolean; + /** + * JSON Schema for configuring an Operator with this Operator Type. Following https://json-schema.org/ + */ + configSchema: any; + /** + * The date that this Operator Type was created, given in ISO 8601 format. + */ + dateCreated: Date; + /** + * The date that this Operator Type was updated, given in ISO 8601 format. + */ + dateUpdated: Date; + /** + * The URL of this resource. + */ + url: string; + + private get _proxy(): OperatorTypeContext { + this._context = + this._context || + new OperatorTypeContextImpl(this._version, this._solution.sid); + return this._context; + } + + /** + * Fetch a OperatorTypeInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed OperatorTypeInstance + */ + fetch( + callback?: (error: Error | null, item?: OperatorTypeInstance) => any + ): Promise { + return this._proxy.fetch(callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + name: this.name, + sid: this.sid, + friendlyName: this.friendlyName, + description: this.description, + docsLink: this.docsLink, + outputType: this.outputType, + supportedLanguages: this.supportedLanguages, + provider: this.provider, + availability: this.availability, + configurable: this.configurable, + configSchema: this.configSchema, + dateCreated: this.dateCreated, + dateUpdated: this.dateUpdated, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export interface OperatorTypeSolution {} + +export interface OperatorTypeListInstance { + _version: V2; + _solution: OperatorTypeSolution; + _uri: string; + + (sid: string): OperatorTypeContext; + get(sid: string): OperatorTypeContext; + + /** + * Streams OperatorTypeInstance 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 { OperatorTypeListInstanceEachOptions } [params] - Options for request + * @param { function } [callback] - Function to process each record + */ + each( + callback?: (item: OperatorTypeInstance, done: (err?: Error) => void) => void + ): void; + each( + params: OperatorTypeListInstanceEachOptions, + callback?: (item: OperatorTypeInstance, done: (err?: Error) => void) => void + ): void; + /** + * Retrieve a single target page of OperatorTypeInstance records from the API. + * + * The request is executed immediately. + * + * @param { string } [targetUrl] - API-generated URL for the requested results page + * @param { function } [callback] - Callback to handle list of records + */ + getPage( + targetUrl: string, + callback?: (error: Error | null, items: OperatorTypePage) => any + ): Promise; + /** + * Lists OperatorTypeInstance 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 { OperatorTypeListInstanceOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + list( + callback?: (error: Error | null, items: OperatorTypeInstance[]) => any + ): Promise; + list( + params: OperatorTypeListInstanceOptions, + callback?: (error: Error | null, items: OperatorTypeInstance[]) => any + ): Promise; + /** + * Retrieve a single page of OperatorTypeInstance 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 { OperatorTypeListInstancePageOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + page( + callback?: (error: Error | null, items: OperatorTypePage) => any + ): Promise; + page( + params: OperatorTypeListInstancePageOptions, + callback?: (error: Error | null, items: OperatorTypePage) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function OperatorTypeListInstance( + version: V2 +): OperatorTypeListInstance { + const instance = ((sid) => instance.get(sid)) as OperatorTypeListInstance; + + instance.get = function get(sid): OperatorTypeContext { + return new OperatorTypeContextImpl(version, sid); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = `/OperatorTypes`; + + instance.page = function page( + params?: + | OperatorTypeListInstancePageOptions + | ((error: Error | null, items: OperatorTypePage) => any), + callback?: (error: Error | null, items: OperatorTypePage) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; + + if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; + if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; + + const headers: any = {}; + + let operationVersion = version, + operationPromise = operationVersion.page({ + uri: instance._uri, + method: "get", + params: data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new OperatorTypePage(operationVersion, payload, instance._solution) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + instance.each = instance._version.each; + instance.list = instance._version.list; + + instance.getPage = function getPage( + targetUrl: string, + callback?: (error: Error | null, items: OperatorTypePage) => any + ): Promise { + const operationPromise = instance._version._domain.twilio.request({ + method: "get", + uri: targetUrl, + }); + + let pagePromise = operationPromise.then( + (payload) => + new OperatorTypePage(instance._version, payload, instance._solution) + ); + pagePromise = instance._version.setPromiseCallback(pagePromise, callback); + return pagePromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +export class OperatorTypePage extends Page< + V2, + OperatorTypePayload, + OperatorTypeResource, + OperatorTypeInstance +> { + /** + * Initialize the OperatorTypePage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor( + version: V2, + response: Response, + solution: OperatorTypeSolution + ) { + super(version, response, solution); + } + + /** + * Build an instance of OperatorTypeInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: OperatorTypeResource): OperatorTypeInstance { + return new OperatorTypeInstance(this._version, payload); + } + + [inspect.custom](depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/intelligence/v2/prebuiltOperator.ts b/src/rest/intelligence/v2/prebuiltOperator.ts new file mode 100644 index 0000000000..768e0f3559 --- /dev/null +++ b/src/rest/intelligence/v2/prebuiltOperator.ts @@ -0,0 +1,510 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Intelligence + * 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 Page, { TwilioResponsePayload } from "../../../base/Page"; +import Response from "../../../http/response"; +import V2 from "../V2"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +export type PrebuiltOperatorAvailability = + | "internal" + | "beta" + | "public" + | "retired"; + +/** + * Options to pass to each + */ +export interface PrebuiltOperatorListInstanceEachOptions { + /** Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: PrebuiltOperatorAvailability; + /** Returns Pre-built Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Function to process each record. If this and a positional callback are passed, this one will be used */ + callback?: ( + item: PrebuiltOperatorInstance, + done: (err?: Error) => void + ) => void; + /** Function to be called upon completion of streaming */ + done?: Function; + /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to list + */ +export interface PrebuiltOperatorListInstanceOptions { + /** Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: PrebuiltOperatorAvailability; + /** Returns Pre-built Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ + limit?: number; +} + +/** + * Options to pass to page + */ +export interface PrebuiltOperatorListInstancePageOptions { + /** Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. */ + availability?: PrebuiltOperatorAvailability; + /** Returns Pre-built Operators that support the provided language code. */ + languageCode?: string; + /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ + pageSize?: number; + /** Page Number, this value is simply for client state */ + pageNumber?: number; + /** PageToken provided by the API */ + pageToken?: string; +} + +export interface PrebuiltOperatorContext { + /** + * Fetch a PrebuiltOperatorInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PrebuiltOperatorInstance + */ + fetch( + callback?: (error: Error | null, item?: PrebuiltOperatorInstance) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface PrebuiltOperatorContextSolution { + sid: string; +} + +export class PrebuiltOperatorContextImpl implements PrebuiltOperatorContext { + protected _solution: PrebuiltOperatorContextSolution; + protected _uri: string; + + constructor(protected _version: V2, sid: string) { + if (!isValidPathParam(sid)) { + throw new Error("Parameter 'sid' is not valid."); + } + + this._solution = { sid }; + this._uri = `/Operators/PreBuilt/${sid}`; + } + + fetch( + callback?: (error: Error | null, item?: PrebuiltOperatorInstance) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + }); + + operationPromise = operationPromise.then( + (payload) => + new PrebuiltOperatorInstance( + operationVersion, + payload, + instance._solution.sid + ) + ); + + 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 PrebuiltOperatorPayload extends TwilioResponsePayload { + operators: PrebuiltOperatorResource[]; +} + +interface PrebuiltOperatorResource { + account_sid: string; + sid: string; + friendly_name: string; + description: string; + author: string; + operator_type: string; + version: number; + availability: PrebuiltOperatorAvailability; + config: any; + date_created: Date; + date_updated: Date; + url: string; +} + +export class PrebuiltOperatorInstance { + protected _solution: PrebuiltOperatorContextSolution; + protected _context?: PrebuiltOperatorContext; + + constructor( + protected _version: V2, + payload: PrebuiltOperatorResource, + sid?: string + ) { + this.accountSid = payload.account_sid; + this.sid = payload.sid; + this.friendlyName = payload.friendly_name; + this.description = payload.description; + this.author = payload.author; + this.operatorType = payload.operator_type; + this.version = deserialize.integer(payload.version); + this.availability = payload.availability; + this.config = payload.config; + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); + this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); + this.url = payload.url; + + this._solution = { sid: sid || this.sid }; + } + + /** + * The unique SID identifier of the Account the Pre-built Operator belongs to. + */ + accountSid: string; + /** + * A 34 character string that uniquely identifies this Pre-built Operator. + */ + sid: string; + /** + * A human-readable name of this resource, up to 64 characters. + */ + friendlyName: string; + /** + * A human-readable description of this resource, longer than the friendly name. + */ + description: string; + /** + * The creator of the Operator. Pre-built Operators can only be created by Twilio. + */ + author: string; + /** + * Operator Type for this Operator. References an existing Operator Type resource. + */ + operatorType: string; + /** + * Numeric Operator version. Incremented with each update on the resource, used to ensure integrity when updating the Operator. + */ + version: number; + availability: PrebuiltOperatorAvailability; + /** + * Operator configuration, following the schema defined by the Operator Type. Only available on Custom Operators created by the Account, will be empty for Pre-Built Operators. + */ + config: any; + /** + * The date that this Pre-built Operator was created, given in ISO 8601 format. + */ + dateCreated: Date; + /** + * The date that this Pre-built Operator was updated, given in ISO 8601 format. + */ + dateUpdated: Date; + /** + * The URL of this resource. + */ + url: string; + + private get _proxy(): PrebuiltOperatorContext { + this._context = + this._context || + new PrebuiltOperatorContextImpl(this._version, this._solution.sid); + return this._context; + } + + /** + * Fetch a PrebuiltOperatorInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PrebuiltOperatorInstance + */ + fetch( + callback?: (error: Error | null, item?: PrebuiltOperatorInstance) => any + ): Promise { + return this._proxy.fetch(callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + accountSid: this.accountSid, + sid: this.sid, + friendlyName: this.friendlyName, + description: this.description, + author: this.author, + operatorType: this.operatorType, + version: this.version, + availability: this.availability, + config: this.config, + dateCreated: this.dateCreated, + dateUpdated: this.dateUpdated, + url: this.url, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + +export interface PrebuiltOperatorSolution {} + +export interface PrebuiltOperatorListInstance { + _version: V2; + _solution: PrebuiltOperatorSolution; + _uri: string; + + (sid: string): PrebuiltOperatorContext; + get(sid: string): PrebuiltOperatorContext; + + /** + * Streams PrebuiltOperatorInstance 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 { PrebuiltOperatorListInstanceEachOptions } [params] - Options for request + * @param { function } [callback] - Function to process each record + */ + each( + callback?: ( + item: PrebuiltOperatorInstance, + done: (err?: Error) => void + ) => void + ): void; + each( + params: PrebuiltOperatorListInstanceEachOptions, + callback?: ( + item: PrebuiltOperatorInstance, + done: (err?: Error) => void + ) => void + ): void; + /** + * Retrieve a single target page of PrebuiltOperatorInstance records from the API. + * + * The request is executed immediately. + * + * @param { string } [targetUrl] - API-generated URL for the requested results page + * @param { function } [callback] - Callback to handle list of records + */ + getPage( + targetUrl: string, + callback?: (error: Error | null, items: PrebuiltOperatorPage) => any + ): Promise; + /** + * Lists PrebuiltOperatorInstance 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 { PrebuiltOperatorListInstanceOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + list( + callback?: (error: Error | null, items: PrebuiltOperatorInstance[]) => any + ): Promise; + list( + params: PrebuiltOperatorListInstanceOptions, + callback?: (error: Error | null, items: PrebuiltOperatorInstance[]) => any + ): Promise; + /** + * Retrieve a single page of PrebuiltOperatorInstance 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 { PrebuiltOperatorListInstancePageOptions } [params] - Options for request + * @param { function } [callback] - Callback to handle list of records + */ + page( + callback?: (error: Error | null, items: PrebuiltOperatorPage) => any + ): Promise; + page( + params: PrebuiltOperatorListInstancePageOptions, + callback?: (error: Error | null, items: PrebuiltOperatorPage) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function PrebuiltOperatorListInstance( + version: V2 +): PrebuiltOperatorListInstance { + const instance = ((sid) => instance.get(sid)) as PrebuiltOperatorListInstance; + + instance.get = function get(sid): PrebuiltOperatorContext { + return new PrebuiltOperatorContextImpl(version, sid); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Operators/PreBuilt`; + + instance.page = function page( + params?: + | PrebuiltOperatorListInstancePageOptions + | ((error: Error | null, items: PrebuiltOperatorPage) => any), + callback?: (error: Error | null, items: PrebuiltOperatorPage) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + if (params["availability"] !== undefined) + data["Availability"] = params["availability"]; + if (params["languageCode"] !== undefined) + data["LanguageCode"] = params["languageCode"]; + if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; + + if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; + if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; + + const headers: any = {}; + + let operationVersion = version, + operationPromise = operationVersion.page({ + uri: instance._uri, + method: "get", + params: data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new PrebuiltOperatorPage(operationVersion, payload, instance._solution) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + instance.each = instance._version.each; + instance.list = instance._version.list; + + instance.getPage = function getPage( + targetUrl: string, + callback?: (error: Error | null, items: PrebuiltOperatorPage) => any + ): Promise { + const operationPromise = instance._version._domain.twilio.request({ + method: "get", + uri: targetUrl, + }); + + let pagePromise = operationPromise.then( + (payload) => + new PrebuiltOperatorPage(instance._version, payload, instance._solution) + ); + pagePromise = instance._version.setPromiseCallback(pagePromise, callback); + return pagePromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +export class PrebuiltOperatorPage extends Page< + V2, + PrebuiltOperatorPayload, + PrebuiltOperatorResource, + PrebuiltOperatorInstance +> { + /** + * Initialize the PrebuiltOperatorPage + * + * @param version - Version of the resource + * @param response - Response from the API + * @param solution - Path solution + */ + constructor( + version: V2, + response: Response, + solution: PrebuiltOperatorSolution + ) { + super(version, response, solution); + } + + /** + * Build an instance of PrebuiltOperatorInstance + * + * @param payload - Payload response from the API + */ + getInstance(payload: PrebuiltOperatorResource): PrebuiltOperatorInstance { + return new PrebuiltOperatorInstance(this._version, payload); + } + + [inspect.custom](depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/intelligence/v2/service.ts b/src/rest/intelligence/v2/service.ts index bc937fc5f6..efa49a506f 100644 --- a/src/rest/intelligence/v2/service.ts +++ b/src/rest/intelligence/v2/service.ts @@ -34,8 +34,6 @@ export interface ServiceContextUpdateOptions { dataLogging?: boolean; /** A human readable description of this resource, up to 64 characters. */ friendlyName?: string; - /** The default language code of the audio. */ - languageCode?: string; /** Provides a unique and addressable name to be assigned to this Service, assigned by the developer, to be optionally used in addition to SID. */ uniqueName?: string; /** Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. */ @@ -60,7 +58,7 @@ export interface ServiceListInstanceCreateOptions { dataLogging?: boolean; /** A human readable description of this resource, up to 64 characters. */ friendlyName?: string; - /** The default language code of the audio. */ + /** The language code set during Service creation determines the Transcription language for all call recordings processed by that Service. The default is en-US if no language code is set. A Service can only support one language code, and it cannot be updated once it\\\'s set. */ languageCode?: string; /** Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. */ autoRedaction?: boolean; @@ -237,8 +235,6 @@ export class ServiceContextImpl implements ServiceContext { data["DataLogging"] = serialize.bool(params["dataLogging"]); if (params["friendlyName"] !== undefined) data["FriendlyName"] = params["friendlyName"]; - if (params["languageCode"] !== undefined) - data["LanguageCode"] = params["languageCode"]; if (params["uniqueName"] !== undefined) data["UniqueName"] = params["uniqueName"]; if (params["autoRedaction"] !== undefined) @@ -309,6 +305,7 @@ interface ServiceResource { url: string; webhook_url: string; webhook_http_method: ServiceHttpMethod; + read_only_attached_operator_sids: Array; version: number; } @@ -331,6 +328,8 @@ export class ServiceInstance { this.url = payload.url; this.webhookUrl = payload.webhook_url; this.webhookHttpMethod = payload.webhook_http_method; + this.readOnlyAttachedOperatorSids = + payload.read_only_attached_operator_sids; this.version = deserialize.integer(payload.version); this._solution = { sid: sid || this.sid }; @@ -369,7 +368,7 @@ export class ServiceInstance { */ friendlyName: string; /** - * The default language code of the audio. + * The language code set during Service creation determines the Transcription language for all call recordings processed by that Service. The default is en-US if no language code is set. A Service can only support one language code, and it cannot be updated once it\'s set. */ languageCode: string; /** @@ -389,6 +388,10 @@ export class ServiceInstance { */ webhookUrl: string; webhookHttpMethod: ServiceHttpMethod; + /** + * Operator sids attached to this service, read only + */ + readOnlyAttachedOperatorSids: Array; /** * The version number of this Service. */ @@ -478,6 +481,7 @@ export class ServiceInstance { url: this.url, webhookUrl: this.webhookUrl, webhookHttpMethod: this.webhookHttpMethod, + readOnlyAttachedOperatorSids: this.readOnlyAttachedOperatorSids, version: this.version, }; } diff --git a/src/rest/messaging/v1/service.ts b/src/rest/messaging/v1/service.ts index 60c7571700..f0addca520 100644 --- a/src/rest/messaging/v1/service.ts +++ b/src/rest/messaging/v1/service.ts @@ -421,7 +421,6 @@ interface ServiceResource { usecase: string; us_app_to_person_registered: boolean; use_inbound_webhook_on_number: boolean; - sending_windows: any; } export class ServiceInstance { @@ -452,7 +451,6 @@ export class ServiceInstance { this.usecase = payload.usecase; this.usAppToPersonRegistered = payload.us_app_to_person_registered; this.useInboundWebhookOnNumber = payload.use_inbound_webhook_on_number; - this.sendingWindows = payload.sending_windows; this._solution = { sid: sid || this.sid }; } @@ -546,10 +544,6 @@ export class ServiceInstance { * A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. */ useInboundWebhookOnNumber: boolean; - /** - * A list of Sending Windows, which indicate defined time ranges in which a message can be sent, in the UTC time zone. Each window is defined by two strings, labeled \"start_time\" and \"end_time\". - */ - sendingWindows: any; private get _proxy(): ServiceContext { this._context = @@ -686,7 +680,6 @@ export class ServiceInstance { usecase: this.usecase, usAppToPersonRegistered: this.usAppToPersonRegistered, useInboundWebhookOnNumber: this.useInboundWebhookOnNumber, - sendingWindows: this.sendingWindows, }; } diff --git a/src/rest/numbers/V1.ts b/src/rest/numbers/V1.ts index 3905e3878a..547dec9679 100644 --- a/src/rest/numbers/V1.ts +++ b/src/rest/numbers/V1.ts @@ -16,11 +16,12 @@ import NumbersBase from "../NumbersBase"; import Version from "../../base/Version"; import { BulkEligibilityListInstance } from "./v1/bulkEligibility"; import { EligibilityListInstance } from "./v1/eligibility"; -import { PortingBulkPortabilityListInstance } from "./v1/portingBulkPortability"; import { PortingPortInListInstance } from "./v1/portingPortIn"; -import { PortingPortInFetchListInstance } from "./v1/portingPortInFetch"; import { PortingPortInPhoneNumberListInstance } from "./v1/portingPortInPhoneNumber"; import { PortingPortabilityListInstance } from "./v1/portingPortability"; +import { PortingWebhookConfigurationListInstance } from "./v1/portingWebhookConfiguration"; +import { PortingWebhookConfigurationDeleteListInstance } from "./v1/portingWebhookConfigurationDelete"; +import { PortingWebhookConfigurationFetchListInstance } from "./v1/portingWebhookConfigurationFetch"; export default class V1 extends Version { /** @@ -36,16 +37,18 @@ export default class V1 extends Version { protected _bulkEligibilities?: BulkEligibilityListInstance; /** eligibilities - { Twilio.Numbers.V1.EligibilityListInstance } resource */ protected _eligibilities?: EligibilityListInstance; - /** portingBulkPortabilities - { Twilio.Numbers.V1.PortingBulkPortabilityListInstance } resource */ - protected _portingBulkPortabilities?: PortingBulkPortabilityListInstance; /** portingPortIns - { Twilio.Numbers.V1.PortingPortInListInstance } resource */ protected _portingPortIns?: PortingPortInListInstance; - /** portingPortInsFetch - { Twilio.Numbers.V1.PortingPortInFetchListInstance } resource */ - protected _portingPortInsFetch?: PortingPortInFetchListInstance; /** portingPortInPhoneNumber - { Twilio.Numbers.V1.PortingPortInPhoneNumberListInstance } resource */ protected _portingPortInPhoneNumber?: PortingPortInPhoneNumberListInstance; /** portingPortabilities - { Twilio.Numbers.V1.PortingPortabilityListInstance } resource */ protected _portingPortabilities?: PortingPortabilityListInstance; + /** portingWebhookConfigurations - { Twilio.Numbers.V1.PortingWebhookConfigurationListInstance } resource */ + protected _portingWebhookConfigurations?: PortingWebhookConfigurationListInstance; + /** portingWebhookConfigurationsDelete - { Twilio.Numbers.V1.PortingWebhookConfigurationDeleteListInstance } resource */ + protected _portingWebhookConfigurationsDelete?: PortingWebhookConfigurationDeleteListInstance; + /** portingWebhookConfigurationFetch - { Twilio.Numbers.V1.PortingWebhookConfigurationFetchListInstance } resource */ + protected _portingWebhookConfigurationFetch?: PortingWebhookConfigurationFetchListInstance; /** Getter for bulkEligibilities resource */ get bulkEligibilities(): BulkEligibilityListInstance { @@ -60,14 +63,6 @@ export default class V1 extends Version { return this._eligibilities; } - /** Getter for portingBulkPortabilities resource */ - get portingBulkPortabilities(): PortingBulkPortabilityListInstance { - this._portingBulkPortabilities = - this._portingBulkPortabilities || - PortingBulkPortabilityListInstance(this); - return this._portingBulkPortabilities; - } - /** Getter for portingPortIns resource */ get portingPortIns(): PortingPortInListInstance { this._portingPortIns = @@ -75,13 +70,6 @@ export default class V1 extends Version { return this._portingPortIns; } - /** Getter for portingPortInsFetch resource */ - get portingPortInsFetch(): PortingPortInFetchListInstance { - this._portingPortInsFetch = - this._portingPortInsFetch || PortingPortInFetchListInstance(this); - return this._portingPortInsFetch; - } - /** Getter for portingPortInPhoneNumber resource */ get portingPortInPhoneNumber(): PortingPortInPhoneNumberListInstance { this._portingPortInPhoneNumber = @@ -96,4 +84,28 @@ export default class V1 extends Version { this._portingPortabilities || PortingPortabilityListInstance(this); return this._portingPortabilities; } + + /** Getter for portingWebhookConfigurations resource */ + get portingWebhookConfigurations(): PortingWebhookConfigurationListInstance { + this._portingWebhookConfigurations = + this._portingWebhookConfigurations || + PortingWebhookConfigurationListInstance(this); + return this._portingWebhookConfigurations; + } + + /** Getter for portingWebhookConfigurationsDelete resource */ + get portingWebhookConfigurationsDelete(): PortingWebhookConfigurationDeleteListInstance { + this._portingWebhookConfigurationsDelete = + this._portingWebhookConfigurationsDelete || + PortingWebhookConfigurationDeleteListInstance(this); + return this._portingWebhookConfigurationsDelete; + } + + /** Getter for portingWebhookConfigurationFetch resource */ + get portingWebhookConfigurationFetch(): PortingWebhookConfigurationFetchListInstance { + this._portingWebhookConfigurationFetch = + this._portingWebhookConfigurationFetch || + PortingWebhookConfigurationFetchListInstance(this); + return this._portingWebhookConfigurationFetch; + } } diff --git a/src/rest/numbers/v1/portingBulkPortability.ts b/src/rest/numbers/v1/portingBulkPortability.ts deleted file mode 100644 index dcd63022ab..0000000000 --- a/src/rest/numbers/v1/portingBulkPortability.ts +++ /dev/null @@ -1,316 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Numbers - * 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"; - -export type PortingBulkPortabilityStatus = - | "in-progress" - | "completed" - | "expired"; - -/** - * Options to pass to create a PortingBulkPortabilityInstance - */ -export interface PortingBulkPortabilityListInstanceCreateOptions { - /** The phone numbers which portability is to be checked. This should be a list of strings. Phone numbers are in E.164 format (e.g. +16175551212). . */ - phoneNumbers: Array; -} - -export interface PortingBulkPortabilityContext { - /** - * Fetch a PortingBulkPortabilityInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PortingBulkPortabilityInstance - */ - fetch( - callback?: ( - error: Error | null, - item?: PortingBulkPortabilityInstance - ) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface PortingBulkPortabilityContextSolution { - sid: string; -} - -export class PortingBulkPortabilityContextImpl - implements PortingBulkPortabilityContext -{ - protected _solution: PortingBulkPortabilityContextSolution; - protected _uri: string; - - constructor(protected _version: V1, sid: string) { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { sid }; - this._uri = `/Porting/Portability/${sid}`; - } - - fetch( - callback?: ( - error: Error | null, - item?: PortingBulkPortabilityInstance - ) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new PortingBulkPortabilityInstance( - operationVersion, - payload, - instance._solution.sid - ) - ); - - 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 PortingBulkPortabilityPayload - extends PortingBulkPortabilityResource {} - -interface PortingBulkPortabilityResource { - sid: string; - status: PortingBulkPortabilityStatus; - datetime_created: Date; - phone_numbers: Array; - url: string; -} - -export class PortingBulkPortabilityInstance { - protected _solution: PortingBulkPortabilityContextSolution; - protected _context?: PortingBulkPortabilityContext; - - constructor( - protected _version: V1, - payload: PortingBulkPortabilityResource, - sid?: string - ) { - this.sid = payload.sid; - this.status = payload.status; - this.datetimeCreated = deserialize.iso8601DateTime( - payload.datetime_created - ); - this.phoneNumbers = payload.phone_numbers; - this.url = payload.url; - - this._solution = { sid: sid || this.sid }; - } - - /** - * A 34 character string that uniquely identifies this Portability check. - */ - sid: string; - status: PortingBulkPortabilityStatus; - /** - * The date that the Portability check was created, given in ISO 8601 format. - */ - datetimeCreated: Date; - /** - * Contains a list with all the information of the requested phone numbers. Each phone number contains the following properties: `phone_number`: The phone number which portability is to be checked. `portable`: Boolean flag specifying if phone number is portable or not. `not_portable_reason`: Reason why the phone number cannot be ported into Twilio, `null` otherwise. `not_portable_reason_code`: The Portability Reason Code for the phone number if it cannot be ported in Twilio, `null` otherwise. `pin_and_account_number_required`: Boolean flag specifying if PIN and account number is required for the phone number. `number_type`: The type of the requested phone number. `country` Country the phone number belongs to. `messaging_carrier` Current messaging carrier of the phone number. `voice_carrier` Current voice carrier of the phone number. - */ - phoneNumbers: Array; - /** - * This is the url of the request that you\'re trying to reach out to locate the resource. - */ - url: string; - - private get _proxy(): PortingBulkPortabilityContext { - this._context = - this._context || - new PortingBulkPortabilityContextImpl(this._version, this._solution.sid); - return this._context; - } - - /** - * Fetch a PortingBulkPortabilityInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PortingBulkPortabilityInstance - */ - fetch( - callback?: ( - error: Error | null, - item?: PortingBulkPortabilityInstance - ) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - status: this.status, - datetimeCreated: this.datetimeCreated, - phoneNumbers: this.phoneNumbers, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface PortingBulkPortabilitySolution {} - -export interface PortingBulkPortabilityListInstance { - _version: V1; - _solution: PortingBulkPortabilitySolution; - _uri: string; - - (sid: string): PortingBulkPortabilityContext; - get(sid: string): PortingBulkPortabilityContext; - - /** - * Create a PortingBulkPortabilityInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PortingBulkPortabilityInstance - */ - create( - params: PortingBulkPortabilityListInstanceCreateOptions, - callback?: ( - error: Error | null, - item?: PortingBulkPortabilityInstance - ) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function PortingBulkPortabilityListInstance( - version: V1 -): PortingBulkPortabilityListInstance { - const instance = ((sid) => - instance.get(sid)) as PortingBulkPortabilityListInstance; - - instance.get = function get(sid): PortingBulkPortabilityContext { - return new PortingBulkPortabilityContextImpl(version, sid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = `/Porting/Portability`; - - instance.create = function create( - params: PortingBulkPortabilityListInstanceCreateOptions, - callback?: ( - error: Error | null, - items: PortingBulkPortabilityInstance - ) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if ( - params["phoneNumbers"] === null || - params["phoneNumbers"] === undefined - ) { - throw new Error("Required parameter \"params['phoneNumbers']\" missing."); - } - - let data: any = {}; - - data["PhoneNumbers"] = serialize.map( - params["phoneNumbers"], - (e: string) => e - ); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - let operationVersion = version, - operationPromise = operationVersion.create({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => new PortingBulkPortabilityInstance(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/src/rest/numbers/v1/portingPortIn.ts b/src/rest/numbers/v1/portingPortIn.ts index 5d4353516b..826ec8e015 100644 --- a/src/rest/numbers/v1/portingPortIn.ts +++ b/src/rest/numbers/v1/portingPortIn.ts @@ -38,6 +38,17 @@ export interface PortingPortInContext { callback?: (error: Error | null, item?: boolean) => any ): Promise; + /** + * Fetch a PortingPortInInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PortingPortInInstance + */ + fetch( + callback?: (error: Error | null, item?: PortingPortInInstance) => any + ): Promise; + /** * Provide a user-friendly representation */ @@ -79,6 +90,32 @@ export class PortingPortInContextImpl implements PortingPortInContext { return operationPromise; } + fetch( + callback?: (error: Error | null, item?: PortingPortInInstance) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + }); + + operationPromise = operationPromise.then( + (payload) => + new PortingPortInInstance( + operationVersion, + payload, + instance._solution.portInRequestSid + ) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + /** * Provide a user-friendly representation * @@ -98,6 +135,15 @@ interface PortingPortInPayload extends PortingPortInResource {} interface PortingPortInResource { port_in_request_sid: string; url: string; + account_sid: string; + notification_emails: Array; + target_port_in_date: Date; + target_port_in_time_range_start: string; + target_port_in_time_range_end: string; + port_in_request_status: string; + losing_carrier_information: any; + phone_numbers: Array; + documents: Array; } export class PortingPortInInstance { @@ -111,6 +157,17 @@ export class PortingPortInInstance { ) { this.portInRequestSid = payload.port_in_request_sid; this.url = payload.url; + this.accountSid = payload.account_sid; + this.notificationEmails = payload.notification_emails; + this.targetPortInDate = deserialize.iso8601Date( + payload.target_port_in_date + ); + this.targetPortInTimeRangeStart = payload.target_port_in_time_range_start; + this.targetPortInTimeRangeEnd = payload.target_port_in_time_range_end; + this.portInRequestStatus = payload.port_in_request_status; + this.losingCarrierInformation = payload.losing_carrier_information; + this.phoneNumbers = payload.phone_numbers; + this.documents = payload.documents; this._solution = { portInRequestSid: portInRequestSid || this.portInRequestSid, @@ -121,7 +178,46 @@ export class PortingPortInInstance { * The SID of the Port In request. This is a unique identifier of the port in request. */ portInRequestSid: string; + /** + * The URL of this Port In request + */ url: string; + /** + * The Account SID that the numbers will be added to after they are ported into Twilio. + */ + accountSid: string; + /** + * List of emails for getting notifications about the LOA signing process. Allowed Max 10 emails. + */ + notificationEmails: Array; + /** + * Minimum number of days in the future (at least 2 days) needs to be established with the Ops team for validation. + */ + targetPortInDate: Date; + /** + * Minimum hour in the future needs to be established with the Ops team for validation. + */ + targetPortInTimeRangeStart: string; + /** + * Maximum hour in the future needs to be established with the Ops team for validation. + */ + targetPortInTimeRangeEnd: string; + /** + * The status of the port in request. The possible values are: In progress, Completed, Expired, In review, Waiting for Signature, Action Required, and Canceled. + */ + portInRequestStatus: string; + /** + * The information for the losing carrier. + */ + losingCarrierInformation: any; + /** + * The list of phone numbers to Port in. Phone numbers are in E.164 format (e.g. +16175551212). + */ + phoneNumbers: Array; + /** + * The list of documents SID referencing a utility bills + */ + documents: Array; private get _proxy(): PortingPortInContext { this._context = @@ -146,6 +242,19 @@ export class PortingPortInInstance { return this._proxy.remove(callback); } + /** + * Fetch a PortingPortInInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PortingPortInInstance + */ + fetch( + callback?: (error: Error | null, item?: PortingPortInInstance) => any + ): Promise { + return this._proxy.fetch(callback); + } + /** * Provide a user-friendly representation * @@ -155,6 +264,15 @@ export class PortingPortInInstance { return { portInRequestSid: this.portInRequestSid, url: this.url, + accountSid: this.accountSid, + notificationEmails: this.notificationEmails, + targetPortInDate: this.targetPortInDate, + targetPortInTimeRangeStart: this.targetPortInTimeRangeStart, + targetPortInTimeRangeEnd: this.targetPortInTimeRangeEnd, + portInRequestStatus: this.portInRequestStatus, + losingCarrierInformation: this.losingCarrierInformation, + phoneNumbers: this.phoneNumbers, + documents: this.documents, }; } diff --git a/src/rest/numbers/v1/portingPortInFetch.ts b/src/rest/numbers/v1/portingPortInFetch.ts deleted file mode 100644 index ffd9f7f102..0000000000 --- a/src/rest/numbers/v1/portingPortInFetch.ts +++ /dev/null @@ -1,280 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Numbers - * 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"; - -export interface PortingPortInFetchContext { - /** - * Fetch a PortingPortInFetchInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PortingPortInFetchInstance - */ - fetch( - callback?: (error: Error | null, item?: PortingPortInFetchInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface PortingPortInFetchContextSolution { - portInRequestSid: string; -} - -export class PortingPortInFetchContextImpl - implements PortingPortInFetchContext -{ - protected _solution: PortingPortInFetchContextSolution; - protected _uri: string; - - constructor(protected _version: V1, portInRequestSid: string) { - if (!isValidPathParam(portInRequestSid)) { - throw new Error("Parameter 'portInRequestSid' is not valid."); - } - - this._solution = { portInRequestSid }; - this._uri = `/Porting/PortIn/${portInRequestSid}`; - } - - fetch( - callback?: (error: Error | null, item?: PortingPortInFetchInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new PortingPortInFetchInstance( - operationVersion, - payload, - instance._solution.portInRequestSid - ) - ); - - 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 PortingPortInFetchPayload extends PortingPortInFetchResource {} - -interface PortingPortInFetchResource { - port_in_request_sid: string; - url: string; - account_sid: string; - notification_emails: Array; - target_port_in_date: Date; - target_port_in_time_range_start: string; - target_port_in_time_range_end: string; - port_in_request_status: string; - losing_carrier_information: any; - phone_numbers: Array; - documents: Array; -} - -export class PortingPortInFetchInstance { - protected _solution: PortingPortInFetchContextSolution; - protected _context?: PortingPortInFetchContext; - - constructor( - protected _version: V1, - payload: PortingPortInFetchResource, - portInRequestSid?: string - ) { - this.portInRequestSid = payload.port_in_request_sid; - this.url = payload.url; - this.accountSid = payload.account_sid; - this.notificationEmails = payload.notification_emails; - this.targetPortInDate = deserialize.iso8601Date( - payload.target_port_in_date - ); - this.targetPortInTimeRangeStart = payload.target_port_in_time_range_start; - this.targetPortInTimeRangeEnd = payload.target_port_in_time_range_end; - this.portInRequestStatus = payload.port_in_request_status; - this.losingCarrierInformation = payload.losing_carrier_information; - this.phoneNumbers = payload.phone_numbers; - this.documents = payload.documents; - - this._solution = { - portInRequestSid: portInRequestSid || this.portInRequestSid, - }; - } - - /** - * The SID of the Port In request. This is a unique identifier of the port in request. - */ - portInRequestSid: string; - /** - * The URL of this Port In request - */ - url: string; - /** - * The Account SID that the numbers will be added to after they are ported into Twilio. - */ - accountSid: string; - /** - * List of emails for getting notifications about the LOA signing process. Allowed Max 10 emails. - */ - notificationEmails: Array; - /** - * Minimum number of days in the future (at least 2 days) needs to be established with the Ops team for validation. - */ - targetPortInDate: Date; - /** - * Minimum hour in the future needs to be established with the Ops team for validation. - */ - targetPortInTimeRangeStart: string; - /** - * Maximum hour in the future needs to be established with the Ops team for validation. - */ - targetPortInTimeRangeEnd: string; - /** - * The status of the port in request. The possible values are: In progress, Completed, Expired, In review, Waiting for Signature, Action Required, and Canceled. - */ - portInRequestStatus: string; - /** - * The information for the losing carrier. - */ - losingCarrierInformation: any; - /** - * The list of phone numbers to Port in. Phone numbers are in E.164 format (e.g. +16175551212). - */ - phoneNumbers: Array; - /** - * The list of documents SID referencing a utility bills - */ - documents: Array; - - private get _proxy(): PortingPortInFetchContext { - this._context = - this._context || - new PortingPortInFetchContextImpl( - this._version, - this._solution.portInRequestSid - ); - return this._context; - } - - /** - * Fetch a PortingPortInFetchInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PortingPortInFetchInstance - */ - fetch( - callback?: (error: Error | null, item?: PortingPortInFetchInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - portInRequestSid: this.portInRequestSid, - url: this.url, - accountSid: this.accountSid, - notificationEmails: this.notificationEmails, - targetPortInDate: this.targetPortInDate, - targetPortInTimeRangeStart: this.targetPortInTimeRangeStart, - targetPortInTimeRangeEnd: this.targetPortInTimeRangeEnd, - portInRequestStatus: this.portInRequestStatus, - losingCarrierInformation: this.losingCarrierInformation, - phoneNumbers: this.phoneNumbers, - documents: this.documents, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface PortingPortInFetchSolution {} - -export interface PortingPortInFetchListInstance { - _version: V1; - _solution: PortingPortInFetchSolution; - _uri: string; - - (portInRequestSid: string): PortingPortInFetchContext; - get(portInRequestSid: string): PortingPortInFetchContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function PortingPortInFetchListInstance( - version: V1 -): PortingPortInFetchListInstance { - const instance = ((portInRequestSid) => - instance.get(portInRequestSid)) as PortingPortInFetchListInstance; - - instance.get = function get(portInRequestSid): PortingPortInFetchContext { - return new PortingPortInFetchContextImpl(version, portInRequestSid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = ``; - - 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/src/rest/numbers/v1/portingPortInPhoneNumber.ts b/src/rest/numbers/v1/portingPortInPhoneNumber.ts index 1141bea752..809d694373 100644 --- a/src/rest/numbers/v1/portingPortInPhoneNumber.ts +++ b/src/rest/numbers/v1/portingPortInPhoneNumber.ts @@ -30,6 +30,20 @@ export interface PortingPortInPhoneNumberContext { callback?: (error: Error | null, item?: boolean) => any ): Promise; + /** + * Fetch a PortingPortInPhoneNumberInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PortingPortInPhoneNumberInstance + */ + fetch( + callback?: ( + error: Error | null, + item?: PortingPortInPhoneNumberInstance + ) => any + ): Promise; + /** * Provide a user-friendly representation */ @@ -82,6 +96,36 @@ export class PortingPortInPhoneNumberContextImpl return operationPromise; } + fetch( + callback?: ( + error: Error | null, + item?: PortingPortInPhoneNumberInstance + ) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + }); + + operationPromise = operationPromise.then( + (payload) => + new PortingPortInPhoneNumberInstance( + operationVersion, + payload, + instance._solution.portInRequestSid, + instance._solution.phoneNumberSid + ) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + } + /** * Provide a user-friendly representation * @@ -96,6 +140,182 @@ export class PortingPortInPhoneNumberContextImpl } } +interface PortingPortInPhoneNumberPayload + extends PortingPortInPhoneNumberResource {} + +interface PortingPortInPhoneNumberResource { + port_in_request_sid: string; + phone_number_sid: string; + url: string; + account_sid: string; + phone_number_type: string; + date_created: Date; + country: string; + missing_required_fields: boolean; + status_last_time_updated_timestamp: Date; + phone_number: string; + portable: boolean; + not_portability_reason: string; + not_portability_reason_code: string; + port_in_phone_number_status: string; +} + +export class PortingPortInPhoneNumberInstance { + protected _solution: PortingPortInPhoneNumberContextSolution; + protected _context?: PortingPortInPhoneNumberContext; + + constructor( + protected _version: V1, + payload: PortingPortInPhoneNumberResource, + portInRequestSid?: string, + phoneNumberSid?: string + ) { + this.portInRequestSid = payload.port_in_request_sid; + this.phoneNumberSid = payload.phone_number_sid; + this.url = payload.url; + this.accountSid = payload.account_sid; + this.phoneNumberType = payload.phone_number_type; + this.dateCreated = deserialize.iso8601DateTime(payload.date_created); + this.country = payload.country; + this.missingRequiredFields = payload.missing_required_fields; + this.statusLastTimeUpdatedTimestamp = deserialize.iso8601DateTime( + payload.status_last_time_updated_timestamp + ); + this.phoneNumber = payload.phone_number; + this.portable = payload.portable; + this.notPortabilityReason = payload.not_portability_reason; + this.notPortabilityReasonCode = payload.not_portability_reason_code; + this.portInPhoneNumberStatus = payload.port_in_phone_number_status; + + this._solution = { + portInRequestSid: portInRequestSid || this.portInRequestSid, + phoneNumberSid: phoneNumberSid || this.phoneNumberSid, + }; + } + + /** + * The SID of the Port In request. This is a unique identifier of the port in request. + */ + portInRequestSid: string; + /** + * The SID of the Port In request phone number. This is a unique identifier of the phone number. + */ + phoneNumberSid: string; + url: string; + /** + * The SID of the account that the phone number belongs to. + */ + accountSid: string; + /** + * The type of the phone number. + */ + phoneNumberType: string; + /** + * The date when the phone number was created. + */ + dateCreated: Date; + /** + * The country of the phone number. + */ + country: string; + /** + * The phone number is missing required fields. + */ + missingRequiredFields: boolean; + /** + * The timestamp when the status was last updated. + */ + statusLastTimeUpdatedTimestamp: Date; + /** + * The phone number. + */ + phoneNumber: string; + /** + * The phone number is portable. + */ + portable: boolean; + /** + * The reason why the phone number is not portable. + */ + notPortabilityReason: string; + /** + * The code of the reason why the phone number is not portable. + */ + notPortabilityReasonCode: string; + /** + * The status of the phone number in the port in request. + */ + portInPhoneNumberStatus: string; + + private get _proxy(): PortingPortInPhoneNumberContext { + this._context = + this._context || + new PortingPortInPhoneNumberContextImpl( + this._version, + this._solution.portInRequestSid, + this._solution.phoneNumberSid + ); + return this._context; + } + + /** + * Remove a PortingPortInPhoneNumberInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + return this._proxy.remove(callback); + } + + /** + * Fetch a PortingPortInPhoneNumberInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PortingPortInPhoneNumberInstance + */ + fetch( + callback?: ( + error: Error | null, + item?: PortingPortInPhoneNumberInstance + ) => any + ): Promise { + return this._proxy.fetch(callback); + } + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + portInRequestSid: this.portInRequestSid, + phoneNumberSid: this.phoneNumberSid, + url: this.url, + accountSid: this.accountSid, + phoneNumberType: this.phoneNumberType, + dateCreated: this.dateCreated, + country: this.country, + missingRequiredFields: this.missingRequiredFields, + statusLastTimeUpdatedTimestamp: this.statusLastTimeUpdatedTimestamp, + phoneNumber: this.phoneNumber, + portable: this.portable, + notPortabilityReason: this.notPortabilityReason, + notPortabilityReasonCode: this.notPortabilityReasonCode, + portInPhoneNumberStatus: this.portInPhoneNumberStatus, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} + export interface PortingPortInPhoneNumberSolution {} export interface PortingPortInPhoneNumberListInstance { diff --git a/src/rest/numbers/v1/portingWebhookConfiguration.ts b/src/rest/numbers/v1/portingWebhookConfiguration.ts new file mode 100644 index 0000000000..dfbdeb0969 --- /dev/null +++ b/src/rest/numbers/v1/portingWebhookConfiguration.ts @@ -0,0 +1,196 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Numbers + * 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 create a PortingWebhookConfigurationInstance + */ +export interface PortingWebhookConfigurationListInstanceCreateOptions { + /** */ + body?: object; +} + +export interface PortingWebhookConfigurationSolution {} + +export interface PortingWebhookConfigurationListInstance { + _version: V1; + _solution: PortingWebhookConfigurationSolution; + _uri: string; + + /** + * Create a PortingWebhookConfigurationInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PortingWebhookConfigurationInstance + */ + create( + callback?: ( + error: Error | null, + item?: PortingWebhookConfigurationInstance + ) => any + ): Promise; + /** + * Create a PortingWebhookConfigurationInstance + * + * @param params - Body for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PortingWebhookConfigurationInstance + */ + create( + params: object, + callback?: ( + error: Error | null, + item?: PortingWebhookConfigurationInstance + ) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function PortingWebhookConfigurationListInstance( + version: V1 +): PortingWebhookConfigurationListInstance { + const instance = {} as PortingWebhookConfigurationListInstance; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Porting/Configuration/Webhook`; + + instance.create = function create( + params?: + | object + | (( + error: Error | null, + items: PortingWebhookConfigurationInstance + ) => any), + callback?: ( + error: Error | null, + items: PortingWebhookConfigurationInstance + ) => any + ): Promise { + if (params instanceof Function) { + callback = params; + params = {}; + } else { + params = params || {}; + } + + let data: any = {}; + + data = params; + + const headers: any = {}; + headers["Content-Type"] = "application/json"; + + let operationVersion = version, + operationPromise = operationVersion.create({ + uri: instance._uri, + method: "post", + data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => + new PortingWebhookConfigurationInstance(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 PortingWebhookConfigurationPayload + extends PortingWebhookConfigurationResource {} + +interface PortingWebhookConfigurationResource { + url: string; + port_in_target_url: string; + port_out_target_url: string; + notifications_of: Array; +} + +export class PortingWebhookConfigurationInstance { + constructor( + protected _version: V1, + payload: PortingWebhookConfigurationResource + ) { + this.url = payload.url; + this.portInTargetUrl = payload.port_in_target_url; + this.portOutTargetUrl = payload.port_out_target_url; + this.notificationsOf = payload.notifications_of; + } + + /** + * The URL of the webhook configuration request + */ + url: string; + /** + * Webhook URL to send a request when a port in request or port in phone number event happens + */ + portInTargetUrl: string; + /** + * Webhook URL to send a request when a port out phone number event happens + */ + portOutTargetUrl: string; + /** + * List of notification events to send a request to the webhook URL + */ + notificationsOf: Array; + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + url: this.url, + portInTargetUrl: this.portInTargetUrl, + portOutTargetUrl: this.portOutTargetUrl, + notificationsOf: this.notificationsOf, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/numbers/v1/portingWebhookConfigurationDelete.ts b/src/rest/numbers/v1/portingWebhookConfigurationDelete.ts new file mode 100644 index 0000000000..8d0181c962 --- /dev/null +++ b/src/rest/numbers/v1/portingWebhookConfigurationDelete.ts @@ -0,0 +1,149 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Numbers + * 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"; + +export type PortingWebhookConfigurationDeleteWebhookType = + | "PORT_IN" + | "PORT_OUT"; + +export interface PortingWebhookConfigurationDeleteContext { + /** + * Remove a PortingWebhookConfigurationDeleteInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed boolean + */ + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export interface PortingWebhookConfigurationDeleteContextSolution { + webhookType: PortingWebhookConfigurationDeleteWebhookType; +} + +export class PortingWebhookConfigurationDeleteContextImpl + implements PortingWebhookConfigurationDeleteContext +{ + protected _solution: PortingWebhookConfigurationDeleteContextSolution; + protected _uri: string; + + constructor( + protected _version: V1, + webhookType: PortingWebhookConfigurationDeleteWebhookType + ) { + if (!isValidPathParam(webhookType)) { + throw new Error("Parameter 'webhookType' is not valid."); + } + + this._solution = { webhookType }; + this._uri = `/Porting/Configuration/Webhook/${webhookType}`; + } + + remove( + callback?: (error: Error | null, item?: boolean) => any + ): Promise { + const instance = this; + let operationVersion = instance._version, + operationPromise = operationVersion.remove({ + uri: instance._uri, + method: "delete", + }); + + 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); + } +} + +export interface PortingWebhookConfigurationDeleteSolution {} + +export interface PortingWebhookConfigurationDeleteListInstance { + _version: V1; + _solution: PortingWebhookConfigurationDeleteSolution; + _uri: string; + + ( + webhookType: PortingWebhookConfigurationDeleteWebhookType + ): PortingWebhookConfigurationDeleteContext; + get( + webhookType: PortingWebhookConfigurationDeleteWebhookType + ): PortingWebhookConfigurationDeleteContext; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function PortingWebhookConfigurationDeleteListInstance( + version: V1 +): PortingWebhookConfigurationDeleteListInstance { + const instance = ((webhookType) => + instance.get(webhookType)) as PortingWebhookConfigurationDeleteListInstance; + + instance.get = function get( + webhookType + ): PortingWebhookConfigurationDeleteContext { + return new PortingWebhookConfigurationDeleteContextImpl( + version, + webhookType + ); + }; + + instance._version = version; + instance._solution = {}; + instance._uri = ``; + + 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/src/rest/numbers/v1/portingWebhookConfigurationFetch.ts b/src/rest/numbers/v1/portingWebhookConfigurationFetch.ts new file mode 100644 index 0000000000..8662080e01 --- /dev/null +++ b/src/rest/numbers/v1/portingWebhookConfigurationFetch.ts @@ -0,0 +1,169 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Numbers + * 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"; + +export interface PortingWebhookConfigurationFetchSolution {} + +export interface PortingWebhookConfigurationFetchListInstance { + _version: V1; + _solution: PortingWebhookConfigurationFetchSolution; + _uri: string; + + /** + * Fetch a PortingWebhookConfigurationFetchInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed PortingWebhookConfigurationFetchInstance + */ + fetch( + callback?: ( + error: Error | null, + item?: PortingWebhookConfigurationFetchInstance + ) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function PortingWebhookConfigurationFetchListInstance( + version: V1 +): PortingWebhookConfigurationFetchListInstance { + const instance = {} as PortingWebhookConfigurationFetchListInstance; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Porting/Configuration/Webhook`; + + instance.fetch = function fetch( + callback?: ( + error: Error | null, + items: PortingWebhookConfigurationFetchInstance + ) => any + ): Promise { + let operationVersion = version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + }); + + operationPromise = operationPromise.then( + (payload) => + new PortingWebhookConfigurationFetchInstance(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 PortingWebhookConfigurationFetchPayload + extends PortingWebhookConfigurationFetchResource {} + +interface PortingWebhookConfigurationFetchResource { + url: string; + port_in_target_url: string; + port_out_target_url: string; + notifications_of: Array; + port_in_target_date_created: Date; + port_out_target_date_created: Date; +} + +export class PortingWebhookConfigurationFetchInstance { + constructor( + protected _version: V1, + payload: PortingWebhookConfigurationFetchResource + ) { + this.url = payload.url; + this.portInTargetUrl = payload.port_in_target_url; + this.portOutTargetUrl = payload.port_out_target_url; + this.notificationsOf = payload.notifications_of; + this.portInTargetDateCreated = deserialize.iso8601DateTime( + payload.port_in_target_date_created + ); + this.portOutTargetDateCreated = deserialize.iso8601DateTime( + payload.port_out_target_date_created + ); + } + + /** + * The URL of the webhook configuration request + */ + url: string; + /** + * Webhook URL to send a request when a port in request or port in phone number event happens + */ + portInTargetUrl: string; + /** + * Webhook URL to send a request when a port out phone number event happens + */ + portOutTargetUrl: string; + /** + * List of notification events to send a request to the webhook URL + */ + notificationsOf: Array; + /** + * Creation date for the port in webhook configuration + */ + portInTargetDateCreated: Date; + /** + * Creation date for the port out webhook configuration + */ + portOutTargetDateCreated: Date; + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + url: this.url, + portInTargetUrl: this.portInTargetUrl, + portOutTargetUrl: this.portOutTargetUrl, + notificationsOf: this.notificationsOf, + portInTargetDateCreated: this.portInTargetDateCreated, + portOutTargetDateCreated: this.portOutTargetDateCreated, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/taskrouter/v1/workspace/task.ts b/src/rest/taskrouter/v1/workspace/task.ts index eb92c492ff..8c3ead4c27 100644 --- a/src/rest/taskrouter/v1/workspace/task.ts +++ b/src/rest/taskrouter/v1/workspace/task.ts @@ -73,6 +73,12 @@ export interface TaskListInstanceCreateOptions { attributes?: string; /** The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can\\\'t be in the future. */ virtualStartTime?: Date; + /** A SID of a Worker, Queue, or Workflow to route a Task to */ + routingTarget?: string; + /** A boolean indicating if a new task should respect a worker\\\'s capacity during assignment */ + ignoreCapacity?: string; + /** The SID of the TaskQueue in which the Task belongs */ + taskQueueSid?: string; } /** * Options to pass to each @@ -92,6 +98,8 @@ export interface TaskListInstanceEachOptions { taskQueueName?: string; /** The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. */ evaluateTaskAttributes?: string; + /** A SID of a Worker, Queue, or Workflow to route a Task to */ + routingTarget?: string; /** How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. */ ordering?: string; /** Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. */ @@ -124,6 +132,8 @@ export interface TaskListInstanceOptions { taskQueueName?: string; /** The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. */ evaluateTaskAttributes?: string; + /** A SID of a Worker, Queue, or Workflow to route a Task to */ + routingTarget?: string; /** How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. */ ordering?: string; /** Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. */ @@ -152,6 +162,8 @@ export interface TaskListInstancePageOptions { taskQueueName?: string; /** The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. */ evaluateTaskAttributes?: string; + /** A SID of a Worker, Queue, or Workflow to route a Task to */ + routingTarget?: string; /** How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. */ ordering?: string; /** Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. */ @@ -428,6 +440,8 @@ interface TaskResource { url: string; links: Record; virtual_start_time: Date; + ignore_capacity: boolean; + routing_target: string; } export class TaskInstance { @@ -466,6 +480,8 @@ export class TaskInstance { this.virtualStartTime = deserialize.iso8601DateTime( payload.virtual_start_time ); + this.ignoreCapacity = payload.ignore_capacity; + this.routingTarget = payload.routing_target; this._solution = { workspaceSid, sid: sid || this.sid }; } @@ -555,6 +571,14 @@ export class TaskInstance { * The date and time in GMT indicating the ordering for routing of the Task specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. */ virtualStartTime: Date; + /** + * A boolean indicating if a new task should respect a worker\'s capacity during assignment + */ + ignoreCapacity: boolean; + /** + * A SID of a Worker, Queue, or Workflow to route a Task to + */ + routingTarget: string; private get _proxy(): TaskContext { this._context = @@ -676,6 +700,8 @@ export class TaskInstance { url: this.url, links: this.links, virtualStartTime: this.virtualStartTime, + ignoreCapacity: this.ignoreCapacity, + routingTarget: this.routingTarget, }; } @@ -840,6 +866,12 @@ export function TaskListInstance( data["VirtualStartTime"] = serialize.iso8601DateTime( params["virtualStartTime"] ); + if (params["routingTarget"] !== undefined) + data["RoutingTarget"] = params["routingTarget"]; + if (params["ignoreCapacity"] !== undefined) + data["IgnoreCapacity"] = params["ignoreCapacity"]; + if (params["taskQueueSid"] !== undefined) + data["TaskQueueSid"] = params["taskQueueSid"]; const headers: any = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; @@ -899,6 +931,8 @@ export function TaskListInstance( data["TaskQueueName"] = params["taskQueueName"]; if (params["evaluateTaskAttributes"] !== undefined) data["EvaluateTaskAttributes"] = params["evaluateTaskAttributes"]; + if (params["routingTarget"] !== undefined) + data["RoutingTarget"] = params["routingTarget"]; if (params["ordering"] !== undefined) data["Ordering"] = params["ordering"]; if (params["hasAddons"] !== undefined) data["HasAddons"] = serialize.bool(params["hasAddons"]); diff --git a/src/rest/trusthub/v1/complianceTollfreeInquiries.ts b/src/rest/trusthub/v1/complianceTollfreeInquiries.ts index 47c7c767f3..177056fb97 100644 --- a/src/rest/trusthub/v1/complianceTollfreeInquiries.ts +++ b/src/rest/trusthub/v1/complianceTollfreeInquiries.ts @@ -71,6 +71,8 @@ export interface ComplianceTollfreeInquiriesListInstanceCreateOptions { businessContactEmail?: string; /** The phone number of the contact for the business or organization using the Tollfree number. */ businessContactPhone?: string; + /** Theme id for styling the inquiry form. */ + themeSetId?: string; } export interface ComplianceTollfreeInquiriesSolution {} @@ -191,6 +193,8 @@ export function ComplianceTollfreeInquiriesListInstance( data["BusinessContactEmail"] = params["businessContactEmail"]; if (params["businessContactPhone"] !== undefined) data["BusinessContactPhone"] = params["businessContactPhone"]; + if (params["themeSetId"] !== undefined) + data["ThemeSetId"] = params["themeSetId"]; const headers: any = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; diff --git a/src/rest/trusthub/v1/customerProfiles.ts b/src/rest/trusthub/v1/customerProfiles.ts index c2fd319f21..744a5661f4 100644 --- a/src/rest/trusthub/v1/customerProfiles.ts +++ b/src/rest/trusthub/v1/customerProfiles.ts @@ -346,6 +346,7 @@ interface CustomerProfilesResource { date_updated: Date; url: string; links: Record; + errors: Array; } export class CustomerProfilesInstance { @@ -369,6 +370,7 @@ export class CustomerProfilesInstance { this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); this.url = payload.url; this.links = payload.links; + this.errors = payload.errors; this._solution = { sid: sid || this.sid }; } @@ -418,6 +420,10 @@ export class CustomerProfilesInstance { * The URLs of the Assigned Items of the Customer-Profile resource. */ links: Record; + /** + * The error codes associated with the rejection of the Customer-Profile. + */ + errors: Array; private get _proxy(): CustomerProfilesContext { this._context = @@ -522,6 +528,7 @@ export class CustomerProfilesInstance { dateUpdated: this.dateUpdated, url: this.url, links: this.links, + errors: this.errors, }; } diff --git a/src/rest/trusthub/v1/trustProducts.ts b/src/rest/trusthub/v1/trustProducts.ts index d47b67ee90..3db9c5915f 100644 --- a/src/rest/trusthub/v1/trustProducts.ts +++ b/src/rest/trusthub/v1/trustProducts.ts @@ -340,6 +340,7 @@ interface TrustProductsResource { date_updated: Date; url: string; links: Record; + errors: Array; } export class TrustProductsInstance { @@ -363,6 +364,7 @@ export class TrustProductsInstance { this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); this.url = payload.url; this.links = payload.links; + this.errors = payload.errors; this._solution = { sid: sid || this.sid }; } @@ -412,6 +414,10 @@ export class TrustProductsInstance { * The URLs of the Assigned Items of the Trust Product resource. */ links: Record; + /** + * The error codes associated with the rejection of the Trust Product. + */ + errors: Array; private get _proxy(): TrustProductsContext { this._context = @@ -516,6 +522,7 @@ export class TrustProductsInstance { dateUpdated: this.dateUpdated, url: this.url, links: this.links, + errors: this.errors, }; } diff --git a/src/rest/verify/v2/service.ts b/src/rest/verify/v2/service.ts index 32316cc641..e3b36a21df 100644 --- a/src/rest/verify/v2/service.ts +++ b/src/rest/verify/v2/service.ts @@ -489,7 +489,7 @@ export class ServiceInstance { */ accountSid: string; /** - * The string that you assigned to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** + * The name that appears in the body of your verification messages. It can be up to 30 characters long and can include letters, numbers, spaces, dashes, underscores. Phone numbers, special characters or links are NOT allowed. **This value should not contain PII.** */ friendlyName: string; /** diff --git a/src/rest/verify/v2/service/verification.ts b/src/rest/verify/v2/service/verification.ts index 4b2b3cb87c..f58804f8c8 100644 --- a/src/rest/verify/v2/service/verification.ts +++ b/src/rest/verify/v2/service/verification.ts @@ -279,7 +279,7 @@ export class VerificationInstance { to: string; channel: VerificationChannel; /** - * The status of the verification. One of: `pending`, `approved`, or `canceled` + * The status of the verification. Can be: `pending`, `approved`, `canceled`, `max_attempts_reached`, `deleted`, `failed` or `expired`. */ status: string; /** diff --git a/src/rest/verify/v2/service/verificationCheck.ts b/src/rest/verify/v2/service/verificationCheck.ts index 73311a9188..4d642bb8db 100644 --- a/src/rest/verify/v2/service/verificationCheck.ts +++ b/src/rest/verify/v2/service/verificationCheck.ts @@ -212,7 +212,7 @@ export class VerificationCheckInstance { to: string; channel: VerificationCheckChannel; /** - * The status of the verification. Can be: `pending`, `approved`, or `canceled`. + * The status of the verification. Can be: `pending`, `approved`, `canceled`, `max_attempts_reached`, `deleted`, `failed` or `expired`. */ status: string; /**