Auto-commit 2026-04-29 16:31

This commit is contained in:
2026-04-29 16:31:27 -04:00
parent e8687bb6b2
commit 0495ee5bd2
19691 changed files with 3272886 additions and 138 deletions

15
node_modules/twilio/lib/rest/proxy/V1.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import ProxyBase from "../ProxyBase";
import Version from "../../base/Version";
import { ServiceListInstance } from "./v1/service";
export default class V1 extends Version {
/**
* Initialize the V1 version of Proxy
*
* @param domain - The Twilio (Twilio.Proxy) domain
*/
constructor(domain: ProxyBase);
/** services - { Twilio.Proxy.V1.ServiceListInstance } resource */
protected _services?: ServiceListInstance;
/** Getter for services resource */
get services(): ServiceListInstance;
}

36
node_modules/twilio/lib/rest/proxy/V1.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Proxy
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Version_1 = __importDefault(require("../../base/Version"));
const service_1 = require("./v1/service");
class V1 extends Version_1.default {
/**
* Initialize the V1 version of Proxy
*
* @param domain - The Twilio (Twilio.Proxy) domain
*/
constructor(domain) {
super(domain, "v1");
}
/** Getter for services resource */
get services() {
this._services = this._services || (0, service_1.ServiceListInstance)(this);
return this._services;
}
}
exports.default = V1;

516
node_modules/twilio/lib/rest/proxy/v1/service.d.ts generated vendored Normal file
View File

