From b8a6bde3b8bf2cbf886dfd5815bf2d652962fd67 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Sat, 27 Jan 2024 11:44:15 +0530 Subject: [PATCH 1/2] chore: removed static files for oath and autopilot --- src/rest/Autopilot.ts | 5 ----- src/rest/AutopilotBase.ts | 33 --------------------------------- src/rest/Oauth.ts | 5 ----- src/rest/OauthBase.ts | 33 --------------------------------- src/rest/Twilio.ts | 18 ------------------ 5 files changed, 94 deletions(-) delete mode 100644 src/rest/Autopilot.ts delete mode 100644 src/rest/AutopilotBase.ts delete mode 100644 src/rest/Oauth.ts delete mode 100644 src/rest/OauthBase.ts diff --git a/src/rest/Autopilot.ts b/src/rest/Autopilot.ts deleted file mode 100644 index 06641612fb..0000000000 --- a/src/rest/Autopilot.ts +++ /dev/null @@ -1,5 +0,0 @@ -import AutopilotBase from "./AutopilotBase"; - -class Autopilot extends AutopilotBase {} - -export = Autopilot; diff --git a/src/rest/AutopilotBase.ts b/src/rest/AutopilotBase.ts deleted file mode 100644 index 59242a4497..0000000000 --- a/src/rest/AutopilotBase.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import Domain from "../base/Domain"; -import V1 from "./autopilot/V1"; - -class AutopilotBase extends Domain { - _v1?: V1; - - /** - * Initialize autopilot domain - * - * @param twilio - The twilio client - */ - constructor(twilio: any) { - super(twilio, "https://autopilot.twilio.com"); - } - - get v1(): V1 { - this._v1 = this._v1 || new V1(this); - return this._v1; - } -} - -export = AutopilotBase; diff --git a/src/rest/Oauth.ts b/src/rest/Oauth.ts deleted file mode 100644 index 62ea7c5e57..0000000000 --- a/src/rest/Oauth.ts +++ /dev/null @@ -1,5 +0,0 @@ -import OauthBase from "./OauthBase"; - -class Oauth extends OauthBase {} - -export = Oauth; diff --git a/src/rest/OauthBase.ts b/src/rest/OauthBase.ts deleted file mode 100644 index 513dd037f3..0000000000 --- a/src/rest/OauthBase.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import Domain from "../base/Domain"; -import V1 from "./oauth/V1"; - -class OauthBase extends Domain { - _v1?: V1; - - /** - * Initialize oauth domain - * - * @param twilio - The twilio client - */ - constructor(twilio: any) { - super(twilio, "https://oauth.twilio.com"); - } - - get v1(): V1 { - this._v1 = this._v1 || new V1(this); - return this._v1; - } -} - -export = OauthBase; diff --git a/src/rest/Twilio.ts b/src/rest/Twilio.ts index 1a21d3a500..ca69fa3b22 100644 --- a/src/rest/Twilio.ts +++ b/src/rest/Twilio.ts @@ -12,7 +12,6 @@ import { Client, ClientOpts, RequestOpts } from "../base/BaseTwilio"; import Accounts from "./Accounts"; import Api from "./Api"; -import Autopilot from "./Autopilot"; import Bulkexports from "./Bulkexports"; import Chat from "./Chat"; import Content from "./Content"; @@ -30,7 +29,6 @@ import Microvisor from "./Microvisor"; import Monitor from "./Monitor"; import Notify from "./Notify"; import Numbers from "./Numbers"; -import Oauth from "./Oauth"; import Preview from "./Preview"; import Pricing from "./Pricing"; import Proxy from "./Proxy"; @@ -82,8 +80,6 @@ class Twilio extends Client { _accounts?: Accounts; /** (Twilio.Api) - api domain */ _api?: Api; - /** (Twilio.Autopilot) - autopilot domain */ - _autopilot?: Autopilot; /** (Twilio.Bulkexports) - bulkexports domain */ _bulkexports?: Bulkexports; /** (Twilio.Chat) - chat domain */ @@ -118,8 +114,6 @@ class Twilio extends Client { _notify?: Notify; /** (Twilio.Numbers) - numbers domain */ _numbers?: Numbers; - /** (Twilio.Oauth) - oauth domain */ - _oauth?: Oauth; /** (Twilio.Preview) - preview domain */ _preview?: Preview; /** (Twilio.Pricing) - pricing domain */ @@ -170,7 +164,6 @@ class Twilio extends Client { if (this.opts?.lazyLoading === false) { this.accounts; this.api; - this.autopilot; this.bulkexports; this.chat; this.content; @@ -188,7 +181,6 @@ class Twilio extends Client { this.monitor; this.notify; this.numbers; - this.oauth; this.preview; this.pricing; this.proxy; @@ -218,12 +210,6 @@ class Twilio extends Client { get api(): Api { return this._api ?? (this._api = new (require("./Api"))(this)); } - /** Getter for (Twilio.Autopilot) domain */ - get autopilot(): Autopilot { - return ( - this._autopilot ?? (this._autopilot = new (require("./Autopilot"))(this)) - ); - } /** Getter for (Twilio.Bulkexports) domain */ get bulkexports(): Bulkexports { return ( @@ -314,10 +300,6 @@ class Twilio extends Client { get numbers(): Numbers { return this._numbers ?? (this._numbers = new (require("./Numbers"))(this)); } - /** Getter for (Twilio.Oauth) domain */ - get oauth(): Oauth { - return this._oauth ?? (this._oauth = new (require("./Oauth"))(this)); - } /** Getter for (Twilio.Preview) domain */ get preview(): Preview { return this._preview ?? (this._preview = new (require("./Preview"))(this)); From b390aea12f7a488e23aee12e784be23c35a1727f Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Sat, 27 Jan 2024 11:46:45 +0530 Subject: [PATCH 2/2] chore: removed autopilot and oauth folders --- src/rest/autopilot/V1.ts | 47 - src/rest/autopilot/v1/assistant.ts | 890 ------------------ src/rest/autopilot/v1/assistant/defaults.ts | 335 ------- src/rest/autopilot/v1/assistant/dialogue.ts | 246 ----- src/rest/autopilot/v1/assistant/fieldType.ts | 726 -------------- .../v1/assistant/fieldType/fieldValue.ts | 634 ------------- src/rest/autopilot/v1/assistant/modelBuild.ts | 722 -------------- src/rest/autopilot/v1/assistant/query.ts | 776 --------------- src/rest/autopilot/v1/assistant/styleSheet.ts | 335 ------- src/rest/autopilot/v1/assistant/task.ts | 806 ---------------- src/rest/autopilot/v1/assistant/task/field.ts | 614 ------------ .../autopilot/v1/assistant/task/sample.ts | 749 --------------- .../v1/assistant/task/taskActions.ts | 360 ------- .../v1/assistant/task/taskStatistics.ts | 259 ----- src/rest/autopilot/v1/assistant/webhook.ts | 733 --------------- src/rest/autopilot/v1/restoreAssistant.ts | 224 ----- src/rest/oauth/V1.ts | 74 -- src/rest/oauth/v1/deviceCode.ts | 192 ---- src/rest/oauth/v1/oauth.ts | 185 ---- src/rest/oauth/v1/openidDiscovery.ts | 266 ------ src/rest/oauth/v1/token.ts | 204 ---- src/rest/oauth/v1/userInfo.ts | 213 ----- 22 files changed, 9590 deletions(-) delete mode 100644 src/rest/autopilot/V1.ts delete mode 100644 src/rest/autopilot/v1/assistant.ts delete mode 100644 src/rest/autopilot/v1/assistant/defaults.ts delete mode 100644 src/rest/autopilot/v1/assistant/dialogue.ts delete mode 100644 src/rest/autopilot/v1/assistant/fieldType.ts delete mode 100644 src/rest/autopilot/v1/assistant/fieldType/fieldValue.ts delete mode 100644 src/rest/autopilot/v1/assistant/modelBuild.ts delete mode 100644 src/rest/autopilot/v1/assistant/query.ts delete mode 100644 src/rest/autopilot/v1/assistant/styleSheet.ts delete mode 100644 src/rest/autopilot/v1/assistant/task.ts delete mode 100644 src/rest/autopilot/v1/assistant/task/field.ts delete mode 100644 src/rest/autopilot/v1/assistant/task/sample.ts delete mode 100644 src/rest/autopilot/v1/assistant/task/taskActions.ts delete mode 100644 src/rest/autopilot/v1/assistant/task/taskStatistics.ts delete mode 100644 src/rest/autopilot/v1/assistant/webhook.ts delete mode 100644 src/rest/autopilot/v1/restoreAssistant.ts delete mode 100644 src/rest/oauth/V1.ts delete mode 100644 src/rest/oauth/v1/deviceCode.ts delete mode 100644 src/rest/oauth/v1/oauth.ts delete mode 100644 src/rest/oauth/v1/openidDiscovery.ts delete mode 100644 src/rest/oauth/v1/token.ts delete mode 100644 src/rest/oauth/v1/userInfo.ts diff --git a/src/rest/autopilot/V1.ts b/src/rest/autopilot/V1.ts deleted file mode 100644 index cc10686e37..0000000000 --- a/src/rest/autopilot/V1.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 AutopilotBase from "../AutopilotBase"; -import Version from "../../base/Version"; -import { AssistantListInstance } from "./v1/assistant"; -import { RestoreAssistantListInstance } from "./v1/restoreAssistant"; - -export default class V1 extends Version { - /** - * Initialize the V1 version of Autopilot - * - * @param domain - The Twilio (Twilio.Autopilot) domain - */ - constructor(domain: AutopilotBase) { - super(domain, "v1"); - } - - /** assistants - { Twilio.Autopilot.V1.AssistantListInstance } resource */ - protected _assistants?: AssistantListInstance; - /** restoreAssistant - { Twilio.Autopilot.V1.RestoreAssistantListInstance } resource */ - protected _restoreAssistant?: RestoreAssistantListInstance; - - /** Getter for assistants resource */ - get assistants(): AssistantListInstance { - this._assistants = this._assistants || AssistantListInstance(this); - return this._assistants; - } - - /** Getter for restoreAssistant resource */ - get restoreAssistant(): RestoreAssistantListInstance { - this._restoreAssistant = - this._restoreAssistant || RestoreAssistantListInstance(this); - return this._restoreAssistant; - } -} diff --git a/src/rest/autopilot/v1/assistant.ts b/src/rest/autopilot/v1/assistant.ts deleted file mode 100644 index 516ea6472f..0000000000 --- a/src/rest/autopilot/v1/assistant.ts +++ /dev/null @@ -1,890 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../V1"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; -import { DefaultsListInstance } from "./assistant/defaults"; -import { DialogueListInstance } from "./assistant/dialogue"; -import { FieldTypeListInstance } from "./assistant/fieldType"; -import { ModelBuildListInstance } from "./assistant/modelBuild"; -import { QueryListInstance } from "./assistant/query"; -import { StyleSheetListInstance } from "./assistant/styleSheet"; -import { TaskListInstance } from "./assistant/task"; -import { WebhookListInstance } from "./assistant/webhook"; - -/** - * Options to pass to update a AssistantInstance - */ -export interface AssistantContextUpdateOptions { - /** A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. */ - friendlyName?: string; - /** Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. */ - logQueries?: boolean; - /** An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. */ - uniqueName?: string; - /** Reserved. */ - callbackUrl?: string; - /** Reserved. */ - callbackEvents?: string; - /** The JSON string that defines the Assistant\\\'s [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet) */ - styleSheet?: any; - /** A JSON object that defines the Assistant\\\'s [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks. */ - defaults?: any; - /** A string describing the state of the assistant. */ - developmentStage?: string; -} - -/** - * Options to pass to create a AssistantInstance - */ -export interface AssistantListInstanceCreateOptions { - /** A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. */ - friendlyName?: string; - /** Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. */ - logQueries?: boolean; - /** An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. */ - uniqueName?: string; - /** Reserved. */ - callbackUrl?: string; - /** Reserved. */ - callbackEvents?: string; - /** The JSON string that defines the Assistant\\\'s [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet) */ - styleSheet?: any; - /** A JSON object that defines the Assistant\\\'s [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks. */ - defaults?: any; -} -/** - * Options to pass to each - */ -export interface AssistantListInstanceEachOptions { - /** 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: AssistantInstance, 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 AssistantListInstanceOptions { - /** 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 AssistantListInstancePageOptions { - /** 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 AssistantContext { - defaults: DefaultsListInstance; - dialogues: DialogueListInstance; - fieldTypes: FieldTypeListInstance; - modelBuilds: ModelBuildListInstance; - queries: QueryListInstance; - styleSheet: StyleSheetListInstance; - tasks: TaskListInstance; - webhooks: WebhookListInstance; - - /** - * Remove a AssistantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a AssistantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AssistantInstance - */ - fetch( - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise; - - /** - * Update a AssistantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AssistantInstance - */ - update( - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise; - /** - * Update a AssistantInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AssistantInstance - */ - update( - params: AssistantContextUpdateOptions, - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface AssistantContextSolution { - sid: string; -} - -export class AssistantContextImpl implements AssistantContext { - protected _solution: AssistantContextSolution; - protected _uri: string; - - protected _defaults?: DefaultsListInstance; - protected _dialogues?: DialogueListInstance; - protected _fieldTypes?: FieldTypeListInstance; - protected _modelBuilds?: ModelBuildListInstance; - protected _queries?: QueryListInstance; - protected _styleSheet?: StyleSheetListInstance; - protected _tasks?: TaskListInstance; - protected _webhooks?: WebhookListInstance; - - constructor(protected _version: V1, sid: string) { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { sid }; - this._uri = `/Assistants/${sid}`; - } - - get defaults(): DefaultsListInstance { - this._defaults = - this._defaults || DefaultsListInstance(this._version, this._solution.sid); - return this._defaults; - } - - get dialogues(): DialogueListInstance { - this._dialogues = - this._dialogues || - DialogueListInstance(this._version, this._solution.sid); - return this._dialogues; - } - - get fieldTypes(): FieldTypeListInstance { - this._fieldTypes = - this._fieldTypes || - FieldTypeListInstance(this._version, this._solution.sid); - return this._fieldTypes; - } - - get modelBuilds(): ModelBuildListInstance { - this._modelBuilds = - this._modelBuilds || - ModelBuildListInstance(this._version, this._solution.sid); - return this._modelBuilds; - } - - get queries(): QueryListInstance { - this._queries = - this._queries || QueryListInstance(this._version, this._solution.sid); - return this._queries; - } - - get styleSheet(): StyleSheetListInstance { - this._styleSheet = - this._styleSheet || - StyleSheetListInstance(this._version, this._solution.sid); - return this._styleSheet; - } - - get tasks(): TaskListInstance { - this._tasks = - this._tasks || TaskListInstance(this._version, this._solution.sid); - return this._tasks; - } - - get webhooks(): WebhookListInstance { - this._webhooks = - this._webhooks || WebhookListInstance(this._version, this._solution.sid); - return this._webhooks; - } - - 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?: AssistantInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new AssistantInstance(operationVersion, payload, instance._solution.sid) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | AssistantContextUpdateOptions - | ((error: Error | null, item?: AssistantInstance) => any), - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["logQueries"] !== undefined) - data["LogQueries"] = serialize.bool(params["logQueries"]); - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - if (params["callbackUrl"] !== undefined) - data["CallbackUrl"] = params["callbackUrl"]; - if (params["callbackEvents"] !== undefined) - data["CallbackEvents"] = params["callbackEvents"]; - if (params["styleSheet"] !== undefined) - data["StyleSheet"] = serialize.object(params["styleSheet"]); - if (params["defaults"] !== undefined) - data["Defaults"] = serialize.object(params["defaults"]); - if (params["developmentStage"] !== undefined) - data["DevelopmentStage"] = params["developmentStage"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new AssistantInstance(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 AssistantPayload extends TwilioResponsePayload { - assistants: AssistantResource[]; -} - -interface AssistantResource { - account_sid: string; - date_created: Date; - date_updated: Date; - friendly_name: string; - latest_model_build_sid: string; - links: Record; - log_queries: boolean; - development_stage: string; - needs_model_build: boolean; - sid: string; - unique_name: string; - url: string; - callback_url: string; - callback_events: string; -} - -export class AssistantInstance { - protected _solution: AssistantContextSolution; - protected _context?: AssistantContext; - - constructor( - protected _version: V1, - payload: AssistantResource, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.friendlyName = payload.friendly_name; - this.latestModelBuildSid = payload.latest_model_build_sid; - this.links = payload.links; - this.logQueries = payload.log_queries; - this.developmentStage = payload.development_stage; - this.needsModelBuild = payload.needs_model_build; - this.sid = payload.sid; - this.uniqueName = payload.unique_name; - this.url = payload.url; - this.callbackUrl = payload.callback_url; - this.callbackEvents = payload.callback_events; - - this._solution = { sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long. - */ - friendlyName: string; - /** - * Reserved. - */ - latestModelBuildSid: string; - /** - * A list of the URLs of the Assistant\'s related resources. - */ - links: Record; - /** - * Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - */ - logQueries: boolean; - /** - * A string describing the state of the assistant. - */ - developmentStage: string; - /** - * Whether model needs to be rebuilt. - */ - needsModelBuild: boolean; - /** - * The unique string that we created to identify the Assistant resource. - */ - sid: string; - /** - * An application-defined string that uniquely identifies the resource. It can be used in place of the resource\'s `sid` in the URL to address the resource. It can be up to 64 characters long. - */ - uniqueName: string; - /** - * The absolute URL of the Assistant resource. - */ - url: string; - /** - * Reserved. - */ - callbackUrl: string; - /** - * Reserved. - */ - callbackEvents: string; - - private get _proxy(): AssistantContext { - this._context = - this._context || - new AssistantContextImpl(this._version, this._solution.sid); - return this._context; - } - - /** - * Remove a AssistantInstance - * - * @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 AssistantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AssistantInstance - */ - fetch( - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a AssistantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AssistantInstance - */ - update( - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise; - /** - * Update a AssistantInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AssistantInstance - */ - update( - params: AssistantContextUpdateOptions, - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Access the defaults. - */ - defaults(): DefaultsListInstance { - return this._proxy.defaults; - } - - /** - * Access the dialogues. - */ - dialogues(): DialogueListInstance { - return this._proxy.dialogues; - } - - /** - * Access the fieldTypes. - */ - fieldTypes(): FieldTypeListInstance { - return this._proxy.fieldTypes; - } - - /** - * Access the modelBuilds. - */ - modelBuilds(): ModelBuildListInstance { - return this._proxy.modelBuilds; - } - - /** - * Access the queries. - */ - queries(): QueryListInstance { - return this._proxy.queries; - } - - /** - * Access the styleSheet. - */ - styleSheet(): StyleSheetListInstance { - return this._proxy.styleSheet; - } - - /** - * Access the tasks. - */ - tasks(): TaskListInstance { - return this._proxy.tasks; - } - - /** - * Access the webhooks. - */ - webhooks(): WebhookListInstance { - return this._proxy.webhooks; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - friendlyName: this.friendlyName, - latestModelBuildSid: this.latestModelBuildSid, - links: this.links, - logQueries: this.logQueries, - developmentStage: this.developmentStage, - needsModelBuild: this.needsModelBuild, - sid: this.sid, - uniqueName: this.uniqueName, - url: this.url, - callbackUrl: this.callbackUrl, - callbackEvents: this.callbackEvents, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface AssistantSolution {} - -export interface AssistantListInstance { - _version: V1; - _solution: AssistantSolution; - _uri: string; - - (sid: string): AssistantContext; - get(sid: string): AssistantContext; - - /** - * Create a AssistantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AssistantInstance - */ - create( - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise; - /** - * Create a AssistantInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed AssistantInstance - */ - create( - params: AssistantListInstanceCreateOptions, - callback?: (error: Error | null, item?: AssistantInstance) => any - ): Promise; - - /** - * Streams AssistantInstance 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 { AssistantListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: AssistantInstance, done: (err?: Error) => void) => void - ): void; - each( - params: AssistantListInstanceEachOptions, - callback?: (item: AssistantInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of AssistantInstance 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: AssistantPage) => any - ): Promise; - /** - * Lists AssistantInstance 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 { AssistantListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: AssistantInstance[]) => any - ): Promise; - list( - params: AssistantListInstanceOptions, - callback?: (error: Error | null, items: AssistantInstance[]) => any - ): Promise; - /** - * Retrieve a single page of AssistantInstance 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 { AssistantListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: AssistantPage) => any - ): Promise; - page( - params: AssistantListInstancePageOptions, - callback?: (error: Error | null, items: AssistantPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function AssistantListInstance(version: V1): AssistantListInstance { - const instance = ((sid) => instance.get(sid)) as AssistantListInstance; - - instance.get = function get(sid): AssistantContext { - return new AssistantContextImpl(version, sid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = `/Assistants`; - - instance.create = function create( - params?: - | AssistantListInstanceCreateOptions - | ((error: Error | null, items: AssistantInstance) => any), - callback?: (error: Error | null, items: AssistantInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["logQueries"] !== undefined) - data["LogQueries"] = serialize.bool(params["logQueries"]); - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - if (params["callbackUrl"] !== undefined) - data["CallbackUrl"] = params["callbackUrl"]; - if (params["callbackEvents"] !== undefined) - data["CallbackEvents"] = params["callbackEvents"]; - if (params["styleSheet"] !== undefined) - data["StyleSheet"] = serialize.object(params["styleSheet"]); - if (params["defaults"] !== undefined) - data["Defaults"] = serialize.object(params["defaults"]); - - 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 AssistantInstance(operationVersion, payload) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | AssistantListInstancePageOptions - | ((error: Error | null, items: AssistantPage) => any), - callback?: (error: Error | null, items: AssistantPage) => 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 AssistantPage(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: AssistantPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new AssistantPage(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 AssistantPage extends Page< - V1, - AssistantPayload, - AssistantResource, - AssistantInstance -> { - /** - * Initialize the AssistantPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: AssistantSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of AssistantInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: AssistantResource): AssistantInstance { - return new AssistantInstance(this._version, payload); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/assistant/defaults.ts b/src/rest/autopilot/v1/assistant/defaults.ts deleted file mode 100644 index b234dcaeba..0000000000 --- a/src/rest/autopilot/v1/assistant/defaults.ts +++ /dev/null @@ -1,335 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 update a DefaultsInstance - */ -export interface DefaultsContextUpdateOptions { - /** A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations. */ - defaults?: any; -} - -export interface DefaultsContext { - /** - * Fetch a DefaultsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DefaultsInstance - */ - fetch( - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise; - - /** - * Update a DefaultsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DefaultsInstance - */ - update( - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise; - /** - * Update a DefaultsInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DefaultsInstance - */ - update( - params: DefaultsContextUpdateOptions, - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface DefaultsContextSolution { - assistantSid: string; -} - -export class DefaultsContextImpl implements DefaultsContext { - protected _solution: DefaultsContextSolution; - protected _uri: string; - - constructor(protected _version: V1, assistantSid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - this._solution = { assistantSid }; - this._uri = `/Assistants/${assistantSid}/Defaults`; - } - - fetch( - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new DefaultsInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | DefaultsContextUpdateOptions - | ((error: Error | null, item?: DefaultsInstance) => any), - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["defaults"] !== undefined) - data["Defaults"] = serialize.object(params["defaults"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new DefaultsInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - 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 DefaultsPayload extends DefaultsResource {} - -interface DefaultsResource { - account_sid: string; - assistant_sid: string; - url: string; - data: any; -} - -export class DefaultsInstance { - protected _solution: DefaultsContextSolution; - protected _context?: DefaultsContext; - - constructor( - protected _version: V1, - payload: DefaultsResource, - assistantSid: string - ) { - this.accountSid = payload.account_sid; - this.assistantSid = payload.assistant_sid; - this.url = payload.url; - this.data = payload.data; - - this._solution = { assistantSid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Defaults resource. - */ - accountSid: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - */ - assistantSid: string; - /** - * The absolute URL of the Defaults resource. - */ - url: string; - /** - * The JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations. - */ - data: any; - - private get _proxy(): DefaultsContext { - this._context = - this._context || - new DefaultsContextImpl(this._version, this._solution.assistantSid); - return this._context; - } - - /** - * Fetch a DefaultsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DefaultsInstance - */ - fetch( - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a DefaultsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DefaultsInstance - */ - update( - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise; - /** - * Update a DefaultsInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DefaultsInstance - */ - update( - params: DefaultsContextUpdateOptions, - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: DefaultsInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - assistantSid: this.assistantSid, - url: this.url, - data: this.data, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface DefaultsSolution { - assistantSid: string; -} - -export interface DefaultsListInstance { - _version: V1; - _solution: DefaultsSolution; - _uri: string; - - (): DefaultsContext; - get(): DefaultsContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function DefaultsListInstance( - version: V1, - assistantSid: string -): DefaultsListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - const instance = (() => instance.get()) as DefaultsListInstance; - - instance.get = function get(): DefaultsContext { - return new DefaultsContextImpl(version, assistantSid); - }; - - instance._version = version; - instance._solution = { assistantSid }; - 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/autopilot/v1/assistant/dialogue.ts b/src/rest/autopilot/v1/assistant/dialogue.ts deleted file mode 100644 index 484d5c592a..0000000000 --- a/src/rest/autopilot/v1/assistant/dialogue.ts +++ /dev/null @@ -1,246 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 DialogueContext { - /** - * Fetch a DialogueInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DialogueInstance - */ - fetch( - callback?: (error: Error | null, item?: DialogueInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface DialogueContextSolution { - assistantSid: string; - sid: string; -} - -export class DialogueContextImpl implements DialogueContext { - protected _solution: DialogueContextSolution; - protected _uri: string; - - constructor(protected _version: V1, assistantSid: string, sid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, sid }; - this._uri = `/Assistants/${assistantSid}/Dialogues/${sid}`; - } - - fetch( - callback?: (error: Error | null, item?: DialogueInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new DialogueInstance( - operationVersion, - payload, - instance._solution.assistantSid, - 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 DialoguePayload extends DialogueResource {} - -interface DialogueResource { - account_sid: string; - assistant_sid: string; - sid: string; - data: any; - url: string; -} - -export class DialogueInstance { - protected _solution: DialogueContextSolution; - protected _context?: DialogueContext; - - constructor( - protected _version: V1, - payload: DialogueResource, - assistantSid: string, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.data = payload.data; - this.url = payload.url; - - this._solution = { assistantSid, sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Dialogue resource. - */ - accountSid: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the Dialogue resource. - */ - sid: string; - /** - * The JSON string that describes the dialogue session object. - */ - data: any; - /** - * The absolute URL of the Dialogue resource. - */ - url: string; - - private get _proxy(): DialogueContext { - this._context = - this._context || - new DialogueContextImpl( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._context; - } - - /** - * Fetch a DialogueInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DialogueInstance - */ - fetch( - callback?: (error: Error | null, item?: DialogueInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - assistantSid: this.assistantSid, - sid: this.sid, - data: this.data, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface DialogueSolution { - assistantSid: string; -} - -export interface DialogueListInstance { - _version: V1; - _solution: DialogueSolution; - _uri: string; - - (sid: string): DialogueContext; - get(sid: string): DialogueContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function DialogueListInstance( - version: V1, - assistantSid: string -): DialogueListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as DialogueListInstance; - - instance.get = function get(sid): DialogueContext { - return new DialogueContextImpl(version, assistantSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid }; - 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/autopilot/v1/assistant/fieldType.ts b/src/rest/autopilot/v1/assistant/fieldType.ts deleted file mode 100644 index 567db552e3..0000000000 --- a/src/rest/autopilot/v1/assistant/fieldType.ts +++ /dev/null @@ -1,726 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../../V1"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; -import { FieldValueListInstance } from "./fieldType/fieldValue"; - -/** - * Options to pass to update a FieldTypeInstance - */ -export interface FieldTypeContextUpdateOptions { - /** A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. */ - friendlyName?: string; - /** An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. */ - uniqueName?: string; -} - -/** - * Options to pass to create a FieldTypeInstance - */ -export interface FieldTypeListInstanceCreateOptions { - /** An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. */ - uniqueName: string; - /** A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. */ - friendlyName?: string; -} -/** - * Options to pass to each - */ -export interface FieldTypeListInstanceEachOptions { - /** 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: FieldTypeInstance, 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 FieldTypeListInstanceOptions { - /** 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 FieldTypeListInstancePageOptions { - /** 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 FieldTypeContext { - fieldValues: FieldValueListInstance; - - /** - * Remove a FieldTypeInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a FieldTypeInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldTypeInstance - */ - fetch( - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise; - - /** - * Update a FieldTypeInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldTypeInstance - */ - update( - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise; - /** - * Update a FieldTypeInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldTypeInstance - */ - update( - params: FieldTypeContextUpdateOptions, - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface FieldTypeContextSolution { - assistantSid: string; - sid: string; -} - -export class FieldTypeContextImpl implements FieldTypeContext { - protected _solution: FieldTypeContextSolution; - protected _uri: string; - - protected _fieldValues?: FieldValueListInstance; - - constructor(protected _version: V1, assistantSid: string, sid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, sid }; - this._uri = `/Assistants/${assistantSid}/FieldTypes/${sid}`; - } - - get fieldValues(): FieldValueListInstance { - this._fieldValues = - this._fieldValues || - FieldValueListInstance( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._fieldValues; - } - - 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?: FieldTypeInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new FieldTypeInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | FieldTypeContextUpdateOptions - | ((error: Error | null, item?: FieldTypeInstance) => any), - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new FieldTypeInstance( - operationVersion, - payload, - instance._solution.assistantSid, - 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 FieldTypePayload extends TwilioResponsePayload { - field_types: FieldTypeResource[]; -} - -interface FieldTypeResource { - account_sid: string; - date_created: Date; - date_updated: Date; - friendly_name: string; - links: Record; - assistant_sid: string; - sid: string; - unique_name: string; - url: string; -} - -export class FieldTypeInstance { - protected _solution: FieldTypeContextSolution; - protected _context?: FieldTypeContext; - - constructor( - protected _version: V1, - payload: FieldTypeResource, - assistantSid: string, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.friendlyName = payload.friendly_name; - this.links = payload.links; - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.uniqueName = payload.unique_name; - this.url = payload.url; - - this._solution = { assistantSid, sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the FieldType resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long. - */ - friendlyName: string; - /** - * A list of the URLs of related resources. - */ - links: Record; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the FieldType resource. - */ - sid: string; - /** - * An application-defined string that uniquely identifies the resource. It can be used in place of the resource\'s `sid` in the URL to address the resource. - */ - uniqueName: string; - /** - * The absolute URL of the FieldType resource. - */ - url: string; - - private get _proxy(): FieldTypeContext { - this._context = - this._context || - new FieldTypeContextImpl( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a FieldTypeInstance - * - * @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 FieldTypeInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldTypeInstance - */ - fetch( - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a FieldTypeInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldTypeInstance - */ - update( - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise; - /** - * Update a FieldTypeInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldTypeInstance - */ - update( - params: FieldTypeContextUpdateOptions, - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Access the fieldValues. - */ - fieldValues(): FieldValueListInstance { - return this._proxy.fieldValues; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - friendlyName: this.friendlyName, - links: this.links, - assistantSid: this.assistantSid, - sid: this.sid, - uniqueName: this.uniqueName, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface FieldTypeSolution { - assistantSid: string; -} - -export interface FieldTypeListInstance { - _version: V1; - _solution: FieldTypeSolution; - _uri: string; - - (sid: string): FieldTypeContext; - get(sid: string): FieldTypeContext; - - /** - * Create a FieldTypeInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldTypeInstance - */ - create( - params: FieldTypeListInstanceCreateOptions, - callback?: (error: Error | null, item?: FieldTypeInstance) => any - ): Promise; - - /** - * Streams FieldTypeInstance 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 { FieldTypeListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: FieldTypeInstance, done: (err?: Error) => void) => void - ): void; - each( - params: FieldTypeListInstanceEachOptions, - callback?: (item: FieldTypeInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of FieldTypeInstance 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: FieldTypePage) => any - ): Promise; - /** - * Lists FieldTypeInstance 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 { FieldTypeListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: FieldTypeInstance[]) => any - ): Promise; - list( - params: FieldTypeListInstanceOptions, - callback?: (error: Error | null, items: FieldTypeInstance[]) => any - ): Promise; - /** - * Retrieve a single page of FieldTypeInstance 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 { FieldTypeListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: FieldTypePage) => any - ): Promise; - page( - params: FieldTypeListInstancePageOptions, - callback?: (error: Error | null, items: FieldTypePage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function FieldTypeListInstance( - version: V1, - assistantSid: string -): FieldTypeListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as FieldTypeListInstance; - - instance.get = function get(sid): FieldTypeContext { - return new FieldTypeContextImpl(version, assistantSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid }; - instance._uri = `/Assistants/${assistantSid}/FieldTypes`; - - instance.create = function create( - params: FieldTypeListInstanceCreateOptions, - callback?: (error: Error | null, items: FieldTypeInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["uniqueName"] === null || params["uniqueName"] === undefined) { - throw new Error("Required parameter \"params['uniqueName']\" missing."); - } - - let data: any = {}; - - data["UniqueName"] = params["uniqueName"]; - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - - 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 FieldTypeInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | FieldTypeListInstancePageOptions - | ((error: Error | null, items: FieldTypePage) => any), - callback?: (error: Error | null, items: FieldTypePage) => 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 FieldTypePage(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: FieldTypePage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new FieldTypePage(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 FieldTypePage extends Page< - V1, - FieldTypePayload, - FieldTypeResource, - FieldTypeInstance -> { - /** - * Initialize the FieldTypePage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: FieldTypeSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of FieldTypeInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: FieldTypeResource): FieldTypeInstance { - return new FieldTypeInstance( - this._version, - payload, - this._solution.assistantSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/assistant/fieldType/fieldValue.ts b/src/rest/autopilot/v1/assistant/fieldType/fieldValue.ts deleted file mode 100644 index 00c0aec730..0000000000 --- a/src/rest/autopilot/v1/assistant/fieldType/fieldValue.ts +++ /dev/null @@ -1,634 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../../../V1"; -const deserialize = require("../../../../../base/deserialize"); -const serialize = require("../../../../../base/serialize"); -import { isValidPathParam } from "../../../../../base/utility"; - -/** - * Options to pass to create a FieldValueInstance - */ -export interface FieldValueListInstanceCreateOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` */ - language: string; - /** The Field Value data. */ - value: string; - /** The string value that indicates which word the field value is a synonym of. */ - synonymOf?: string; -} -/** - * Options to pass to each - */ -export interface FieldValueListInstanceEachOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` */ - language?: 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: FieldValueInstance, 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 FieldValueListInstanceOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` */ - language?: 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 FieldValueListInstancePageOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` */ - language?: 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 FieldValueContext { - /** - * Remove a FieldValueInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a FieldValueInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldValueInstance - */ - fetch( - callback?: (error: Error | null, item?: FieldValueInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface FieldValueContextSolution { - assistantSid: string; - fieldTypeSid: string; - sid: string; -} - -export class FieldValueContextImpl implements FieldValueContext { - protected _solution: FieldValueContextSolution; - protected _uri: string; - - constructor( - protected _version: V1, - assistantSid: string, - fieldTypeSid: string, - sid: string - ) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(fieldTypeSid)) { - throw new Error("Parameter 'fieldTypeSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, fieldTypeSid, sid }; - this._uri = `/Assistants/${assistantSid}/FieldTypes/${fieldTypeSid}/FieldValues/${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?: FieldValueInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new FieldValueInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.fieldTypeSid, - 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 FieldValuePayload extends TwilioResponsePayload { - field_values: FieldValueResource[]; -} - -interface FieldValueResource { - account_sid: string; - date_created: Date; - date_updated: Date; - field_type_sid: string; - language: string; - assistant_sid: string; - sid: string; - value: string; - url: string; - synonym_of: string; -} - -export class FieldValueInstance { - protected _solution: FieldValueContextSolution; - protected _context?: FieldValueContext; - - constructor( - protected _version: V1, - payload: FieldValueResource, - assistantSid: string, - fieldTypeSid: string, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.fieldTypeSid = payload.field_type_sid; - this.language = payload.language; - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.value = payload.value; - this.url = payload.url; - this.synonymOf = payload.synonym_of; - - this._solution = { assistantSid, fieldTypeSid, sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the FieldValue resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The SID of the Field Type associated with the Field Value. - */ - fieldTypeSid: string; - /** - * The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - */ - language: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the FieldType associated with the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the FieldValue resource. - */ - sid: string; - /** - * The Field Value data. - */ - value: string; - /** - * The absolute URL of the FieldValue resource. - */ - url: string; - /** - * The word for which the field value is a synonym of. - */ - synonymOf: string; - - private get _proxy(): FieldValueContext { - this._context = - this._context || - new FieldValueContextImpl( - this._version, - this._solution.assistantSid, - this._solution.fieldTypeSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a FieldValueInstance - * - * @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 FieldValueInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldValueInstance - */ - fetch( - callback?: (error: Error | null, item?: FieldValueInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - fieldTypeSid: this.fieldTypeSid, - language: this.language, - assistantSid: this.assistantSid, - sid: this.sid, - value: this.value, - url: this.url, - synonymOf: this.synonymOf, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface FieldValueSolution { - assistantSid: string; - fieldTypeSid: string; -} - -export interface FieldValueListInstance { - _version: V1; - _solution: FieldValueSolution; - _uri: string; - - (sid: string): FieldValueContext; - get(sid: string): FieldValueContext; - - /** - * Create a FieldValueInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldValueInstance - */ - create( - params: FieldValueListInstanceCreateOptions, - callback?: (error: Error | null, item?: FieldValueInstance) => any - ): Promise; - - /** - * Streams FieldValueInstance 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 { FieldValueListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: FieldValueInstance, done: (err?: Error) => void) => void - ): void; - each( - params: FieldValueListInstanceEachOptions, - callback?: (item: FieldValueInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of FieldValueInstance 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: FieldValuePage) => any - ): Promise; - /** - * Lists FieldValueInstance 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 { FieldValueListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: FieldValueInstance[]) => any - ): Promise; - list( - params: FieldValueListInstanceOptions, - callback?: (error: Error | null, items: FieldValueInstance[]) => any - ): Promise; - /** - * Retrieve a single page of FieldValueInstance 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 { FieldValueListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: FieldValuePage) => any - ): Promise; - page( - params: FieldValueListInstancePageOptions, - callback?: (error: Error | null, items: FieldValuePage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function FieldValueListInstance( - version: V1, - assistantSid: string, - fieldTypeSid: string -): FieldValueListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(fieldTypeSid)) { - throw new Error("Parameter 'fieldTypeSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as FieldValueListInstance; - - instance.get = function get(sid): FieldValueContext { - return new FieldValueContextImpl(version, assistantSid, fieldTypeSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid, fieldTypeSid }; - instance._uri = `/Assistants/${assistantSid}/FieldTypes/${fieldTypeSid}/FieldValues`; - - instance.create = function create( - params: FieldValueListInstanceCreateOptions, - callback?: (error: Error | null, items: FieldValueInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["language"] === null || params["language"] === undefined) { - throw new Error("Required parameter \"params['language']\" missing."); - } - - if (params["value"] === null || params["value"] === undefined) { - throw new Error("Required parameter \"params['value']\" missing."); - } - - let data: any = {}; - - data["Language"] = params["language"]; - - data["Value"] = params["value"]; - if (params["synonymOf"] !== undefined) - data["SynonymOf"] = params["synonymOf"]; - - 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 FieldValueInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.fieldTypeSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | FieldValueListInstancePageOptions - | ((error: Error | null, items: FieldValuePage) => any), - callback?: (error: Error | null, items: FieldValuePage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["language"] !== undefined) data["Language"] = params["language"]; - 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 FieldValuePage(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: FieldValuePage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new FieldValuePage(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 FieldValuePage extends Page< - V1, - FieldValuePayload, - FieldValueResource, - FieldValueInstance -> { - /** - * Initialize the FieldValuePage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: FieldValueSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of FieldValueInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: FieldValueResource): FieldValueInstance { - return new FieldValueInstance( - this._version, - payload, - this._solution.assistantSid, - this._solution.fieldTypeSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/assistant/modelBuild.ts b/src/rest/autopilot/v1/assistant/modelBuild.ts deleted file mode 100644 index 19140b39e5..0000000000 --- a/src/rest/autopilot/v1/assistant/modelBuild.ts +++ /dev/null @@ -1,722 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../../V1"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -export type ModelBuildStatus = - | "enqueued" - | "building" - | "completed" - | "failed" - | "canceled"; - -/** - * Options to pass to update a ModelBuildInstance - */ -export interface ModelBuildContextUpdateOptions { - /** An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. */ - uniqueName?: string; -} - -/** - * Options to pass to create a ModelBuildInstance - */ -export interface ModelBuildListInstanceCreateOptions { - /** The URL we should call using a POST method to send status information to your application. */ - statusCallback?: string; - /** An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. */ - uniqueName?: string; -} -/** - * Options to pass to each - */ -export interface ModelBuildListInstanceEachOptions { - /** 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: ModelBuildInstance, 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 ModelBuildListInstanceOptions { - /** 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 ModelBuildListInstancePageOptions { - /** 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 ModelBuildContext { - /** - * Remove a ModelBuildInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a ModelBuildInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ModelBuildInstance - */ - fetch( - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise; - - /** - * Update a ModelBuildInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ModelBuildInstance - */ - update( - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise; - /** - * Update a ModelBuildInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ModelBuildInstance - */ - update( - params: ModelBuildContextUpdateOptions, - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface ModelBuildContextSolution { - assistantSid: string; - sid: string; -} - -export class ModelBuildContextImpl implements ModelBuildContext { - protected _solution: ModelBuildContextSolution; - protected _uri: string; - - constructor(protected _version: V1, assistantSid: string, sid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, sid }; - this._uri = `/Assistants/${assistantSid}/ModelBuilds/${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?: ModelBuildInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new ModelBuildInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | ModelBuildContextUpdateOptions - | ((error: Error | null, item?: ModelBuildInstance) => any), - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new ModelBuildInstance( - operationVersion, - payload, - instance._solution.assistantSid, - 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 ModelBuildPayload extends TwilioResponsePayload { - model_builds: ModelBuildResource[]; -} - -interface ModelBuildResource { - account_sid: string; - date_created: Date; - date_updated: Date; - assistant_sid: string; - sid: string; - status: ModelBuildStatus; - unique_name: string; - url: string; - build_duration: number; - error_code: number; -} - -export class ModelBuildInstance { - protected _solution: ModelBuildContextSolution; - protected _context?: ModelBuildContext; - - constructor( - protected _version: V1, - payload: ModelBuildResource, - assistantSid: string, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.status = payload.status; - this.uniqueName = payload.unique_name; - this.url = payload.url; - this.buildDuration = deserialize.integer(payload.build_duration); - this.errorCode = deserialize.integer(payload.error_code); - - this._solution = { assistantSid, sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ModelBuild resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the ModelBuild resource. - */ - sid: string; - status: ModelBuildStatus; - /** - * An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. - */ - uniqueName: string; - /** - * The absolute URL of the ModelBuild resource. - */ - url: string; - /** - * The time in seconds it took to build the model. - */ - buildDuration: number; - /** - * If the `status` for the model build is `failed`, this value is a code to more information about the failure. This value will be null for all other statuses. See [error code dictionary](https://www.twilio.com/docs/api/errors) for a description of the error. - */ - errorCode: number; - - private get _proxy(): ModelBuildContext { - this._context = - this._context || - new ModelBuildContextImpl( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a ModelBuildInstance - * - * @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 ModelBuildInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ModelBuildInstance - */ - fetch( - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a ModelBuildInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ModelBuildInstance - */ - update( - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise; - /** - * Update a ModelBuildInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ModelBuildInstance - */ - update( - params: ModelBuildContextUpdateOptions, - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - assistantSid: this.assistantSid, - sid: this.sid, - status: this.status, - uniqueName: this.uniqueName, - url: this.url, - buildDuration: this.buildDuration, - errorCode: this.errorCode, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface ModelBuildSolution { - assistantSid: string; -} - -export interface ModelBuildListInstance { - _version: V1; - _solution: ModelBuildSolution; - _uri: string; - - (sid: string): ModelBuildContext; - get(sid: string): ModelBuildContext; - - /** - * Create a ModelBuildInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ModelBuildInstance - */ - create( - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise; - /** - * Create a ModelBuildInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ModelBuildInstance - */ - create( - params: ModelBuildListInstanceCreateOptions, - callback?: (error: Error | null, item?: ModelBuildInstance) => any - ): Promise; - - /** - * Streams ModelBuildInstance 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 { ModelBuildListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: ModelBuildInstance, done: (err?: Error) => void) => void - ): void; - each( - params: ModelBuildListInstanceEachOptions, - callback?: (item: ModelBuildInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of ModelBuildInstance 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: ModelBuildPage) => any - ): Promise; - /** - * Lists ModelBuildInstance 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 { ModelBuildListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: ModelBuildInstance[]) => any - ): Promise; - list( - params: ModelBuildListInstanceOptions, - callback?: (error: Error | null, items: ModelBuildInstance[]) => any - ): Promise; - /** - * Retrieve a single page of ModelBuildInstance 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 { ModelBuildListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: ModelBuildPage) => any - ): Promise; - page( - params: ModelBuildListInstancePageOptions, - callback?: (error: Error | null, items: ModelBuildPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function ModelBuildListInstance( - version: V1, - assistantSid: string -): ModelBuildListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as ModelBuildListInstance; - - instance.get = function get(sid): ModelBuildContext { - return new ModelBuildContextImpl(version, assistantSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid }; - instance._uri = `/Assistants/${assistantSid}/ModelBuilds`; - - instance.create = function create( - params?: - | ModelBuildListInstanceCreateOptions - | ((error: Error | null, items: ModelBuildInstance) => any), - callback?: (error: Error | null, items: ModelBuildInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["statusCallback"] !== undefined) - data["StatusCallback"] = params["statusCallback"]; - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - - 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 ModelBuildInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | ModelBuildListInstancePageOptions - | ((error: Error | null, items: ModelBuildPage) => any), - callback?: (error: Error | null, items: ModelBuildPage) => 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 ModelBuildPage(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: ModelBuildPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new ModelBuildPage(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 ModelBuildPage extends Page< - V1, - ModelBuildPayload, - ModelBuildResource, - ModelBuildInstance -> { - /** - * Initialize the ModelBuildPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: ModelBuildSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of ModelBuildInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: ModelBuildResource): ModelBuildInstance { - return new ModelBuildInstance( - this._version, - payload, - this._solution.assistantSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/assistant/query.ts b/src/rest/autopilot/v1/assistant/query.ts deleted file mode 100644 index b124853f6a..0000000000 --- a/src/rest/autopilot/v1/assistant/query.ts +++ /dev/null @@ -1,776 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../../V1"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Options to pass to update a QueryInstance - */ -export interface QueryContextUpdateOptions { - /** The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query. */ - sampleSid?: string; - /** The new status of the resource. Can be: `pending-review`, `reviewed`, or `discarded` */ - status?: string; -} - -/** - * Options to pass to create a QueryInstance - */ -export interface QueryListInstanceCreateOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new query. For example: `en-US`. */ - language: string; - /** The end-user\\\'s natural language input. It can be up to 2048 characters long. */ - query: string; - /** The list of tasks to limit the new query to. Tasks are expressed as a comma-separated list of task `unique_name` values. For example, `task-unique_name-1, task-unique_name-2`. Listing specific tasks is useful to constrain the paths that a user can take. */ - tasks?: string; - /** The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. */ - modelBuild?: string; -} -/** - * Options to pass to each - */ -export interface QueryListInstanceEachOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. */ - language?: string; - /** The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. */ - modelBuild?: string; - /** The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` */ - status?: string; - /** The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). */ - dialogueSid?: 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: QueryInstance, 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 QueryListInstanceOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. */ - language?: string; - /** The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. */ - modelBuild?: string; - /** The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` */ - status?: string; - /** The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). */ - dialogueSid?: 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 QueryListInstancePageOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. */ - language?: string; - /** The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. */ - modelBuild?: string; - /** The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` */ - status?: string; - /** The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). */ - dialogueSid?: 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 QueryContext { - /** - * Remove a QueryInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a QueryInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed QueryInstance - */ - fetch( - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise; - - /** - * Update a QueryInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed QueryInstance - */ - update( - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise; - /** - * Update a QueryInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed QueryInstance - */ - update( - params: QueryContextUpdateOptions, - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface QueryContextSolution { - assistantSid: string; - sid: string; -} - -export class QueryContextImpl implements QueryContext { - protected _solution: QueryContextSolution; - protected _uri: string; - - constructor(protected _version: V1, assistantSid: string, sid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, sid }; - this._uri = `/Assistants/${assistantSid}/Queries/${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?: QueryInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new QueryInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | QueryContextUpdateOptions - | ((error: Error | null, item?: QueryInstance) => any), - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["sampleSid"] !== undefined) - data["SampleSid"] = params["sampleSid"]; - if (params["status"] !== undefined) data["Status"] = params["status"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new QueryInstance( - operationVersion, - payload, - instance._solution.assistantSid, - 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 QueryPayload extends TwilioResponsePayload { - queries: QueryResource[]; -} - -interface QueryResource { - account_sid: string; - date_created: Date; - date_updated: Date; - results: any; - language: string; - model_build_sid: string; - query: string; - sample_sid: string; - assistant_sid: string; - sid: string; - status: string; - url: string; - source_channel: string; - dialogue_sid: string; -} - -export class QueryInstance { - protected _solution: QueryContextSolution; - protected _context?: QueryContext; - - constructor( - protected _version: V1, - payload: QueryResource, - assistantSid: string, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.results = payload.results; - this.language = payload.language; - this.modelBuildSid = payload.model_build_sid; - this.query = payload.query; - this.sampleSid = payload.sample_sid; - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.status = payload.status; - this.url = payload.url; - this.sourceChannel = payload.source_channel; - this.dialogueSid = payload.dialogue_sid; - - this._solution = { assistantSid, sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Query resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The natural language analysis results that include the [Task](https://www.twilio.com/docs/autopilot/api/task) recognized and a list of identified [Fields](https://www.twilio.com/docs/autopilot/api/task-field). - */ - results: any; - /** - * The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query. For example: `en-US`. - */ - language: string; - /** - * The SID of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) queried. - */ - modelBuildSid: string; - /** - * The end-user\'s natural language input. - */ - query: string; - /** - * The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query. - */ - sampleSid: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the Query resource. - */ - sid: string; - /** - * The status of the Query. Can be: `pending-review`, `reviewed`, or `discarded` - */ - status: string; - /** - * The absolute URL of the Query resource. - */ - url: string; - /** - * The communication channel from where the end-user input came. - */ - sourceChannel: string; - /** - * The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - */ - dialogueSid: string; - - private get _proxy(): QueryContext { - this._context = - this._context || - new QueryContextImpl( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a QueryInstance - * - * @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 QueryInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed QueryInstance - */ - fetch( - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a QueryInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed QueryInstance - */ - update( - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise; - /** - * Update a QueryInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed QueryInstance - */ - update( - params: QueryContextUpdateOptions, - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - results: this.results, - language: this.language, - modelBuildSid: this.modelBuildSid, - query: this.query, - sampleSid: this.sampleSid, - assistantSid: this.assistantSid, - sid: this.sid, - status: this.status, - url: this.url, - sourceChannel: this.sourceChannel, - dialogueSid: this.dialogueSid, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface QuerySolution { - assistantSid: string; -} - -export interface QueryListInstance { - _version: V1; - _solution: QuerySolution; - _uri: string; - - (sid: string): QueryContext; - get(sid: string): QueryContext; - - /** - * Create a QueryInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed QueryInstance - */ - create( - params: QueryListInstanceCreateOptions, - callback?: (error: Error | null, item?: QueryInstance) => any - ): Promise; - - /** - * Streams QueryInstance 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 { QueryListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: QueryInstance, done: (err?: Error) => void) => void - ): void; - each( - params: QueryListInstanceEachOptions, - callback?: (item: QueryInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of QueryInstance 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: QueryPage) => any - ): Promise; - /** - * Lists QueryInstance 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 { QueryListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: QueryInstance[]) => any - ): Promise; - list( - params: QueryListInstanceOptions, - callback?: (error: Error | null, items: QueryInstance[]) => any - ): Promise; - /** - * Retrieve a single page of QueryInstance 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 { QueryListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: QueryPage) => any - ): Promise; - page( - params: QueryListInstancePageOptions, - callback?: (error: Error | null, items: QueryPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function QueryListInstance( - version: V1, - assistantSid: string -): QueryListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as QueryListInstance; - - instance.get = function get(sid): QueryContext { - return new QueryContextImpl(version, assistantSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid }; - instance._uri = `/Assistants/${assistantSid}/Queries`; - - instance.create = function create( - params: QueryListInstanceCreateOptions, - callback?: (error: Error | null, items: QueryInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["language"] === null || params["language"] === undefined) { - throw new Error("Required parameter \"params['language']\" missing."); - } - - if (params["query"] === null || params["query"] === undefined) { - throw new Error("Required parameter \"params['query']\" missing."); - } - - let data: any = {}; - - data["Language"] = params["language"]; - - data["Query"] = params["query"]; - if (params["tasks"] !== undefined) data["Tasks"] = params["tasks"]; - if (params["modelBuild"] !== undefined) - data["ModelBuild"] = params["modelBuild"]; - - 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 QueryInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | QueryListInstancePageOptions - | ((error: Error | null, items: QueryPage) => any), - callback?: (error: Error | null, items: QueryPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["language"] !== undefined) data["Language"] = params["language"]; - if (params["modelBuild"] !== undefined) - data["ModelBuild"] = params["modelBuild"]; - if (params["status"] !== undefined) data["Status"] = params["status"]; - if (params["dialogueSid"] !== undefined) - data["DialogueSid"] = params["dialogueSid"]; - 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 QueryPage(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: QueryPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => new QueryPage(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 QueryPage extends Page< - V1, - QueryPayload, - QueryResource, - QueryInstance -> { - /** - * Initialize the QueryPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: QuerySolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of QueryInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: QueryResource): QueryInstance { - return new QueryInstance( - this._version, - payload, - this._solution.assistantSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/assistant/styleSheet.ts b/src/rest/autopilot/v1/assistant/styleSheet.ts deleted file mode 100644 index b6da0cbed7..0000000000 --- a/src/rest/autopilot/v1/assistant/styleSheet.ts +++ /dev/null @@ -1,335 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 update a StyleSheetInstance - */ -export interface StyleSheetContextUpdateOptions { - /** The JSON string that describes the style sheet object. */ - styleSheet?: any; -} - -export interface StyleSheetContext { - /** - * Fetch a StyleSheetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed StyleSheetInstance - */ - fetch( - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise; - - /** - * Update a StyleSheetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed StyleSheetInstance - */ - update( - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise; - /** - * Update a StyleSheetInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed StyleSheetInstance - */ - update( - params: StyleSheetContextUpdateOptions, - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface StyleSheetContextSolution { - assistantSid: string; -} - -export class StyleSheetContextImpl implements StyleSheetContext { - protected _solution: StyleSheetContextSolution; - protected _uri: string; - - constructor(protected _version: V1, assistantSid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - this._solution = { assistantSid }; - this._uri = `/Assistants/${assistantSid}/StyleSheet`; - } - - fetch( - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new StyleSheetInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | StyleSheetContextUpdateOptions - | ((error: Error | null, item?: StyleSheetInstance) => any), - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["styleSheet"] !== undefined) - data["StyleSheet"] = serialize.object(params["styleSheet"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new StyleSheetInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - 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 StyleSheetPayload extends StyleSheetResource {} - -interface StyleSheetResource { - account_sid: string; - assistant_sid: string; - url: string; - data: any; -} - -export class StyleSheetInstance { - protected _solution: StyleSheetContextSolution; - protected _context?: StyleSheetContext; - - constructor( - protected _version: V1, - payload: StyleSheetResource, - assistantSid: string - ) { - this.accountSid = payload.account_sid; - this.assistantSid = payload.assistant_sid; - this.url = payload.url; - this.data = payload.data; - - this._solution = { assistantSid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the StyleSheet resource. - */ - accountSid: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - */ - assistantSid: string; - /** - * The absolute URL of the StyleSheet resource. - */ - url: string; - /** - * The JSON string that describes the style sheet object. - */ - data: any; - - private get _proxy(): StyleSheetContext { - this._context = - this._context || - new StyleSheetContextImpl(this._version, this._solution.assistantSid); - return this._context; - } - - /** - * Fetch a StyleSheetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed StyleSheetInstance - */ - fetch( - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a StyleSheetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed StyleSheetInstance - */ - update( - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise; - /** - * Update a StyleSheetInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed StyleSheetInstance - */ - update( - params: StyleSheetContextUpdateOptions, - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: StyleSheetInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - assistantSid: this.assistantSid, - url: this.url, - data: this.data, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface StyleSheetSolution { - assistantSid: string; -} - -export interface StyleSheetListInstance { - _version: V1; - _solution: StyleSheetSolution; - _uri: string; - - (): StyleSheetContext; - get(): StyleSheetContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function StyleSheetListInstance( - version: V1, - assistantSid: string -): StyleSheetListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - const instance = (() => instance.get()) as StyleSheetListInstance; - - instance.get = function get(): StyleSheetContext { - return new StyleSheetContextImpl(version, assistantSid); - }; - - instance._version = version; - instance._solution = { assistantSid }; - 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/autopilot/v1/assistant/task.ts b/src/rest/autopilot/v1/assistant/task.ts deleted file mode 100644 index 48858c661d..0000000000 --- a/src/rest/autopilot/v1/assistant/task.ts +++ /dev/null @@ -1,806 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../../V1"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; -import { FieldListInstance } from "./task/field"; -import { SampleListInstance } from "./task/sample"; -import { TaskActionsListInstance } from "./task/taskActions"; -import { TaskStatisticsListInstance } from "./task/taskStatistics"; - -/** - * Options to pass to update a TaskInstance - */ -export interface TaskContextUpdateOptions { - /** A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. */ - friendlyName?: string; - /** An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource. */ - uniqueName?: string; - /** The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. */ - actions?: any; - /** The URL from which the Assistant can fetch actions. */ - actionsUrl?: string; -} - -/** - * Options to pass to create a TaskInstance - */ -export interface TaskListInstanceCreateOptions { - /** An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. */ - uniqueName: string; - /** A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. */ - friendlyName?: string; - /** The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. It is optional and not unique. */ - actions?: any; - /** The URL from which the Assistant can fetch actions. */ - actionsUrl?: string; -} -/** - * Options to pass to each - */ -export interface TaskListInstanceEachOptions { - /** 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: TaskInstance, 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 TaskListInstanceOptions { - /** 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 TaskListInstancePageOptions { - /** 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 TaskContext { - fields: FieldListInstance; - samples: SampleListInstance; - taskActions: TaskActionsListInstance; - statistics: TaskStatisticsListInstance; - - /** - * Remove a TaskInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a TaskInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskInstance - */ - fetch( - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise; - - /** - * Update a TaskInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskInstance - */ - update( - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise; - /** - * Update a TaskInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskInstance - */ - update( - params: TaskContextUpdateOptions, - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface TaskContextSolution { - assistantSid: string; - sid: string; -} - -export class TaskContextImpl implements TaskContext { - protected _solution: TaskContextSolution; - protected _uri: string; - - protected _fields?: FieldListInstance; - protected _samples?: SampleListInstance; - protected _taskActions?: TaskActionsListInstance; - protected _statistics?: TaskStatisticsListInstance; - - constructor(protected _version: V1, assistantSid: string, sid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, sid }; - this._uri = `/Assistants/${assistantSid}/Tasks/${sid}`; - } - - get fields(): FieldListInstance { - this._fields = - this._fields || - FieldListInstance( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._fields; - } - - get samples(): SampleListInstance { - this._samples = - this._samples || - SampleListInstance( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._samples; - } - - get taskActions(): TaskActionsListInstance { - this._taskActions = - this._taskActions || - TaskActionsListInstance( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._taskActions; - } - - get statistics(): TaskStatisticsListInstance { - this._statistics = - this._statistics || - TaskStatisticsListInstance( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._statistics; - } - - 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?: TaskInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new TaskInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | TaskContextUpdateOptions - | ((error: Error | null, item?: TaskInstance) => any), - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - if (params["actions"] !== undefined) - data["Actions"] = serialize.object(params["actions"]); - if (params["actionsUrl"] !== undefined) - data["ActionsUrl"] = params["actionsUrl"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new TaskInstance( - operationVersion, - payload, - instance._solution.assistantSid, - 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 TaskPayload extends TwilioResponsePayload { - tasks: TaskResource[]; -} - -interface TaskResource { - account_sid: string; - date_created: Date; - date_updated: Date; - friendly_name: string; - links: Record; - assistant_sid: string; - sid: string; - unique_name: string; - actions_url: string; - url: string; -} - -export class TaskInstance { - protected _solution: TaskContextSolution; - protected _context?: TaskContext; - - constructor( - protected _version: V1, - payload: TaskResource, - assistantSid: string, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.friendlyName = payload.friendly_name; - this.links = payload.links; - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.uniqueName = payload.unique_name; - this.actionsUrl = payload.actions_url; - this.url = payload.url; - - this._solution = { assistantSid, sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Task resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long. - */ - friendlyName: string; - /** - * A list of the URLs of related resources. - */ - links: Record; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the Task resource. - */ - sid: string; - /** - * An application-defined string that uniquely identifies the resource. It can be used in place of the resource\'s `sid` in the URL to address the resource. - */ - uniqueName: string; - /** - * The URL from which the Assistant can fetch actions. - */ - actionsUrl: string; - /** - * The absolute URL of the Task resource. - */ - url: string; - - private get _proxy(): TaskContext { - this._context = - this._context || - new TaskContextImpl( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a TaskInstance - * - * @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 TaskInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskInstance - */ - fetch( - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a TaskInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskInstance - */ - update( - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise; - /** - * Update a TaskInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskInstance - */ - update( - params: TaskContextUpdateOptions, - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Access the fields. - */ - fields(): FieldListInstance { - return this._proxy.fields; - } - - /** - * Access the samples. - */ - samples(): SampleListInstance { - return this._proxy.samples; - } - - /** - * Access the taskActions. - */ - taskActions(): TaskActionsListInstance { - return this._proxy.taskActions; - } - - /** - * Access the statistics. - */ - statistics(): TaskStatisticsListInstance { - return this._proxy.statistics; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - friendlyName: this.friendlyName, - links: this.links, - assistantSid: this.assistantSid, - sid: this.sid, - uniqueName: this.uniqueName, - actionsUrl: this.actionsUrl, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface TaskSolution { - assistantSid: string; -} - -export interface TaskListInstance { - _version: V1; - _solution: TaskSolution; - _uri: string; - - (sid: string): TaskContext; - get(sid: string): TaskContext; - - /** - * Create a TaskInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskInstance - */ - create( - params: TaskListInstanceCreateOptions, - callback?: (error: Error | null, item?: TaskInstance) => any - ): Promise; - - /** - * Streams TaskInstance 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 { TaskListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: TaskInstance, done: (err?: Error) => void) => void - ): void; - each( - params: TaskListInstanceEachOptions, - callback?: (item: TaskInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of TaskInstance 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: TaskPage) => any - ): Promise; - /** - * Lists TaskInstance 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 { TaskListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: TaskInstance[]) => any - ): Promise; - list( - params: TaskListInstanceOptions, - callback?: (error: Error | null, items: TaskInstance[]) => any - ): Promise; - /** - * Retrieve a single page of TaskInstance 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 { TaskListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: TaskPage) => any - ): Promise; - page( - params: TaskListInstancePageOptions, - callback?: (error: Error | null, items: TaskPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function TaskListInstance( - version: V1, - assistantSid: string -): TaskListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as TaskListInstance; - - instance.get = function get(sid): TaskContext { - return new TaskContextImpl(version, assistantSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid }; - instance._uri = `/Assistants/${assistantSid}/Tasks`; - - instance.create = function create( - params: TaskListInstanceCreateOptions, - callback?: (error: Error | null, items: TaskInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["uniqueName"] === null || params["uniqueName"] === undefined) { - throw new Error("Required parameter \"params['uniqueName']\" missing."); - } - - let data: any = {}; - - data["UniqueName"] = params["uniqueName"]; - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["actions"] !== undefined) - data["Actions"] = serialize.object(params["actions"]); - if (params["actionsUrl"] !== undefined) - data["ActionsUrl"] = params["actionsUrl"]; - - 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 TaskInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | TaskListInstancePageOptions - | ((error: Error | null, items: TaskPage) => any), - callback?: (error: Error | null, items: TaskPage) => 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 TaskPage(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: TaskPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => new TaskPage(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 TaskPage extends Page< - V1, - TaskPayload, - TaskResource, - TaskInstance -> { - /** - * Initialize the TaskPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor(version: V1, response: Response, solution: TaskSolution) { - super(version, response, solution); - } - - /** - * Build an instance of TaskInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: TaskResource): TaskInstance { - return new TaskInstance( - this._version, - payload, - this._solution.assistantSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/assistant/task/field.ts b/src/rest/autopilot/v1/assistant/task/field.ts deleted file mode 100644 index c46a280a40..0000000000 --- a/src/rest/autopilot/v1/assistant/task/field.ts +++ /dev/null @@ -1,614 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../../../V1"; -const deserialize = require("../../../../../base/deserialize"); -const serialize = require("../../../../../base/serialize"); -import { isValidPathParam } from "../../../../../base/utility"; - -/** - * Options to pass to create a FieldInstance - */ -export interface FieldListInstanceCreateOptions { - /** The Field Type of the new field. Can be: a [Built-in Field Type](https://www.twilio.com/docs/autopilot/built-in-field-types), the `unique_name`, or the `sid` of a custom Field Type. */ - fieldType: string; - /** An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. */ - uniqueName: string; -} -/** - * Options to pass to each - */ -export interface FieldListInstanceEachOptions { - /** 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: FieldInstance, 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 FieldListInstanceOptions { - /** 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 FieldListInstancePageOptions { - /** 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 FieldContext { - /** - * Remove a FieldInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a FieldInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldInstance - */ - fetch( - callback?: (error: Error | null, item?: FieldInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface FieldContextSolution { - assistantSid: string; - taskSid: string; - sid: string; -} - -export class FieldContextImpl implements FieldContext { - protected _solution: FieldContextSolution; - protected _uri: string; - - constructor( - protected _version: V1, - assistantSid: string, - taskSid: string, - sid: string - ) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(taskSid)) { - throw new Error("Parameter 'taskSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, taskSid, sid }; - this._uri = `/Assistants/${assistantSid}/Tasks/${taskSid}/Fields/${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?: FieldInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new FieldInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.taskSid, - 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 FieldPayload extends TwilioResponsePayload { - fields: FieldResource[]; -} - -interface FieldResource { - account_sid: string; - date_created: Date; - date_updated: Date; - field_type: string; - task_sid: string; - assistant_sid: string; - sid: string; - unique_name: string; - url: string; -} - -export class FieldInstance { - protected _solution: FieldContextSolution; - protected _context?: FieldContext; - - constructor( - protected _version: V1, - payload: FieldResource, - assistantSid: string, - taskSid: string, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.fieldType = payload.field_type; - this.taskSid = payload.task_sid; - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.uniqueName = payload.unique_name; - this.url = payload.url; - - this._solution = { assistantSid, taskSid, sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Field resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The Field Type of the field. Can be: a [Built-in Field Type](https://www.twilio.com/docs/autopilot/built-in-field-types), the unique_name, or the SID of a custom Field Type. - */ - fieldType: string; - /** - * The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with this Field. - */ - taskSid: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the Field resource. - */ - sid: string; - /** - * An application-defined string that uniquely identifies the resource. It can be used in place of the resource\'s `sid` in the URL to address the resource. - */ - uniqueName: string; - /** - * The absolute URL of the Field resource. - */ - url: string; - - private get _proxy(): FieldContext { - this._context = - this._context || - new FieldContextImpl( - this._version, - this._solution.assistantSid, - this._solution.taskSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a FieldInstance - * - * @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 FieldInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldInstance - */ - fetch( - callback?: (error: Error | null, item?: FieldInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - fieldType: this.fieldType, - taskSid: this.taskSid, - assistantSid: this.assistantSid, - sid: this.sid, - uniqueName: this.uniqueName, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface FieldSolution { - assistantSid: string; - taskSid: string; -} - -export interface FieldListInstance { - _version: V1; - _solution: FieldSolution; - _uri: string; - - (sid: string): FieldContext; - get(sid: string): FieldContext; - - /** - * Create a FieldInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FieldInstance - */ - create( - params: FieldListInstanceCreateOptions, - callback?: (error: Error | null, item?: FieldInstance) => any - ): Promise; - - /** - * Streams FieldInstance 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 { FieldListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: FieldInstance, done: (err?: Error) => void) => void - ): void; - each( - params: FieldListInstanceEachOptions, - callback?: (item: FieldInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of FieldInstance 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: FieldPage) => any - ): Promise; - /** - * Lists FieldInstance 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 { FieldListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: FieldInstance[]) => any - ): Promise; - list( - params: FieldListInstanceOptions, - callback?: (error: Error | null, items: FieldInstance[]) => any - ): Promise; - /** - * Retrieve a single page of FieldInstance 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 { FieldListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: FieldPage) => any - ): Promise; - page( - params: FieldListInstancePageOptions, - callback?: (error: Error | null, items: FieldPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function FieldListInstance( - version: V1, - assistantSid: string, - taskSid: string -): FieldListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(taskSid)) { - throw new Error("Parameter 'taskSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as FieldListInstance; - - instance.get = function get(sid): FieldContext { - return new FieldContextImpl(version, assistantSid, taskSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid, taskSid }; - instance._uri = `/Assistants/${assistantSid}/Tasks/${taskSid}/Fields`; - - instance.create = function create( - params: FieldListInstanceCreateOptions, - callback?: (error: Error | null, items: FieldInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["fieldType"] === null || params["fieldType"] === undefined) { - throw new Error("Required parameter \"params['fieldType']\" missing."); - } - - if (params["uniqueName"] === null || params["uniqueName"] === undefined) { - throw new Error("Required parameter \"params['uniqueName']\" missing."); - } - - let data: any = {}; - - data["FieldType"] = params["fieldType"]; - - data["UniqueName"] = params["uniqueName"]; - - 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 FieldInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.taskSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | FieldListInstancePageOptions - | ((error: Error | null, items: FieldPage) => any), - callback?: (error: Error | null, items: FieldPage) => 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 FieldPage(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: FieldPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => new FieldPage(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 FieldPage extends Page< - V1, - FieldPayload, - FieldResource, - FieldInstance -> { - /** - * Initialize the FieldPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: FieldSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of FieldInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: FieldResource): FieldInstance { - return new FieldInstance( - this._version, - payload, - this._solution.assistantSid, - this._solution.taskSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/assistant/task/sample.ts b/src/rest/autopilot/v1/assistant/task/sample.ts deleted file mode 100644 index 7770b05881..0000000000 --- a/src/rest/autopilot/v1/assistant/task/sample.ts +++ /dev/null @@ -1,749 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../../../V1"; -const deserialize = require("../../../../../base/deserialize"); -const serialize = require("../../../../../base/serialize"); -import { isValidPathParam } from "../../../../../base/utility"; - -/** - * Options to pass to update a SampleInstance - */ -export interface SampleContextUpdateOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. */ - language?: string; - /** The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). */ - taggedText?: string; - /** The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. */ - sourceChannel?: string; -} - -/** - * Options to pass to create a SampleInstance - */ -export interface SampleListInstanceCreateOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new sample. For example: `en-US`. */ - language: string; - /** The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). */ - taggedText: string; - /** The communication channel from which the new sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. */ - sourceChannel?: string; -} -/** - * Options to pass to each - */ -export interface SampleListInstanceEachOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. */ - language?: 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: SampleInstance, 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 SampleListInstanceOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. */ - language?: 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 SampleListInstancePageOptions { - /** The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. */ - language?: 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 SampleContext { - /** - * Remove a SampleInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a SampleInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SampleInstance - */ - fetch( - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise; - - /** - * Update a SampleInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SampleInstance - */ - update( - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise; - /** - * Update a SampleInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SampleInstance - */ - update( - params: SampleContextUpdateOptions, - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface SampleContextSolution { - assistantSid: string; - taskSid: string; - sid: string; -} - -export class SampleContextImpl implements SampleContext { - protected _solution: SampleContextSolution; - protected _uri: string; - - constructor( - protected _version: V1, - assistantSid: string, - taskSid: string, - sid: string - ) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(taskSid)) { - throw new Error("Parameter 'taskSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, taskSid, sid }; - this._uri = `/Assistants/${assistantSid}/Tasks/${taskSid}/Samples/${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?: SampleInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new SampleInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.taskSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | SampleContextUpdateOptions - | ((error: Error | null, item?: SampleInstance) => any), - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["language"] !== undefined) data["Language"] = params["language"]; - if (params["taggedText"] !== undefined) - data["TaggedText"] = params["taggedText"]; - if (params["sourceChannel"] !== undefined) - data["SourceChannel"] = params["sourceChannel"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new SampleInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.taskSid, - 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 SamplePayload extends TwilioResponsePayload { - samples: SampleResource[]; -} - -interface SampleResource { - account_sid: string; - date_created: Date; - date_updated: Date; - task_sid: string; - language: string; - assistant_sid: string; - sid: string; - tagged_text: string; - url: string; - source_channel: string; -} - -export class SampleInstance { - protected _solution: SampleContextSolution; - protected _context?: SampleContext; - - constructor( - protected _version: V1, - payload: SampleResource, - assistantSid: string, - taskSid: string, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.taskSid = payload.task_sid; - this.language = payload.language; - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.taggedText = payload.tagged_text; - this.url = payload.url; - this.sourceChannel = payload.source_channel; - - this._solution = { assistantSid, taskSid, sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sample resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the resource. - */ - taskSid: string; - /** - * The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - */ - language: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the Sample resource. - */ - sid: string; - /** - * The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). - */ - taggedText: string; - /** - * The absolute URL of the Sample resource. - */ - url: string; - /** - * The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. - */ - sourceChannel: string; - - private get _proxy(): SampleContext { - this._context = - this._context || - new SampleContextImpl( - this._version, - this._solution.assistantSid, - this._solution.taskSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a SampleInstance - * - * @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 SampleInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SampleInstance - */ - fetch( - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a SampleInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SampleInstance - */ - update( - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise; - /** - * Update a SampleInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SampleInstance - */ - update( - params: SampleContextUpdateOptions, - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - taskSid: this.taskSid, - language: this.language, - assistantSid: this.assistantSid, - sid: this.sid, - taggedText: this.taggedText, - url: this.url, - sourceChannel: this.sourceChannel, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface SampleSolution { - assistantSid: string; - taskSid: string; -} - -export interface SampleListInstance { - _version: V1; - _solution: SampleSolution; - _uri: string; - - (sid: string): SampleContext; - get(sid: string): SampleContext; - - /** - * Create a SampleInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SampleInstance - */ - create( - params: SampleListInstanceCreateOptions, - callback?: (error: Error | null, item?: SampleInstance) => any - ): Promise; - - /** - * Streams SampleInstance 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 { SampleListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: SampleInstance, done: (err?: Error) => void) => void - ): void; - each( - params: SampleListInstanceEachOptions, - callback?: (item: SampleInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of SampleInstance 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: SamplePage) => any - ): Promise; - /** - * Lists SampleInstance 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 { SampleListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: SampleInstance[]) => any - ): Promise; - list( - params: SampleListInstanceOptions, - callback?: (error: Error | null, items: SampleInstance[]) => any - ): Promise; - /** - * Retrieve a single page of SampleInstance 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 { SampleListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: SamplePage) => any - ): Promise; - page( - params: SampleListInstancePageOptions, - callback?: (error: Error | null, items: SamplePage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function SampleListInstance( - version: V1, - assistantSid: string, - taskSid: string -): SampleListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(taskSid)) { - throw new Error("Parameter 'taskSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as SampleListInstance; - - instance.get = function get(sid): SampleContext { - return new SampleContextImpl(version, assistantSid, taskSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid, taskSid }; - instance._uri = `/Assistants/${assistantSid}/Tasks/${taskSid}/Samples`; - - instance.create = function create( - params: SampleListInstanceCreateOptions, - callback?: (error: Error | null, items: SampleInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["language"] === null || params["language"] === undefined) { - throw new Error("Required parameter \"params['language']\" missing."); - } - - if (params["taggedText"] === null || params["taggedText"] === undefined) { - throw new Error("Required parameter \"params['taggedText']\" missing."); - } - - let data: any = {}; - - data["Language"] = params["language"]; - - data["TaggedText"] = params["taggedText"]; - if (params["sourceChannel"] !== undefined) - data["SourceChannel"] = params["sourceChannel"]; - - 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 SampleInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.taskSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | SampleListInstancePageOptions - | ((error: Error | null, items: SamplePage) => any), - callback?: (error: Error | null, items: SamplePage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["language"] !== undefined) data["Language"] = params["language"]; - 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 SamplePage(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: SamplePage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new SamplePage(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 SamplePage extends Page< - V1, - SamplePayload, - SampleResource, - SampleInstance -> { - /** - * Initialize the SamplePage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: SampleSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of SampleInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: SampleResource): SampleInstance { - return new SampleInstance( - this._version, - payload, - this._solution.assistantSid, - this._solution.taskSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/assistant/task/taskActions.ts b/src/rest/autopilot/v1/assistant/task/taskActions.ts deleted file mode 100644 index ace8cb3aeb..0000000000 --- a/src/rest/autopilot/v1/assistant/task/taskActions.ts +++ /dev/null @@ -1,360 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 update a TaskActionsInstance - */ -export interface TaskActionsContextUpdateOptions { - /** The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. */ - actions?: any; -} - -export interface TaskActionsContext { - /** - * Fetch a TaskActionsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskActionsInstance - */ - fetch( - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise; - - /** - * Update a TaskActionsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskActionsInstance - */ - update( - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise; - /** - * Update a TaskActionsInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskActionsInstance - */ - update( - params: TaskActionsContextUpdateOptions, - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface TaskActionsContextSolution { - assistantSid: string; - taskSid: string; -} - -export class TaskActionsContextImpl implements TaskActionsContext { - protected _solution: TaskActionsContextSolution; - protected _uri: string; - - constructor(protected _version: V1, assistantSid: string, taskSid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(taskSid)) { - throw new Error("Parameter 'taskSid' is not valid."); - } - - this._solution = { assistantSid, taskSid }; - this._uri = `/Assistants/${assistantSid}/Tasks/${taskSid}/Actions`; - } - - fetch( - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new TaskActionsInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.taskSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | TaskActionsContextUpdateOptions - | ((error: Error | null, item?: TaskActionsInstance) => any), - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["actions"] !== undefined) - data["Actions"] = serialize.object(params["actions"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new TaskActionsInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.taskSid - ) - ); - - 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 TaskActionsPayload extends TaskActionsResource {} - -interface TaskActionsResource { - account_sid: string; - assistant_sid: string; - task_sid: string; - url: string; - data: any; -} - -export class TaskActionsInstance { - protected _solution: TaskActionsContextSolution; - protected _context?: TaskActionsContext; - - constructor( - protected _version: V1, - payload: TaskActionsResource, - assistantSid: string, - taskSid: string - ) { - this.accountSid = payload.account_sid; - this.assistantSid = payload.assistant_sid; - this.taskSid = payload.task_sid; - this.url = payload.url; - this.data = payload.data; - - this._solution = { assistantSid, taskSid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskActions resource. - */ - accountSid: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource. - */ - assistantSid: string; - /** - * The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the resource. - */ - taskSid: string; - /** - * The absolute URL of the TaskActions resource. - */ - url: string; - /** - * The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - */ - data: any; - - private get _proxy(): TaskActionsContext { - this._context = - this._context || - new TaskActionsContextImpl( - this._version, - this._solution.assistantSid, - this._solution.taskSid - ); - return this._context; - } - - /** - * Fetch a TaskActionsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskActionsInstance - */ - fetch( - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a TaskActionsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskActionsInstance - */ - update( - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise; - /** - * Update a TaskActionsInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskActionsInstance - */ - update( - params: TaskActionsContextUpdateOptions, - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: TaskActionsInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - assistantSid: this.assistantSid, - taskSid: this.taskSid, - url: this.url, - data: this.data, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface TaskActionsSolution { - assistantSid: string; - taskSid: string; -} - -export interface TaskActionsListInstance { - _version: V1; - _solution: TaskActionsSolution; - _uri: string; - - (): TaskActionsContext; - get(): TaskActionsContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function TaskActionsListInstance( - version: V1, - assistantSid: string, - taskSid: string -): TaskActionsListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(taskSid)) { - throw new Error("Parameter 'taskSid' is not valid."); - } - - const instance = (() => instance.get()) as TaskActionsListInstance; - - instance.get = function get(): TaskActionsContext { - return new TaskActionsContextImpl(version, assistantSid, taskSid); - }; - - instance._version = version; - instance._solution = { assistantSid, taskSid }; - 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/autopilot/v1/assistant/task/taskStatistics.ts b/src/rest/autopilot/v1/assistant/task/taskStatistics.ts deleted file mode 100644 index 7916aad6e2..0000000000 --- a/src/rest/autopilot/v1/assistant/task/taskStatistics.ts +++ /dev/null @@ -1,259 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 TaskStatisticsContext { - /** - * Fetch a TaskStatisticsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskStatisticsInstance - */ - fetch( - callback?: (error: Error | null, item?: TaskStatisticsInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface TaskStatisticsContextSolution { - assistantSid: string; - taskSid: string; -} - -export class TaskStatisticsContextImpl implements TaskStatisticsContext { - protected _solution: TaskStatisticsContextSolution; - protected _uri: string; - - constructor(protected _version: V1, assistantSid: string, taskSid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(taskSid)) { - throw new Error("Parameter 'taskSid' is not valid."); - } - - this._solution = { assistantSid, taskSid }; - this._uri = `/Assistants/${assistantSid}/Tasks/${taskSid}/Statistics`; - } - - fetch( - callback?: (error: Error | null, item?: TaskStatisticsInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new TaskStatisticsInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.taskSid - ) - ); - - 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 TaskStatisticsPayload extends TaskStatisticsResource {} - -interface TaskStatisticsResource { - account_sid: string; - assistant_sid: string; - task_sid: string; - samples_count: number; - fields_count: number; - url: string; -} - -export class TaskStatisticsInstance { - protected _solution: TaskStatisticsContextSolution; - protected _context?: TaskStatisticsContext; - - constructor( - protected _version: V1, - payload: TaskStatisticsResource, - assistantSid: string, - taskSid: string - ) { - this.accountSid = payload.account_sid; - this.assistantSid = payload.assistant_sid; - this.taskSid = payload.task_sid; - this.samplesCount = deserialize.integer(payload.samples_count); - this.fieldsCount = deserialize.integer(payload.fields_count); - this.url = payload.url; - - this._solution = { assistantSid, taskSid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskStatistics resource. - */ - accountSid: string; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource. - */ - assistantSid: string; - /** - * The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) for which the statistics were collected. - */ - taskSid: string; - /** - * The total number of [Samples](https://www.twilio.com/docs/autopilot/api/task-sample) associated with the Task. - */ - samplesCount: number; - /** - * The total number of [Fields](https://www.twilio.com/docs/autopilot/api/task-field) associated with the Task. - */ - fieldsCount: number; - /** - * The absolute URL of the TaskStatistics resource. - */ - url: string; - - private get _proxy(): TaskStatisticsContext { - this._context = - this._context || - new TaskStatisticsContextImpl( - this._version, - this._solution.assistantSid, - this._solution.taskSid - ); - return this._context; - } - - /** - * Fetch a TaskStatisticsInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TaskStatisticsInstance - */ - fetch( - callback?: (error: Error | null, item?: TaskStatisticsInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - assistantSid: this.assistantSid, - taskSid: this.taskSid, - samplesCount: this.samplesCount, - fieldsCount: this.fieldsCount, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface TaskStatisticsSolution { - assistantSid: string; - taskSid: string; -} - -export interface TaskStatisticsListInstance { - _version: V1; - _solution: TaskStatisticsSolution; - _uri: string; - - (): TaskStatisticsContext; - get(): TaskStatisticsContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function TaskStatisticsListInstance( - version: V1, - assistantSid: string, - taskSid: string -): TaskStatisticsListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(taskSid)) { - throw new Error("Parameter 'taskSid' is not valid."); - } - - const instance = (() => instance.get()) as TaskStatisticsListInstance; - - instance.get = function get(): TaskStatisticsContext { - return new TaskStatisticsContextImpl(version, assistantSid, taskSid); - }; - - instance._version = version; - instance._solution = { assistantSid, taskSid }; - 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/autopilot/v1/assistant/webhook.ts b/src/rest/autopilot/v1/assistant/webhook.ts deleted file mode 100644 index 5666c2df29..0000000000 --- a/src/rest/autopilot/v1/assistant/webhook.ts +++ /dev/null @@ -1,733 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 V1 from "../../V1"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Options to pass to update a WebhookInstance - */ -export interface WebhookContextUpdateOptions { - /** An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. */ - uniqueName?: string; - /** The list of space-separated events that this Webhook will subscribe to. */ - events?: string; - /** The URL associated with this Webhook. */ - webhookUrl?: string; - /** The method to be used when calling the webhook\\\'s URL. */ - webhookMethod?: string; -} - -/** - * Options to pass to create a WebhookInstance - */ -export interface WebhookListInstanceCreateOptions { - /** An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. */ - uniqueName: string; - /** The list of space-separated events that this Webhook will subscribe to. */ - events: string; - /** The URL associated with this Webhook. */ - webhookUrl: string; - /** The method to be used when calling the webhook\\\'s URL. */ - webhookMethod?: string; -} -/** - * Options to pass to each - */ -export interface WebhookListInstanceEachOptions { - /** 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: WebhookInstance, 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 WebhookListInstanceOptions { - /** 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 WebhookListInstancePageOptions { - /** 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 WebhookContext { - /** - * Remove a WebhookInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a WebhookInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed WebhookInstance - */ - fetch( - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise; - - /** - * Update a WebhookInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed WebhookInstance - */ - update( - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise; - /** - * Update a WebhookInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed WebhookInstance - */ - update( - params: WebhookContextUpdateOptions, - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface WebhookContextSolution { - assistantSid: string; - sid: string; -} - -export class WebhookContextImpl implements WebhookContext { - protected _solution: WebhookContextSolution; - protected _uri: string; - - constructor(protected _version: V1, assistantSid: string, sid: string) { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { assistantSid, sid }; - this._uri = `/Assistants/${assistantSid}/Webhooks/${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?: WebhookInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new WebhookInstance( - operationVersion, - payload, - instance._solution.assistantSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | WebhookContextUpdateOptions - | ((error: Error | null, item?: WebhookInstance) => any), - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - if (params["events"] !== undefined) data["Events"] = params["events"]; - if (params["webhookUrl"] !== undefined) - data["WebhookUrl"] = params["webhookUrl"]; - if (params["webhookMethod"] !== undefined) - data["WebhookMethod"] = params["webhookMethod"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new WebhookInstance( - operationVersion, - payload, - instance._solution.assistantSid, - 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 WebhookPayload extends TwilioResponsePayload { - webhooks: WebhookResource[]; -} - -interface WebhookResource { - url: string; - account_sid: string; - date_created: Date; - date_updated: Date; - assistant_sid: string; - sid: string; - unique_name: string; - events: string; - webhook_url: string; - webhook_method: string; -} - -export class WebhookInstance { - protected _solution: WebhookContextSolution; - protected _context?: WebhookContext; - - constructor( - protected _version: V1, - payload: WebhookResource, - assistantSid: string, - sid?: string - ) { - this.url = payload.url; - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.assistantSid = payload.assistant_sid; - this.sid = payload.sid; - this.uniqueName = payload.unique_name; - this.events = payload.events; - this.webhookUrl = payload.webhook_url; - this.webhookMethod = payload.webhook_method; - - this._solution = { assistantSid, sid: sid || this.sid }; - } - - /** - * The absolute URL of the Webhook resource. - */ - url: string; - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Webhook resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - */ - assistantSid: string; - /** - * The unique string that we created to identify the Webhook resource. - */ - sid: string; - /** - * An application-defined string that uniquely identifies the resource. It can be used in place of the resource\'s `sid` in the URL to address the resource. - */ - uniqueName: string; - /** - * The list of space-separated events that this Webhook is subscribed to. - */ - events: string; - /** - * The URL associated with this Webhook. - */ - webhookUrl: string; - /** - * The method used when calling the webhook\'s URL. - */ - webhookMethod: string; - - private get _proxy(): WebhookContext { - this._context = - this._context || - new WebhookContextImpl( - this._version, - this._solution.assistantSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a WebhookInstance - * - * @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 WebhookInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed WebhookInstance - */ - fetch( - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a WebhookInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed WebhookInstance - */ - update( - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise; - /** - * Update a WebhookInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed WebhookInstance - */ - update( - params: WebhookContextUpdateOptions, - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - url: this.url, - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - assistantSid: this.assistantSid, - sid: this.sid, - uniqueName: this.uniqueName, - events: this.events, - webhookUrl: this.webhookUrl, - webhookMethod: this.webhookMethod, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface WebhookSolution { - assistantSid: string; -} - -export interface WebhookListInstance { - _version: V1; - _solution: WebhookSolution; - _uri: string; - - (sid: string): WebhookContext; - get(sid: string): WebhookContext; - - /** - * Create a WebhookInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed WebhookInstance - */ - create( - params: WebhookListInstanceCreateOptions, - callback?: (error: Error | null, item?: WebhookInstance) => any - ): Promise; - - /** - * Streams WebhookInstance 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 { WebhookListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: WebhookInstance, done: (err?: Error) => void) => void - ): void; - each( - params: WebhookListInstanceEachOptions, - callback?: (item: WebhookInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of WebhookInstance 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: WebhookPage) => any - ): Promise; - /** - * Lists WebhookInstance 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 { WebhookListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: WebhookInstance[]) => any - ): Promise; - list( - params: WebhookListInstanceOptions, - callback?: (error: Error | null, items: WebhookInstance[]) => any - ): Promise; - /** - * Retrieve a single page of WebhookInstance 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 { WebhookListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: WebhookPage) => any - ): Promise; - page( - params: WebhookListInstancePageOptions, - callback?: (error: Error | null, items: WebhookPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function WebhookListInstance( - version: V1, - assistantSid: string -): WebhookListInstance { - if (!isValidPathParam(assistantSid)) { - throw new Error("Parameter 'assistantSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as WebhookListInstance; - - instance.get = function get(sid): WebhookContext { - return new WebhookContextImpl(version, assistantSid, sid); - }; - - instance._version = version; - instance._solution = { assistantSid }; - instance._uri = `/Assistants/${assistantSid}/Webhooks`; - - instance.create = function create( - params: WebhookListInstanceCreateOptions, - callback?: (error: Error | null, items: WebhookInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["uniqueName"] === null || params["uniqueName"] === undefined) { - throw new Error("Required parameter \"params['uniqueName']\" missing."); - } - - if (params["events"] === null || params["events"] === undefined) { - throw new Error("Required parameter \"params['events']\" missing."); - } - - if (params["webhookUrl"] === null || params["webhookUrl"] === undefined) { - throw new Error("Required parameter \"params['webhookUrl']\" missing."); - } - - let data: any = {}; - - data["UniqueName"] = params["uniqueName"]; - - data["Events"] = params["events"]; - - data["WebhookUrl"] = params["webhookUrl"]; - if (params["webhookMethod"] !== undefined) - data["WebhookMethod"] = params["webhookMethod"]; - - 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 WebhookInstance( - operationVersion, - payload, - instance._solution.assistantSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | WebhookListInstancePageOptions - | ((error: Error | null, items: WebhookPage) => any), - callback?: (error: Error | null, items: WebhookPage) => 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 WebhookPage(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: WebhookPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new WebhookPage(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 WebhookPage extends Page< - V1, - WebhookPayload, - WebhookResource, - WebhookInstance -> { - /** - * Initialize the WebhookPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: WebhookSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of WebhookInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: WebhookResource): WebhookInstance { - return new WebhookInstance( - this._version, - payload, - this._solution.assistantSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/autopilot/v1/restoreAssistant.ts b/src/rest/autopilot/v1/restoreAssistant.ts deleted file mode 100644 index ddd75b6802..0000000000 --- a/src/rest/autopilot/v1/restoreAssistant.ts +++ /dev/null @@ -1,224 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Autopilot - * 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 update a RestoreAssistantInstance - */ -export interface RestoreAssistantListInstanceUpdateOptions { - /** The Twilio-provided string that uniquely identifies the Assistant resource to restore. */ - assistant: string; -} - -export interface RestoreAssistantSolution {} - -export interface RestoreAssistantListInstance { - _version: V1; - _solution: RestoreAssistantSolution; - _uri: string; - - /** - * Update a RestoreAssistantInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed RestoreAssistantInstance - */ - update( - params: RestoreAssistantListInstanceUpdateOptions, - callback?: (error: Error | null, item?: RestoreAssistantInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function RestoreAssistantListInstance( - version: V1 -): RestoreAssistantListInstance { - const instance = {} as RestoreAssistantListInstance; - - instance._version = version; - instance._solution = {}; - instance._uri = `/Assistants/Restore`; - - instance.update = function update( - params: RestoreAssistantListInstanceUpdateOptions, - callback?: (error: Error | null, items: RestoreAssistantInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["assistant"] === null || params["assistant"] === undefined) { - throw new Error("Required parameter \"params['assistant']\" missing."); - } - - let data: any = {}; - - data["Assistant"] = params["assistant"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - let operationVersion = version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => new RestoreAssistantInstance(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 RestoreAssistantPayload extends RestoreAssistantResource {} - -interface RestoreAssistantResource { - account_sid: string; - sid: string; - date_created: Date; - date_updated: Date; - unique_name: string; - friendly_name: string; - needs_model_build: boolean; - latest_model_build_sid: string; - log_queries: boolean; - development_stage: string; - callback_url: string; - callback_events: string; -} - -export class RestoreAssistantInstance { - constructor(protected _version: V1, payload: RestoreAssistantResource) { - this.accountSid = payload.account_sid; - this.sid = payload.sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.uniqueName = payload.unique_name; - this.friendlyName = payload.friendly_name; - this.needsModelBuild = payload.needs_model_build; - this.latestModelBuildSid = payload.latest_model_build_sid; - this.logQueries = payload.log_queries; - this.developmentStage = payload.development_stage; - this.callbackUrl = payload.callback_url; - this.callbackEvents = payload.callback_events; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource. - */ - accountSid: string; - /** - * The unique string that we created to identify the Assistant resource. - */ - sid: string; - /** - * The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - dateUpdated: Date; - /** - * An application-defined string that uniquely identifies the resource. It can be used in place of the resource\'s `sid` in the URL to address the resource. - */ - uniqueName: string; - /** - * The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long. - */ - friendlyName: string; - /** - * Whether model needs to be rebuilt. - */ - needsModelBuild: boolean; - /** - * Reserved. - */ - latestModelBuildSid: string; - /** - * Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - */ - logQueries: boolean; - /** - * A string describing the state of the assistant. - */ - developmentStage: string; - /** - * Reserved. - */ - callbackUrl: string; - /** - * Reserved. - */ - callbackEvents: string; - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - sid: this.sid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - uniqueName: this.uniqueName, - friendlyName: this.friendlyName, - needsModelBuild: this.needsModelBuild, - latestModelBuildSid: this.latestModelBuildSid, - logQueries: this.logQueries, - developmentStage: this.developmentStage, - callbackUrl: this.callbackUrl, - callbackEvents: this.callbackEvents, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/oauth/V1.ts b/src/rest/oauth/V1.ts deleted file mode 100644 index ab2759f368..0000000000 --- a/src/rest/oauth/V1.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Oauth - * 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 OauthBase from "../OauthBase"; -import Version from "../../base/Version"; -import { DeviceCodeListInstance } from "./v1/deviceCode"; -import { OauthListInstance } from "./v1/oauth"; -import { OpenidDiscoveryListInstance } from "./v1/openidDiscovery"; -import { TokenListInstance } from "./v1/token"; -import { UserInfoListInstance } from "./v1/userInfo"; - -export default class V1 extends Version { - /** - * Initialize the V1 version of Oauth - * - * @param domain - The Twilio (Twilio.Oauth) domain - */ - constructor(domain: OauthBase) { - super(domain, "v1"); - } - - /** deviceCode - { Twilio.Oauth.V1.DeviceCodeListInstance } resource */ - protected _deviceCode?: DeviceCodeListInstance; - /** oauth - { Twilio.Oauth.V1.OauthListInstance } resource */ - protected _oauth?: OauthListInstance; - /** openidDiscovery - { Twilio.Oauth.V1.OpenidDiscoveryListInstance } resource */ - protected _openidDiscovery?: OpenidDiscoveryListInstance; - /** token - { Twilio.Oauth.V1.TokenListInstance } resource */ - protected _token?: TokenListInstance; - /** userInfo - { Twilio.Oauth.V1.UserInfoListInstance } resource */ - protected _userInfo?: UserInfoListInstance; - - /** Getter for deviceCode resource */ - get deviceCode(): DeviceCodeListInstance { - this._deviceCode = this._deviceCode || DeviceCodeListInstance(this); - return this._deviceCode; - } - - /** Getter for oauth resource */ - get oauth(): OauthListInstance { - this._oauth = this._oauth || OauthListInstance(this); - return this._oauth; - } - - /** Getter for openidDiscovery resource */ - get openidDiscovery(): OpenidDiscoveryListInstance { - this._openidDiscovery = - this._openidDiscovery || OpenidDiscoveryListInstance(this); - return this._openidDiscovery; - } - - /** Getter for token resource */ - get token(): TokenListInstance { - this._token = this._token || TokenListInstance(this); - return this._token; - } - - /** Getter for userInfo resource */ - get userInfo(): UserInfoListInstance { - this._userInfo = this._userInfo || UserInfoListInstance(this); - return this._userInfo; - } -} diff --git a/src/rest/oauth/v1/deviceCode.ts b/src/rest/oauth/v1/deviceCode.ts deleted file mode 100644 index da60047a46..0000000000 --- a/src/rest/oauth/v1/deviceCode.ts +++ /dev/null @@ -1,192 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Oauth - * 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 DeviceCodeInstance - */ -export interface DeviceCodeListInstanceCreateOptions { - /** A 34 character string that uniquely identifies this OAuth App. */ - clientSid: string; - /** An Array of scopes for authorization request */ - scopes: Array; - /** An array of intended audiences for token requests */ - audiences?: Array; -} - -export interface DeviceCodeSolution {} - -export interface DeviceCodeListInstance { - _version: V1; - _solution: DeviceCodeSolution; - _uri: string; - - /** - * Create a DeviceCodeInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceCodeInstance - */ - create( - params: DeviceCodeListInstanceCreateOptions, - callback?: (error: Error | null, item?: DeviceCodeInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function DeviceCodeListInstance(version: V1): DeviceCodeListInstance { - const instance = {} as DeviceCodeListInstance; - - instance._version = version; - instance._solution = {}; - instance._uri = `/device/code`; - - instance.create = function create( - params: DeviceCodeListInstanceCreateOptions, - callback?: (error: Error | null, items: DeviceCodeInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["clientSid"] === null || params["clientSid"] === undefined) { - throw new Error("Required parameter \"params['clientSid']\" missing."); - } - - if (params["scopes"] === null || params["scopes"] === undefined) { - throw new Error("Required parameter \"params['scopes']\" missing."); - } - - let data: any = {}; - - data["ClientSid"] = params["clientSid"]; - - data["Scopes"] = serialize.map(params["scopes"], (e: string) => e); - if (params["audiences"] !== undefined) - data["Audiences"] = serialize.map(params["audiences"], (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 DeviceCodeInstance(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 DeviceCodePayload extends DeviceCodeResource {} - -interface DeviceCodeResource { - device_code: string; - user_code: string; - verification_uri: string; - verification_uri_complete: string; - expires_in: number; - interval: number; -} - -export class DeviceCodeInstance { - constructor(protected _version: V1, payload: DeviceCodeResource) { - this.deviceCode = payload.device_code; - this.userCode = payload.user_code; - this.verificationUri = payload.verification_uri; - this.verificationUriComplete = payload.verification_uri_complete; - this.expiresIn = payload.expires_in; - this.interval = deserialize.integer(payload.interval); - } - - /** - * The device verification code. - */ - deviceCode: string; - /** - * The verification code which end user uses to verify authorization request. - */ - userCode: string; - /** - * The URI that the end user visits to verify authorization request. - */ - verificationUri: string; - /** - * The URI with user_code that the end-user alternatively visits to verify authorization request. - */ - verificationUriComplete: string; - /** - * The expiration time of the device_code and user_code in seconds. - */ - expiresIn: number; - /** - * The minimum amount of time in seconds that the client should wait between polling requests to the token endpoint. - */ - interval: number; - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - deviceCode: this.deviceCode, - userCode: this.userCode, - verificationUri: this.verificationUri, - verificationUriComplete: this.verificationUriComplete, - expiresIn: this.expiresIn, - interval: this.interval, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/oauth/v1/oauth.ts b/src/rest/oauth/v1/oauth.ts deleted file mode 100644 index 7752f30008..0000000000 --- a/src/rest/oauth/v1/oauth.ts +++ /dev/null @@ -1,185 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Oauth - * 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 OauthContext { - /** - * Fetch a OauthInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed OauthInstance - */ - fetch( - callback?: (error: Error | null, item?: OauthInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface OauthContextSolution {} - -export class OauthContextImpl implements OauthContext { - protected _solution: OauthContextSolution; - protected _uri: string; - - constructor(protected _version: V1) { - this._solution = {}; - this._uri = `/certs`; - } - - fetch( - callback?: (error: Error | null, item?: OauthInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => new OauthInstance(operationVersion, payload) - ); - - 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 OauthPayload extends OauthResource {} - -interface OauthResource { - keys: any; - url: string; -} - -export class OauthInstance { - protected _solution: OauthContextSolution; - protected _context?: OauthContext; - - constructor(protected _version: V1, payload: OauthResource) { - this.keys = payload.keys; - this.url = payload.url; - - this._solution = {}; - } - - /** - * A collection of certificates where are signed Twilio-issued tokens. - */ - keys: any; - url: string; - - private get _proxy(): OauthContext { - this._context = this._context || new OauthContextImpl(this._version); - return this._context; - } - - /** - * Fetch a OauthInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed OauthInstance - */ - fetch( - callback?: (error: Error | null, item?: OauthInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - keys: this.keys, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface OauthSolution {} - -export interface OauthListInstance { - _version: V1; - _solution: OauthSolution; - _uri: string; - - (): OauthContext; - get(): OauthContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function OauthListInstance(version: V1): OauthListInstance { - const instance = (() => instance.get()) as OauthListInstance; - - instance.get = function get(): OauthContext { - return new OauthContextImpl(version); - }; - - 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/oauth/v1/openidDiscovery.ts b/src/rest/oauth/v1/openidDiscovery.ts deleted file mode 100644 index 24b8aa9a9f..0000000000 --- a/src/rest/oauth/v1/openidDiscovery.ts +++ /dev/null @@ -1,266 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Oauth - * 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 OpenidDiscoveryContext { - /** - * Fetch a OpenidDiscoveryInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed OpenidDiscoveryInstance - */ - fetch( - callback?: (error: Error | null, item?: OpenidDiscoveryInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface OpenidDiscoveryContextSolution {} - -export class OpenidDiscoveryContextImpl implements OpenidDiscoveryContext { - protected _solution: OpenidDiscoveryContextSolution; - protected _uri: string; - - constructor(protected _version: V1) { - this._solution = {}; - this._uri = `/.well-known/openid-configuration`; - } - - fetch( - callback?: (error: Error | null, item?: OpenidDiscoveryInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => new OpenidDiscoveryInstance(operationVersion, payload) - ); - - 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 OpenidDiscoveryPayload extends OpenidDiscoveryResource {} - -interface OpenidDiscoveryResource { - issuer: string; - authorization_endpoint: string; - device_authorization_endpoint: string; - token_endpoint: string; - userinfo_endpoint: string; - revocation_endpoint: string; - jwk_uri: string; - response_type_supported: Array; - subject_type_supported: Array; - id_token_signing_alg_values_supported: Array; - scopes_supported: Array; - claims_supported: Array; - url: string; -} - -export class OpenidDiscoveryInstance { - protected _solution: OpenidDiscoveryContextSolution; - protected _context?: OpenidDiscoveryContext; - - constructor(protected _version: V1, payload: OpenidDiscoveryResource) { - this.issuer = payload.issuer; - this.authorizationEndpoint = payload.authorization_endpoint; - this.deviceAuthorizationEndpoint = payload.device_authorization_endpoint; - this.tokenEndpoint = payload.token_endpoint; - this.userinfoEndpoint = payload.userinfo_endpoint; - this.revocationEndpoint = payload.revocation_endpoint; - this.jwkUri = payload.jwk_uri; - this.responseTypeSupported = payload.response_type_supported; - this.subjectTypeSupported = payload.subject_type_supported; - this.idTokenSigningAlgValuesSupported = - payload.id_token_signing_alg_values_supported; - this.scopesSupported = payload.scopes_supported; - this.claimsSupported = payload.claims_supported; - this.url = payload.url; - - this._solution = {}; - } - - /** - * The URL of the party that will create the token and sign it with its private key. - */ - issuer: string; - /** - * The endpoint that validates all authorization requests. - */ - authorizationEndpoint: string; - /** - * The endpoint that validates all device code related authorization requests. - */ - deviceAuthorizationEndpoint: string; - /** - * The URL of the token endpoint. After a client has received an authorization code, that code is presented to the token endpoint and exchanged for an identity token, an access token, and a refresh token. - */ - tokenEndpoint: string; - /** - * The URL of the user info endpoint, which returns user profile information to a client. Keep in mind that the user info endpoint returns only the information that has been requested. - */ - userinfoEndpoint: string; - /** - * The endpoint used to revoke access or refresh tokens issued by the authorization server. - */ - revocationEndpoint: string; - /** - * The URL of your JSON Web Key Set. This set is a collection of JSON Web Keys, a standard method for representing cryptographic keys in a JSON structure. - */ - jwkUri: string; - /** - * A collection of response type supported by authorization server. - */ - responseTypeSupported: Array; - /** - * A collection of subject by authorization server. - */ - subjectTypeSupported: Array; - /** - * A collection of JWS signing algorithms supported by authorization server to sign identity token. - */ - idTokenSigningAlgValuesSupported: Array; - /** - * A collection of scopes supported by authorization server for identity token - */ - scopesSupported: Array; - /** - * A collection of claims supported by authorization server for identity token - */ - claimsSupported: Array; - url: string; - - private get _proxy(): OpenidDiscoveryContext { - this._context = - this._context || new OpenidDiscoveryContextImpl(this._version); - return this._context; - } - - /** - * Fetch a OpenidDiscoveryInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed OpenidDiscoveryInstance - */ - fetch( - callback?: (error: Error | null, item?: OpenidDiscoveryInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - issuer: this.issuer, - authorizationEndpoint: this.authorizationEndpoint, - deviceAuthorizationEndpoint: this.deviceAuthorizationEndpoint, - tokenEndpoint: this.tokenEndpoint, - userinfoEndpoint: this.userinfoEndpoint, - revocationEndpoint: this.revocationEndpoint, - jwkUri: this.jwkUri, - responseTypeSupported: this.responseTypeSupported, - subjectTypeSupported: this.subjectTypeSupported, - idTokenSigningAlgValuesSupported: this.idTokenSigningAlgValuesSupported, - scopesSupported: this.scopesSupported, - claimsSupported: this.claimsSupported, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface OpenidDiscoverySolution {} - -export interface OpenidDiscoveryListInstance { - _version: V1; - _solution: OpenidDiscoverySolution; - _uri: string; - - (): OpenidDiscoveryContext; - get(): OpenidDiscoveryContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function OpenidDiscoveryListInstance( - version: V1 -): OpenidDiscoveryListInstance { - const instance = (() => instance.get()) as OpenidDiscoveryListInstance; - - instance.get = function get(): OpenidDiscoveryContext { - return new OpenidDiscoveryContextImpl(version); - }; - - 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/oauth/v1/token.ts b/src/rest/oauth/v1/token.ts deleted file mode 100644 index 918bb2576b..0000000000 --- a/src/rest/oauth/v1/token.ts +++ /dev/null @@ -1,204 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Oauth - * 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 TokenInstance - */ -export interface TokenListInstanceCreateOptions { - /** Grant type is a credential representing resource owner\\\'s authorization which can be used by client to obtain access token. */ - grantType: string; - /** A 34 character string that uniquely identifies this OAuth App. */ - clientSid: string; - /** The credential for confidential OAuth App. */ - clientSecret?: string; - /** JWT token related to the authorization code grant type. */ - code?: string; - /** A code which is generation cryptographically. */ - codeVerifier?: string; - /** JWT token related to the device code grant type. */ - deviceCode?: string; - /** JWT token related to the refresh token grant type. */ - refreshToken?: string; - /** The Id of the device associated with the token (refresh token). */ - deviceId?: string; -} - -export interface TokenSolution {} - -export interface TokenListInstance { - _version: V1; - _solution: TokenSolution; - _uri: string; - - /** - * Create a TokenInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed TokenInstance - */ - create( - params: TokenListInstanceCreateOptions, - callback?: (error: Error | null, item?: TokenInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function TokenListInstance(version: V1): TokenListInstance { - const instance = {} as TokenListInstance; - - instance._version = version; - instance._solution = {}; - instance._uri = `/token`; - - instance.create = function create( - params: TokenListInstanceCreateOptions, - callback?: (error: Error | null, items: TokenInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["grantType"] === null || params["grantType"] === undefined) { - throw new Error("Required parameter \"params['grantType']\" missing."); - } - - if (params["clientSid"] === null || params["clientSid"] === undefined) { - throw new Error("Required parameter \"params['clientSid']\" missing."); - } - - let data: any = {}; - - data["GrantType"] = params["grantType"]; - - data["ClientSid"] = params["clientSid"]; - if (params["clientSecret"] !== undefined) - data["ClientSecret"] = params["clientSecret"]; - if (params["code"] !== undefined) data["Code"] = params["code"]; - if (params["codeVerifier"] !== undefined) - data["CodeVerifier"] = params["codeVerifier"]; - if (params["deviceCode"] !== undefined) - data["DeviceCode"] = params["deviceCode"]; - if (params["refreshToken"] !== undefined) - data["RefreshToken"] = params["refreshToken"]; - if (params["deviceId"] !== undefined) data["DeviceId"] = params["deviceId"]; - - 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 TokenInstance(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 TokenPayload extends TokenResource {} - -interface TokenResource { - access_token: string; - refresh_token: string; - id_token: string; - refresh_token_expires_at: Date; - access_token_expires_at: Date; -} - -export class TokenInstance { - constructor(protected _version: V1, payload: TokenResource) { - this.accessToken = payload.access_token; - this.refreshToken = payload.refresh_token; - this.idToken = payload.id_token; - this.refreshTokenExpiresAt = deserialize.iso8601DateTime( - payload.refresh_token_expires_at - ); - this.accessTokenExpiresAt = deserialize.iso8601DateTime( - payload.access_token_expires_at - ); - } - - /** - * Token which carries the necessary information to access a Twilio resource directly. - */ - accessToken: string; - /** - * Token which carries the information necessary to get a new access token. - */ - refreshToken: string; - idToken: string; - /** - * The date and time in GMT when the refresh token expires in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - refreshTokenExpiresAt: Date; - /** - * The date and time in GMT when the refresh token expires in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - */ - accessTokenExpiresAt: Date; - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accessToken: this.accessToken, - refreshToken: this.refreshToken, - idToken: this.idToken, - refreshTokenExpiresAt: this.refreshTokenExpiresAt, - accessTokenExpiresAt: this.accessTokenExpiresAt, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/oauth/v1/userInfo.ts b/src/rest/oauth/v1/userInfo.ts deleted file mode 100644 index 5b974309b8..0000000000 --- a/src/rest/oauth/v1/userInfo.ts +++ /dev/null @@ -1,213 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Oauth - * 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 UserInfoContext { - /** - * Fetch a UserInfoInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed UserInfoInstance - */ - fetch( - callback?: (error: Error | null, item?: UserInfoInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface UserInfoContextSolution {} - -export class UserInfoContextImpl implements UserInfoContext { - protected _solution: UserInfoContextSolution; - protected _uri: string; - - constructor(protected _version: V1) { - this._solution = {}; - this._uri = `/userinfo`; - } - - fetch( - callback?: (error: Error | null, item?: UserInfoInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => new UserInfoInstance(operationVersion, payload) - ); - - 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 UserInfoPayload extends UserInfoResource {} - -interface UserInfoResource { - user_sid: string; - first_name: string; - last_name: string; - friendly_name: string; - email: string; - url: string; -} - -export class UserInfoInstance { - protected _solution: UserInfoContextSolution; - protected _context?: UserInfoContext; - - constructor(protected _version: V1, payload: UserInfoResource) { - this.userSid = payload.user_sid; - this.firstName = payload.first_name; - this.lastName = payload.last_name; - this.friendlyName = payload.friendly_name; - this.email = payload.email; - this.url = payload.url; - - this._solution = {}; - } - - /** - * The URL of the party that will create the token and sign it with its private key. - */ - userSid: string; - /** - * The first name of the end-user. - */ - firstName: string; - /** - * The last name of the end-user. - */ - lastName: string; - /** - * The friendly name of the end-user. - */ - friendlyName: string; - /** - * The end-user\'s preferred email address. - */ - email: string; - url: string; - - private get _proxy(): UserInfoContext { - this._context = this._context || new UserInfoContextImpl(this._version); - return this._context; - } - - /** - * Fetch a UserInfoInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed UserInfoInstance - */ - fetch( - callback?: (error: Error | null, item?: UserInfoInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - userSid: this.userSid, - firstName: this.firstName, - lastName: this.lastName, - friendlyName: this.friendlyName, - email: this.email, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface UserInfoSolution {} - -export interface UserInfoListInstance { - _version: V1; - _solution: UserInfoSolution; - _uri: string; - - (): UserInfoContext; - get(): UserInfoContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function UserInfoListInstance(version: V1): UserInfoListInstance { - const instance = (() => instance.get()) as UserInfoListInstance; - - instance.get = function get(): UserInfoContext { - return new UserInfoContextImpl(version); - }; - - 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; -}