@@ -0,0 +1,516 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../base/Page";
import Response from "../../../http/response";
import V1 from "../V1";
import { ApiResponse } from "../../../base/ApiResponse";
import { PhoneNumberListInstance } from "./service/phoneNumber";
import { SessionListInstance } from "./service/session";
/**
* Where a proxy number must be located relative to the participant identifier. Can be: `country`, `area-code`, or `extended-area-code`. The default value is `country` and more specific areas than `country` are only available in North America.
*/
export type ServiceGeoMatchLevel = "area-code" | "overlay" | "radius" | "country";
/**
* The preference for Proxy Number selection in the Service instance. Can be: `prefer-sticky` or `avoid-sticky`. `prefer-sticky` means that we will try and select the same Proxy Number for a given participant if they have previous [Sessions](https://www.twilio.com/docs/proxy/api/session), but we will not fail if that Proxy Number cannot be used. `avoid-sticky` means that we will try to use different Proxy Numbers as long as that is possible within a given pool rather than try and use a previously assigned number.
*/
export type ServiceNumberSelectionBehavior = "avoid-sticky" | "prefer-sticky";
/**
* Options to pass to update a ServiceInstance
*/
export interface ServiceContextUpdateOptions {
/** An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.** */
uniqueName?: string;
/** The default `ttl` value to set for Sessions created in the Service. The TTL (time to live) is measured in seconds after the Session\\\'s last create or last Interaction. The default value of `0` indicates an unlimited Session length. You can override a Session\\\'s default TTL value by setting its `ttl` value. */
defaultTtl?: number;
/** The URL we should call when the interaction status changes. */
callbackUrl?: string;
/** */
geoMatchLevel?: ServiceGeoMatchLevel;
/** */
numberSelectionBehavior?: ServiceNumberSelectionBehavior;
/** The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. */
interceptCallbackUrl?: string;
/** The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. */
outOfSessionCallbackUrl?: string;
/** The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. */
chatInstanceSid?: string;
}
/**
* Options to pass to create a ServiceInstance
*/
export interface ServiceListInstanceCreateOptions {
/** An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.** */
uniqueName: string;
/** The default `ttl` value to set for Sessions created in the Service. The TTL (time to live) is measured in seconds after the Session\\\'s last create or last Interaction. The default value of `0` indicates an unlimited Session length. You can override a Session\\\'s default TTL value by setting its `ttl` value. */
defaultTtl?: number;
/** The URL we should call when the interaction status changes. */
callbackUrl?: string;
/** */
geoMatchLevel?: ServiceGeoMatchLevel;
/** */
numberSelectionBehavior?: ServiceNumberSelectionBehavior;
/** The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. */
interceptCallbackUrl?: string;
/** The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. */
outOfSessionCallbackUrl?: string;
/** The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. */
chatInstanceSid?: string;
}
/**
* Options to pass to each
*/
export interface ServiceListInstanceEachOptions {
/** 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: ServiceInstance, 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 ServiceListInstanceOptions {
/** 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 ServiceListInstancePageOptions {
/** 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 ServiceContext {
phoneNumbers: PhoneNumberListInstance;
sessions: SessionListInstance;
/**
* Remove a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
fetch(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Fetch a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Update a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
update(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Update a ServiceInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
update(params: ServiceContextUpdateOptions, callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Update a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Update a ServiceInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
updateWithHttpInfo(params: ServiceContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface ServiceContextSolution {
sid: string;
}
export declare class ServiceContextImpl implements ServiceContext {
protected _version: V1;
protected _solution: ServiceContextSolution;
protected _uri: string;
protected _phoneNumbers?: PhoneNumberListInstance;
protected _sessions?: SessionListInstance;
constructor(_version: V1, sid: string);
get phoneNumbers(): PhoneNumberListInstance;
get sessions(): SessionListInstance;
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
update(params?: ServiceContextUpdateOptions | ((error: Error | null, item?: ServiceInstance) => any), callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
updateWithHttpInfo(params?: ServiceContextUpdateOptions | ((error: Error | null, item?: ApiResponse<ServiceInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ServiceContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ServicePayload extends TwilioResponsePayload {
services: ServiceResource[];
}
interface ServiceResource {
sid: string;
unique_name: string;
account_sid: string;
chat_instance_sid: string;
callback_url: string;
default_ttl: number;
number_selection_behavior: ServiceNumberSelectionBehavior;
geo_match_level: ServiceGeoMatchLevel;
intercept_callback_url: string;
out_of_session_callback_url: string;
date_created: Date;
date_updated: Date;
url: string;
links: Record<string, string>;
}
export declare class ServiceInstance {
protected _version: V1;
protected _solution: ServiceContextSolution;
protected _context?: ServiceContext;
constructor(_version: V1, payload: ServiceResource, sid?: string);
/**
* The unique string that we created to identify the Service resource.
*/
sid: string;
/**
* An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. Supports UTF-8 characters. **This value should not have PII.**
*/
uniqueName: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
*/
accountSid: string;
/**
* The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship.
*/
chatInstanceSid: string;
/**
* The URL we call when the interaction status changes.
*/
callbackUrl: string;
/**
* The default `ttl` value for Sessions created in the Service. The TTL (time to live) is measured in seconds after the Session\'s last create or last Interaction. The default value of `0` indicates an unlimited Session length. You can override a Session\'s default TTL value by setting its `ttl` value.
*/
defaultTtl: number;
numberSelectionBehavior: ServiceNumberSelectionBehavior;
geoMatchLevel: ServiceGeoMatchLevel;
/**
* The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues.
*/
interceptCallbackUrl: string;
/**
* The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information.
*/
outOfSessionCallbackUrl: string;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created.
*/
dateCreated: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated.
*/
dateUpdated: Date;
/**
* The absolute URL of the Service resource.
*/
url: string;
/**
* The URLs of resources related to the Service.
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
fetch(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Fetch a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Update a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
update(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Update a ServiceInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
update(params: ServiceContextUpdateOptions, callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Update a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Update a ServiceInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
updateWithHttpInfo(params: ServiceContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Access the phoneNumbers.
*/
phoneNumbers(): PhoneNumberListInstance;
/**
* Access the sessions.
*/
sessions(): SessionListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
uniqueName: string;
accountSid: string;
chatInstanceSid: string;
callbackUrl: string;
defaultTtl: number;
numberSelectionBehavior: ServiceNumberSelectionBehavior;
geoMatchLevel: ServiceGeoMatchLevel;
interceptCallbackUrl: string;
outOfSessionCallbackUrl: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface ServiceSolution {
}
export interface ServiceListInstance {
_version: V1;
_solution: ServiceSolution;
_uri: string;
(sid: string): ServiceContext;
get(sid: string): ServiceContext;
/**
* Create a ServiceInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
create(params: ServiceListInstanceCreateOptions, callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Create a ServiceInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
createWithHttpInfo(params: ServiceListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Streams ServiceInstance 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 { ServiceListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void;
each(params: ServiceListInstanceEachOptions, callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void;
/**
* Streams ServiceInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* 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 { ServiceListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: ServiceListInstanceEachOptions, callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of ServiceInstance 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: ServicePage) => any): Promise<ServicePage>;
/**
* Retrieve a single target page of ServiceInstance records from the API with HTTP metadata.
*
* 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 with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<ServicePage>) => any): Promise<ApiResponse<ServicePage>>;
/**
* Lists ServiceInstance 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 { ServiceListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: ServiceInstance[]) => any): Promise<ServiceInstance[]>;
list(params: ServiceListInstanceOptions, callback?: (error: Error | null, items: ServiceInstance[]) => any): Promise<ServiceInstance[]>;
/**
* Lists ServiceInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ServiceListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ServiceInstance[]>) => any): Promise<ApiResponse<ServiceInstance[]>>;
listWithHttpInfo(params: ServiceListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<ServiceInstance[]>) => any): Promise<ApiResponse<ServiceInstance[]>>;
/**
* Retrieve a single page of ServiceInstance 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 { ServiceListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: ServicePage) => any): Promise<ServicePage>;
page(params: ServiceListInstancePageOptions, callback?: (error: Error | null, items: ServicePage) => any): Promise<ServicePage>;
/**
* Retrieve a single page of ServiceInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ServiceListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ServicePage>) => any): Promise<ApiResponse<ServicePage>>;
pageWithHttpInfo(params: ServiceListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<ServicePage>) => any): Promise<ApiResponse<ServicePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function ServiceListInstance(version: V1): ServiceListInstance;
export declare class ServicePage extends Page<V1, ServicePayload, ServiceResource, ServiceInstance> {
/**
* Initialize the ServicePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: ServiceSolution);
/**
* Build an instance of ServiceInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: ServiceResource): ServiceInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

516
node_modules/twilio/lib/rest/proxy/v1/service.js generated vendored Normal file
View File

@@ -0,0 +1,516 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Proxy
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServicePage = exports.ServiceInstance = exports.ServiceContextImpl = void 0;
exports.ServiceListInstance = ServiceListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../base/Page"));
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
const utility_1 = require("../../../base/utility");
const phoneNumber_1 = require("./service/phoneNumber");
const session_1 = require("./service/session");
class ServiceContextImpl {
constructor(_version, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { sid };
this._uri = `/Services/${sid}`;
}
get phoneNumbers() {
this._phoneNumbers =
this._phoneNumbers ||
(0, phoneNumber_1.PhoneNumberListInstance)(this._version, this._solution.sid);
return this._phoneNumbers;
}
get sessions() {
this._sessions =
this._sessions || (0, session_1.SessionListInstance)(this._version, this._solution.sid);
return this._sessions;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new ServiceInstance(operationVersion, payload, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new ServiceInstance(operationVersion, response.body, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["defaultTtl"] !== undefined)
data["DefaultTtl"] = params["defaultTtl"];
if (params["callbackUrl"] !== undefined)
data["CallbackUrl"] = params["callbackUrl"];
if (params["geoMatchLevel"] !== undefined)
data["GeoMatchLevel"] = params["geoMatchLevel"];
if (params["numberSelectionBehavior"] !== undefined)
data["NumberSelectionBehavior"] = params["numberSelectionBehavior"];
if (params["interceptCallbackUrl"] !== undefined)
data["InterceptCallbackUrl"] = params["interceptCallbackUrl"];
if (params["outOfSessionCallbackUrl"] !== undefined)
data["OutOfSessionCallbackUrl"] = params["outOfSessionCallbackUrl"];
if (params["chatInstanceSid"] !== undefined)
data["ChatInstanceSid"] = params["chatInstanceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ServiceInstance(operationVersion, payload, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["defaultTtl"] !== undefined)
data["DefaultTtl"] = params["defaultTtl"];
if (params["callbackUrl"] !== undefined)
data["CallbackUrl"] = params["callbackUrl"];
if (params["geoMatchLevel"] !== undefined)
data["GeoMatchLevel"] = params["geoMatchLevel"];
if (params["numberSelectionBehavior"] !== undefined)
data["NumberSelectionBehavior"] = params["numberSelectionBehavior"];
if (params["interceptCallbackUrl"] !== undefined)
data["InterceptCallbackUrl"] = params["interceptCallbackUrl"];
if (params["outOfSessionCallbackUrl"] !== undefined)
data["OutOfSessionCallbackUrl"] = params["outOfSessionCallbackUrl"];
if (params["chatInstanceSid"] !== undefined)
data["ChatInstanceSid"] = params["chatInstanceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ServiceInstance(operationVersion, response.body, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ServiceContextImpl = ServiceContextImpl;
class ServiceInstance {
constructor(_version, payload, sid) {
this._version = _version;
this.sid = payload.sid;
this.uniqueName = payload.unique_name;
this.accountSid = payload.account_sid;
this.chatInstanceSid = payload.chat_instance_sid;
this.callbackUrl = payload.callback_url;
this.defaultTtl = deserialize.integer(payload.default_ttl);
this.numberSelectionBehavior = payload.number_selection_behavior;
this.geoMatchLevel = payload.geo_match_level;
this.interceptCallbackUrl = payload.intercept_callback_url;
this.outOfSessionCallbackUrl = payload.out_of_session_callback_url;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this.links = payload.links;
this._solution = { sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new ServiceContextImpl(this._version, this._solution.sid);
return this._context;
}
/**
* Remove a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Access the phoneNumbers.
*/
phoneNumbers() {
return this._proxy.phoneNumbers;
}
/**
* Access the sessions.
*/
sessions() {
return this._proxy.sessions;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
uniqueName: this.uniqueName,
accountSid: this.accountSid,
chatInstanceSid: this.chatInstanceSid,
callbackUrl: this.callbackUrl,
defaultTtl: this.defaultTtl,
numberSelectionBehavior: this.numberSelectionBehavior,
geoMatchLevel: this.geoMatchLevel,
interceptCallbackUrl: this.interceptCallbackUrl,
outOfSessionCallbackUrl: this.outOfSessionCallbackUrl,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ServiceInstance = ServiceInstance;
function ServiceListInstance(version) {
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new ServiceContextImpl(version, sid);
};
instance._version = version;
instance._solution = {};
instance._uri = `/Services`;
instance.create = function create(params, callback) {
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 = {};
data["UniqueName"] = params["uniqueName"];
if (params["defaultTtl"] !== undefined)
data["DefaultTtl"] = params["defaultTtl"];
if (params["callbackUrl"] !== undefined)
data["CallbackUrl"] = params["callbackUrl"];
if (params["geoMatchLevel"] !== undefined)
data["GeoMatchLevel"] = params["geoMatchLevel"];
if (params["numberSelectionBehavior"] !== undefined)
data["NumberSelectionBehavior"] = params["numberSelectionBehavior"];
if (params["interceptCallbackUrl"] !== undefined)
data["InterceptCallbackUrl"] = params["interceptCallbackUrl"];
if (params["outOfSessionCallbackUrl"] !== undefined)
data["OutOfSessionCallbackUrl"] = params["outOfSessionCallbackUrl"];
if (params["chatInstanceSid"] !== undefined)
data["ChatInstanceSid"] = params["chatInstanceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ServiceInstance(operationVersion, payload));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
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 = {};
data["UniqueName"] = params["uniqueName"];
if (params["defaultTtl"] !== undefined)
data["DefaultTtl"] = params["defaultTtl"];
if (params["callbackUrl"] !== undefined)
data["CallbackUrl"] = params["callbackUrl"];
if (params["geoMatchLevel"] !== undefined)
data["GeoMatchLevel"] = params["geoMatchLevel"];
if (params["numberSelectionBehavior"] !== undefined)
data["NumberSelectionBehavior"] = params["numberSelectionBehavior"];
if (params["interceptCallbackUrl"] !== undefined)
data["InterceptCallbackUrl"] = params["interceptCallbackUrl"];
if (params["outOfSessionCallbackUrl"] !== undefined)
data["OutOfSessionCallbackUrl"] = params["outOfSessionCallbackUrl"];
if (params["chatInstanceSid"] !== undefined)
data["ChatInstanceSid"] = params["chatInstanceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ServiceInstance(operationVersion, response.body),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new ServicePage(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, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new ServicePage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new ServicePage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new ServicePage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class ServicePage extends Page_1.default {
/**
* Initialize the ServicePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of ServiceInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new ServiceInstance(this._version, payload);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ServicePage = ServicePage;

View File

@@ -0,0 +1,478 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V1 from "../../V1";
import { ApiResponse } from "../../../../base/ApiResponse";
import { PhoneNumberCapabilities } from "../../../../interfaces";
/**
* Options to pass to update a PhoneNumberInstance
*/
export interface PhoneNumberContextUpdateOptions {
/** Whether the phone number should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. */
isReserved?: boolean;
}
/**
* Options to pass to create a PhoneNumberInstance
*/
export interface PhoneNumberListInstanceCreateOptions {
/** The SID of a Twilio [IncomingPhoneNumber](https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource) resource that represents the Twilio Number you would like to assign to your Proxy Service. */
sid?: string;
/** The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234. */
phoneNumber?: string;
/** Whether the new phone number should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. */
isReserved?: boolean;
}
/**
* Options to pass to each
*/
export interface PhoneNumberListInstanceEachOptions {
/** 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: PhoneNumberInstance, 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 PhoneNumberListInstanceOptions {
/** 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 PhoneNumberListInstancePageOptions {
/** 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 PhoneNumberContext {
/**
* Remove a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
fetch(callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
/**
* Fetch a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Update a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
update(callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
/**
* Update a PhoneNumberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
update(params: PhoneNumberContextUpdateOptions, callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
/**
* Update a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Update a PhoneNumberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
updateWithHttpInfo(params: PhoneNumberContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface PhoneNumberContextSolution {
serviceSid: string;
sid: string;
}
export declare class PhoneNumberContextImpl implements PhoneNumberContext {
protected _version: V1;
protected _solution: PhoneNumberContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, sid: string);
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
update(params?: PhoneNumberContextUpdateOptions | ((error: Error | null, item?: PhoneNumberInstance) => any), callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
updateWithHttpInfo(params?: PhoneNumberContextUpdateOptions | ((error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): PhoneNumberContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface PhoneNumberPayload extends TwilioResponsePayload {
phone_numbers: PhoneNumberResource[];
}
interface PhoneNumberResource {
sid: string;
account_sid: string;
service_sid: string;
date_created: Date;
date_updated: Date;
phone_number: string;
friendly_name: string;
iso_country: string;
capabilities: PhoneNumberCapabilities;
url: string;
is_reserved: boolean;
in_use: number;
}
export declare class PhoneNumberInstance {
protected _version: V1;
protected _solution: PhoneNumberContextSolution;
protected _context?: PhoneNumberContext;
constructor(_version: V1, payload: PhoneNumberResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the PhoneNumber resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the PhoneNumber resource.
*/
accountSid: string;
/**
* The SID of the PhoneNumber resource\'s parent [Service](https://www.twilio.com/docs/proxy/api/service) resource.
*/
serviceSid: string;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created.
*/
dateCreated: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated.
*/
dateUpdated: Date;
/**
* The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
*/
phoneNumber: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
/**
* The ISO Country Code for the phone number.
*/
isoCountry: string;
capabilities: PhoneNumberCapabilities;
/**
* The absolute URL of the PhoneNumber resource.
*/
url: string;
/**
* Whether the phone number should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information.
*/
isReserved: boolean;
/**
* The number of open session assigned to the number. See the [How many Phone Numbers do I need?](https://www.twilio.com/docs/proxy/phone-numbers-needed) guide for more information.
*/
inUse: number;
private get _proxy();
/**
* Remove a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
fetch(callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
/**
* Fetch a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Update a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
update(callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
/**
* Update a PhoneNumberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
update(params: PhoneNumberContextUpdateOptions, callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
/**
* Update a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Update a PhoneNumberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
updateWithHttpInfo(params: PhoneNumberContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
dateCreated: Date;
dateUpdated: Date;
phoneNumber: string;
friendlyName: string;
isoCountry: string;
capabilities: PhoneNumberCapabilities;
url: string;
isReserved: boolean;
inUse: number;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface PhoneNumberSolution {
serviceSid: string;
}
export interface PhoneNumberListInstance {
_version: V1;
_solution: PhoneNumberSolution;
_uri: string;
(sid: string): PhoneNumberContext;
get(sid: string): PhoneNumberContext;
/**
* Create a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
create(callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
/**
* Create a PhoneNumberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
create(params: PhoneNumberListInstanceCreateOptions, callback?: (error: Error | null, item?: PhoneNumberInstance) => any): Promise<PhoneNumberInstance>;
/**
* Create a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Create a PhoneNumberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
createWithHttpInfo(params: PhoneNumberListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<PhoneNumberInstance>) => any): Promise<ApiResponse<PhoneNumberInstance>>;
/**
* Streams PhoneNumberInstance 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 { PhoneNumberListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: PhoneNumberInstance, done: (err?: Error) => void) => void): void;
each(params: PhoneNumberListInstanceEachOptions, callback?: (item: PhoneNumberInstance, done: (err?: Error) => void) => void): void;
/**
* Streams PhoneNumberInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* 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 { PhoneNumberListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: PhoneNumberInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: PhoneNumberListInstanceEachOptions, callback?: (item: PhoneNumberInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of PhoneNumberInstance 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: PhoneNumberPage) => any): Promise<PhoneNumberPage>;
/**
* Retrieve a single target page of PhoneNumberInstance records from the API with HTTP metadata.
*
* 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 with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<PhoneNumberPage>) => any): Promise<ApiResponse<PhoneNumberPage>>;
/**
* Lists PhoneNumberInstance 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 { PhoneNumberListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: PhoneNumberInstance[]) => any): Promise<PhoneNumberInstance[]>;
list(params: PhoneNumberListInstanceOptions, callback?: (error: Error | null, items: PhoneNumberInstance[]) => any): Promise<PhoneNumberInstance[]>;
/**
* Lists PhoneNumberInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { PhoneNumberListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<PhoneNumberInstance[]>) => any): Promise<ApiResponse<PhoneNumberInstance[]>>;
listWithHttpInfo(params: PhoneNumberListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<PhoneNumberInstance[]>) => any): Promise<ApiResponse<PhoneNumberInstance[]>>;
/**
* Retrieve a single page of PhoneNumberInstance 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 { PhoneNumberListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: PhoneNumberPage) => any): Promise<PhoneNumberPage>;
page(params: PhoneNumberListInstancePageOptions, callback?: (error: Error | null, items: PhoneNumberPage) => any): Promise<PhoneNumberPage>;
/**
* Retrieve a single page of PhoneNumberInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { PhoneNumberListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<PhoneNumberPage>) => any): Promise<ApiResponse<PhoneNumberPage>>;
pageWithHttpInfo(params: PhoneNumberListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<PhoneNumberPage>) => any): Promise<ApiResponse<PhoneNumberPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function PhoneNumberListInstance(version: V1, serviceSid: string): PhoneNumberListInstance;
export declare class PhoneNumberPage extends Page<V1, PhoneNumberPayload, PhoneNumberResource, PhoneNumberInstance> {
/**
* Initialize the PhoneNumberPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: PhoneNumberSolution);
/**
* Build an instance of PhoneNumberInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: PhoneNumberResource): PhoneNumberInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,449 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Proxy
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PhoneNumberPage = exports.PhoneNumberInstance = exports.PhoneNumberContextImpl = void 0;
exports.PhoneNumberListInstance = PhoneNumberListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../base/Page"));
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class PhoneNumberContextImpl {
constructor(_version, serviceSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sid };
this._uri = `/Services/${serviceSid}/PhoneNumbers/${sid}`;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new PhoneNumberInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new PhoneNumberInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["isReserved"] !== undefined)
data["IsReserved"] = serialize.bool(params["isReserved"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new PhoneNumberInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["isReserved"] !== undefined)
data["IsReserved"] = serialize.bool(params["isReserved"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new PhoneNumberInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.PhoneNumberContextImpl = PhoneNumberContextImpl;
class PhoneNumberInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.phoneNumber = payload.phone_number;
this.friendlyName = payload.friendly_name;
this.isoCountry = payload.iso_country;
this.capabilities = payload.capabilities;
this.url = payload.url;
this.isReserved = payload.is_reserved;
this.inUse = deserialize.integer(payload.in_use);
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new PhoneNumberContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a PhoneNumberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a PhoneNumberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed PhoneNumberInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
phoneNumber: this.phoneNumber,
friendlyName: this.friendlyName,
isoCountry: this.isoCountry,
capabilities: this.capabilities,
url: this.url,
isReserved: this.isReserved,
inUse: this.inUse,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.PhoneNumberInstance = PhoneNumberInstance;
function PhoneNumberListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new PhoneNumberContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/PhoneNumbers`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["sid"] !== undefined)
data["Sid"] = params["sid"];
if (params["phoneNumber"] !== undefined)
data["PhoneNumber"] = params["phoneNumber"];
if (params["isReserved"] !== undefined)
data["IsReserved"] = serialize.bool(params["isReserved"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new PhoneNumberInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["sid"] !== undefined)
data["Sid"] = params["sid"];
if (params["phoneNumber"] !== undefined)
data["PhoneNumber"] = params["phoneNumber"];
if (params["isReserved"] !== undefined)
data["IsReserved"] = serialize.bool(params["isReserved"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new PhoneNumberInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new PhoneNumberPage(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, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new PhoneNumberPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new PhoneNumberPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new PhoneNumberPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class PhoneNumberPage extends Page_1.default {
/**
* Initialize the PhoneNumberPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of PhoneNumberInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new PhoneNumberInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.PhoneNumberPage = PhoneNumberPage;

View File

@@ -0,0 +1,532 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V1 from "../../V1";
import { ApiResponse } from "../../../../base/ApiResponse";
import { InteractionListInstance } from "./session/interaction";
import { ParticipantListInstance } from "./session/participant";
/**
* The Mode of the Session. Can be: `message-only`, `voice-only`, or `voice-and-message`.
*/
export type SessionMode = "message-only" | "voice-only" | "voice-and-message";
/**
* The status of the Session. Can be: `open`, `in-progress`, `closed`, `failed`, or `unknown`.
*/
export type SessionStatus = "open" | "in-progress" | "closed" | "failed" | "unknown";
/**
* Options to pass to update a SessionInstance
*/
export interface SessionContextUpdateOptions {
/** The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session should expire. If this is value is present, it overrides the `ttl` value. */
dateExpiry?: Date;
/** The time, in seconds, when the session will expire. The time is measured from the last Session create or the Session\\\'s last Interaction. */
ttl?: number;
/** */
status?: SessionStatus;
}
/**
* Options to pass to create a SessionInstance
*/
export interface SessionListInstanceCreateOptions {
/** An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.** */
uniqueName?: string;
/** The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session should expire. If this is value is present, it overrides the `ttl` value. */
dateExpiry?: Date;
/** The time, in seconds, when the session will expire. The time is measured from the last Session create or the Session\\\'s last Interaction. */
ttl?: number;
/** */
mode?: SessionMode;
/** */
status?: SessionStatus;
/** The Participant objects to include in the new session. */
participants?: Array<any>;
}
/**
* Options to pass to each
*/
export interface SessionListInstanceEachOptions {
/** 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: SessionInstance, 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 SessionListInstanceOptions {
/** 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 SessionListInstancePageOptions {
/** 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 SessionContext {
interactions: InteractionListInstance;
participants: ParticipantListInstance;
/**
* Remove a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
fetch(callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
/**
* Fetch a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Update a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
update(callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
/**
* Update a SessionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
update(params: SessionContextUpdateOptions, callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
/**
* Update a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Update a SessionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
updateWithHttpInfo(params: SessionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SessionContextSolution {
serviceSid: string;
sid: string;
}
export declare class SessionContextImpl implements SessionContext {
protected _version: V1;
protected _solution: SessionContextSolution;
protected _uri: string;
protected _interactions?: InteractionListInstance;
protected _participants?: ParticipantListInstance;
constructor(_version: V1, serviceSid: string, sid: string);
get interactions(): InteractionListInstance;
get participants(): ParticipantListInstance;
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
update(params?: SessionContextUpdateOptions | ((error: Error | null, item?: SessionInstance) => any), callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
updateWithHttpInfo(params?: SessionContextUpdateOptions | ((error: Error | null, item?: ApiResponse<SessionInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SessionContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SessionPayload extends TwilioResponsePayload {
sessions: SessionResource[];
}
interface SessionResource {
sid: string;
service_sid: string;
account_sid: string;
date_started: Date;
date_ended: Date;
date_last_interaction: Date;
date_expiry: Date;
unique_name: string;
status: SessionStatus;
closed_reason: string;
ttl: number;
mode: SessionMode;
date_created: Date;
date_updated: Date;
url: string;
links: Record<string, string>;
}
export declare class SessionInstance {
protected _version: V1;
protected _solution: SessionContextSolution;
protected _context?: SessionContext;
constructor(_version: V1, payload: SessionResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Session resource.
*/
sid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/proxy/api/service) the session is associated with.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Session resource.
*/
accountSid: string;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session started.
*/
dateStarted: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session ended.
*/
dateEnded: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session last had an interaction.
*/
dateLastInteraction: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Session should expire. If this is value is present, it overrides the `ttl` value.
*/
dateExpiry: Date;
/**
* An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. Supports UTF-8 characters. **This value should not have PII.**
*/
uniqueName: string;
status: SessionStatus;
/**
* The reason the Session ended.
*/
closedReason: string;
/**
* The time, in seconds, when the session will expire. The time is measured from the last Session create or the Session\'s last Interaction.
*/
ttl: number;
mode: SessionMode;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created.
*/
dateCreated: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated.
*/
dateUpdated: Date;
/**
* The absolute URL of the Session resource.
*/
url: string;
/**
* The URLs of resources related to the Session.
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
fetch(callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
/**
* Fetch a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Update a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
update(callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
/**
* Update a SessionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
update(params: SessionContextUpdateOptions, callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
/**
* Update a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Update a SessionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
updateWithHttpInfo(params: SessionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Access the interactions.
*/
interactions(): InteractionListInstance;
/**
* Access the participants.
*/
participants(): ParticipantListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
serviceSid: string;
accountSid: string;
dateStarted: Date;
dateEnded: Date;
dateLastInteraction: Date;
dateExpiry: Date;
uniqueName: string;
status: SessionStatus;
closedReason: string;
ttl: number;
mode: SessionMode;
dateCreated: Date;
dateUpdated: Date;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SessionSolution {
serviceSid: string;
}
export interface SessionListInstance {
_version: V1;
_solution: SessionSolution;
_uri: string;
(sid: string): SessionContext;
get(sid: string): SessionContext;
/**
* Create a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
create(callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
/**
* Create a SessionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
create(params: SessionListInstanceCreateOptions, callback?: (error: Error | null, item?: SessionInstance) => any): Promise<SessionInstance>;
/**
* Create a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Create a SessionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
createWithHttpInfo(params: SessionListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<SessionInstance>) => any): Promise<ApiResponse<SessionInstance>>;
/**
* Streams SessionInstance 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 { SessionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: SessionInstance, done: (err?: Error) => void) => void): void;
each(params: SessionListInstanceEachOptions, callback?: (item: SessionInstance, done: (err?: Error) => void) => void): void;
/**
* Streams SessionInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* 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 { SessionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: SessionInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: SessionListInstanceEachOptions, callback?: (item: SessionInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of SessionInstance 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: SessionPage) => any): Promise<SessionPage>;
/**
* Retrieve a single target page of SessionInstance records from the API with HTTP metadata.
*
* 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 with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<SessionPage>) => any): Promise<ApiResponse<SessionPage>>;
/**
* Lists SessionInstance 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 { SessionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: SessionInstance[]) => any): Promise<SessionInstance[]>;
list(params: SessionListInstanceOptions, callback?: (error: Error | null, items: SessionInstance[]) => any): Promise<SessionInstance[]>;
/**
* Lists SessionInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { SessionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SessionInstance[]>) => any): Promise<ApiResponse<SessionInstance[]>>;
listWithHttpInfo(params: SessionListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<SessionInstance[]>) => any): Promise<ApiResponse<SessionInstance[]>>;
/**
* Retrieve a single page of SessionInstance 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 { SessionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: SessionPage) => any): Promise<SessionPage>;
page(params: SessionListInstancePageOptions, callback?: (error: Error | null, items: SessionPage) => any): Promise<SessionPage>;
/**
* Retrieve a single page of SessionInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { SessionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SessionPage>) => any): Promise<ApiResponse<SessionPage>>;
pageWithHttpInfo(params: SessionListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<SessionPage>) => any): Promise<ApiResponse<SessionPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SessionListInstance(version: V1, serviceSid: string): SessionListInstance;
export declare class SessionPage extends Page<V1, SessionPayload, SessionResource, SessionInstance> {
/**
* Initialize the SessionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: SessionSolution);
/**
* Build an instance of SessionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: SessionResource): SessionInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,503 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Proxy
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionPage = exports.SessionInstance = exports.SessionContextImpl = void 0;
exports.SessionListInstance = SessionListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../base/Page"));
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
const interaction_1 = require("./session/interaction");
const participant_1 = require("./session/participant");
class SessionContextImpl {
constructor(_version, serviceSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sid };
this._uri = `/Services/${serviceSid}/Sessions/${sid}`;
}
get interactions() {
this._interactions =
this._interactions ||
(0, interaction_1.InteractionListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._interactions;
}
get participants() {
this._participants =
this._participants ||
(0, participant_1.ParticipantListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._participants;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new SessionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new SessionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["dateExpiry"] !== undefined)
data["DateExpiry"] = serialize.iso8601DateTime(params["dateExpiry"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new SessionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["dateExpiry"] !== undefined)
data["DateExpiry"] = serialize.iso8601DateTime(params["dateExpiry"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new SessionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SessionContextImpl = SessionContextImpl;
class SessionInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.dateStarted = deserialize.iso8601DateTime(payload.date_started);
this.dateEnded = deserialize.iso8601DateTime(payload.date_ended);
this.dateLastInteraction = deserialize.iso8601DateTime(payload.date_last_interaction);
this.dateExpiry = deserialize.iso8601DateTime(payload.date_expiry);
this.uniqueName = payload.unique_name;
this.status = payload.status;
this.closedReason = payload.closed_reason;
this.ttl = deserialize.integer(payload.ttl);
this.mode = payload.mode;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new SessionContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a SessionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SessionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SessionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Access the interactions.
*/
interactions() {
return this._proxy.interactions;
}
/**
* Access the participants.
*/
participants() {
return this._proxy.participants;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
dateStarted: this.dateStarted,
dateEnded: this.dateEnded,
dateLastInteraction: this.dateLastInteraction,
dateExpiry: this.dateExpiry,
uniqueName: this.uniqueName,
status: this.status,
closedReason: this.closedReason,
ttl: this.ttl,
mode: this.mode,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SessionInstance = SessionInstance;
function SessionListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new SessionContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Sessions`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["dateExpiry"] !== undefined)
data["DateExpiry"] = serialize.iso8601DateTime(params["dateExpiry"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["mode"] !== undefined)
data["Mode"] = params["mode"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["participants"] !== undefined)
data["Participants"] = serialize.map(params["participants"], (e) => serialize.object(e));
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new SessionInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["dateExpiry"] !== undefined)
data["DateExpiry"] = serialize.iso8601DateTime(params["dateExpiry"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["mode"] !== undefined)
data["Mode"] = params["mode"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["participants"] !== undefined)
data["Participants"] = serialize.map(params["participants"], (e) => serialize.object(e));
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new SessionInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new SessionPage(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, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new SessionPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new SessionPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new SessionPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class SessionPage extends Page_1.default {
/**
* Initialize the SessionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of SessionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new SessionInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SessionPage = SessionPage;

View File

@@ -0,0 +1,401 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V1 from "../../../V1";
import { ApiResponse } from "../../../../../base/ApiResponse";
/**
* The inbound resource status of the Interaction. Will always be `delivered` for messages and `in-progress` for calls.
*/
export type InteractionResourceStatus = "accepted" | "answered" | "busy" | "canceled" | "completed" | "deleted" | "delivered" | "delivery-unknown" | "failed" | "in-progress" | "initiated" | "no-answer" | "queued" | "received" | "receiving" | "ringing" | "scheduled" | "sending" | "sent" | "undelivered" | "unknown";
/**
* The Type of the Interaction. Can be: `message`, `voice` or `unknown`.
*/
export type InteractionType = "message" | "voice" | "unknown";
/**
* Options to pass to each
*/
export interface InteractionListInstanceEachOptions {
/** 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: InteractionInstance, 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 InteractionListInstanceOptions {
/** 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 InteractionListInstancePageOptions {
/** 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 InteractionContext {
/**
* Remove a InteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a InteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a InteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InteractionInstance
*/
fetch(callback?: (error: Error | null, item?: InteractionInstance) => any): Promise<InteractionInstance>;
/**
* Fetch a InteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InteractionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InteractionInstance>) => any): Promise<ApiResponse<InteractionInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface InteractionContextSolution {
serviceSid: string;
sessionSid: string;
sid: string;
}
export declare class InteractionContextImpl implements InteractionContext {
protected _version: V1;
protected _solution: InteractionContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, sessionSid: string, sid: string);
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: InteractionInstance) => any): Promise<InteractionInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InteractionInstance>) => any): Promise<ApiResponse<InteractionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): InteractionContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface InteractionPayload extends TwilioResponsePayload {
interactions: InteractionResource[];
}
interface InteractionResource {
sid: string;
session_sid: string;
service_sid: string;
account_sid: string;
data: string;
type: InteractionType;
inbound_participant_sid: string;
inbound_resource_sid: string;
inbound_resource_status: InteractionResourceStatus;
inbound_resource_type: string;
inbound_resource_url: string;
outbound_participant_sid: string;
outbound_resource_sid: string;
outbound_resource_status: InteractionResourceStatus;
outbound_resource_type: string;
outbound_resource_url: string;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class InteractionInstance {
protected _version: V1;
protected _solution: InteractionContextSolution;
protected _context?: InteractionContext;
constructor(_version: V1, payload: InteractionResource, serviceSid: string, sessionSid: string, sid?: string);
/**
* The unique string that we created to identify the Interaction resource.
*/
sid: string;
/**
* The SID of the parent [Session](https://www.twilio.com/docs/proxy/api/session) resource.
*/
sessionSid: string;
/**
* The SID of the parent [Service](https://www.twilio.com/docs/proxy/api/service) resource.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Interaction resource.
*/
accountSid: string;
/**
* A JSON string that includes the message body of message interactions (e.g. `{\"body\": \"hello\"}`) or the call duration (when available) of a call (e.g. `{\"duration\": \"5\"}`).
*/
data: string;
type: InteractionType;
/**
* The SID of the inbound [Participant](https://www.twilio.com/docs/proxy/api/participant) resource.
*/
inboundParticipantSid: string;
/**
* The SID of the inbound resource; either the [Call](https://www.twilio.com/docs/voice/api/call-resource) or [Message](https://www.twilio.com/docs/sms/api/message-resource).
*/
inboundResourceSid: string;
inboundResourceStatus: InteractionResourceStatus;
/**
* The inbound resource type. Can be [Call](https://www.twilio.com/docs/voice/api/call-resource) or [Message](https://www.twilio.com/docs/sms/api/message-resource).
*/
inboundResourceType: string;
/**
* The URL of the Twilio inbound resource
*/
inboundResourceUrl: string;
/**
* The SID of the outbound [Participant](https://www.twilio.com/docs/proxy/api/participant)).
*/
outboundParticipantSid: string;
/**
* The SID of the outbound resource; either the [Call](https://www.twilio.com/docs/voice/api/call-resource) or [Message](https://www.twilio.com/docs/sms/api/message-resource).
*/
outboundResourceSid: string;
outboundResourceStatus: InteractionResourceStatus;
/**
* The outbound resource type. Can be: [Call](https://www.twilio.com/docs/voice/api/call-resource) or [Message](https://www.twilio.com/docs/sms/api/message-resource).
*/
outboundResourceType: string;
/**
* The URL of the Twilio outbound resource.
*/
outboundResourceUrl: string;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the Interaction was created.
*/
dateCreated: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated.
*/
dateUpdated: Date;
/**
* The absolute URL of the Interaction resource.
*/
url: string;
private get _proxy();
/**
* Remove a InteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a InteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a InteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InteractionInstance
*/
fetch(callback?: (error: Error | null, item?: InteractionInstance) => any): Promise<InteractionInstance>;
/**
* Fetch a InteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InteractionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InteractionInstance>) => any): Promise<ApiResponse<InteractionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
sessionSid: string;
serviceSid: string;
accountSid: string;
data: string;
type: InteractionType;
inboundParticipantSid: string;
inboundResourceSid: string;
inboundResourceStatus: InteractionResourceStatus;
inboundResourceType: string;
inboundResourceUrl: string;
outboundParticipantSid: string;
outboundResourceSid: string;
outboundResourceStatus: InteractionResourceStatus;
outboundResourceType: string;
outboundResourceUrl: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface InteractionSolution {
serviceSid: string;
sessionSid: string;
}
export interface InteractionListInstance {
_version: V1;
_solution: InteractionSolution;
_uri: string;
(sid: string): InteractionContext;
get(sid: string): InteractionContext;
/**
* Streams InteractionInstance 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 { InteractionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: InteractionInstance, done: (err?: Error) => void) => void): void;
each(params: InteractionListInstanceEachOptions, callback?: (item: InteractionInstance, done: (err?: Error) => void) => void): void;
/**
* Streams InteractionInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* 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 { InteractionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: InteractionInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: InteractionListInstanceEachOptions, callback?: (item: InteractionInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of InteractionInstance 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: InteractionPage) => any): Promise<InteractionPage>;
/**
* Retrieve a single target page of InteractionInstance records from the API with HTTP metadata.
*
* 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 with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<InteractionPage>) => any): Promise<ApiResponse<InteractionPage>>;
/**
* Lists InteractionInstance 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 { InteractionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: InteractionInstance[]) => any): Promise<InteractionInstance[]>;
list(params: InteractionListInstanceOptions, callback?: (error: Error | null, items: InteractionInstance[]) => any): Promise<InteractionInstance[]>;
/**
* Lists InteractionInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { InteractionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<InteractionInstance[]>) => any): Promise<ApiResponse<InteractionInstance[]>>;
listWithHttpInfo(params: InteractionListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<InteractionInstance[]>) => any): Promise<ApiResponse<InteractionInstance[]>>;
/**
* Retrieve a single page of InteractionInstance 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 { InteractionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: InteractionPage) => any): Promise<InteractionPage>;
page(params: InteractionListInstancePageOptions, callback?: (error: Error | null, items: InteractionPage) => any): Promise<InteractionPage>;
/**
* Retrieve a single page of InteractionInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { InteractionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<InteractionPage>) => any): Promise<ApiResponse<InteractionPage>>;
pageWithHttpInfo(params: InteractionListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<InteractionPage>) => any): Promise<ApiResponse<InteractionPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function InteractionListInstance(version: V1, serviceSid: string, sessionSid: string): InteractionListInstance;
export declare class InteractionPage extends Page<V1, InteractionPayload, InteractionResource, InteractionInstance> {
/**
* Initialize the InteractionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: InteractionSolution);
/**
* Build an instance of InteractionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: InteractionResource): InteractionInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,345 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Proxy
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InteractionPage = exports.InteractionInstance = exports.InteractionContextImpl = void 0;
exports.InteractionListInstance = InteractionListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../../base/Page"));
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
const utility_1 = require("../../../../../base/utility");
class InteractionContextImpl {
constructor(_version, serviceSid, sessionSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sessionSid)) {
throw new Error("Parameter 'sessionSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sessionSid, sid };
this._uri = `/Services/${serviceSid}/Sessions/${sessionSid}/Interactions/${sid}`;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new InteractionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sessionSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new InteractionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sessionSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.InteractionContextImpl = InteractionContextImpl;
class InteractionInstance {
constructor(_version, payload, serviceSid, sessionSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.sessionSid = payload.session_sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.data = payload.data;
this.type = payload.type;
this.inboundParticipantSid = payload.inbound_participant_sid;
this.inboundResourceSid = payload.inbound_resource_sid;
this.inboundResourceStatus = payload.inbound_resource_status;
this.inboundResourceType = payload.inbound_resource_type;
this.inboundResourceUrl = payload.inbound_resource_url;
this.outboundParticipantSid = payload.outbound_participant_sid;
this.outboundResourceSid = payload.outbound_resource_sid;
this.outboundResourceStatus = payload.outbound_resource_status;
this.outboundResourceType = payload.outbound_resource_type;
this.outboundResourceUrl = payload.outbound_resource_url;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = { serviceSid, sessionSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new InteractionContextImpl(this._version, this._solution.serviceSid, this._solution.sessionSid, this._solution.sid);
return this._context;
}
/**
* Remove a InteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a InteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a InteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InteractionInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a InteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InteractionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
sessionSid: this.sessionSid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
data: this.data,
type: this.type,
inboundParticipantSid: this.inboundParticipantSid,
inboundResourceSid: this.inboundResourceSid,
inboundResourceStatus: this.inboundResourceStatus,
inboundResourceType: this.inboundResourceType,
inboundResourceUrl: this.inboundResourceUrl,
outboundParticipantSid: this.outboundParticipantSid,
outboundResourceSid: this.outboundResourceSid,
outboundResourceStatus: this.outboundResourceStatus,
outboundResourceType: this.outboundResourceType,
outboundResourceUrl: this.outboundResourceUrl,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.InteractionInstance = InteractionInstance;
function InteractionListInstance(version, serviceSid, sessionSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sessionSid)) {
throw new Error("Parameter 'sessionSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new InteractionContextImpl(version, serviceSid, sessionSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, sessionSid };
instance._uri = `/Services/${serviceSid}/Sessions/${sessionSid}/Interactions`;
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new InteractionPage(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, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new InteractionPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new InteractionPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new InteractionPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class InteractionPage extends Page_1.default {
/**
* Initialize the InteractionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of InteractionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new InteractionInstance(this._version, payload, this._solution.serviceSid, this._solution.sessionSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.InteractionPage = InteractionPage;

View File

@@ -0,0 +1,405 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V1 from "../../../V1";
import { ApiResponse } from "../../../../../base/ApiResponse";
import { MessageInteractionListInstance } from "./participant/messageInteraction";
/**
* Options to pass to create a ParticipantInstance
*/
export interface ParticipantListInstanceCreateOptions {
/** The phone number of the Participant. */
identifier: string;
/** The string that you assigned to describe the participant. This value must be 255 characters or fewer. **This value should not have PII.** */
friendlyName?: string;
/** The proxy phone number to use for the Participant. If not specified, Proxy will select a number from the pool. */
proxyIdentifier?: string;
/** The SID of the Proxy Identifier to assign to the Participant. */
proxyIdentifierSid?: string;
}
/**
* Options to pass to each
*/
export interface ParticipantListInstanceEachOptions {
/** 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: ParticipantInstance, 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 ParticipantListInstanceOptions {
/** 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 ParticipantListInstancePageOptions {
/** 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 ParticipantContext {
messageInteractions: MessageInteractionListInstance;
/**
* Remove a ParticipantInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ParticipantInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a ParticipantInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ParticipantInstance
*/
fetch(callback?: (error: Error | null, item?: ParticipantInstance) => any): Promise<ParticipantInstance>;
/**
* Fetch a ParticipantInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ParticipantInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ParticipantInstance>) => any): Promise<ApiResponse<ParticipantInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface ParticipantContextSolution {
serviceSid: string;
sessionSid: string;
sid: string;
}
export declare class ParticipantContextImpl implements ParticipantContext {
protected _version: V1;
protected _solution: ParticipantContextSolution;
protected _uri: string;
protected _messageInteractions?: MessageInteractionListInstance;
constructor(_version: V1, serviceSid: string, sessionSid: string, sid: string);
get messageInteractions(): MessageInteractionListInstance;
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: ParticipantInstance) => any): Promise<ParticipantInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ParticipantInstance>) => any): Promise<ApiResponse<ParticipantInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ParticipantContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ParticipantPayload extends TwilioResponsePayload {
participants: ParticipantResource[];
}
interface ParticipantResource {
sid: string;
session_sid: string;
service_sid: string;
account_sid: string;
friendly_name: string;
identifier: string;
proxy_identifier: string;
proxy_identifier_sid: string;
date_deleted: Date;
date_created: Date;
date_updated: Date;
url: string;
links: Record<string, string>;
}
export declare class ParticipantInstance {
protected _version: V1;
protected _solution: ParticipantContextSolution;
protected _context?: ParticipantContext;
constructor(_version: V1, payload: ParticipantResource, serviceSid: string, sessionSid: string, sid?: string);
/**
* The unique string that we created to identify the Participant resource.
*/
sid: string;
/**
* The SID of the parent [Session](https://www.twilio.com/docs/proxy/api/session) resource.
*/
sessionSid: string;
/**
* The SID of the resource\'s parent [Service](https://www.twilio.com/docs/proxy/api/service) resource.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resource.
*/
accountSid: string;
/**
* The string that you assigned to describe the participant. This value must be 255 characters or fewer. Supports UTF-8 characters. **This value should not have PII.**
*/
friendlyName: string;
/**
* The phone number or channel identifier of the Participant. This value must be 191 characters or fewer. Supports UTF-8 characters.
*/
identifier: string;
/**
* The phone number or short code (masked number) of the participant\'s partner. The participant will call or message the partner participant at this number.
*/
proxyIdentifier: string;
/**
* The SID of the Proxy Identifier assigned to the Participant.
*/
proxyIdentifierSid: string;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the Participant was removed from the session.
*/
dateDeleted: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created.
*/
dateCreated: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated.
*/
dateUpdated: Date;
/**
* The absolute URL of the Participant resource.
*/
url: string;
/**
* The URLs to resources related the participant.
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a ParticipantInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ParticipantInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a ParticipantInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ParticipantInstance
*/
fetch(callback?: (error: Error | null, item?: ParticipantInstance) => any): Promise<ParticipantInstance>;
/**
* Fetch a ParticipantInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ParticipantInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ParticipantInstance>) => any): Promise<ApiResponse<ParticipantInstance>>;
/**
* Access the messageInteractions.
*/
messageInteractions(): MessageInteractionListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
sessionSid: string;
serviceSid: string;
accountSid: string;
friendlyName: string;
identifier: string;
proxyIdentifier: string;
proxyIdentifierSid: string;
dateDeleted: Date;
dateCreated: Date;
dateUpdated: Date;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface ParticipantSolution {
serviceSid: string;
sessionSid: string;
}
export interface ParticipantListInstance {
_version: V1;
_solution: ParticipantSolution;
_uri: string;
(sid: string): ParticipantContext;
get(sid: string): ParticipantContext;
/**
* Create a ParticipantInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ParticipantInstance
*/
create(params: ParticipantListInstanceCreateOptions, callback?: (error: Error | null, item?: ParticipantInstance) => any): Promise<ParticipantInstance>;
/**
* Create a ParticipantInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ParticipantInstance with HTTP metadata
*/
createWithHttpInfo(params: ParticipantListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<ParticipantInstance>) => any): Promise<ApiResponse<ParticipantInstance>>;
/**
* Streams ParticipantInstance 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 { ParticipantListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: ParticipantInstance, done: (err?: Error) => void) => void): void;
each(params: ParticipantListInstanceEachOptions, callback?: (item: ParticipantInstance, done: (err?: Error) => void) => void): void;
/**
* Streams ParticipantInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* 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 { ParticipantListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: ParticipantInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: ParticipantListInstanceEachOptions, callback?: (item: ParticipantInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of ParticipantInstance 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: ParticipantPage) => any): Promise<ParticipantPage>;
/**
* Retrieve a single target page of ParticipantInstance records from the API with HTTP metadata.
*
* 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 with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<ParticipantPage>) => any): Promise<ApiResponse<ParticipantPage>>;
/**
* Lists ParticipantInstance 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 { ParticipantListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: ParticipantInstance[]) => any): Promise<ParticipantInstance[]>;
list(params: ParticipantListInstanceOptions, callback?: (error: Error | null, items: ParticipantInstance[]) => any): Promise<ParticipantInstance[]>;
/**
* Lists ParticipantInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ParticipantListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ParticipantInstance[]>) => any): Promise<ApiResponse<ParticipantInstance[]>>;
listWithHttpInfo(params: ParticipantListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<ParticipantInstance[]>) => any): Promise<ApiResponse<ParticipantInstance[]>>;
/**
* Retrieve a single page of ParticipantInstance 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 { ParticipantListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: ParticipantPage) => any): Promise<ParticipantPage>;
page(params: ParticipantListInstancePageOptions, callback?: (error: Error | null, items: ParticipantPage) => any): Promise<ParticipantPage>;
/**
* Retrieve a single page of ParticipantInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ParticipantListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ParticipantPage>) => any): Promise<ApiResponse<ParticipantPage>>;
pageWithHttpInfo(params: ParticipantListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<ParticipantPage>) => any): Promise<ApiResponse<ParticipantPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function ParticipantListInstance(version: V1, serviceSid: string, sessionSid: string): ParticipantListInstance;
export declare class ParticipantPage extends Page<V1, ParticipantPayload, ParticipantResource, ParticipantInstance> {
/**
* Initialize the ParticipantPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: ParticipantSolution);
/**
* Build an instance of ParticipantInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: ParticipantResource): ParticipantInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,408 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Proxy
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParticipantPage = exports.ParticipantInstance = exports.ParticipantContextImpl = void 0;
exports.ParticipantListInstance = ParticipantListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../../base/Page"));
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
const utility_1 = require("../../../../../base/utility");
const messageInteraction_1 = require("./participant/messageInteraction");
class ParticipantContextImpl {
constructor(_version, serviceSid, sessionSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sessionSid)) {
throw new Error("Parameter 'sessionSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sessionSid, sid };
this._uri = `/Services/${serviceSid}/Sessions/${sessionSid}/Participants/${sid}`;
}
get messageInteractions() {
this._messageInteractions =
this._messageInteractions ||
(0, messageInteraction_1.MessageInteractionListInstance)(this._version, this._solution.serviceSid, this._solution.sessionSid, this._solution.sid);
return this._messageInteractions;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new ParticipantInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sessionSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new ParticipantInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sessionSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ParticipantContextImpl = ParticipantContextImpl;
class ParticipantInstance {
constructor(_version, payload, serviceSid, sessionSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.sessionSid = payload.session_sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.identifier = payload.identifier;
this.proxyIdentifier = payload.proxy_identifier;
this.proxyIdentifierSid = payload.proxy_identifier_sid;
this.dateDeleted = deserialize.iso8601DateTime(payload.date_deleted);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid, sessionSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new ParticipantContextImpl(this._version, this._solution.serviceSid, this._solution.sessionSid, this._solution.sid);
return this._context;
}
/**
* Remove a ParticipantInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a ParticipantInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a ParticipantInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ParticipantInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a ParticipantInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ParticipantInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Access the messageInteractions.
*/
messageInteractions() {
return this._proxy.messageInteractions;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
sessionSid: this.sessionSid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
friendlyName: this.friendlyName,
identifier: this.identifier,
proxyIdentifier: this.proxyIdentifier,
proxyIdentifierSid: this.proxyIdentifierSid,
dateDeleted: this.dateDeleted,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ParticipantInstance = ParticipantInstance;
function ParticipantListInstance(version, serviceSid, sessionSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sessionSid)) {
throw new Error("Parameter 'sessionSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new ParticipantContextImpl(version, serviceSid, sessionSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, sessionSid };
instance._uri = `/Services/${serviceSid}/Sessions/${sessionSid}/Participants`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identifier"] === null || params["identifier"] === undefined) {
throw new Error("Required parameter \"params['identifier']\" missing.");
}
let data = {};
data["Identifier"] = params["identifier"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["proxyIdentifier"] !== undefined)
data["ProxyIdentifier"] = params["proxyIdentifier"];
if (params["proxyIdentifierSid"] !== undefined)
data["ProxyIdentifierSid"] = params["proxyIdentifierSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ParticipantInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sessionSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identifier"] === null || params["identifier"] === undefined) {
throw new Error("Required parameter \"params['identifier']\" missing.");
}
let data = {};
data["Identifier"] = params["identifier"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["proxyIdentifier"] !== undefined)
data["ProxyIdentifier"] = params["proxyIdentifier"];
if (params["proxyIdentifierSid"] !== undefined)
data["ProxyIdentifierSid"] = params["proxyIdentifierSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ParticipantInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sessionSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new ParticipantPage(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, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new ParticipantPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new ParticipantPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new ParticipantPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class ParticipantPage extends Page_1.default {
/**
* Initialize the ParticipantPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of ParticipantInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new ParticipantInstance(this._version, payload, this._solution.serviceSid, this._solution.sessionSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ParticipantPage = ParticipantPage;

View File

@@ -0,0 +1,418 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../../base/Page";
import Response from "../../../../../../http/response";
import V1 from "../../../../V1";
import { ApiResponse } from "../../../../../../base/ApiResponse";
/**
* Always empty for created Message Interactions.
*/
export type MessageInteractionResourceStatus = "accepted" | "answered" | "busy" | "canceled" | "completed" | "deleted" | "delivered" | "delivery-unknown" | "failed" | "in-progress" | "initiated" | "no-answer" | "queued" | "received" | "receiving" | "ringing" | "scheduled" | "sending" | "sent" | "undelivered" | "unknown";
/**
* The Type of Message Interaction. This value is always `message`.
*/
export type MessageInteractionType = "message" | "voice" | "unknown";
/**
* Options to pass to create a MessageInteractionInstance
*/
export interface MessageInteractionListInstanceCreateOptions {
/** The message to send to the participant */
body?: string;
/** Reserved. Not currently supported. */
mediaUrl?: Array<string>;
}
/**
* Options to pass to each
*/
export interface MessageInteractionListInstanceEachOptions {
/** 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: MessageInteractionInstance, 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 MessageInteractionListInstanceOptions {
/** 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 MessageInteractionListInstancePageOptions {
/** 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 MessageInteractionContext {
/**
* Fetch a MessageInteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance
*/
fetch(callback?: (error: Error | null, item?: MessageInteractionInstance) => any): Promise<MessageInteractionInstance>;
/**
* Fetch a MessageInteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInteractionInstance>) => any): Promise<ApiResponse<MessageInteractionInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface MessageInteractionContextSolution {
serviceSid: string;
sessionSid: string;
participantSid: string;
sid: string;
}
export declare class MessageInteractionContextImpl implements MessageInteractionContext {
protected _version: V1;
protected _solution: MessageInteractionContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, sessionSid: string, participantSid: string, sid: string);
fetch(callback?: (error: Error | null, item?: MessageInteractionInstance) => any): Promise<MessageInteractionInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInteractionInstance>) => any): Promise<ApiResponse<MessageInteractionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): MessageInteractionContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface MessageInteractionPayload extends TwilioResponsePayload {
interactions: MessageInteractionResource[];
}
interface MessageInteractionResource {
sid: string;
session_sid: string;
service_sid: string;
account_sid: string;
data: string;
type: MessageInteractionType;
participant_sid: string;
inbound_participant_sid: string;
inbound_resource_sid: string;
inbound_resource_status: MessageInteractionResourceStatus;
inbound_resource_type: string;
inbound_resource_url: string;
outbound_participant_sid: string;
outbound_resource_sid: string;
outbound_resource_status: MessageInteractionResourceStatus;
outbound_resource_type: string;
outbound_resource_url: string;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class MessageInteractionInstance {
protected _version: V1;
protected _solution: MessageInteractionContextSolution;
protected _context?: MessageInteractionContext;
constructor(_version: V1, payload: MessageInteractionResource, serviceSid: string, sessionSid: string, participantSid: string, sid?: string);
/**
* The unique string that we created to identify the MessageInteraction resource.
*/
sid: string;
/**
* The SID of the parent [Session](https://www.twilio.com/docs/proxy/api/session) resource.
*/
sessionSid: string;
/**
* The SID of the parent [Service](https://www.twilio.com/docs/proxy/api/service) resource.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MessageInteraction resource.
*/
accountSid: string;
/**
* A JSON string that includes the message body sent to the participant. (e.g. `{\"body\": \"hello\"}`)
*/
data: string;
type: MessageInteractionType;
/**
* The SID of the [Participant](https://www.twilio.com/docs/proxy/api/participant) resource.
*/
participantSid: string;
/**
* Always empty for created Message Interactions.
*/
inboundParticipantSid: string;
/**
* Always empty for created Message Interactions.
*/
inboundResourceSid: string;
inboundResourceStatus: MessageInteractionResourceStatus;
/**
* Always empty for created Message Interactions.
*/
inboundResourceType: string;
/**
* Always empty for created Message Interactions.
*/
inboundResourceUrl: string;
/**
* The SID of the outbound [Participant](https://www.twilio.com/docs/proxy/api/participant) resource.
*/
outboundParticipantSid: string;
/**
* The SID of the outbound [Message](https://www.twilio.com/docs/sms/api/message-resource) resource.
*/
outboundResourceSid: string;
outboundResourceStatus: MessageInteractionResourceStatus;
/**
* The outbound resource type. This value is always `Message`.
*/
outboundResourceType: string;
/**
* The URL of the Twilio message resource.
*/
outboundResourceUrl: string;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created.
*/
dateCreated: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated.
*/
dateUpdated: Date;
/**
* The absolute URL of the MessageInteraction resource.
*/
url: string;
private get _proxy();
/**
* Fetch a MessageInteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance
*/
fetch(callback?: (error: Error | null, item?: MessageInteractionInstance) => any): Promise<MessageInteractionInstance>;
/**
* Fetch a MessageInteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInteractionInstance>) => any): Promise<ApiResponse<MessageInteractionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
sessionSid: string;
serviceSid: string;
accountSid: string;
data: string;
type: MessageInteractionType;
participantSid: string;
inboundParticipantSid: string;
inboundResourceSid: string;
inboundResourceStatus: MessageInteractionResourceStatus;
inboundResourceType: string;
inboundResourceUrl: string;
outboundParticipantSid: string;
outboundResourceSid: string;
outboundResourceStatus: MessageInteractionResourceStatus;
outboundResourceType: string;
outboundResourceUrl: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface MessageInteractionSolution {
serviceSid: string;
sessionSid: string;
participantSid: string;
}
export interface MessageInteractionListInstance {
_version: V1;
_solution: MessageInteractionSolution;
_uri: string;
(sid: string): MessageInteractionContext;
get(sid: string): MessageInteractionContext;
/**
* Create a MessageInteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance
*/
create(callback?: (error: Error | null, item?: MessageInteractionInstance) => any): Promise<MessageInteractionInstance>;
/**
* Create a MessageInteractionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance
*/
create(params: MessageInteractionListInstanceCreateOptions, callback?: (error: Error | null, item?: MessageInteractionInstance) => any): Promise<MessageInteractionInstance>;
/**
* Create a MessageInteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInteractionInstance>) => any): Promise<ApiResponse<MessageInteractionInstance>>;
/**
* Create a MessageInteractionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance with HTTP metadata
*/
createWithHttpInfo(params: MessageInteractionListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<MessageInteractionInstance>) => any): Promise<ApiResponse<MessageInteractionInstance>>;
/**
* Streams MessageInteractionInstance 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 { MessageInteractionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: MessageInteractionInstance, done: (err?: Error) => void) => void): void;
each(params: MessageInteractionListInstanceEachOptions, callback?: (item: MessageInteractionInstance, done: (err?: Error) => void) => void): void;
/**
* Streams MessageInteractionInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* 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 { MessageInteractionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: MessageInteractionInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: MessageInteractionListInstanceEachOptions, callback?: (item: MessageInteractionInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of MessageInteractionInstance 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: MessageInteractionPage) => any): Promise<MessageInteractionPage>;
/**
* Retrieve a single target page of MessageInteractionInstance records from the API with HTTP metadata.
*
* 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 with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<MessageInteractionPage>) => any): Promise<ApiResponse<MessageInteractionPage>>;
/**
* Lists MessageInteractionInstance 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 { MessageInteractionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: MessageInteractionInstance[]) => any): Promise<MessageInteractionInstance[]>;
list(params: MessageInteractionListInstanceOptions, callback?: (error: Error | null, items: MessageInteractionInstance[]) => any): Promise<MessageInteractionInstance[]>;
/**
* Lists MessageInteractionInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { MessageInteractionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MessageInteractionInstance[]>) => any): Promise<ApiResponse<MessageInteractionInstance[]>>;
listWithHttpInfo(params: MessageInteractionListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<MessageInteractionInstance[]>) => any): Promise<ApiResponse<MessageInteractionInstance[]>>;
/**
* Retrieve a single page of MessageInteractionInstance 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 { MessageInteractionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: MessageInteractionPage) => any): Promise<MessageInteractionPage>;
page(params: MessageInteractionListInstancePageOptions, callback?: (error: Error | null, items: MessageInteractionPage) => any): Promise<MessageInteractionPage>;
/**
* Retrieve a single page of MessageInteractionInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { MessageInteractionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MessageInteractionPage>) => any): Promise<ApiResponse<MessageInteractionPage>>;
pageWithHttpInfo(params: MessageInteractionListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<MessageInteractionPage>) => any): Promise<ApiResponse<MessageInteractionPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function MessageInteractionListInstance(version: V1, serviceSid: string, sessionSid: string, participantSid: string): MessageInteractionListInstance;
export declare class MessageInteractionPage extends Page<V1, MessageInteractionPayload, MessageInteractionResource, MessageInteractionInstance> {
/**
* Initialize the MessageInteractionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: MessageInteractionSolution);
/**
* Build an instance of MessageInteractionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: MessageInteractionResource): MessageInteractionInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,371 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Proxy
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageInteractionPage = exports.MessageInteractionInstance = exports.MessageInteractionContextImpl = void 0;
exports.MessageInteractionListInstance = MessageInteractionListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../../../base/Page"));
const deserialize = require("../../../../../../base/deserialize");
const serialize = require("../../../../../../base/serialize");
const utility_1 = require("../../../../../../base/utility");
class MessageInteractionContextImpl {
constructor(_version, serviceSid, sessionSid, participantSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sessionSid)) {
throw new Error("Parameter 'sessionSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(participantSid)) {
throw new Error("Parameter 'participantSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sessionSid, participantSid, sid };
this._uri = `/Services/${serviceSid}/Sessions/${sessionSid}/Participants/${participantSid}/MessageInteractions/${sid}`;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new MessageInteractionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sessionSid, instance._solution.participantSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new MessageInteractionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sessionSid, instance._solution.participantSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessageInteractionContextImpl = MessageInteractionContextImpl;
class MessageInteractionInstance {
constructor(_version, payload, serviceSid, sessionSid, participantSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.sessionSid = payload.session_sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.data = payload.data;
this.type = payload.type;
this.participantSid = payload.participant_sid;
this.inboundParticipantSid = payload.inbound_participant_sid;
this.inboundResourceSid = payload.inbound_resource_sid;
this.inboundResourceStatus = payload.inbound_resource_status;
this.inboundResourceType = payload.inbound_resource_type;
this.inboundResourceUrl = payload.inbound_resource_url;
this.outboundParticipantSid = payload.outbound_participant_sid;
this.outboundResourceSid = payload.outbound_resource_sid;
this.outboundResourceStatus = payload.outbound_resource_status;
this.outboundResourceType = payload.outbound_resource_type;
this.outboundResourceUrl = payload.outbound_resource_url;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = {
serviceSid,
sessionSid,
participantSid,
sid: sid || this.sid,
};
}
get _proxy() {
this._context =
this._context ||
new MessageInteractionContextImpl(this._version, this._solution.serviceSid, this._solution.sessionSid, this._solution.participantSid, this._solution.sid);
return this._context;
}
/**
* Fetch a MessageInteractionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a MessageInteractionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInteractionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
sessionSid: this.sessionSid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
data: this.data,
type: this.type,
participantSid: this.participantSid,
inboundParticipantSid: this.inboundParticipantSid,
inboundResourceSid: this.inboundResourceSid,
inboundResourceStatus: this.inboundResourceStatus,
inboundResourceType: this.inboundResourceType,
inboundResourceUrl: this.inboundResourceUrl,
outboundParticipantSid: this.outboundParticipantSid,
outboundResourceSid: this.outboundResourceSid,
outboundResourceStatus: this.outboundResourceStatus,
outboundResourceType: this.outboundResourceType,
outboundResourceUrl: this.outboundResourceUrl,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessageInteractionInstance = MessageInteractionInstance;
function MessageInteractionListInstance(version, serviceSid, sessionSid, participantSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sessionSid)) {
throw new Error("Parameter 'sessionSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(participantSid)) {
throw new Error("Parameter 'participantSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new MessageInteractionContextImpl(version, serviceSid, sessionSid, participantSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, sessionSid, participantSid };
instance._uri = `/Services/${serviceSid}/Sessions/${sessionSid}/Participants/${participantSid}/MessageInteractions`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["body"] !== undefined)
data["Body"] = params["body"];
if (params["mediaUrl"] !== undefined)
data["MediaUrl"] = serialize.map(params["mediaUrl"], (e) => e);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new MessageInteractionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sessionSid, instance._solution.participantSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["body"] !== undefined)
data["Body"] = params["body"];
if (params["mediaUrl"] !== undefined)
data["MediaUrl"] = serialize.map(params["mediaUrl"], (e) => e);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new MessageInteractionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sessionSid, instance._solution.participantSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new MessageInteractionPage(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, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new MessageInteractionPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
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 = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new MessageInteractionPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new MessageInteractionPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class MessageInteractionPage extends Page_1.default {
/**
* Initialize the MessageInteractionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of MessageInteractionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new MessageInteractionInstance(this._version, payload, this._solution.serviceSid, this._solution.sessionSid, this._solution.participantSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessageInteractionPage = MessageInteractionPage;