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

20
node_modules/twilio/lib/rest/chat/V1.d.ts generated vendored Normal file
View File

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

42
node_modules/twilio/lib/rest/chat/V1.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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 credential_1 = require("./v1/credential");
const service_1 = require("./v1/service");
class V1 extends Version_1.default {
/**
* Initialize the V1 version of Chat
*
* @param domain - The Twilio (Twilio.Chat) domain
*/
constructor(domain) {
super(domain, "v1");
}
/** Getter for credentials resource */
get credentials() {
this._credentials = this._credentials || (0, credential_1.CredentialListInstance)(this);
return this._credentials;
}
/** Getter for services resource */
get services() {
this._services = this._services || (0, service_1.ServiceListInstance)(this);
return this._services;
}
}
exports.default = V1;

20
node_modules/twilio/lib/rest/chat/V2.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import ChatBase from "../ChatBase";
import Version from "../../base/Version";
import { CredentialListInstance } from "./v2/credential";
import { ServiceListInstance } from "./v2/service";
export default class V2 extends Version {
/**
* Initialize the V2 version of Chat
*
* @param domain - The Twilio (Twilio.Chat) domain
*/
constructor(domain: ChatBase);
/** credentials - { Twilio.Chat.V2.CredentialListInstance } resource */
protected _credentials?: CredentialListInstance;
/** services - { Twilio.Chat.V2.ServiceListInstance } resource */
protected _services?: ServiceListInstance;
/** Getter for credentials resource */
get credentials(): CredentialListInstance;
/** Getter for services resource */
get services(): ServiceListInstance;
}

42
node_modules/twilio/lib/rest/chat/V2.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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 credential_1 = require("./v2/credential");
const service_1 = require("./v2/service");
class V2 extends Version_1.default {
/**
* Initialize the V2 version of Chat
*
* @param domain - The Twilio (Twilio.Chat) domain
*/
constructor(domain) {
super(domain, "v2");
}
/** Getter for credentials resource */
get credentials() {
this._credentials = this._credentials || (0, credential_1.CredentialListInstance)(this);
return this._credentials;
}
/** Getter for services resource */
get services() {
this._services = this._services || (0, service_1.ServiceListInstance)(this);
return this._services;
}
}
exports.default = V2;

15
node_modules/twilio/lib/rest/chat/V3.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import ChatBase from "../ChatBase";
import Version from "../../base/Version";
import { ChannelListInstance } from "./v3/channel";
export default class V3 extends Version {
/**
* Initialize the V3 version of Chat
*
* @param domain - The Twilio (Twilio.Chat) domain
*/
constructor(domain: ChatBase);
/** channels - { Twilio.Chat.V3.ChannelListInstance } resource */
protected _channels?: ChannelListInstance;
/** Getter for channels resource */
get channels(): ChannelListInstance;
}

36
node_modules/twilio/lib/rest/chat/V3.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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 channel_1 = require("./v3/channel");
class V3 extends Version_1.default {
/**
* Initialize the V3 version of Chat
*
* @param domain - The Twilio (Twilio.Chat) domain
*/
constructor(domain) {
super(domain, "v3");
}
/** Getter for channels resource */
get channels() {
this._channels = this._channels || (0, channel_1.ChannelListInstance)(this);
return this._channels;
}
}
exports.default = V3;

457
node_modules/twilio/lib/rest/chat/v1/credential.d.ts generated vendored Normal file
View File

@@ -0,0 +1,457 @@
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 type of push-notification service the credential is for. Can be: `gcm`, `fcm`, or `apn`.
*/
export type CredentialPushService = "gcm" | "apn" | "fcm";
/**
* Options to pass to update a CredentialInstance
*/
export interface CredentialContextUpdateOptions {
/** A descriptive string that you create to describe the resource. It can be up to 64 characters long. */
friendlyName?: string;
/** [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A== -----END CERTIFICATE-----` */
certificate?: string;
/** [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR. -----END RSA PRIVATE KEY-----` */
privateKey?: string;
/** [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. */
sandbox?: boolean;
/** [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. */
apiKey?: string;
/** [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. */
secret?: string;
}
/**
* Options to pass to create a CredentialInstance
*/
export interface CredentialListInstanceCreateOptions {
/** */
type: CredentialPushService;
/** A descriptive string that you create to describe the new resource. It can be up to 64 characters long. */
friendlyName?: string;
/** [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A== -----END CERTIFICATE-----` */
certificate?: string;
/** [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR. -----END RSA PRIVATE KEY-----` */
privateKey?: string;
/** [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. */
sandbox?: boolean;
/** [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. */
apiKey?: string;
/** [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. */
secret?: string;
}
/**
* Options to pass to each
*/
export interface CredentialListInstanceEachOptions {
/** 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: CredentialInstance, 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 CredentialListInstanceOptions {
/** 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 CredentialListInstancePageOptions {
/** 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 CredentialContext {
/**
* Remove a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a CredentialInstance 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 CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
fetch(callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Fetch a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Update a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
update(callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Update a CredentialInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
update(params: CredentialContextUpdateOptions, callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Update a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Update a CredentialInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
updateWithHttpInfo(params: CredentialContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface CredentialContextSolution {
sid: string;
}
export declare class CredentialContextImpl implements CredentialContext {
protected _version: V1;
protected _solution: CredentialContextSolution;
protected _uri: string;
constructor(_version: V1, 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?: CredentialInstance) => any): Promise<CredentialInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
update(params?: CredentialContextUpdateOptions | ((error: Error | null, item?: CredentialInstance) => any), callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
updateWithHttpInfo(params?: CredentialContextUpdateOptions | ((error: Error | null, item?: ApiResponse<CredentialInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): CredentialContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface CredentialPayload extends TwilioResponsePayload {
credentials: CredentialResource[];
}
interface CredentialResource {
sid: string;
account_sid: string;
friendly_name: string;
type: CredentialPushService;
sandbox: string;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class CredentialInstance {
protected _version: V1;
protected _solution: CredentialContextSolution;
protected _context?: CredentialContext;
constructor(_version: V1, payload: CredentialResource, sid?: string);
/**
* The unique string that we created to identify the Credential resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Credential resource.
*/
accountSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
type: CredentialPushService;
/**
* [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
*/
sandbox: string;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The absolute URL of the Credential resource.
*/
url: string;
private get _proxy();
/**
* Remove a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a CredentialInstance 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 CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
fetch(callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Fetch a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Update a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
update(callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Update a CredentialInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
update(params: CredentialContextUpdateOptions, callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Update a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Update a CredentialInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
updateWithHttpInfo(params: CredentialContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
friendlyName: string;
type: CredentialPushService;
sandbox: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface CredentialSolution {
}
export interface CredentialListInstance {
_version: V1;
_solution: CredentialSolution;
_uri: string;
(sid: string): CredentialContext;
get(sid: string): CredentialContext;
/**
* Create a CredentialInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
create(params: CredentialListInstanceCreateOptions, callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Create a CredentialInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
createWithHttpInfo(params: CredentialListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Streams CredentialInstance 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 { CredentialListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: CredentialInstance, done: (err?: Error) => void) => void): void;
each(params: CredentialListInstanceEachOptions, callback?: (item: CredentialInstance, done: (err?: Error) => void) => void): void;
/**
* Streams CredentialInstance 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 { CredentialListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: CredentialInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: CredentialListInstanceEachOptions, callback?: (item: CredentialInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of CredentialInstance 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: CredentialPage) => any): Promise<CredentialPage>;
/**
* Retrieve a single target page of CredentialInstance 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<CredentialPage>) => any): Promise<ApiResponse<CredentialPage>>;
/**
* Lists CredentialInstance 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 { CredentialListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: CredentialInstance[]) => any): Promise<CredentialInstance[]>;
list(params: CredentialListInstanceOptions, callback?: (error: Error | null, items: CredentialInstance[]) => any): Promise<CredentialInstance[]>;
/**
* Lists CredentialInstance 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 { CredentialListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<CredentialInstance[]>) => any): Promise<ApiResponse<CredentialInstance[]>>;
listWithHttpInfo(params: CredentialListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<CredentialInstance[]>) => any): Promise<ApiResponse<CredentialInstance[]>>;
/**
* Retrieve a single page of CredentialInstance 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 { CredentialListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: CredentialPage) => any): Promise<CredentialPage>;
page(params: CredentialListInstancePageOptions, callback?: (error: Error | null, items: CredentialPage) => any): Promise<CredentialPage>;
/**
* Retrieve a single page of CredentialInstance 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 { CredentialListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<CredentialPage>) => any): Promise<ApiResponse<CredentialPage>>;
pageWithHttpInfo(params: CredentialListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<CredentialPage>) => any): Promise<ApiResponse<CredentialPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function CredentialListInstance(version: V1): CredentialListInstance;
export declare class CredentialPage extends Page<V1, CredentialPayload, CredentialResource, CredentialInstance> {
/**
* Initialize the CredentialPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: CredentialSolution);
/**
* Build an instance of CredentialInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: CredentialResource): CredentialInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

467
node_modules/twilio/lib/rest/chat/v1/credential.js generated vendored Normal file
View File

@@ -0,0 +1,467 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.CredentialPage = exports.CredentialInstance = exports.CredentialContextImpl = void 0;
exports.CredentialListInstance = CredentialListInstance;
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 CredentialContextImpl {
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 = `/Credentials/${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 CredentialInstance(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 CredentialInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["certificate"] !== undefined)
data["Certificate"] = params["certificate"];
if (params["privateKey"] !== undefined)
data["PrivateKey"] = params["privateKey"];
if (params["sandbox"] !== undefined)
data["Sandbox"] = serialize.bool(params["sandbox"]);
if (params["apiKey"] !== undefined)
data["ApiKey"] = params["apiKey"];
if (params["secret"] !== undefined)
data["Secret"] = params["secret"];
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 CredentialInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["certificate"] !== undefined)
data["Certificate"] = params["certificate"];
if (params["privateKey"] !== undefined)
data["PrivateKey"] = params["privateKey"];
if (params["sandbox"] !== undefined)
data["Sandbox"] = serialize.bool(params["sandbox"]);
if (params["apiKey"] !== undefined)
data["ApiKey"] = params["apiKey"];
if (params["secret"] !== undefined)
data["Secret"] = params["secret"];
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 CredentialInstance(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.CredentialContextImpl = CredentialContextImpl;
class CredentialInstance {
constructor(_version, payload, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.type = payload.type;
this.sandbox = payload.sandbox;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = { sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new CredentialContextImpl(this._version, this._solution.sid);
return this._context;
}
/**
* Remove a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a CredentialInstance 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 CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance 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,
friendlyName: this.friendlyName,
type: this.type,
sandbox: this.sandbox,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.CredentialInstance = CredentialInstance;
function CredentialListInstance(version) {
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new CredentialContextImpl(version, sid);
};
instance._version = version;
instance._solution = {};
instance._uri = `/Credentials`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
let data = {};
data["Type"] = params["type"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["certificate"] !== undefined)
data["Certificate"] = params["certificate"];
if (params["privateKey"] !== undefined)
data["PrivateKey"] = params["privateKey"];
if (params["sandbox"] !== undefined)
data["Sandbox"] = serialize.bool(params["sandbox"]);
if (params["apiKey"] !== undefined)
data["ApiKey"] = params["apiKey"];
if (params["secret"] !== undefined)
data["Secret"] = params["secret"];
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 CredentialInstance(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["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
let data = {};
data["Type"] = params["type"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["certificate"] !== undefined)
data["Certificate"] = params["certificate"];
if (params["privateKey"] !== undefined)
data["PrivateKey"] = params["privateKey"];
if (params["sandbox"] !== undefined)
data["Sandbox"] = serialize.bool(params["sandbox"]);
if (params["apiKey"] !== undefined)
data["ApiKey"] = params["apiKey"];
if (params["secret"] !== undefined)
data["Secret"] = params["secret"];
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 CredentialInstance(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 CredentialPage(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 CredentialPage(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 CredentialPage(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 CredentialPage(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 CredentialPage extends Page_1.default {
/**
* Initialize the CredentialPage
*
* @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 CredentialInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new CredentialInstance(this._version, payload);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.CredentialPage = CredentialPage;

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

@@ -0,0 +1,642 @@
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 { ChannelListInstance } from "./service/channel";
import { RoleListInstance } from "./service/role";
import { UserListInstance } from "./service/user";
/**
* Options to pass to update a ServiceInstance
*/
export interface ServiceContextUpdateOptions {
/** A descriptive string that you create to describe the resource. It can be up to 64 characters long. */
friendlyName?: string;
/** The service role assigned to users when they are added to the service. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details. */
defaultServiceRoleSid?: string;
/** The channel role assigned to users when they are added to a channel. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details. */
defaultChannelRoleSid?: string;
/** The channel role assigned to a channel creator when they join a new channel. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details. */
defaultChannelCreatorRoleSid?: string;
/** Whether to enable the [Message Consumption Horizon](https://www.twilio.com/docs/chat/consumption-horizon) feature. The default is `true`. */
readStatusEnabled?: boolean;
/** Whether to enable the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) for this Service instance. The default is `false`. */
reachabilityEnabled?: boolean;
/** How long in seconds after a `started typing` event until clients should assume that user is no longer typing, even if no `ended typing` message was received. The default is 5 seconds. */
typingIndicatorTimeout?: number;
/** DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints. */
consumptionReportInterval?: number;
/** Whether to send a notification when a new message is added to a channel. Can be: `true` or `false` and the default is `false`. */
"notifications.newMessage.enabled"?: boolean;
/** The template to use to create the notification text displayed when a new message is added to a channel and `notifications.new_message.enabled` is `true`. */
"notifications.newMessage.template"?: string;
/** Whether to send a notification when a member is added to a channel. Can be: `true` or `false` and the default is `false`. */
"notifications.addedToChannel.enabled"?: boolean;
/** The template to use to create the notification text displayed when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`. */
"notifications.addedToChannel.template"?: string;
/** Whether to send a notification to a user when they are removed from a channel. Can be: `true` or `false` and the default is `false`. */
"notifications.removedFromChannel.enabled"?: boolean;
/** The template to use to create the notification text displayed to a user when they are removed from a channel and `notifications.removed_from_channel.enabled` is `true`. */
"notifications.removedFromChannel.template"?: string;
/** Whether to send a notification when a user is invited to a channel. Can be: `true` or `false` and the default is `false`. */
"notifications.invitedToChannel.enabled"?: boolean;
/** The template to use to create the notification text displayed when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`. */
"notifications.invitedToChannel.template"?: string;
/** The URL for pre-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/api/chat/webhooks) for more details. */
preWebhookUrl?: string;
/** The URL for post-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/api/chat/webhooks) for more details. */
postWebhookUrl?: string;
/** The HTTP method to use for calls to the `pre_webhook_url` and `post_webhook_url` webhooks. Can be: `POST` or `GET` and the default is `POST`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. */
webhookMethod?: string;
/** The list of WebHook events that are enabled for this Service instance. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. */
webhookFilters?: Array<string>;
/** The URL of the webhook to call in response to the `on_message_send` event using the `webhooks.on_message_send.method` HTTP method. */
"webhooks.onMessageSend.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_message_send.url`. */
"webhooks.onMessageSend.method"?: string;
/** The URL of the webhook to call in response to the `on_message_update` event using the `webhooks.on_message_update.method` HTTP method. */
"webhooks.onMessageUpdate.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_message_update.url`. */
"webhooks.onMessageUpdate.method"?: string;
/** The URL of the webhook to call in response to the `on_message_remove` event using the `webhooks.on_message_remove.method` HTTP method. */
"webhooks.onMessageRemove.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_message_remove.url`. */
"webhooks.onMessageRemove.method"?: string;
/** The URL of the webhook to call in response to the `on_channel_add` event using the `webhooks.on_channel_add.method` HTTP method. */
"webhooks.onChannelAdd.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_channel_add.url`. */
"webhooks.onChannelAdd.method"?: string;
/** The URL of the webhook to call in response to the `on_channel_destroy` event using the `webhooks.on_channel_destroy.method` HTTP method. */
"webhooks.onChannelDestroy.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_channel_destroy.url`. */
"webhooks.onChannelDestroy.method"?: string;
/** The URL of the webhook to call in response to the `on_channel_update` event using the `webhooks.on_channel_update.method` HTTP method. */
"webhooks.onChannelUpdate.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_channel_update.url`. */
"webhooks.onChannelUpdate.method"?: string;
/** The URL of the webhook to call in response to the `on_member_add` event using the `webhooks.on_member_add.method` HTTP method. */
"webhooks.onMemberAdd.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_member_add.url`. */
"webhooks.onMemberAdd.method"?: string;
/** The URL of the webhook to call in response to the `on_member_remove` event using the `webhooks.on_member_remove.method` HTTP method. */
"webhooks.onMemberRemove.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_member_remove.url`. */
"webhooks.onMemberRemove.method"?: string;
/** The URL of the webhook to call in response to the `on_message_sent` event using the `webhooks.on_message_sent.method` HTTP method. */
"webhooks.onMessageSent.url"?: string;
/** The URL of the webhook to call in response to the `on_message_sent` event`. */
"webhooks.onMessageSent.method"?: string;
/** The URL of the webhook to call in response to the `on_message_updated` event using the `webhooks.on_message_updated.method` HTTP method. */
"webhooks.onMessageUpdated.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_message_updated.url`. */
"webhooks.onMessageUpdated.method"?: string;
/** The URL of the webhook to call in response to the `on_message_removed` event using the `webhooks.on_message_removed.method` HTTP method. */
"webhooks.onMessageRemoved.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_message_removed.url`. */
"webhooks.onMessageRemoved.method"?: string;
/** The URL of the webhook to call in response to the `on_channel_added` event using the `webhooks.on_channel_added.method` HTTP method. */
"webhooks.onChannelAdded.url"?: string;
/** The URL of the webhook to call in response to the `on_channel_added` event`. */
"webhooks.onChannelAdded.method"?: string;
/** The URL of the webhook to call in response to the `on_channel_added` event using the `webhooks.on_channel_destroyed.method` HTTP method. */
"webhooks.onChannelDestroyed.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_channel_destroyed.url`. */
"webhooks.onChannelDestroyed.method"?: string;
/** The URL of the webhook to call in response to the `on_channel_updated` event using the `webhooks.on_channel_updated.method` HTTP method. */
"webhooks.onChannelUpdated.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_channel_updated.url`. */
"webhooks.onChannelUpdated.method"?: string;
/** The URL of the webhook to call in response to the `on_channel_updated` event using the `webhooks.on_channel_updated.method` HTTP method. */
"webhooks.onMemberAdded.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_channel_updated.url`. */
"webhooks.onMemberAdded.method"?: string;
/** The URL of the webhook to call in response to the `on_member_removed` event using the `webhooks.on_member_removed.method` HTTP method. */
"webhooks.onMemberRemoved.url"?: string;
/** The HTTP method to use when calling the `webhooks.on_member_removed.url`. */
"webhooks.onMemberRemoved.method"?: string;
/** The maximum number of Members that can be added to Channels within this Service. Can be up to 1,000. */
"limits.channelMembers"?: number;
/** The maximum number of Channels Users can be a Member of within this Service. Can be up to 1,000. */
"limits.userChannels"?: number;
}
/**
* Options to pass to create a ServiceInstance
*/
export interface ServiceListInstanceCreateOptions {
/** A descriptive string that you create to describe the resource. It can be up to 64 characters long. */
friendlyName: 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 100. */
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 100. */
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 100. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface ServiceContext {
channels: ChannelListInstance;
roles: RoleListInstance;
users: UserListInstance;
/**
* 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 _channels?: ChannelListInstance;
protected _roles?: RoleListInstance;
protected _users?: UserListInstance;
constructor(_version: V1, sid: string);
get channels(): ChannelListInstance;
get roles(): RoleListInstance;
get users(): UserListInstance;
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;
account_sid: string;
friendly_name: string;
date_created: Date;
date_updated: Date;
default_service_role_sid: string;
default_channel_role_sid: string;
default_channel_creator_role_sid: string;
read_status_enabled: boolean;
reachability_enabled: boolean;
typing_indicator_timeout: number;
consumption_report_interval: number;
limits: any;
webhooks: any;
pre_webhook_url: string;
post_webhook_url: string;
webhook_method: string;
webhook_filters: Array<string>;
notifications: any;
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;
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Service resource.
*/
accountSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The service role assigned to users when they are added to the service. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details.
*/
defaultServiceRoleSid: string;
/**
* The channel role assigned to users when they are added to a channel. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details.
*/
defaultChannelRoleSid: string;
/**
* The channel role assigned to a channel creator when they join a new channel. See the [Roles endpoint](https://www.twilio.com/docs/chat/api/roles) for more details.
*/
defaultChannelCreatorRoleSid: string;
/**
* Whether the [Message Consumption Horizon](https://www.twilio.com/docs/chat/consumption-horizon) feature is enabled. The default is `true`.
*/
readStatusEnabled: boolean;
/**
* Whether the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) is enabled for this Service instance. The default is `false`.
*/
reachabilityEnabled: boolean;
/**
* How long in seconds after a `started typing` event until clients should assume that user is no longer typing, even if no `ended typing` message was received. The default is 5 seconds.
*/
typingIndicatorTimeout: number;
/**
* DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints.
*/
consumptionReportInterval: number;
/**
* An object that describes the limits of the service instance. The `limits` object contains `channel_members` to describe the members/channel limit and `user_channels` to describe the channels/user limit. `channel_members` can be 1,000 or less, with a default of 250. `user_channels` can be 1,000 or less, with a default value of 100.
*/
limits: any;
/**
* An object that contains information about the webhooks configured for this service.
*/
webhooks: any;
/**
* The URL for pre-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/api/chat/webhooks) for more details.
*/
preWebhookUrl: string;
/**
* The URL for post-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/api/chat/webhooks) for more details.
*/
postWebhookUrl: string;
/**
* The HTTP method to use for calls to the `pre_webhook_url` and `post_webhook_url` webhooks. Can be: `POST` or `GET` and the default is `POST`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
*/
webhookMethod: string;
/**
* The list of WebHook events that are enabled for this Service instance. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
*/
webhookFilters: Array<string>;
/**
* The notification configuration for the Service instance. See [Push Notification Configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more information.
*/
notifications: any;
/**
* The absolute URL of the Service resource.
*/
url: string;
/**
* The absolute URLs of the Service\'s [Channels](https://www.twilio.com/docs/chat/api/channels), [Roles](https://www.twilio.com/docs/chat/api/roles), and [Users](https://www.twilio.com/docs/chat/api/users).
*/
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 channels.
*/
channels(): ChannelListInstance;
/**
* Access the roles.
*/
roles(): RoleListInstance;
/**
* Access the users.
*/
users(): UserListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
friendlyName: string;
dateCreated: Date;
dateUpdated: Date;
defaultServiceRoleSid: string;
defaultChannelRoleSid: string;
defaultChannelCreatorRoleSid: string;
readStatusEnabled: boolean;
reachabilityEnabled: boolean;
typingIndicatorTimeout: number;
consumptionReportInterval: number;
limits: any;
webhooks: any;
preWebhookUrl: string;
postWebhookUrl: string;
webhookMethod: string;
webhookFilters: string[];
notifications: any;
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 {};

764
node_modules/twilio/lib/rest/chat/v1/service.js generated vendored Normal file
View File

@@ -0,0 +1,764 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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 channel_1 = require("./service/channel");
const role_1 = require("./service/role");
const user_1 = require("./service/user");
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 channels() {
this._channels =
this._channels || (0, channel_1.ChannelListInstance)(this._version, this._solution.sid);
return this._channels;
}
get roles() {
this._roles =
this._roles || (0, role_1.RoleListInstance)(this._version, this._solution.sid);
return this._roles;
}
get users() {
this._users =
this._users || (0, user_1.UserListInstance)(this._version, this._solution.sid);
return this._users;
}
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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["defaultServiceRoleSid"] !== undefined)
data["DefaultServiceRoleSid"] = params["defaultServiceRoleSid"];
if (params["defaultChannelRoleSid"] !== undefined)
data["DefaultChannelRoleSid"] = params["defaultChannelRoleSid"];
if (params["defaultChannelCreatorRoleSid"] !== undefined)
data["DefaultChannelCreatorRoleSid"] =
params["defaultChannelCreatorRoleSid"];
if (params["readStatusEnabled"] !== undefined)
data["ReadStatusEnabled"] = serialize.bool(params["readStatusEnabled"]);
if (params["reachabilityEnabled"] !== undefined)
data["ReachabilityEnabled"] = serialize.bool(params["reachabilityEnabled"]);
if (params["typingIndicatorTimeout"] !== undefined)
data["TypingIndicatorTimeout"] = params["typingIndicatorTimeout"];
if (params["consumptionReportInterval"] !== undefined)
data["ConsumptionReportInterval"] = params["consumptionReportInterval"];
if (params["notifications.newMessage.enabled"] !== undefined)
data["Notifications.NewMessage.Enabled"] = serialize.bool(params["notifications.newMessage.enabled"]);
if (params["notifications.newMessage.template"] !== undefined)
data["Notifications.NewMessage.Template"] =
params["notifications.newMessage.template"];
if (params["notifications.addedToChannel.enabled"] !== undefined)
data["Notifications.AddedToChannel.Enabled"] = serialize.bool(params["notifications.addedToChannel.enabled"]);
if (params["notifications.addedToChannel.template"] !== undefined)
data["Notifications.AddedToChannel.Template"] =
params["notifications.addedToChannel.template"];
if (params["notifications.removedFromChannel.enabled"] !== undefined)
data["Notifications.RemovedFromChannel.Enabled"] = serialize.bool(params["notifications.removedFromChannel.enabled"]);
if (params["notifications.removedFromChannel.template"] !== undefined)
data["Notifications.RemovedFromChannel.Template"] =
params["notifications.removedFromChannel.template"];
if (params["notifications.invitedToChannel.enabled"] !== undefined)
data["Notifications.InvitedToChannel.Enabled"] = serialize.bool(params["notifications.invitedToChannel.enabled"]);
if (params["notifications.invitedToChannel.template"] !== undefined)
data["Notifications.InvitedToChannel.Template"] =
params["notifications.invitedToChannel.template"];
if (params["preWebhookUrl"] !== undefined)
data["PreWebhookUrl"] = params["preWebhookUrl"];
if (params["postWebhookUrl"] !== undefined)
data["PostWebhookUrl"] = params["postWebhookUrl"];
if (params["webhookMethod"] !== undefined)
data["WebhookMethod"] = params["webhookMethod"];
if (params["webhookFilters"] !== undefined)
data["WebhookFilters"] = serialize.map(params["webhookFilters"], (e) => e);
if (params["webhooks.onMessageSend.url"] !== undefined)
data["Webhooks.OnMessageSend.Url"] = params["webhooks.onMessageSend.url"];
if (params["webhooks.onMessageSend.method"] !== undefined)
data["Webhooks.OnMessageSend.Method"] =
params["webhooks.onMessageSend.method"];
if (params["webhooks.onMessageUpdate.url"] !== undefined)
data["Webhooks.OnMessageUpdate.Url"] =
params["webhooks.onMessageUpdate.url"];
if (params["webhooks.onMessageUpdate.method"] !== undefined)
data["Webhooks.OnMessageUpdate.Method"] =
params["webhooks.onMessageUpdate.method"];
if (params["webhooks.onMessageRemove.url"] !== undefined)
data["Webhooks.OnMessageRemove.Url"] =
params["webhooks.onMessageRemove.url"];
if (params["webhooks.onMessageRemove.method"] !== undefined)
data["Webhooks.OnMessageRemove.Method"] =
params["webhooks.onMessageRemove.method"];
if (params["webhooks.onChannelAdd.url"] !== undefined)
data["Webhooks.OnChannelAdd.Url"] = params["webhooks.onChannelAdd.url"];
if (params["webhooks.onChannelAdd.method"] !== undefined)
data["Webhooks.OnChannelAdd.Method"] =
params["webhooks.onChannelAdd.method"];
if (params["webhooks.onChannelDestroy.url"] !== undefined)
data["Webhooks.OnChannelDestroy.Url"] =
params["webhooks.onChannelDestroy.url"];
if (params["webhooks.onChannelDestroy.method"] !== undefined)
data["Webhooks.OnChannelDestroy.Method"] =
params["webhooks.onChannelDestroy.method"];
if (params["webhooks.onChannelUpdate.url"] !== undefined)
data["Webhooks.OnChannelUpdate.Url"] =
params["webhooks.onChannelUpdate.url"];
if (params["webhooks.onChannelUpdate.method"] !== undefined)
data["Webhooks.OnChannelUpdate.Method"] =
params["webhooks.onChannelUpdate.method"];
if (params["webhooks.onMemberAdd.url"] !== undefined)
data["Webhooks.OnMemberAdd.Url"] = params["webhooks.onMemberAdd.url"];
if (params["webhooks.onMemberAdd.method"] !== undefined)
data["Webhooks.OnMemberAdd.Method"] =
params["webhooks.onMemberAdd.method"];
if (params["webhooks.onMemberRemove.url"] !== undefined)
data["Webhooks.OnMemberRemove.Url"] =
params["webhooks.onMemberRemove.url"];
if (params["webhooks.onMemberRemove.method"] !== undefined)
data["Webhooks.OnMemberRemove.Method"] =
params["webhooks.onMemberRemove.method"];
if (params["webhooks.onMessageSent.url"] !== undefined)
data["Webhooks.OnMessageSent.Url"] = params["webhooks.onMessageSent.url"];
if (params["webhooks.onMessageSent.method"] !== undefined)
data["Webhooks.OnMessageSent.Method"] =
params["webhooks.onMessageSent.method"];
if (params["webhooks.onMessageUpdated.url"] !== undefined)
data["Webhooks.OnMessageUpdated.Url"] =
params["webhooks.onMessageUpdated.url"];
if (params["webhooks.onMessageUpdated.method"] !== undefined)
data["Webhooks.OnMessageUpdated.Method"] =
params["webhooks.onMessageUpdated.method"];
if (params["webhooks.onMessageRemoved.url"] !== undefined)
data["Webhooks.OnMessageRemoved.Url"] =
params["webhooks.onMessageRemoved.url"];
if (params["webhooks.onMessageRemoved.method"] !== undefined)
data["Webhooks.OnMessageRemoved.Method"] =
params["webhooks.onMessageRemoved.method"];
if (params["webhooks.onChannelAdded.url"] !== undefined)
data["Webhooks.OnChannelAdded.Url"] =
params["webhooks.onChannelAdded.url"];
if (params["webhooks.onChannelAdded.method"] !== undefined)
data["Webhooks.OnChannelAdded.Method"] =
params["webhooks.onChannelAdded.method"];
if (params["webhooks.onChannelDestroyed.url"] !== undefined)
data["Webhooks.OnChannelDestroyed.Url"] =
params["webhooks.onChannelDestroyed.url"];
if (params["webhooks.onChannelDestroyed.method"] !== undefined)
data["Webhooks.OnChannelDestroyed.Method"] =
params["webhooks.onChannelDestroyed.method"];
if (params["webhooks.onChannelUpdated.url"] !== undefined)
data["Webhooks.OnChannelUpdated.Url"] =
params["webhooks.onChannelUpdated.url"];
if (params["webhooks.onChannelUpdated.method"] !== undefined)
data["Webhooks.OnChannelUpdated.Method"] =
params["webhooks.onChannelUpdated.method"];
if (params["webhooks.onMemberAdded.url"] !== undefined)
data["Webhooks.OnMemberAdded.Url"] = params["webhooks.onMemberAdded.url"];
if (params["webhooks.onMemberAdded.method"] !== undefined)
data["Webhooks.OnMemberAdded.Method"] =
params["webhooks.onMemberAdded.method"];
if (params["webhooks.onMemberRemoved.url"] !== undefined)
data["Webhooks.OnMemberRemoved.Url"] =
params["webhooks.onMemberRemoved.url"];
if (params["webhooks.onMemberRemoved.method"] !== undefined)
data["Webhooks.OnMemberRemoved.Method"] =
params["webhooks.onMemberRemoved.method"];
if (params["limits.channelMembers"] !== undefined)
data["Limits.ChannelMembers"] = params["limits.channelMembers"];
if (params["limits.userChannels"] !== undefined)
data["Limits.UserChannels"] = params["limits.userChannels"];
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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["defaultServiceRoleSid"] !== undefined)
data["DefaultServiceRoleSid"] = params["defaultServiceRoleSid"];
if (params["defaultChannelRoleSid"] !== undefined)
data["DefaultChannelRoleSid"] = params["defaultChannelRoleSid"];
if (params["defaultChannelCreatorRoleSid"] !== undefined)
data["DefaultChannelCreatorRoleSid"] =
params["defaultChannelCreatorRoleSid"];
if (params["readStatusEnabled"] !== undefined)
data["ReadStatusEnabled"] = serialize.bool(params["readStatusEnabled"]);
if (params["reachabilityEnabled"] !== undefined)
data["ReachabilityEnabled"] = serialize.bool(params["reachabilityEnabled"]);
if (params["typingIndicatorTimeout"] !== undefined)
data["TypingIndicatorTimeout"] = params["typingIndicatorTimeout"];
if (params["consumptionReportInterval"] !== undefined)
data["ConsumptionReportInterval"] = params["consumptionReportInterval"];
if (params["notifications.newMessage.enabled"] !== undefined)
data["Notifications.NewMessage.Enabled"] = serialize.bool(params["notifications.newMessage.enabled"]);
if (params["notifications.newMessage.template"] !== undefined)
data["Notifications.NewMessage.Template"] =
params["notifications.newMessage.template"];
if (params["notifications.addedToChannel.enabled"] !== undefined)
data["Notifications.AddedToChannel.Enabled"] = serialize.bool(params["notifications.addedToChannel.enabled"]);
if (params["notifications.addedToChannel.template"] !== undefined)
data["Notifications.AddedToChannel.Template"] =
params["notifications.addedToChannel.template"];
if (params["notifications.removedFromChannel.enabled"] !== undefined)
data["Notifications.RemovedFromChannel.Enabled"] = serialize.bool(params["notifications.removedFromChannel.enabled"]);
if (params["notifications.removedFromChannel.template"] !== undefined)
data["Notifications.RemovedFromChannel.Template"] =
params["notifications.removedFromChannel.template"];
if (params["notifications.invitedToChannel.enabled"] !== undefined)
data["Notifications.InvitedToChannel.Enabled"] = serialize.bool(params["notifications.invitedToChannel.enabled"]);
if (params["notifications.invitedToChannel.template"] !== undefined)
data["Notifications.InvitedToChannel.Template"] =
params["notifications.invitedToChannel.template"];
if (params["preWebhookUrl"] !== undefined)
data["PreWebhookUrl"] = params["preWebhookUrl"];
if (params["postWebhookUrl"] !== undefined)
data["PostWebhookUrl"] = params["postWebhookUrl"];
if (params["webhookMethod"] !== undefined)
data["WebhookMethod"] = params["webhookMethod"];
if (params["webhookFilters"] !== undefined)
data["WebhookFilters"] = serialize.map(params["webhookFilters"], (e) => e);
if (params["webhooks.onMessageSend.url"] !== undefined)
data["Webhooks.OnMessageSend.Url"] = params["webhooks.onMessageSend.url"];
if (params["webhooks.onMessageSend.method"] !== undefined)
data["Webhooks.OnMessageSend.Method"] =
params["webhooks.onMessageSend.method"];
if (params["webhooks.onMessageUpdate.url"] !== undefined)
data["Webhooks.OnMessageUpdate.Url"] =
params["webhooks.onMessageUpdate.url"];
if (params["webhooks.onMessageUpdate.method"] !== undefined)
data["Webhooks.OnMessageUpdate.Method"] =
params["webhooks.onMessageUpdate.method"];
if (params["webhooks.onMessageRemove.url"] !== undefined)
data["Webhooks.OnMessageRemove.Url"] =
params["webhooks.onMessageRemove.url"];
if (params["webhooks.onMessageRemove.method"] !== undefined)
data["Webhooks.OnMessageRemove.Method"] =
params["webhooks.onMessageRemove.method"];
if (params["webhooks.onChannelAdd.url"] !== undefined)
data["Webhooks.OnChannelAdd.Url"] = params["webhooks.onChannelAdd.url"];
if (params["webhooks.onChannelAdd.method"] !== undefined)
data["Webhooks.OnChannelAdd.Method"] =
params["webhooks.onChannelAdd.method"];
if (params["webhooks.onChannelDestroy.url"] !== undefined)
data["Webhooks.OnChannelDestroy.Url"] =
params["webhooks.onChannelDestroy.url"];
if (params["webhooks.onChannelDestroy.method"] !== undefined)
data["Webhooks.OnChannelDestroy.Method"] =
params["webhooks.onChannelDestroy.method"];
if (params["webhooks.onChannelUpdate.url"] !== undefined)
data["Webhooks.OnChannelUpdate.Url"] =
params["webhooks.onChannelUpdate.url"];
if (params["webhooks.onChannelUpdate.method"] !== undefined)
data["Webhooks.OnChannelUpdate.Method"] =
params["webhooks.onChannelUpdate.method"];
if (params["webhooks.onMemberAdd.url"] !== undefined)
data["Webhooks.OnMemberAdd.Url"] = params["webhooks.onMemberAdd.url"];
if (params["webhooks.onMemberAdd.method"] !== undefined)
data["Webhooks.OnMemberAdd.Method"] =
params["webhooks.onMemberAdd.method"];
if (params["webhooks.onMemberRemove.url"] !== undefined)
data["Webhooks.OnMemberRemove.Url"] =
params["webhooks.onMemberRemove.url"];
if (params["webhooks.onMemberRemove.method"] !== undefined)
data["Webhooks.OnMemberRemove.Method"] =
params["webhooks.onMemberRemove.method"];
if (params["webhooks.onMessageSent.url"] !== undefined)
data["Webhooks.OnMessageSent.Url"] = params["webhooks.onMessageSent.url"];
if (params["webhooks.onMessageSent.method"] !== undefined)
data["Webhooks.OnMessageSent.Method"] =
params["webhooks.onMessageSent.method"];
if (params["webhooks.onMessageUpdated.url"] !== undefined)
data["Webhooks.OnMessageUpdated.Url"] =
params["webhooks.onMessageUpdated.url"];
if (params["webhooks.onMessageUpdated.method"] !== undefined)
data["Webhooks.OnMessageUpdated.Method"] =
params["webhooks.onMessageUpdated.method"];
if (params["webhooks.onMessageRemoved.url"] !== undefined)
data["Webhooks.OnMessageRemoved.Url"] =
params["webhooks.onMessageRemoved.url"];
if (params["webhooks.onMessageRemoved.method"] !== undefined)
data["Webhooks.OnMessageRemoved.Method"] =
params["webhooks.onMessageRemoved.method"];
if (params["webhooks.onChannelAdded.url"] !== undefined)
data["Webhooks.OnChannelAdded.Url"] =
params["webhooks.onChannelAdded.url"];
if (params["webhooks.onChannelAdded.method"] !== undefined)
data["Webhooks.OnChannelAdded.Method"] =
params["webhooks.onChannelAdded.method"];
if (params["webhooks.onChannelDestroyed.url"] !== undefined)
data["Webhooks.OnChannelDestroyed.Url"] =
params["webhooks.onChannelDestroyed.url"];
if (params["webhooks.onChannelDestroyed.method"] !== undefined)
data["Webhooks.OnChannelDestroyed.Method"] =
params["webhooks.onChannelDestroyed.method"];
if (params["webhooks.onChannelUpdated.url"] !== undefined)
data["Webhooks.OnChannelUpdated.Url"] =
params["webhooks.onChannelUpdated.url"];
if (params["webhooks.onChannelUpdated.method"] !== undefined)
data["Webhooks.OnChannelUpdated.Method"] =
params["webhooks.onChannelUpdated.method"];
if (params["webhooks.onMemberAdded.url"] !== undefined)
data["Webhooks.OnMemberAdded.Url"] = params["webhooks.onMemberAdded.url"];
if (params["webhooks.onMemberAdded.method"] !== undefined)
data["Webhooks.OnMemberAdded.Method"] =
params["webhooks.onMemberAdded.method"];
if (params["webhooks.onMemberRemoved.url"] !== undefined)
data["Webhooks.OnMemberRemoved.Url"] =
params["webhooks.onMemberRemoved.url"];
if (params["webhooks.onMemberRemoved.method"] !== undefined)
data["Webhooks.OnMemberRemoved.Method"] =
params["webhooks.onMemberRemoved.method"];
if (params["limits.channelMembers"] !== undefined)
data["Limits.ChannelMembers"] = params["limits.channelMembers"];
if (params["limits.userChannels"] !== undefined)
data["Limits.UserChannels"] = params["limits.userChannels"];
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.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.defaultServiceRoleSid = payload.default_service_role_sid;
this.defaultChannelRoleSid = payload.default_channel_role_sid;
this.defaultChannelCreatorRoleSid =
payload.default_channel_creator_role_sid;
this.readStatusEnabled = payload.read_status_enabled;
this.reachabilityEnabled = payload.reachability_enabled;
this.typingIndicatorTimeout = deserialize.integer(payload.typing_indicator_timeout);
this.consumptionReportInterval = deserialize.integer(payload.consumption_report_interval);
this.limits = payload.limits;
this.webhooks = payload.webhooks;
this.preWebhookUrl = payload.pre_webhook_url;
this.postWebhookUrl = payload.post_webhook_url;
this.webhookMethod = payload.webhook_method;
this.webhookFilters = payload.webhook_filters;
this.notifications = payload.notifications;
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 channels.
*/
channels() {
return this._proxy.channels;
}
/**
* Access the roles.
*/
roles() {
return this._proxy.roles;
}
/**
* Access the users.
*/
users() {
return this._proxy.users;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
friendlyName: this.friendlyName,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
defaultServiceRoleSid: this.defaultServiceRoleSid,
defaultChannelRoleSid: this.defaultChannelRoleSid,
defaultChannelCreatorRoleSid: this.defaultChannelCreatorRoleSid,
readStatusEnabled: this.readStatusEnabled,
reachabilityEnabled: this.reachabilityEnabled,
typingIndicatorTimeout: this.typingIndicatorTimeout,
consumptionReportInterval: this.consumptionReportInterval,
limits: this.limits,
webhooks: this.webhooks,
preWebhookUrl: this.preWebhookUrl,
postWebhookUrl: this.postWebhookUrl,
webhookMethod: this.webhookMethod,
webhookFilters: this.webhookFilters,
notifications: this.notifications,
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["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
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["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
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,529 @@
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 { InviteListInstance } from "./channel/invite";
import { MemberListInstance } from "./channel/member";
import { MessageListInstance } from "./channel/message";
/**
* The visibility of the channel. Can be: `public` or `private`.
*/
export type ChannelChannelType = "public" | "private";
/**
* Options to pass to update a ChannelInstance
*/
export interface ChannelContextUpdateOptions {
/** A descriptive string that you create to describe the resource. It can be up to 64 characters long. */
friendlyName?: string;
/** An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource\\\'s `sid` in the URL. This value must be 64 characters or less in length and be unique within the Service. */
uniqueName?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
}
/**
* Options to pass to create a ChannelInstance
*/
export interface ChannelListInstanceCreateOptions {
/** A descriptive string that you create to describe the new resource. It can be up to 64 characters long. */
friendlyName?: string;
/** An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource\\\'s `sid` in the URL. This value must be 64 characters or less in length and be unique within the Service. */
uniqueName?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** */
type?: ChannelChannelType;
}
/**
* Options to pass to each
*/
export interface ChannelListInstanceEachOptions {
/** The visibility of the Channels to read. Can be: `public` or `private` and defaults to `public`. */
type?: Array<ChannelChannelType>;
/** 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: ChannelInstance, 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 ChannelListInstanceOptions {
/** The visibility of the Channels to read. Can be: `public` or `private` and defaults to `public`. */
type?: Array<ChannelChannelType>;
/** 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 ChannelListInstancePageOptions {
/** The visibility of the Channels to read. Can be: `public` or `private` and defaults to `public`. */
type?: Array<ChannelChannelType>;
/** 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 ChannelContext {
invites: InviteListInstance;
members: MemberListInstance;
messages: MessageListInstance;
/**
* Remove a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ChannelInstance 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 ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
fetch(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Fetch a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface ChannelContextSolution {
serviceSid: string;
sid: string;
}
export declare class ChannelContextImpl implements ChannelContext {
protected _version: V1;
protected _solution: ChannelContextSolution;
protected _uri: string;
protected _invites?: InviteListInstance;
protected _members?: MemberListInstance;
protected _messages?: MessageListInstance;
constructor(_version: V1, serviceSid: string, sid: string);
get invites(): InviteListInstance;
get members(): MemberListInstance;
get messages(): MessageListInstance;
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?: ChannelInstance) => any): Promise<ChannelInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
update(params?: ChannelContextUpdateOptions | ((error: Error | null, item?: ChannelInstance) => any), callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
updateWithHttpInfo(params?: ChannelContextUpdateOptions | ((error: Error | null, item?: ApiResponse<ChannelInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ChannelContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ChannelPayload extends TwilioResponsePayload {
channels: ChannelResource[];
}
interface ChannelResource {
sid: string;
account_sid: string;
service_sid: string;
friendly_name: string;
unique_name: string;
attributes: string;
type: ChannelChannelType;
date_created: Date;
date_updated: Date;
created_by: string;
members_count: number;
messages_count: number;
url: string;
links: Record<string, string>;
}
export declare class ChannelInstance {
protected _version: V1;
protected _solution: ChannelContextSolution;
protected _context?: ChannelContext;
constructor(_version: V1, payload: ChannelResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Channel resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Channel resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/api/chat/rest/services) the resource is associated with.
*/
serviceSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
/**
* An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource\'s `sid` in the URL.
*/
uniqueName: string;
/**
* The JSON string that stores application-specific data. **Note** If this property has been assigned a value, it\'s only displayed in a FETCH action that returns a single resource; otherwise, it\'s null. If the attributes have not been set, `{}` is returned.
*/
attributes: string;
type: ChannelChannelType;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The `identity` of the User that created the channel. If the Channel was created by using the API, the value is `system`.
*/
createdBy: string;
/**
* The number of Members in the Channel.
*/
membersCount: number;
/**
* The number of Messages in the Channel.
*/
messagesCount: number;
/**
* The absolute URL of the Channel resource.
*/
url: string;
/**
* The absolute URLs of the [Members](https://www.twilio.com/docs/chat/api/members), [Messages](https://www.twilio.com/docs/chat/api/messages) , [Invites](https://www.twilio.com/docs/chat/api/invites) and, if it exists, the last [Message](https://www.twilio.com/docs/chat/api/messages) for the Channel.
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ChannelInstance 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 ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
fetch(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Fetch a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Access the invites.
*/
invites(): InviteListInstance;
/**
* Access the members.
*/
members(): MemberListInstance;
/**
* Access the messages.
*/
messages(): MessageListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
friendlyName: string;
uniqueName: string;
attributes: string;
type: ChannelChannelType;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
membersCount: number;
messagesCount: number;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface ChannelSolution {
serviceSid: string;
}
export interface ChannelListInstance {
_version: V1;
_solution: ChannelSolution;
_uri: string;
(sid: string): ChannelContext;
get(sid: string): ChannelContext;
/**
* Create a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
create(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Create a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
create(params: ChannelListInstanceCreateOptions, callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Create a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Create a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
createWithHttpInfo(params: ChannelListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Streams ChannelInstance 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 { ChannelListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: ChannelInstance, done: (err?: Error) => void) => void): void;
each(params: ChannelListInstanceEachOptions, callback?: (item: ChannelInstance, done: (err?: Error) => void) => void): void;
/**
* Streams ChannelInstance 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 { ChannelListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: ChannelInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: ChannelListInstanceEachOptions, callback?: (item: ChannelInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of ChannelInstance 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: ChannelPage) => any): Promise<ChannelPage>;
/**
* Retrieve a single target page of ChannelInstance 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<ChannelPage>) => any): Promise<ApiResponse<ChannelPage>>;
/**
* Lists ChannelInstance 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 { ChannelListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: ChannelInstance[]) => any): Promise<ChannelInstance[]>;
list(params: ChannelListInstanceOptions, callback?: (error: Error | null, items: ChannelInstance[]) => any): Promise<ChannelInstance[]>;
/**
* Lists ChannelInstance 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 { ChannelListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ChannelInstance[]>) => any): Promise<ApiResponse<ChannelInstance[]>>;
listWithHttpInfo(params: ChannelListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<ChannelInstance[]>) => any): Promise<ApiResponse<ChannelInstance[]>>;
/**
* Retrieve a single page of ChannelInstance 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 { ChannelListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: ChannelPage) => any): Promise<ChannelPage>;
page(params: ChannelListInstancePageOptions, callback?: (error: Error | null, items: ChannelPage) => any): Promise<ChannelPage>;
/**
* Retrieve a single page of ChannelInstance 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 { ChannelListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ChannelPage>) => any): Promise<ApiResponse<ChannelPage>>;
pageWithHttpInfo(params: ChannelListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<ChannelPage>) => any): Promise<ApiResponse<ChannelPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function ChannelListInstance(version: V1, serviceSid: string): ChannelListInstance;
export declare class ChannelPage extends Page<V1, ChannelPayload, ChannelResource, ChannelInstance> {
/**
* Initialize the ChannelPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: ChannelSolution);
/**
* Build an instance of ChannelInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: ChannelResource): ChannelInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

508
node_modules/twilio/lib/rest/chat/v1/service/channel.js generated vendored Normal file
View File

@@ -0,0 +1,508 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.ChannelPage = exports.ChannelInstance = exports.ChannelContextImpl = void 0;
exports.ChannelListInstance = ChannelListInstance;
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 invite_1 = require("./channel/invite");
const member_1 = require("./channel/member");
const message_1 = require("./channel/message");
class ChannelContextImpl {
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}/Channels/${sid}`;
}
get invites() {
this._invites =
this._invites ||
(0, invite_1.InviteListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._invites;
}
get members() {
this._members =
this._members ||
(0, member_1.MemberListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._members;
}
get messages() {
this._messages =
this._messages ||
(0, message_1.MessageListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._messages;
}
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 ChannelInstance(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 ChannelInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
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 ChannelInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
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 ChannelInstance(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.ChannelContextImpl = ChannelContextImpl;
class ChannelInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.friendlyName = payload.friendly_name;
this.uniqueName = payload.unique_name;
this.attributes = payload.attributes;
this.type = payload.type;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this.membersCount = deserialize.integer(payload.members_count);
this.messagesCount = deserialize.integer(payload.messages_count);
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new ChannelContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a ChannelInstance 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 ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance 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 invites.
*/
invites() {
return this._proxy.invites;
}
/**
* Access the members.
*/
members() {
return this._proxy.members;
}
/**
* Access the messages.
*/
messages() {
return this._proxy.messages;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
friendlyName: this.friendlyName,
uniqueName: this.uniqueName,
attributes: this.attributes,
type: this.type,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
membersCount: this.membersCount,
messagesCount: this.messagesCount,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ChannelInstance = ChannelInstance;
function ChannelListInstance(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 ChannelContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Channels`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["type"] !== undefined)
data["Type"] = params["type"];
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 ChannelInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["type"] !== undefined)
data["Type"] = params["type"];
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 ChannelInstance(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["type"] !== undefined)
data["Type"] = serialize.map(params["type"], (e) => e);
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 ChannelPage(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 ChannelPage(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["type"] !== undefined)
data["Type"] = serialize.map(params["type"], (e) => e);
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 ChannelPage(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 ChannelPage(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 ChannelPage extends Page_1.default {
/**
* Initialize the ChannelPage
*
* @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 ChannelInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new ChannelInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ChannelPage = ChannelPage;

View File

@@ -0,0 +1,381 @@
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";
/**
* Options to pass to create a InviteInstance
*/
export interface InviteListInstanceCreateOptions {
/** The `identity` value that uniquely identifies the new resource\\\'s [User](https://www.twilio.com/docs/api/chat/rest/v1/user) within the [Service](https://www.twilio.com/docs/api/chat/rest/v1/service). See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more info. */
identity: string;
/** The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to the new member. */
roleSid?: string;
}
/**
* Options to pass to each
*/
export interface InviteListInstanceEachOptions {
/** The [User](https://www.twilio.com/docs/api/chat/rest/v1/user)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: InviteInstance, 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 InviteListInstanceOptions {
/** The [User](https://www.twilio.com/docs/api/chat/rest/v1/user)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface InviteListInstancePageOptions {
/** The [User](https://www.twilio.com/docs/api/chat/rest/v1/user)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface InviteContext {
/**
* Remove a InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a InviteInstance 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 InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance
*/
fetch(callback?: (error: Error | null, item?: InviteInstance) => any): Promise<InviteInstance>;
/**
* Fetch a InviteInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InviteInstance>) => any): Promise<ApiResponse<InviteInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface InviteContextSolution {
serviceSid: string;
channelSid: string;
sid: string;
}
export declare class InviteContextImpl implements InviteContext {
protected _version: V1;
protected _solution: InviteContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, channelSid: 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?: InviteInstance) => any): Promise<InviteInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InviteInstance>) => any): Promise<ApiResponse<InviteInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): InviteContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface InvitePayload extends TwilioResponsePayload {
invites: InviteResource[];
}
interface InviteResource {
sid: string;
account_sid: string;
channel_sid: string;
service_sid: string;
identity: string;
date_created: Date;
date_updated: Date;
role_sid: string;
created_by: string;
url: string;
}
export declare class InviteInstance {
protected _version: V1;
protected _solution: InviteContextSolution;
protected _context?: InviteContext;
constructor(_version: V1, payload: InviteResource, serviceSid: string, channelSid: string, sid?: string);
/**
* The unique string that we created to identify the Invite resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Invite resource.
*/
accountSid: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/api/chat/rest/channels) the resource belongs to.
*/
channelSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/api/chat/rest/services) the resource is associated with.
*/
serviceSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s [User](https://www.twilio.com/docs/api/chat/rest/users) within the [Service](https://www.twilio.com/docs/api/chat/rest/services). See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more info.
*/
identity: string;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to the resource.
*/
roleSid: string;
/**
* The `identity` of the User that created the invite.
*/
createdBy: string;
/**
* The absolute URL of the Invite resource.
*/
url: string;
private get _proxy();
/**
* Remove a InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a InviteInstance 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 InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance
*/
fetch(callback?: (error: Error | null, item?: InviteInstance) => any): Promise<InviteInstance>;
/**
* Fetch a InviteInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InviteInstance>) => any): Promise<ApiResponse<InviteInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
channelSid: string;
serviceSid: string;
identity: string;
dateCreated: Date;
dateUpdated: Date;
roleSid: string;
createdBy: string;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface InviteSolution {
serviceSid: string;
channelSid: string;
}
export interface InviteListInstance {
_version: V1;
_solution: InviteSolution;
_uri: string;
(sid: string): InviteContext;
get(sid: string): InviteContext;
/**
* Create a InviteInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance
*/
create(params: InviteListInstanceCreateOptions, callback?: (error: Error | null, item?: InviteInstance) => any): Promise<InviteInstance>;
/**
* Create a InviteInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance with HTTP metadata
*/
createWithHttpInfo(params: InviteListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<InviteInstance>) => any): Promise<ApiResponse<InviteInstance>>;
/**
* Streams InviteInstance 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 { InviteListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: InviteInstance, done: (err?: Error) => void) => void): void;
each(params: InviteListInstanceEachOptions, callback?: (item: InviteInstance, done: (err?: Error) => void) => void): void;
/**
* Streams InviteInstance 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 { InviteListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: InviteInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: InviteListInstanceEachOptions, callback?: (item: InviteInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of InviteInstance 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: InvitePage) => any): Promise<InvitePage>;
/**
* Retrieve a single target page of InviteInstance 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<InvitePage>) => any): Promise<ApiResponse<InvitePage>>;
/**
* Lists InviteInstance 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 { InviteListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: InviteInstance[]) => any): Promise<InviteInstance[]>;
list(params: InviteListInstanceOptions, callback?: (error: Error | null, items: InviteInstance[]) => any): Promise<InviteInstance[]>;
/**
* Lists InviteInstance 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 { InviteListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<InviteInstance[]>) => any): Promise<ApiResponse<InviteInstance[]>>;
listWithHttpInfo(params: InviteListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<InviteInstance[]>) => any): Promise<ApiResponse<InviteInstance[]>>;
/**
* Retrieve a single page of InviteInstance 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 { InviteListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: InvitePage) => any): Promise<InvitePage>;
page(params: InviteListInstancePageOptions, callback?: (error: Error | null, items: InvitePage) => any): Promise<InvitePage>;
/**
* Retrieve a single page of InviteInstance 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 { InviteListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<InvitePage>) => any): Promise<ApiResponse<InvitePage>>;
pageWithHttpInfo(params: InviteListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<InvitePage>) => any): Promise<ApiResponse<InvitePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function InviteListInstance(version: V1, serviceSid: string, channelSid: string): InviteListInstance;
export declare class InvitePage extends Page<V1, InvitePayload, InviteResource, InviteInstance> {
/**
* Initialize the InvitePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: InviteSolution);
/**
* Build an instance of InviteInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: InviteResource): InviteInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,385 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.InvitePage = exports.InviteInstance = exports.InviteContextImpl = void 0;
exports.InviteListInstance = InviteListInstance;
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 InviteContextImpl {
constructor(_version, serviceSid, channelSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, channelSid, sid };
this._uri = `/Services/${serviceSid}/Channels/${channelSid}/Invites/${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 InviteInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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 InviteInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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.InviteContextImpl = InviteContextImpl;
class InviteInstance {
constructor(_version, payload, serviceSid, channelSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.channelSid = payload.channel_sid;
this.serviceSid = payload.service_sid;
this.identity = payload.identity;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.roleSid = payload.role_sid;
this.createdBy = payload.created_by;
this.url = payload.url;
this._solution = { serviceSid, channelSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new InviteContextImpl(this._version, this._solution.serviceSid, this._solution.channelSid, this._solution.sid);
return this._context;
}
/**
* Remove a InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a InviteInstance 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 InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a InviteInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
channelSid: this.channelSid,
serviceSid: this.serviceSid,
identity: this.identity,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
roleSid: this.roleSid,
createdBy: this.createdBy,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.InviteInstance = InviteInstance;
function InviteListInstance(version, serviceSid, channelSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new InviteContextImpl(version, serviceSid, channelSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, channelSid };
instance._uri = `/Services/${serviceSid}/Channels/${channelSid}/Invites`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
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 InviteInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid));
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["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
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 InviteInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid),
}));
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["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 InvitePage(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 InvitePage(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["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 InvitePage(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 InvitePage(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 InvitePage extends Page_1.default {
/**
* Initialize the InvitePage
*
* @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 InviteInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new InviteInstance(this._version, payload, this._solution.serviceSid, this._solution.channelSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.InvitePage = InvitePage;

View File

@@ -0,0 +1,466 @@
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";
/**
* Options to pass to update a MemberInstance
*/
export interface MemberContextUpdateOptions {
/** The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/api/services). */
roleSid?: string;
/** The index of the last [Message](https://www.twilio.com/docs/api/chat/rest/messages) that the Member has read within the [Channel](https://www.twilio.com/docs/api/chat/rest/channels). */
lastConsumedMessageIndex?: number;
}
/**
* Options to pass to create a MemberInstance
*/
export interface MemberListInstanceCreateOptions {
/** The `identity` value that uniquely identifies the new resource\\\'s [User](https://www.twilio.com/docs/api/chat/rest/v1/user) within the [Service](https://www.twilio.com/docs/api/chat/rest/services). See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. */
identity: string;
/** The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/api/services). */
roleSid?: string;
}
/**
* Options to pass to each
*/
export interface MemberListInstanceEachOptions {
/** The [User](https://www.twilio.com/docs/api/chat/rest/v1/user)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: MemberInstance, 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 MemberListInstanceOptions {
/** The [User](https://www.twilio.com/docs/api/chat/rest/v1/user)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface MemberListInstancePageOptions {
/** The [User](https://www.twilio.com/docs/api/chat/rest/v1/user)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface MemberContext {
/**
* Remove a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MemberInstance 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 MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
fetch(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Fetch a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Update a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
update(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Update a MemberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
update(params: MemberContextUpdateOptions, callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Update a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Update a MemberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
updateWithHttpInfo(params: MemberContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface MemberContextSolution {
serviceSid: string;
channelSid: string;
sid: string;
}
export declare class MemberContextImpl implements MemberContext {
protected _version: V1;
protected _solution: MemberContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, channelSid: 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?: MemberInstance) => any): Promise<MemberInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
update(params?: MemberContextUpdateOptions | ((error: Error | null, item?: MemberInstance) => any), callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
updateWithHttpInfo(params?: MemberContextUpdateOptions | ((error: Error | null, item?: ApiResponse<MemberInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): MemberContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface MemberPayload extends TwilioResponsePayload {
members: MemberResource[];
}
interface MemberResource {
sid: string;
account_sid: string;
channel_sid: string;
service_sid: string;
identity: string;
date_created: Date;
date_updated: Date;
role_sid: string;
last_consumed_message_index: number;
last_consumption_timestamp: Date;
url: string;
}
export declare class MemberInstance {
protected _version: V1;
protected _solution: MemberContextSolution;
protected _context?: MemberContext;
constructor(_version: V1, payload: MemberResource, serviceSid: string, channelSid: string, sid?: string);
/**
* The unique string that we created to identify the Member resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Member resource.
*/
accountSid: string;
/**
* The unique ID of the [Channel](https://www.twilio.com/docs/api/chat/rest/channels) for the member.
*/
channelSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/api/chat/rest/services) the resource is associated with.
*/
serviceSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s [User](https://www.twilio.com/docs/api/chat/rest/users) within the [Service](https://www.twilio.com/docs/api/chat/rest/services). See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more info.
*/
identity: string;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to the member.
*/
roleSid: string;
/**
* The index of the last [Message](https://www.twilio.com/docs/api/chat/rest/messages) in the [Channel](https://www.twilio.com/docs/api/chat/rest/channels) that the Member has read.
*/
lastConsumedMessageIndex: number;
/**
* The ISO 8601 timestamp string that represents the date-time of the last [Message](https://www.twilio.com/docs/api/chat/rest/messages) read event for the Member within the [Channel](https://www.twilio.com/docs/api/chat/rest/channels).
*/
lastConsumptionTimestamp: Date;
/**
* The absolute URL of the Member resource.
*/
url: string;
private get _proxy();
/**
* Remove a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MemberInstance 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 MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
fetch(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Fetch a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Update a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
update(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Update a MemberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
update(params: MemberContextUpdateOptions, callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Update a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Update a MemberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
updateWithHttpInfo(params: MemberContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
channelSid: string;
serviceSid: string;
identity: string;
dateCreated: Date;
dateUpdated: Date;
roleSid: string;
lastConsumedMessageIndex: number;
lastConsumptionTimestamp: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface MemberSolution {
serviceSid: string;
channelSid: string;
}
export interface MemberListInstance {
_version: V1;
_solution: MemberSolution;
_uri: string;
(sid: string): MemberContext;
get(sid: string): MemberContext;
/**
* Create a MemberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
create(params: MemberListInstanceCreateOptions, callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Create a MemberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
createWithHttpInfo(params: MemberListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Streams MemberInstance 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 { MemberListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: MemberInstance, done: (err?: Error) => void) => void): void;
each(params: MemberListInstanceEachOptions, callback?: (item: MemberInstance, done: (err?: Error) => void) => void): void;
/**
* Streams MemberInstance 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 { MemberListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: MemberInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: MemberListInstanceEachOptions, callback?: (item: MemberInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of MemberInstance 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: MemberPage) => any): Promise<MemberPage>;
/**
* Retrieve a single target page of MemberInstance 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<MemberPage>) => any): Promise<ApiResponse<MemberPage>>;
/**
* Lists MemberInstance 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 { MemberListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: MemberInstance[]) => any): Promise<MemberInstance[]>;
list(params: MemberListInstanceOptions, callback?: (error: Error | null, items: MemberInstance[]) => any): Promise<MemberInstance[]>;
/**
* Lists MemberInstance 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 { MemberListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MemberInstance[]>) => any): Promise<ApiResponse<MemberInstance[]>>;
listWithHttpInfo(params: MemberListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<MemberInstance[]>) => any): Promise<ApiResponse<MemberInstance[]>>;
/**
* Retrieve a single page of MemberInstance 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 { MemberListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: MemberPage) => any): Promise<MemberPage>;
page(params: MemberListInstancePageOptions, callback?: (error: Error | null, items: MemberPage) => any): Promise<MemberPage>;
/**
* Retrieve a single page of MemberInstance 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 { MemberListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MemberPage>) => any): Promise<ApiResponse<MemberPage>>;
pageWithHttpInfo(params: MemberListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<MemberPage>) => any): Promise<ApiResponse<MemberPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function MemberListInstance(version: V1, serviceSid: string, channelSid: string): MemberListInstance;
export declare class MemberPage extends Page<V1, MemberPayload, MemberResource, MemberInstance> {
/**
* Initialize the MemberPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: MemberSolution);
/**
* Build an instance of MemberInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: MemberResource): MemberInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,453 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.MemberPage = exports.MemberInstance = exports.MemberContextImpl = void 0;
exports.MemberListInstance = MemberListInstance;
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 MemberContextImpl {
constructor(_version, serviceSid, channelSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, channelSid, sid };
this._uri = `/Services/${serviceSid}/Channels/${channelSid}/Members/${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 MemberInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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 MemberInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["lastConsumedMessageIndex"] !== undefined)
data["LastConsumedMessageIndex"] = params["lastConsumedMessageIndex"];
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 MemberInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["lastConsumedMessageIndex"] !== undefined)
data["LastConsumedMessageIndex"] = params["lastConsumedMessageIndex"];
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 MemberInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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.MemberContextImpl = MemberContextImpl;
class MemberInstance {
constructor(_version, payload, serviceSid, channelSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.channelSid = payload.channel_sid;
this.serviceSid = payload.service_sid;
this.identity = payload.identity;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.roleSid = payload.role_sid;
this.lastConsumedMessageIndex = deserialize.integer(payload.last_consumed_message_index);
this.lastConsumptionTimestamp = deserialize.iso8601DateTime(payload.last_consumption_timestamp);
this.url = payload.url;
this._solution = { serviceSid, channelSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new MemberContextImpl(this._version, this._solution.serviceSid, this._solution.channelSid, this._solution.sid);
return this._context;
}
/**
* Remove a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a MemberInstance 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 MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance 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,
channelSid: this.channelSid,
serviceSid: this.serviceSid,
identity: this.identity,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
roleSid: this.roleSid,
lastConsumedMessageIndex: this.lastConsumedMessageIndex,
lastConsumptionTimestamp: this.lastConsumptionTimestamp,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MemberInstance = MemberInstance;
function MemberListInstance(version, serviceSid, channelSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new MemberContextImpl(version, serviceSid, channelSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, channelSid };
instance._uri = `/Services/${serviceSid}/Channels/${channelSid}/Members`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
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 MemberInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid));
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["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
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 MemberInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid),
}));
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["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 MemberPage(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 MemberPage(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["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 MemberPage(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 MemberPage(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 MemberPage extends Page_1.default {
/**
* Initialize the MemberPage
*
* @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 MemberInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new MemberInstance(this._version, payload, this._solution.serviceSid, this._solution.channelSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MemberPage = MemberPage;

View File

@@ -0,0 +1,481 @@
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";
export type MessageOrderType = "asc" | "desc";
/**
* Options to pass to update a MessageInstance
*/
export interface MessageContextUpdateOptions {
/** The message to send to the channel. Can also be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. */
body?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
}
/**
* Options to pass to create a MessageInstance
*/
export interface MessageListInstanceCreateOptions {
/** The message to send to the channel. Can also be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. */
body: string;
/** The [identity](https://www.twilio.com/docs/api/chat/guides/identity) of the new message\\\'s author. The default value is `system`. */
from?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
}
/**
* Options to pass to each
*/
export interface MessageListInstanceEachOptions {
/** The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default. */
order?: MessageOrderType;
/** 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: MessageInstance, 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 MessageListInstanceOptions {
/** The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default. */
order?: MessageOrderType;
/** 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 MessageListInstancePageOptions {
/** The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default. */
order?: MessageOrderType;
/** 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 MessageContext {
/**
* Remove a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MessageInstance 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 MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
fetch(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Fetch a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Update a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
update(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Update a MessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
update(params: MessageContextUpdateOptions, callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Update a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Update a MessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
updateWithHttpInfo(params: MessageContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface MessageContextSolution {
serviceSid: string;
channelSid: string;
sid: string;
}
export declare class MessageContextImpl implements MessageContext {
protected _version: V1;
protected _solution: MessageContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, channelSid: 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?: MessageInstance) => any): Promise<MessageInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
update(params?: MessageContextUpdateOptions | ((error: Error | null, item?: MessageInstance) => any), callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
updateWithHttpInfo(params?: MessageContextUpdateOptions | ((error: Error | null, item?: ApiResponse<MessageInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): MessageContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface MessagePayload extends TwilioResponsePayload {
messages: MessageResource[];
}
interface MessageResource {
sid: string;
account_sid: string;
attributes: string;
service_sid: string;
to: string;
channel_sid: string;
date_created: Date;
date_updated: Date;
was_edited: boolean;
from: string;
body: string;
index: number;
url: string;
}
export declare class MessageInstance {
protected _version: V1;
protected _solution: MessageContextSolution;
protected _context?: MessageContext;
constructor(_version: V1, payload: MessageResource, serviceSid: string, channelSid: string, sid?: string);
/**
* The unique string that we created to identify the Message resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Message resource.
*/
accountSid: string;
/**
* The JSON string that stores application-specific data. **Note** If this property has been assigned a value, it\'s only displayed in a FETCH action that returns a single resource; otherwise, it\'s null. If the attributes have not been set, `{}` is returned.
*/
attributes: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/api/chat/rest/services) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/chat/api/channels) that the message was sent to.
*/
to: string;
/**
* The unique ID of the [Channel](https://www.twilio.com/docs/api/chat/rest/channels) the Message resource belongs to.
*/
channelSid: string;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* Whether the message has been edited since it was created.
*/
wasEdited: boolean;
/**
* The [identity](https://www.twilio.com/docs/api/chat/guides/identity) of the message\'s author. The default value is `system`.
*/
from: string;
/**
* The content of the message.
*/
body: string;
/**
* The index of the message within the [Channel](https://www.twilio.com/docs/chat/api/channels).
*/
index: number;
/**
* The absolute URL of the Message resource.
*/
url: string;
private get _proxy();
/**
* Remove a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MessageInstance 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 MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
fetch(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Fetch a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Update a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
update(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Update a MessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
update(params: MessageContextUpdateOptions, callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Update a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Update a MessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
updateWithHttpInfo(params: MessageContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
attributes: string;
serviceSid: string;
to: string;
channelSid: string;
dateCreated: Date;
dateUpdated: Date;
wasEdited: boolean;
from: string;
body: string;
index: number;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface MessageSolution {
serviceSid: string;
channelSid: string;
}
export interface MessageListInstance {
_version: V1;
_solution: MessageSolution;
_uri: string;
(sid: string): MessageContext;
get(sid: string): MessageContext;
/**
* Create a MessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
create(params: MessageListInstanceCreateOptions, callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Create a MessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
createWithHttpInfo(params: MessageListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Streams MessageInstance 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 { MessageListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: MessageInstance, done: (err?: Error) => void) => void): void;
each(params: MessageListInstanceEachOptions, callback?: (item: MessageInstance, done: (err?: Error) => void) => void): void;
/**
* Streams MessageInstance 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 { MessageListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: MessageInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: MessageListInstanceEachOptions, callback?: (item: MessageInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of MessageInstance 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: MessagePage) => any): Promise<MessagePage>;
/**
* Retrieve a single target page of MessageInstance 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<MessagePage>) => any): Promise<ApiResponse<MessagePage>>;
/**
* Lists MessageInstance 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 { MessageListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: MessageInstance[]) => any): Promise<MessageInstance[]>;
list(params: MessageListInstanceOptions, callback?: (error: Error | null, items: MessageInstance[]) => any): Promise<MessageInstance[]>;
/**
* Lists MessageInstance 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 { MessageListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MessageInstance[]>) => any): Promise<ApiResponse<MessageInstance[]>>;
listWithHttpInfo(params: MessageListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<MessageInstance[]>) => any): Promise<ApiResponse<MessageInstance[]>>;
/**
* Retrieve a single page of MessageInstance 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 { MessageListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: MessagePage) => any): Promise<MessagePage>;
page(params: MessageListInstancePageOptions, callback?: (error: Error | null, items: MessagePage) => any): Promise<MessagePage>;
/**
* Retrieve a single page of MessageInstance 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 { MessageListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MessagePage>) => any): Promise<ApiResponse<MessagePage>>;
pageWithHttpInfo(params: MessageListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<MessagePage>) => any): Promise<ApiResponse<MessagePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function MessageListInstance(version: V1, serviceSid: string, channelSid: string): MessageListInstance;
export declare class MessagePage extends Page<V1, MessagePayload, MessageResource, MessageInstance> {
/**
* Initialize the MessagePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: MessageSolution);
/**
* Build an instance of MessageInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: MessageResource): MessageInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,461 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.MessagePage = exports.MessageInstance = exports.MessageContextImpl = void 0;
exports.MessageListInstance = MessageListInstance;
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 MessageContextImpl {
constructor(_version, serviceSid, channelSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, channelSid, sid };
this._uri = `/Services/${serviceSid}/Channels/${channelSid}/Messages/${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 MessageInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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 MessageInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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["body"] !== undefined)
data["Body"] = params["body"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
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 MessageInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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["body"] !== undefined)
data["Body"] = params["body"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
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 MessageInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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.MessageContextImpl = MessageContextImpl;
class MessageInstance {
constructor(_version, payload, serviceSid, channelSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.attributes = payload.attributes;
this.serviceSid = payload.service_sid;
this.to = payload.to;
this.channelSid = payload.channel_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.wasEdited = payload.was_edited;
this.from = payload.from;
this.body = payload.body;
this.index = deserialize.integer(payload.index);
this.url = payload.url;
this._solution = { serviceSid, channelSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new MessageContextImpl(this._version, this._solution.serviceSid, this._solution.channelSid, this._solution.sid);
return this._context;
}
/**
* Remove a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a MessageInstance 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 MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance 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,
attributes: this.attributes,
serviceSid: this.serviceSid,
to: this.to,
channelSid: this.channelSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
wasEdited: this.wasEdited,
from: this.from,
body: this.body,
index: this.index,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessageInstance = MessageInstance;
function MessageListInstance(version, serviceSid, channelSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new MessageContextImpl(version, serviceSid, channelSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, channelSid };
instance._uri = `/Services/${serviceSid}/Channels/${channelSid}/Messages`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["body"] === null || params["body"] === undefined) {
throw new Error("Required parameter \"params['body']\" missing.");
}
let data = {};
data["Body"] = params["body"];
if (params["from"] !== undefined)
data["From"] = params["from"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
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 MessageInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid));
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["body"] === null || params["body"] === undefined) {
throw new Error("Required parameter \"params['body']\" missing.");
}
let data = {};
data["Body"] = params["body"];
if (params["from"] !== undefined)
data["From"] = params["from"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
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 MessageInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid),
}));
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["order"] !== undefined)
data["Order"] = params["order"];
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 MessagePage(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 MessagePage(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["order"] !== undefined)
data["Order"] = params["order"];
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 MessagePage(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 MessagePage(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 MessagePage extends Page_1.default {
/**
* Initialize the MessagePage
*
* @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 MessageInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new MessageInstance(this._version, payload, this._solution.serviceSid, this._solution.channelSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessagePage = MessagePage;

415
node_modules/twilio/lib/rest/chat/v1/service/role.d.ts generated vendored Normal file
View File

@@ -0,0 +1,415 @@
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 type of role. Can be: `channel` for [Channel](https://www.twilio.com/docs/chat/api/channels) roles or `deployment` for [Service](https://www.twilio.com/docs/chat/api/services) roles.
*/
export type RoleRoleType = "channel" | "deployment";
/**
* Options to pass to update a RoleInstance
*/
export interface RoleContextUpdateOptions {
/** A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role\\\'s `type` and are described in the documentation. */
permission: Array<string>;
}
/**
* Options to pass to create a RoleInstance
*/
export interface RoleListInstanceCreateOptions {
/** A descriptive string that you create to describe the new resource. It can be up to 64 characters long. */
friendlyName: string;
/** */
type: RoleRoleType;
/** A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role\\\'s `type` and are described in the documentation. */
permission: Array<string>;
}
/**
* Options to pass to each
*/
export interface RoleListInstanceEachOptions {
/** 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: RoleInstance, 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 RoleListInstanceOptions {
/** 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 RoleListInstancePageOptions {
/** 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 RoleContext {
/**
* Remove a RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a RoleInstance 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 RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
fetch(callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Fetch a RoleInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Update a RoleInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
update(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Update a RoleInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
updateWithHttpInfo(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface RoleContextSolution {
serviceSid: string;
sid: string;
}
export declare class RoleContextImpl implements RoleContext {
protected _version: V1;
protected _solution: RoleContextSolution;
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?: RoleInstance) => any): Promise<RoleInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
update(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
updateWithHttpInfo(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): RoleContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface RolePayload extends TwilioResponsePayload {
roles: RoleResource[];
}
interface RoleResource {
sid: string;
account_sid: string;
service_sid: string;
friendly_name: string;
type: RoleRoleType;
permissions: Array<string>;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class RoleInstance {
protected _version: V1;
protected _solution: RoleContextSolution;
protected _context?: RoleContext;
constructor(_version: V1, payload: RoleResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Role resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Role resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/api/chat/rest/services) the resource is associated with.
*/
serviceSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
type: RoleRoleType;
/**
* An array of the permissions the role has been granted, formatted as a JSON string.
*/
permissions: Array<string>;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The absolute URL of the Role resource.
*/
url: string;
private get _proxy();
/**
* Remove a RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a RoleInstance 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 RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
fetch(callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Fetch a RoleInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Update a RoleInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
update(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Update a RoleInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
updateWithHttpInfo(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
friendlyName: string;
type: RoleRoleType;
permissions: string[];
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface RoleSolution {
serviceSid: string;
}
export interface RoleListInstance {
_version: V1;
_solution: RoleSolution;
_uri: string;
(sid: string): RoleContext;
get(sid: string): RoleContext;
/**
* Create a RoleInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
create(params: RoleListInstanceCreateOptions, callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Create a RoleInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
createWithHttpInfo(params: RoleListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Streams RoleInstance 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 { RoleListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: RoleInstance, done: (err?: Error) => void) => void): void;
each(params: RoleListInstanceEachOptions, callback?: (item: RoleInstance, done: (err?: Error) => void) => void): void;
/**
* Streams RoleInstance 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 { RoleListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: RoleInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: RoleListInstanceEachOptions, callback?: (item: RoleInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of RoleInstance 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: RolePage) => any): Promise<RolePage>;
/**
* Retrieve a single target page of RoleInstance 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<RolePage>) => any): Promise<ApiResponse<RolePage>>;
/**
* Lists RoleInstance 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 { RoleListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: RoleInstance[]) => any): Promise<RoleInstance[]>;
list(params: RoleListInstanceOptions, callback?: (error: Error | null, items: RoleInstance[]) => any): Promise<RoleInstance[]>;
/**
* Lists RoleInstance 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 { RoleListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<RoleInstance[]>) => any): Promise<ApiResponse<RoleInstance[]>>;
listWithHttpInfo(params: RoleListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<RoleInstance[]>) => any): Promise<ApiResponse<RoleInstance[]>>;
/**
* Retrieve a single page of RoleInstance 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 { RoleListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: RolePage) => any): Promise<RolePage>;
page(params: RoleListInstancePageOptions, callback?: (error: Error | null, items: RolePage) => any): Promise<RolePage>;
/**
* Retrieve a single page of RoleInstance 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 { RoleListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<RolePage>) => any): Promise<ApiResponse<RolePage>>;
pageWithHttpInfo(params: RoleListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<RolePage>) => any): Promise<ApiResponse<RolePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function RoleListInstance(version: V1, serviceSid: string): RoleListInstance;
export declare class RolePage extends Page<V1, RolePayload, RoleResource, RoleInstance> {
/**
* Initialize the RolePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: RoleSolution);
/**
* Build an instance of RoleInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: RoleResource): RoleInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

445
node_modules/twilio/lib/rest/chat/v1/service/role.js generated vendored Normal file
View File

@@ -0,0 +1,445 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.RolePage = exports.RoleInstance = exports.RoleContextImpl = void 0;
exports.RoleListInstance = RoleListInstance;
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 RoleContextImpl {
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}/Roles/${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 RoleInstance(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 RoleInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["permission"] === null || params["permission"] === undefined) {
throw new Error("Required parameter \"params['permission']\" missing.");
}
let data = {};
data["Permission"] = serialize.map(params["permission"], (e) => e);
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 RoleInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["permission"] === null || params["permission"] === undefined) {
throw new Error("Required parameter \"params['permission']\" missing.");
}
let data = {};
data["Permission"] = serialize.map(params["permission"], (e) => e);
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 RoleInstance(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.RoleContextImpl = RoleContextImpl;
class RoleInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.friendlyName = payload.friendly_name;
this.type = payload.type;
this.permissions = payload.permissions;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new RoleContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a RoleInstance 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 RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a RoleInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance 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,
friendlyName: this.friendlyName,
type: this.type,
permissions: this.permissions,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.RoleInstance = RoleInstance;
function RoleListInstance(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 RoleContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Roles`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
if (params["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
if (params["permission"] === null || params["permission"] === undefined) {
throw new Error("Required parameter \"params['permission']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
data["Type"] = params["type"];
data["Permission"] = serialize.map(params["permission"], (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 RoleInstance(operationVersion, payload, instance._solution.serviceSid));
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["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
if (params["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
if (params["permission"] === null || params["permission"] === undefined) {
throw new Error("Required parameter \"params['permission']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
data["Type"] = params["type"];
data["Permission"] = serialize.map(params["permission"], (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 RoleInstance(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 RolePage(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 RolePage(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 RolePage(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 RolePage(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 RolePage extends Page_1.default {
/**
* Initialize the RolePage
*
* @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 RoleInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new RoleInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.RolePage = RolePage;

490
node_modules/twilio/lib/rest/chat/v1/service/user.d.ts generated vendored Normal file
View File

@@ -0,0 +1,490 @@
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 { UserChannelListInstance } from "./user/userChannel";
/**
* Options to pass to update a UserInstance
*/
export interface UserContextUpdateOptions {
/** The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to this user. */
roleSid?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** A descriptive string that you create to describe the resource. It is often used for display purposes. */
friendlyName?: string;
}
/**
* Options to pass to create a UserInstance
*/
export interface UserListInstanceCreateOptions {
/** The `identity` value that uniquely identifies the new resource\\\'s [User](https://www.twilio.com/docs/api/chat/rest/v1/user) within the [Service](https://www.twilio.com/docs/api/chat/rest/v1/service). This value is often a username or email address. See the Identity documentation for more details. */
identity: string;
/** The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to the new User. */
roleSid?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** A descriptive string that you create to describe the new resource. This value is often used for display purposes. */
friendlyName?: string;
}
/**
* Options to pass to each
*/
export interface UserListInstanceEachOptions {
/** 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: UserInstance, 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 UserListInstanceOptions {
/** 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 UserListInstancePageOptions {
/** 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 UserContext {
userChannels: UserChannelListInstance;
/**
* Remove a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserInstance 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 UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
fetch(callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Fetch a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Update a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
update(callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Update a UserInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
update(params: UserContextUpdateOptions, callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Update a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Update a UserInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
updateWithHttpInfo(params: UserContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface UserContextSolution {
serviceSid: string;
sid: string;
}
export declare class UserContextImpl implements UserContext {
protected _version: V1;
protected _solution: UserContextSolution;
protected _uri: string;
protected _userChannels?: UserChannelListInstance;
constructor(_version: V1, serviceSid: string, sid: string);
get userChannels(): UserChannelListInstance;
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?: UserInstance) => any): Promise<UserInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
update(params?: UserContextUpdateOptions | ((error: Error | null, item?: UserInstance) => any), callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
updateWithHttpInfo(params?: UserContextUpdateOptions | ((error: Error | null, item?: ApiResponse<UserInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): UserContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface UserPayload extends TwilioResponsePayload {
users: UserResource[];
}
interface UserResource {
sid: string;
account_sid: string;
service_sid: string;
attributes: string;
friendly_name: string;
role_sid: string;
identity: string;
is_online: boolean;
is_notifiable: boolean;
date_created: Date;
date_updated: Date;
joined_channels_count: number;
links: Record<string, string>;
url: string;
}
export declare class UserInstance {
protected _version: V1;
protected _solution: UserContextSolution;
protected _context?: UserContext;
constructor(_version: V1, payload: UserResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the User resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the User resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/api/chat/rest/services) the resource is associated with.
*/
serviceSid: string;
/**
* The JSON string that stores application-specific data. **Note** If this property has been assigned a value, it\'s only displayed in a FETCH action that returns a single resource; otherwise, it\'s null. If the attributes have not been set, `{}` is returned.
*/
attributes: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
/**
* The SID of the [Role](https://www.twilio.com/docs/api/chat/rest/roles) assigned to the user.
*/
roleSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s User within the [Service](https://www.twilio.com/docs/api/chat/rest/services). This value is often a username or an email address. See [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens) for more info.
*/
identity: string;
/**
* Whether the User is actively connected to the Service instance and online. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service\'s `reachability_enabled` is `false`, if the User has never been online for the Service instance, even if the Service\'s `reachability_enabled` is `true`.
*/
isOnline: boolean;
/**
* Whether the User has a potentially valid Push Notification registration (APN or GCM) for the Service instance. If at least one registration exists, `true`; otherwise `false`. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service\'s `reachability_enabled` is `false`, and if the User has never had a notification registration, even if the Service\'s `reachability_enabled` is `true`.
*/
isNotifiable: boolean;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The number of Channels this User is a Member of.
*/
joinedChannelsCount: number;
/**
* The absolute URLs of the [Channel](https://www.twilio.com/docs/chat/api/channels) and [Binding](https://www.twilio.com/docs/chat/rest/bindings-resource) resources related to the user.
*/
links: Record<string, string>;
/**
* The absolute URL of the User resource.
*/
url: string;
private get _proxy();
/**
* Remove a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserInstance 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 UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
fetch(callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Fetch a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Update a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
update(callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Update a UserInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
update(params: UserContextUpdateOptions, callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Update a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Update a UserInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
updateWithHttpInfo(params: UserContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Access the userChannels.
*/
userChannels(): UserChannelListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
attributes: string;
friendlyName: string;
roleSid: string;
identity: string;
isOnline: boolean;
isNotifiable: boolean;
dateCreated: Date;
dateUpdated: Date;
joinedChannelsCount: number;
links: Record<string, string>;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface UserSolution {
serviceSid: string;
}
export interface UserListInstance {
_version: V1;
_solution: UserSolution;
_uri: string;
(sid: string): UserContext;
get(sid: string): UserContext;
/**
* Create a UserInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
create(params: UserListInstanceCreateOptions, callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Create a UserInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
createWithHttpInfo(params: UserListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Streams UserInstance 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 { UserListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: UserInstance, done: (err?: Error) => void) => void): void;
each(params: UserListInstanceEachOptions, callback?: (item: UserInstance, done: (err?: Error) => void) => void): void;
/**
* Streams UserInstance 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 { UserListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: UserInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: UserListInstanceEachOptions, callback?: (item: UserInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of UserInstance 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: UserPage) => any): Promise<UserPage>;
/**
* Retrieve a single target page of UserInstance 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<UserPage>) => any): Promise<ApiResponse<UserPage>>;
/**
* Lists UserInstance 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 { UserListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: UserInstance[]) => any): Promise<UserInstance[]>;
list(params: UserListInstanceOptions, callback?: (error: Error | null, items: UserInstance[]) => any): Promise<UserInstance[]>;
/**
* Lists UserInstance 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 { UserListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserInstance[]>) => any): Promise<ApiResponse<UserInstance[]>>;
listWithHttpInfo(params: UserListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<UserInstance[]>) => any): Promise<ApiResponse<UserInstance[]>>;
/**
* Retrieve a single page of UserInstance 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 { UserListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: UserPage) => any): Promise<UserPage>;
page(params: UserListInstancePageOptions, callback?: (error: Error | null, items: UserPage) => any): Promise<UserPage>;
/**
* Retrieve a single page of UserInstance 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 { UserListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserPage>) => any): Promise<ApiResponse<UserPage>>;
pageWithHttpInfo(params: UserListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<UserPage>) => any): Promise<ApiResponse<UserPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function UserListInstance(version: V1, serviceSid: string): UserListInstance;
export declare class UserPage extends Page<V1, UserPayload, UserResource, UserInstance> {
/**
* Initialize the UserPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: UserSolution);
/**
* Build an instance of UserInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: UserResource): UserInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

474
node_modules/twilio/lib/rest/chat/v1/service/user.js generated vendored Normal file
View File

@@ -0,0 +1,474 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.UserPage = exports.UserInstance = exports.UserContextImpl = void 0;
exports.UserListInstance = UserListInstance;
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 userChannel_1 = require("./user/userChannel");
class UserContextImpl {
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}/Users/${sid}`;
}
get userChannels() {
this._userChannels =
this._userChannels ||
(0, userChannel_1.UserChannelListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._userChannels;
}
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 UserInstance(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 UserInstance(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["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
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 UserInstance(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["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
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 UserInstance(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.UserContextImpl = UserContextImpl;
class UserInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.attributes = payload.attributes;
this.friendlyName = payload.friendly_name;
this.roleSid = payload.role_sid;
this.identity = payload.identity;
this.isOnline = payload.is_online;
this.isNotifiable = payload.is_notifiable;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.joinedChannelsCount = deserialize.integer(payload.joined_channels_count);
this.links = payload.links;
this.url = payload.url;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new UserContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a UserInstance 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 UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance 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 userChannels.
*/
userChannels() {
return this._proxy.userChannels;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
attributes: this.attributes,
friendlyName: this.friendlyName,
roleSid: this.roleSid,
identity: this.identity,
isOnline: this.isOnline,
isNotifiable: this.isNotifiable,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
joinedChannelsCount: this.joinedChannelsCount,
links: this.links,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserInstance = UserInstance;
function UserListInstance(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 UserContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Users`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
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 UserInstance(operationVersion, payload, instance._solution.serviceSid));
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["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
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 UserInstance(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 UserPage(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 UserPage(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 UserPage(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 UserPage(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 UserPage extends Page_1.default {
/**
* Initialize the UserPage
*
* @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 UserInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new UserInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserPage = UserPage;

View File

@@ -0,0 +1,239 @@
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 status of the User on the Channel. Can be: `joined`, `invited`, or `not_participating`.
*/
export type UserChannelChannelStatus = "joined" | "invited" | "not_participating";
/**
* Options to pass to each
*/
export interface UserChannelListInstanceEachOptions {
/** 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: UserChannelInstance, 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 UserChannelListInstanceOptions {
/** 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 UserChannelListInstancePageOptions {
/** 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 UserChannelSolution {
serviceSid: string;
userSid: string;
}
export interface UserChannelListInstance {
_version: V1;
_solution: UserChannelSolution;
_uri: string;
/**
* Streams UserChannelInstance 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 { UserChannelListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: UserChannelInstance, done: (err?: Error) => void) => void): void;
each(params: UserChannelListInstanceEachOptions, callback?: (item: UserChannelInstance, done: (err?: Error) => void) => void): void;
/**
* Streams UserChannelInstance 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 { UserChannelListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: UserChannelInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: UserChannelListInstanceEachOptions, callback?: (item: UserChannelInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of UserChannelInstance 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: UserChannelPage) => any): Promise<UserChannelPage>;
/**
* Retrieve a single target page of UserChannelInstance 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<UserChannelPage>) => any): Promise<ApiResponse<UserChannelPage>>;
/**
* Lists UserChannelInstance 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 { UserChannelListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: UserChannelInstance[]) => any): Promise<UserChannelInstance[]>;
list(params: UserChannelListInstanceOptions, callback?: (error: Error | null, items: UserChannelInstance[]) => any): Promise<UserChannelInstance[]>;
/**
* Lists UserChannelInstance 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 { UserChannelListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserChannelInstance[]>) => any): Promise<ApiResponse<UserChannelInstance[]>>;
listWithHttpInfo(params: UserChannelListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<UserChannelInstance[]>) => any): Promise<ApiResponse<UserChannelInstance[]>>;
/**
* Retrieve a single page of UserChannelInstance 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 { UserChannelListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: UserChannelPage) => any): Promise<UserChannelPage>;
page(params: UserChannelListInstancePageOptions, callback?: (error: Error | null, items: UserChannelPage) => any): Promise<UserChannelPage>;
/**
* Retrieve a single page of UserChannelInstance 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 { UserChannelListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserChannelPage>) => any): Promise<ApiResponse<UserChannelPage>>;
pageWithHttpInfo(params: UserChannelListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<UserChannelPage>) => any): Promise<ApiResponse<UserChannelPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function UserChannelListInstance(version: V1, serviceSid: string, userSid: string): UserChannelListInstance;
interface UserChannelPayload extends TwilioResponsePayload {
channels: UserChannelResource[];
}
interface UserChannelResource {
account_sid: string;
service_sid: string;
channel_sid: string;
member_sid: string;
status: UserChannelChannelStatus;
last_consumed_message_index: number;
unread_messages_count: number;
links: Record<string, string>;
}
export declare class UserChannelInstance {
protected _version: V1;
constructor(_version: V1, payload: UserChannelResource, serviceSid: string, userSid: string);
/**
* The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the User Channel resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/api/chat/rest/services) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/api/chat/rest/channels) the resource belongs to.
*/
channelSid: string;
/**
* The SID of a [Member](https://www.twilio.com/docs/api/chat/rest/members) that represents the User on the Channel.
*/
memberSid: string;
status: UserChannelChannelStatus;
/**
* The index of the last [Message](https://www.twilio.com/docs/api/chat/rest/messages) in the [Channel](https://www.twilio.com/docs/api/chat/rest/channels) that the Member has read.
*/
lastConsumedMessageIndex: number;
/**
* The number of unread Messages in the Channel for the User. Note that retrieving messages on a client endpoint does not mean that messages are consumed or read. See [Consumption Horizon feature](/docs/api/chat/guides/consumption-horizon) to learn how to mark messages as consumed.
*/
unreadMessagesCount: number;
/**
* The absolute URLs of the [Members](https://www.twilio.com/docs/chat/api/members), [Messages](https://www.twilio.com/docs/chat/api/messages) , [Invites](https://www.twilio.com/docs/chat/api/invites) and, if it exists, the last [Message](https://www.twilio.com/docs/chat/api/messages) for the Channel.
*/
links: Record<string, string>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
accountSid: string;
serviceSid: string;
channelSid: string;
memberSid: string;
status: UserChannelChannelStatus;
lastConsumedMessageIndex: number;
unreadMessagesCount: number;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export declare class UserChannelPage extends Page<V1, UserChannelPayload, UserChannelResource, UserChannelInstance> {
/**
* Initialize the UserChannelPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: UserChannelSolution);
/**
* Build an instance of UserChannelInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: UserChannelResource): UserChannelInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,188 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.UserChannelPage = exports.UserChannelInstance = void 0;
exports.UserChannelListInstance = UserChannelListInstance;
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");
function UserChannelListInstance(version, serviceSid, userSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(userSid)) {
throw new Error("Parameter 'userSid' is not valid.");
}
const instance = {};
instance._version = version;
instance._solution = { serviceSid, userSid };
instance._uri = `/Services/${serviceSid}/Users/${userSid}/Channels`;
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 UserChannelPage(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 UserChannelPage(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 UserChannelPage(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 UserChannelPage(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 UserChannelInstance {
constructor(_version, payload, serviceSid, userSid) {
this._version = _version;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.channelSid = payload.channel_sid;
this.memberSid = payload.member_sid;
this.status = payload.status;
this.lastConsumedMessageIndex = deserialize.integer(payload.last_consumed_message_index);
this.unreadMessagesCount = deserialize.integer(payload.unread_messages_count);
this.links = payload.links;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
accountSid: this.accountSid,
serviceSid: this.serviceSid,
channelSid: this.channelSid,
memberSid: this.memberSid,
status: this.status,
lastConsumedMessageIndex: this.lastConsumedMessageIndex,
unreadMessagesCount: this.unreadMessagesCount,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserChannelInstance = UserChannelInstance;
class UserChannelPage extends Page_1.default {
/**
* Initialize the UserChannelPage
*
* @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 UserChannelInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new UserChannelInstance(this._version, payload, this._solution.serviceSid, this._solution.userSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserChannelPage = UserChannelPage;

457
node_modules/twilio/lib/rest/chat/v2/credential.d.ts generated vendored Normal file
View File

@@ -0,0 +1,457 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../base/Page";
import Response from "../../../http/response";
import V2 from "../V2";
import { ApiResponse } from "../../../base/ApiResponse";
/**
* The type of push-notification service the credential is for. Can be: `gcm`, `fcm`, or `apn`.
*/
export type CredentialPushService = "gcm" | "apn" | "fcm";
/**
* Options to pass to update a CredentialInstance
*/
export interface CredentialContextUpdateOptions {
/** A descriptive string that you create to describe the resource. It can be up to 64 characters long. */
friendlyName?: string;
/** [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----` */
certificate?: string;
/** [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----` */
privateKey?: string;
/** [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. */
sandbox?: boolean;
/** [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. */
apiKey?: string;
/** [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. */
secret?: string;
}
/**
* Options to pass to create a CredentialInstance
*/
export interface CredentialListInstanceCreateOptions {
/** */
type: CredentialPushService;
/** A descriptive string that you create to describe the new resource. It can be up to 64 characters long. */
friendlyName?: string;
/** [APN only] The URL encoded representation of the certificate. For example, `-----BEGIN CERTIFICATE----- MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A== -----END CERTIFICATE-----` */
certificate?: string;
/** [APN only] The URL encoded representation of the private key. For example, `-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG... -----END RSA PRIVATE KEY-----` */
privateKey?: string;
/** [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production. */
sandbox?: boolean;
/** [GCM only] The API key for the project that was obtained from the Google Developer console for your GCM Service application credential. */
apiKey?: string;
/** [FCM only] The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging. */
secret?: string;
}
/**
* Options to pass to each
*/
export interface CredentialListInstanceEachOptions {
/** 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: CredentialInstance, 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 CredentialListInstanceOptions {
/** 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 CredentialListInstancePageOptions {
/** 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 CredentialContext {
/**
* Remove a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a CredentialInstance 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 CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
fetch(callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Fetch a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Update a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
update(callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Update a CredentialInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
update(params: CredentialContextUpdateOptions, callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Update a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Update a CredentialInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
updateWithHttpInfo(params: CredentialContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface CredentialContextSolution {
sid: string;
}
export declare class CredentialContextImpl implements CredentialContext {
protected _version: V2;
protected _solution: CredentialContextSolution;
protected _uri: string;
constructor(_version: V2, 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?: CredentialInstance) => any): Promise<CredentialInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
update(params?: CredentialContextUpdateOptions | ((error: Error | null, item?: CredentialInstance) => any), callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
updateWithHttpInfo(params?: CredentialContextUpdateOptions | ((error: Error | null, item?: ApiResponse<CredentialInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): CredentialContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface CredentialPayload extends TwilioResponsePayload {
credentials: CredentialResource[];
}
interface CredentialResource {
sid: string;
account_sid: string;
friendly_name: string;
type: CredentialPushService;
sandbox: string;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class CredentialInstance {
protected _version: V2;
protected _solution: CredentialContextSolution;
protected _context?: CredentialContext;
constructor(_version: V2, payload: CredentialResource, sid?: string);
/**
* The unique string that we created to identify the Credential resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Credential resource.
*/
accountSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
type: CredentialPushService;
/**
* [APN only] Whether to send the credential to sandbox APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
*/
sandbox: string;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The absolute URL of the Credential resource.
*/
url: string;
private get _proxy();
/**
* Remove a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a CredentialInstance 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 CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
fetch(callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Fetch a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Update a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
update(callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Update a CredentialInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
update(params: CredentialContextUpdateOptions, callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Update a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Update a CredentialInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
updateWithHttpInfo(params: CredentialContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
friendlyName: string;
type: CredentialPushService;
sandbox: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface CredentialSolution {
}
export interface CredentialListInstance {
_version: V2;
_solution: CredentialSolution;
_uri: string;
(sid: string): CredentialContext;
get(sid: string): CredentialContext;
/**
* Create a CredentialInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
create(params: CredentialListInstanceCreateOptions, callback?: (error: Error | null, item?: CredentialInstance) => any): Promise<CredentialInstance>;
/**
* Create a CredentialInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance with HTTP metadata
*/
createWithHttpInfo(params: CredentialListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<CredentialInstance>) => any): Promise<ApiResponse<CredentialInstance>>;
/**
* Streams CredentialInstance 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 { CredentialListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: CredentialInstance, done: (err?: Error) => void) => void): void;
each(params: CredentialListInstanceEachOptions, callback?: (item: CredentialInstance, done: (err?: Error) => void) => void): void;
/**
* Streams CredentialInstance 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 { CredentialListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: CredentialInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: CredentialListInstanceEachOptions, callback?: (item: CredentialInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of CredentialInstance 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: CredentialPage) => any): Promise<CredentialPage>;
/**
* Retrieve a single target page of CredentialInstance 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<CredentialPage>) => any): Promise<ApiResponse<CredentialPage>>;
/**
* Lists CredentialInstance 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 { CredentialListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: CredentialInstance[]) => any): Promise<CredentialInstance[]>;
list(params: CredentialListInstanceOptions, callback?: (error: Error | null, items: CredentialInstance[]) => any): Promise<CredentialInstance[]>;
/**
* Lists CredentialInstance 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 { CredentialListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<CredentialInstance[]>) => any): Promise<ApiResponse<CredentialInstance[]>>;
listWithHttpInfo(params: CredentialListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<CredentialInstance[]>) => any): Promise<ApiResponse<CredentialInstance[]>>;
/**
* Retrieve a single page of CredentialInstance 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 { CredentialListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: CredentialPage) => any): Promise<CredentialPage>;
page(params: CredentialListInstancePageOptions, callback?: (error: Error | null, items: CredentialPage) => any): Promise<CredentialPage>;
/**
* Retrieve a single page of CredentialInstance 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 { CredentialListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<CredentialPage>) => any): Promise<ApiResponse<CredentialPage>>;
pageWithHttpInfo(params: CredentialListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<CredentialPage>) => any): Promise<ApiResponse<CredentialPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function CredentialListInstance(version: V2): CredentialListInstance;
export declare class CredentialPage extends Page<V2, CredentialPayload, CredentialResource, CredentialInstance> {
/**
* Initialize the CredentialPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: CredentialSolution);
/**
* Build an instance of CredentialInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: CredentialResource): CredentialInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

467
node_modules/twilio/lib/rest/chat/v2/credential.js generated vendored Normal file
View File

@@ -0,0 +1,467 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.CredentialPage = exports.CredentialInstance = exports.CredentialContextImpl = void 0;
exports.CredentialListInstance = CredentialListInstance;
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 CredentialContextImpl {
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 = `/Credentials/${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 CredentialInstance(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 CredentialInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["certificate"] !== undefined)
data["Certificate"] = params["certificate"];
if (params["privateKey"] !== undefined)
data["PrivateKey"] = params["privateKey"];
if (params["sandbox"] !== undefined)
data["Sandbox"] = serialize.bool(params["sandbox"]);
if (params["apiKey"] !== undefined)
data["ApiKey"] = params["apiKey"];
if (params["secret"] !== undefined)
data["Secret"] = params["secret"];
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 CredentialInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["certificate"] !== undefined)
data["Certificate"] = params["certificate"];
if (params["privateKey"] !== undefined)
data["PrivateKey"] = params["privateKey"];
if (params["sandbox"] !== undefined)
data["Sandbox"] = serialize.bool(params["sandbox"]);
if (params["apiKey"] !== undefined)
data["ApiKey"] = params["apiKey"];
if (params["secret"] !== undefined)
data["Secret"] = params["secret"];
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 CredentialInstance(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.CredentialContextImpl = CredentialContextImpl;
class CredentialInstance {
constructor(_version, payload, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.type = payload.type;
this.sandbox = payload.sandbox;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = { sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new CredentialContextImpl(this._version, this._solution.sid);
return this._context;
}
/**
* Remove a CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a CredentialInstance 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 CredentialInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a CredentialInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed CredentialInstance 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,
friendlyName: this.friendlyName,
type: this.type,
sandbox: this.sandbox,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.CredentialInstance = CredentialInstance;
function CredentialListInstance(version) {
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new CredentialContextImpl(version, sid);
};
instance._version = version;
instance._solution = {};
instance._uri = `/Credentials`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
let data = {};
data["Type"] = params["type"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["certificate"] !== undefined)
data["Certificate"] = params["certificate"];
if (params["privateKey"] !== undefined)
data["PrivateKey"] = params["privateKey"];
if (params["sandbox"] !== undefined)
data["Sandbox"] = serialize.bool(params["sandbox"]);
if (params["apiKey"] !== undefined)
data["ApiKey"] = params["apiKey"];
if (params["secret"] !== undefined)
data["Secret"] = params["secret"];
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 CredentialInstance(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["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
let data = {};
data["Type"] = params["type"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["certificate"] !== undefined)
data["Certificate"] = params["certificate"];
if (params["privateKey"] !== undefined)
data["PrivateKey"] = params["privateKey"];
if (params["sandbox"] !== undefined)
data["Sandbox"] = serialize.bool(params["sandbox"]);
if (params["apiKey"] !== undefined)
data["ApiKey"] = params["apiKey"];
if (params["secret"] !== undefined)
data["Secret"] = params["secret"];
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 CredentialInstance(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 CredentialPage(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 CredentialPage(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 CredentialPage(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 CredentialPage(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 CredentialPage extends Page_1.default {
/**
* Initialize the CredentialPage
*
* @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 CredentialInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new CredentialInstance(this._version, payload);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.CredentialPage = CredentialPage;

616
node_modules/twilio/lib/rest/chat/v2/service.d.ts generated vendored Normal file
View File

@@ -0,0 +1,616 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../base/Page";
import Response from "../../../http/response";
import V2 from "../V2";
import { ApiResponse } from "../../../base/ApiResponse";
import { BindingListInstance } from "./service/binding";
import { ChannelListInstance } from "./service/channel";
import { RoleListInstance } from "./service/role";
import { UserListInstance } from "./service/user";
/**
* Options to pass to update a ServiceInstance
*/
export interface ServiceContextUpdateOptions {
/** A descriptive string that you create to describe the resource. */
friendlyName?: string;
/** The service role assigned to users when they are added to the service. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles. */
defaultServiceRoleSid?: string;
/** The channel role assigned to users when they are added to a channel. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles. */
defaultChannelRoleSid?: string;
/** The channel role assigned to a channel creator when they join a new channel. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles. */
defaultChannelCreatorRoleSid?: string;
/** Whether to enable the [Message Consumption Horizon](https://www.twilio.com/docs/chat/consumption-horizon) feature. The default is `true`. */
readStatusEnabled?: boolean;
/** Whether to enable the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) for this Service instance. The default is `false`. */
reachabilityEnabled?: boolean;
/** How long in seconds after a `started typing` event until clients should assume that user is no longer typing, even if no `ended typing` message was received. The default is 5 seconds. */
typingIndicatorTimeout?: number;
/** DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints. */
consumptionReportInterval?: number;
/** Whether to send a notification when a new message is added to a channel. The default is `false`. */
"notifications.newMessage.enabled"?: boolean;
/** The template to use to create the notification text displayed when a new message is added to a channel and `notifications.new_message.enabled` is `true`. */
"notifications.newMessage.template"?: string;
/** The name of the sound to play when a new message is added to a channel and `notifications.new_message.enabled` is `true`. */
"notifications.newMessage.sound"?: string;
/** Whether the new message badge is enabled. The default is `false`. */
"notifications.newMessage.badgeCountEnabled"?: boolean;
/** Whether to send a notification when a member is added to a channel. The default is `false`. */
"notifications.addedToChannel.enabled"?: boolean;
/** The template to use to create the notification text displayed when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`. */
"notifications.addedToChannel.template"?: string;
/** The name of the sound to play when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`. */
"notifications.addedToChannel.sound"?: string;
/** Whether to send a notification to a user when they are removed from a channel. The default is `false`. */
"notifications.removedFromChannel.enabled"?: boolean;
/** The template to use to create the notification text displayed to a user when they are removed from a channel and `notifications.removed_from_channel.enabled` is `true`. */
"notifications.removedFromChannel.template"?: string;
/** The name of the sound to play to a user when they are removed from a channel and `notifications.removed_from_channel.enabled` is `true`. */
"notifications.removedFromChannel.sound"?: string;
/** Whether to send a notification when a user is invited to a channel. The default is `false`. */
"notifications.invitedToChannel.enabled"?: boolean;
/** The template to use to create the notification text displayed when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`. */
"notifications.invitedToChannel.template"?: string;
/** The name of the sound to play when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`. */
"notifications.invitedToChannel.sound"?: string;
/** The URL for pre-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. */
preWebhookUrl?: string;
/** The URL for post-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. */
postWebhookUrl?: string;
/** The HTTP method to use for calls to the `pre_webhook_url` and `post_webhook_url` webhooks. Can be: `POST` or `GET` and the default is `POST`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. */
webhookMethod?: string;
/** The list of webhook events that are enabled for this Service instance. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details. */
webhookFilters?: Array<string>;
/** The maximum number of Members that can be added to Channels within this Service. Can be up to 1,000. */
"limits.channelMembers"?: number;
/** The maximum number of Channels Users can be a Member of within this Service. Can be up to 1,000. */
"limits.userChannels"?: number;
/** The message to send when a media message has no text. Can be used as placeholder message. */
"media.compatibilityMessage"?: string;
/** The number of times to retry a call to the `pre_webhook_url` if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. Default retry count is 0 times, which means the call won\\\'t be retried. */
preWebhookRetryCount?: number;
/** The number of times to retry a call to the `post_webhook_url` if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. The default is 0, which means the call won\\\'t be retried. */
postWebhookRetryCount?: number;
/** Whether to log notifications. The default is `false`. */
"notifications.logEnabled"?: boolean;
}
/**
* Options to pass to create a ServiceInstance
*/
export interface ServiceListInstanceCreateOptions {
/** A descriptive string that you create to describe the new resource. */
friendlyName: 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 100. */
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 100. */
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 100. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface ServiceContext {
bindings: BindingListInstance;
channels: ChannelListInstance;
roles: RoleListInstance;
users: UserListInstance;
/**
* 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: V2;
protected _solution: ServiceContextSolution;
protected _uri: string;
protected _bindings?: BindingListInstance;
protected _channels?: ChannelListInstance;
protected _roles?: RoleListInstance;
protected _users?: UserListInstance;
constructor(_version: V2, sid: string);
get bindings(): BindingListInstance;
get channels(): ChannelListInstance;
get roles(): RoleListInstance;
get users(): UserListInstance;
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;
account_sid: string;
friendly_name: string;
date_created: Date;
date_updated: Date;
default_service_role_sid: string;
default_channel_role_sid: string;
default_channel_creator_role_sid: string;
read_status_enabled: boolean;
reachability_enabled: boolean;
typing_indicator_timeout: number;
consumption_report_interval: number;
limits: any;
pre_webhook_url: string;
post_webhook_url: string;
webhook_method: string;
webhook_filters: Array<string>;
pre_webhook_retry_count: number;
post_webhook_retry_count: number;
notifications: any;
media: any;
url: string;
links: Record<string, string>;
}
export declare class ServiceInstance {
protected _version: V2;
protected _solution: ServiceContextSolution;
protected _context?: ServiceContext;
constructor(_version: V2, payload: ServiceResource, sid?: string);
/**
* The unique string that we created to identify the Service resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
*/
accountSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The service role assigned to users when they are added to the service. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles.
*/
defaultServiceRoleSid: string;
/**
* The channel role assigned to users when they are added to a channel. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles.
*/
defaultChannelRoleSid: string;
/**
* The channel role assigned to a channel creator when they join a new channel. See the [Role resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info about roles.
*/
defaultChannelCreatorRoleSid: string;
/**
* Whether the [Message Consumption Horizon](https://www.twilio.com/docs/chat/consumption-horizon) feature is enabled. The default is `true`.
*/
readStatusEnabled: boolean;
/**
* Whether the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) is enabled for this Service instance. The default is `false`.
*/
reachabilityEnabled: boolean;
/**
* How long in seconds after a `started typing` event until clients should assume that user is no longer typing, even if no `ended typing` message was received. The default is 5 seconds.
*/
typingIndicatorTimeout: number;
/**
* DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints.
*/
consumptionReportInterval: number;
/**
* An object that describes the limits of the service instance. The `limits` object contains `channel_members` to describe the members/channel limit and `user_channels` to describe the channels/user limit. `channel_members` can be 1,000 or less, with a default of 250. `user_channels` can be 1,000 or less, with a default value of 100.
*/
limits: any;
/**
* The URL for pre-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
*/
preWebhookUrl: string;
/**
* The URL for post-event webhooks, which are called by using the `webhook_method`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
*/
postWebhookUrl: string;
/**
* The HTTP method to use for calls to the `pre_webhook_url` and `post_webhook_url` webhooks. Can be: `POST` or `GET` and the default is `POST`. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
*/
webhookMethod: string;
/**
* The list of webhook events that are enabled for this Service instance. See [Webhook Events](https://www.twilio.com/docs/chat/webhook-events) for more details.
*/
webhookFilters: Array<string>;
/**
* The number of times to retry a call to the `pre_webhook_url` if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. Default retry count is 0 times, which means the call won\'t be retried.
*/
preWebhookRetryCount: number;
/**
* The number of times to retry a call to the `post_webhook_url` if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. The default is 0, which means the call won\'t be retried.
*/
postWebhookRetryCount: number;
/**
* The notification configuration for the Service instance. See [Push Notification Configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
*/
notifications: any;
/**
* An object that describes the properties of media that the service supports. The object contains the `size_limit_mb` property, which describes the size of the largest media file in MB; and the `compatibility_message` property, which contains the message text to send when a media message does not have any text.
*/
media: any;
/**
* The absolute URL of the Service resource.
*/
url: string;
/**
* The absolute URLs of the Service\'s [Channels](https://www.twilio.com/docs/chat/channels), [Roles](https://www.twilio.com/docs/chat/rest/role-resource), [Bindings](https://www.twilio.com/docs/chat/rest/binding-resource), and [Users](https://www.twilio.com/docs/chat/rest/user-resource).
*/
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 bindings.
*/
bindings(): BindingListInstance;
/**
* Access the channels.
*/
channels(): ChannelListInstance;
/**
* Access the roles.
*/
roles(): RoleListInstance;
/**
* Access the users.
*/
users(): UserListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
friendlyName: string;
dateCreated: Date;
dateUpdated: Date;
defaultServiceRoleSid: string;
defaultChannelRoleSid: string;
defaultChannelCreatorRoleSid: string;
readStatusEnabled: boolean;
reachabilityEnabled: boolean;
typingIndicatorTimeout: number;
consumptionReportInterval: number;
limits: any;
preWebhookUrl: string;
postWebhookUrl: string;
webhookMethod: string;
webhookFilters: string[];
preWebhookRetryCount: number;
postWebhookRetryCount: number;
notifications: any;
media: any;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface ServiceSolution {
}
export interface ServiceListInstance {
_version: V2;
_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: V2): ServiceListInstance;
export declare class ServicePage extends Page<V2, ServicePayload, ServiceResource, ServiceInstance> {
/**
* Initialize the ServicePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, 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 {};

642
node_modules/twilio/lib/rest/chat/v2/service.js generated vendored Normal file
View File

@@ -0,0 +1,642 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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 binding_1 = require("./service/binding");
const channel_1 = require("./service/channel");
const role_1 = require("./service/role");
const user_1 = require("./service/user");
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 bindings() {
this._bindings =
this._bindings || (0, binding_1.BindingListInstance)(this._version, this._solution.sid);
return this._bindings;
}
get channels() {
this._channels =
this._channels || (0, channel_1.ChannelListInstance)(this._version, this._solution.sid);
return this._channels;
}
get roles() {
this._roles =
this._roles || (0, role_1.RoleListInstance)(this._version, this._solution.sid);
return this._roles;
}
get users() {
this._users =
this._users || (0, user_1.UserListInstance)(this._version, this._solution.sid);
return this._users;
}
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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["defaultServiceRoleSid"] !== undefined)
data["DefaultServiceRoleSid"] = params["defaultServiceRoleSid"];
if (params["defaultChannelRoleSid"] !== undefined)
data["DefaultChannelRoleSid"] = params["defaultChannelRoleSid"];
if (params["defaultChannelCreatorRoleSid"] !== undefined)
data["DefaultChannelCreatorRoleSid"] =
params["defaultChannelCreatorRoleSid"];
if (params["readStatusEnabled"] !== undefined)
data["ReadStatusEnabled"] = serialize.bool(params["readStatusEnabled"]);
if (params["reachabilityEnabled"] !== undefined)
data["ReachabilityEnabled"] = serialize.bool(params["reachabilityEnabled"]);
if (params["typingIndicatorTimeout"] !== undefined)
data["TypingIndicatorTimeout"] = params["typingIndicatorTimeout"];
if (params["consumptionReportInterval"] !== undefined)
data["ConsumptionReportInterval"] = params["consumptionReportInterval"];
if (params["notifications.newMessage.enabled"] !== undefined)
data["Notifications.NewMessage.Enabled"] = serialize.bool(params["notifications.newMessage.enabled"]);
if (params["notifications.newMessage.template"] !== undefined)
data["Notifications.NewMessage.Template"] =
params["notifications.newMessage.template"];
if (params["notifications.newMessage.sound"] !== undefined)
data["Notifications.NewMessage.Sound"] =
params["notifications.newMessage.sound"];
if (params["notifications.newMessage.badgeCountEnabled"] !== undefined)
data["Notifications.NewMessage.BadgeCountEnabled"] = serialize.bool(params["notifications.newMessage.badgeCountEnabled"]);
if (params["notifications.addedToChannel.enabled"] !== undefined)
data["Notifications.AddedToChannel.Enabled"] = serialize.bool(params["notifications.addedToChannel.enabled"]);
if (params["notifications.addedToChannel.template"] !== undefined)
data["Notifications.AddedToChannel.Template"] =
params["notifications.addedToChannel.template"];
if (params["notifications.addedToChannel.sound"] !== undefined)
data["Notifications.AddedToChannel.Sound"] =
params["notifications.addedToChannel.sound"];
if (params["notifications.removedFromChannel.enabled"] !== undefined)
data["Notifications.RemovedFromChannel.Enabled"] = serialize.bool(params["notifications.removedFromChannel.enabled"]);
if (params["notifications.removedFromChannel.template"] !== undefined)
data["Notifications.RemovedFromChannel.Template"] =
params["notifications.removedFromChannel.template"];
if (params["notifications.removedFromChannel.sound"] !== undefined)
data["Notifications.RemovedFromChannel.Sound"] =
params["notifications.removedFromChannel.sound"];
if (params["notifications.invitedToChannel.enabled"] !== undefined)
data["Notifications.InvitedToChannel.Enabled"] = serialize.bool(params["notifications.invitedToChannel.enabled"]);
if (params["notifications.invitedToChannel.template"] !== undefined)
data["Notifications.InvitedToChannel.Template"] =
params["notifications.invitedToChannel.template"];
if (params["notifications.invitedToChannel.sound"] !== undefined)
data["Notifications.InvitedToChannel.Sound"] =
params["notifications.invitedToChannel.sound"];
if (params["preWebhookUrl"] !== undefined)
data["PreWebhookUrl"] = params["preWebhookUrl"];
if (params["postWebhookUrl"] !== undefined)
data["PostWebhookUrl"] = params["postWebhookUrl"];
if (params["webhookMethod"] !== undefined)
data["WebhookMethod"] = params["webhookMethod"];
if (params["webhookFilters"] !== undefined)
data["WebhookFilters"] = serialize.map(params["webhookFilters"], (e) => e);
if (params["limits.channelMembers"] !== undefined)
data["Limits.ChannelMembers"] = params["limits.channelMembers"];
if (params["limits.userChannels"] !== undefined)
data["Limits.UserChannels"] = params["limits.userChannels"];
if (params["media.compatibilityMessage"] !== undefined)
data["Media.CompatibilityMessage"] = params["media.compatibilityMessage"];
if (params["preWebhookRetryCount"] !== undefined)
data["PreWebhookRetryCount"] = params["preWebhookRetryCount"];
if (params["postWebhookRetryCount"] !== undefined)
data["PostWebhookRetryCount"] = params["postWebhookRetryCount"];
if (params["notifications.logEnabled"] !== undefined)
data["Notifications.LogEnabled"] = serialize.bool(params["notifications.logEnabled"]);
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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["defaultServiceRoleSid"] !== undefined)
data["DefaultServiceRoleSid"] = params["defaultServiceRoleSid"];
if (params["defaultChannelRoleSid"] !== undefined)
data["DefaultChannelRoleSid"] = params["defaultChannelRoleSid"];
if (params["defaultChannelCreatorRoleSid"] !== undefined)
data["DefaultChannelCreatorRoleSid"] =
params["defaultChannelCreatorRoleSid"];
if (params["readStatusEnabled"] !== undefined)
data["ReadStatusEnabled"] = serialize.bool(params["readStatusEnabled"]);
if (params["reachabilityEnabled"] !== undefined)
data["ReachabilityEnabled"] = serialize.bool(params["reachabilityEnabled"]);
if (params["typingIndicatorTimeout"] !== undefined)
data["TypingIndicatorTimeout"] = params["typingIndicatorTimeout"];
if (params["consumptionReportInterval"] !== undefined)
data["ConsumptionReportInterval"] = params["consumptionReportInterval"];
if (params["notifications.newMessage.enabled"] !== undefined)
data["Notifications.NewMessage.Enabled"] = serialize.bool(params["notifications.newMessage.enabled"]);
if (params["notifications.newMessage.template"] !== undefined)
data["Notifications.NewMessage.Template"] =
params["notifications.newMessage.template"];
if (params["notifications.newMessage.sound"] !== undefined)
data["Notifications.NewMessage.Sound"] =
params["notifications.newMessage.sound"];
if (params["notifications.newMessage.badgeCountEnabled"] !== undefined)
data["Notifications.NewMessage.BadgeCountEnabled"] = serialize.bool(params["notifications.newMessage.badgeCountEnabled"]);
if (params["notifications.addedToChannel.enabled"] !== undefined)
data["Notifications.AddedToChannel.Enabled"] = serialize.bool(params["notifications.addedToChannel.enabled"]);
if (params["notifications.addedToChannel.template"] !== undefined)
data["Notifications.AddedToChannel.Template"] =
params["notifications.addedToChannel.template"];
if (params["notifications.addedToChannel.sound"] !== undefined)
data["Notifications.AddedToChannel.Sound"] =
params["notifications.addedToChannel.sound"];
if (params["notifications.removedFromChannel.enabled"] !== undefined)
data["Notifications.RemovedFromChannel.Enabled"] = serialize.bool(params["notifications.removedFromChannel.enabled"]);
if (params["notifications.removedFromChannel.template"] !== undefined)
data["Notifications.RemovedFromChannel.Template"] =
params["notifications.removedFromChannel.template"];
if (params["notifications.removedFromChannel.sound"] !== undefined)
data["Notifications.RemovedFromChannel.Sound"] =
params["notifications.removedFromChannel.sound"];
if (params["notifications.invitedToChannel.enabled"] !== undefined)
data["Notifications.InvitedToChannel.Enabled"] = serialize.bool(params["notifications.invitedToChannel.enabled"]);
if (params["notifications.invitedToChannel.template"] !== undefined)
data["Notifications.InvitedToChannel.Template"] =
params["notifications.invitedToChannel.template"];
if (params["notifications.invitedToChannel.sound"] !== undefined)
data["Notifications.InvitedToChannel.Sound"] =
params["notifications.invitedToChannel.sound"];
if (params["preWebhookUrl"] !== undefined)
data["PreWebhookUrl"] = params["preWebhookUrl"];
if (params["postWebhookUrl"] !== undefined)
data["PostWebhookUrl"] = params["postWebhookUrl"];
if (params["webhookMethod"] !== undefined)
data["WebhookMethod"] = params["webhookMethod"];
if (params["webhookFilters"] !== undefined)
data["WebhookFilters"] = serialize.map(params["webhookFilters"], (e) => e);
if (params["limits.channelMembers"] !== undefined)
data["Limits.ChannelMembers"] = params["limits.channelMembers"];
if (params["limits.userChannels"] !== undefined)
data["Limits.UserChannels"] = params["limits.userChannels"];
if (params["media.compatibilityMessage"] !== undefined)
data["Media.CompatibilityMessage"] = params["media.compatibilityMessage"];
if (params["preWebhookRetryCount"] !== undefined)
data["PreWebhookRetryCount"] = params["preWebhookRetryCount"];
if (params["postWebhookRetryCount"] !== undefined)
data["PostWebhookRetryCount"] = params["postWebhookRetryCount"];
if (params["notifications.logEnabled"] !== undefined)
data["Notifications.LogEnabled"] = serialize.bool(params["notifications.logEnabled"]);
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.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.defaultServiceRoleSid = payload.default_service_role_sid;
this.defaultChannelRoleSid = payload.default_channel_role_sid;
this.defaultChannelCreatorRoleSid =
payload.default_channel_creator_role_sid;
this.readStatusEnabled = payload.read_status_enabled;
this.reachabilityEnabled = payload.reachability_enabled;
this.typingIndicatorTimeout = deserialize.integer(payload.typing_indicator_timeout);
this.consumptionReportInterval = deserialize.integer(payload.consumption_report_interval);
this.limits = payload.limits;
this.preWebhookUrl = payload.pre_webhook_url;
this.postWebhookUrl = payload.post_webhook_url;
this.webhookMethod = payload.webhook_method;
this.webhookFilters = payload.webhook_filters;
this.preWebhookRetryCount = deserialize.integer(payload.pre_webhook_retry_count);
this.postWebhookRetryCount = deserialize.integer(payload.post_webhook_retry_count);
this.notifications = payload.notifications;
this.media = payload.media;
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 bindings.
*/
bindings() {
return this._proxy.bindings;
}
/**
* Access the channels.
*/
channels() {
return this._proxy.channels;
}
/**
* Access the roles.
*/
roles() {
return this._proxy.roles;
}
/**
* Access the users.
*/
users() {
return this._proxy.users;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
friendlyName: this.friendlyName,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
defaultServiceRoleSid: this.defaultServiceRoleSid,
defaultChannelRoleSid: this.defaultChannelRoleSid,
defaultChannelCreatorRoleSid: this.defaultChannelCreatorRoleSid,
readStatusEnabled: this.readStatusEnabled,
reachabilityEnabled: this.reachabilityEnabled,
typingIndicatorTimeout: this.typingIndicatorTimeout,
consumptionReportInterval: this.consumptionReportInterval,
limits: this.limits,
preWebhookUrl: this.preWebhookUrl,
postWebhookUrl: this.postWebhookUrl,
webhookMethod: this.webhookMethod,
webhookFilters: this.webhookFilters,
preWebhookRetryCount: this.preWebhookRetryCount,
postWebhookRetryCount: this.postWebhookRetryCount,
notifications: this.notifications,
media: this.media,
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["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
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["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
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,371 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
/**
* The push technology to use for the Binding. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
*/
export type BindingBindingType = "gcm" | "apn" | "fcm";
/**
* Options to pass to each
*/
export interface BindingListInstanceEachOptions {
/** The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. */
bindingType?: Array<BindingBindingType>;
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: BindingInstance, 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 BindingListInstanceOptions {
/** The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. */
bindingType?: Array<BindingBindingType>;
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
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 BindingListInstancePageOptions {
/** The push technology used by the Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. */
bindingType?: Array<BindingBindingType>;
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface BindingContext {
/**
* Remove a BindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a BindingInstance 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 BindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BindingInstance
*/
fetch(callback?: (error: Error | null, item?: BindingInstance) => any): Promise<BindingInstance>;
/**
* Fetch a BindingInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BindingInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<BindingInstance>) => any): Promise<ApiResponse<BindingInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface BindingContextSolution {
serviceSid: string;
sid: string;
}
export declare class BindingContextImpl implements BindingContext {
protected _version: V2;
protected _solution: BindingContextSolution;
protected _uri: string;
constructor(_version: V2, 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?: BindingInstance) => any): Promise<BindingInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<BindingInstance>) => any): Promise<ApiResponse<BindingInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): BindingContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface BindingPayload extends TwilioResponsePayload {
bindings: BindingResource[];
}
interface BindingResource {
sid: string;
account_sid: string;
service_sid: string;
date_created: Date;
date_updated: Date;
endpoint: string;
identity: string;
credential_sid: string;
binding_type: BindingBindingType;
message_types: Array<string>;
url: string;
links: Record<string, string>;
}
export declare class BindingInstance {
protected _version: V2;
protected _solution: BindingContextSolution;
protected _context?: BindingContext;
constructor(_version: V2, payload: BindingResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Binding resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Binding resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the Binding resource is associated with.
*/
serviceSid: string;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The unique endpoint identifier for the Binding. The format of this value depends on the `binding_type`.
*/
endpoint: string;
/**
* The application-defined string that uniquely identifies the resource\'s [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info.
*/
identity: string;
/**
* The SID of the [Credential](https://www.twilio.com/docs/chat/rest/credential-resource) for the binding. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
*/
credentialSid: string;
bindingType: BindingBindingType;
/**
* The [Programmable Chat message types](https://www.twilio.com/docs/chat/push-notification-configuration#push-types) the binding is subscribed to.
*/
messageTypes: Array<string>;
/**
* The absolute URL of the Binding resource.
*/
url: string;
/**
* The absolute URLs of the Binding\'s [User](https://www.twilio.com/docs/chat/rest/user-resource).
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a BindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a BindingInstance 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 BindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BindingInstance
*/
fetch(callback?: (error: Error | null, item?: BindingInstance) => any): Promise<BindingInstance>;
/**
* Fetch a BindingInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BindingInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<BindingInstance>) => any): Promise<ApiResponse<BindingInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
dateCreated: Date;
dateUpdated: Date;
endpoint: string;
identity: string;
credentialSid: string;
bindingType: BindingBindingType;
messageTypes: string[];
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface BindingSolution {
serviceSid: string;
}
export interface BindingListInstance {
_version: V2;
_solution: BindingSolution;
_uri: string;
(sid: string): BindingContext;
get(sid: string): BindingContext;
/**
* Streams BindingInstance 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 { BindingListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: BindingInstance, done: (err?: Error) => void) => void): void;
each(params: BindingListInstanceEachOptions, callback?: (item: BindingInstance, done: (err?: Error) => void) => void): void;
/**
* Streams BindingInstance 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 { BindingListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: BindingInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: BindingListInstanceEachOptions, callback?: (item: BindingInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of BindingInstance 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: BindingPage) => any): Promise<BindingPage>;
/**
* Retrieve a single target page of BindingInstance 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<BindingPage>) => any): Promise<ApiResponse<BindingPage>>;
/**
* Lists BindingInstance 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 { BindingListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: BindingInstance[]) => any): Promise<BindingInstance[]>;
list(params: BindingListInstanceOptions, callback?: (error: Error | null, items: BindingInstance[]) => any): Promise<BindingInstance[]>;
/**
* Lists BindingInstance 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 { BindingListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<BindingInstance[]>) => any): Promise<ApiResponse<BindingInstance[]>>;
listWithHttpInfo(params: BindingListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<BindingInstance[]>) => any): Promise<ApiResponse<BindingInstance[]>>;
/**
* Retrieve a single page of BindingInstance 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 { BindingListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: BindingPage) => any): Promise<BindingPage>;
page(params: BindingListInstancePageOptions, callback?: (error: Error | null, items: BindingPage) => any): Promise<BindingPage>;
/**
* Retrieve a single page of BindingInstance 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 { BindingListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<BindingPage>) => any): Promise<ApiResponse<BindingPage>>;
pageWithHttpInfo(params: BindingListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<BindingPage>) => any): Promise<ApiResponse<BindingPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function BindingListInstance(version: V2, serviceSid: string): BindingListInstance;
export declare class BindingPage extends Page<V2, BindingPayload, BindingResource, BindingInstance> {
/**
* Initialize the BindingPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: BindingSolution);
/**
* Build an instance of BindingInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: BindingResource): BindingInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

333
node_modules/twilio/lib/rest/chat/v2/service/binding.js generated vendored Normal file
View File

@@ -0,0 +1,333 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.BindingPage = exports.BindingInstance = exports.BindingContextImpl = void 0;
exports.BindingListInstance = BindingListInstance;
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 BindingContextImpl {
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}/Bindings/${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 BindingInstance(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 BindingInstance(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.BindingContextImpl = BindingContextImpl;
class BindingInstance {
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.endpoint = payload.endpoint;
this.identity = payload.identity;
this.credentialSid = payload.credential_sid;
this.bindingType = payload.binding_type;
this.messageTypes = payload.message_types;
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new BindingContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a BindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a BindingInstance 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 BindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BindingInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a BindingInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BindingInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(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,
endpoint: this.endpoint,
identity: this.identity,
credentialSid: this.credentialSid,
bindingType: this.bindingType,
messageTypes: this.messageTypes,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.BindingInstance = BindingInstance;
function BindingListInstance(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 BindingContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Bindings`;
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["bindingType"] !== undefined)
data["BindingType"] = serialize.map(params["bindingType"], (e) => e);
if (params["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 BindingPage(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 BindingPage(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["bindingType"] !== undefined)
data["BindingType"] = serialize.map(params["bindingType"], (e) => e);
if (params["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 BindingPage(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 BindingPage(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 BindingPage extends Page_1.default {
/**
* Initialize the BindingPage
*
* @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 BindingInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new BindingInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.BindingPage = BindingPage;

View File

@@ -0,0 +1,597 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
import { InviteListInstance } from "./channel/invite";
import { MemberListInstance } from "./channel/member";
import { MessageListInstance } from "./channel/message";
import { WebhookListInstance } from "./channel/webhook";
/**
* The visibility of the channel. Can be: `public` or `private`.
*/
export type ChannelChannelType = "public" | "private";
export type ChannelWebhookEnabledType = "true" | "false";
/**
* Options to pass to remove a ChannelInstance
*/
export interface ChannelContextRemoveOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: ChannelWebhookEnabledType;
}
/**
* Options to pass to update a ChannelInstance
*/
export interface ChannelContextUpdateOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: ChannelWebhookEnabledType;
/** A descriptive string that you create to describe the resource. It can be up to 256 characters long. */
friendlyName?: string;
/** An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource\\\'s `sid` in the URL. This value must be 256 characters or less in length and unique within the Service. */
uniqueName?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this should only be used in cases where a Channel is being recreated from a backup/separate source. */
dateCreated?: Date;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. */
dateUpdated?: Date;
/** The `identity` of the User that created the channel. Default is: `system`. */
createdBy?: string;
}
/**
* Options to pass to create a ChannelInstance
*/
export interface ChannelListInstanceCreateOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: ChannelWebhookEnabledType;
/** A descriptive string that you create to describe the new resource. It can be up to 64 characters long. */
friendlyName?: string;
/** An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the Channel resource\\\'s `sid` in the URL. This value must be 64 characters or less in length and be unique within the Service. */
uniqueName?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** */
type?: ChannelChannelType;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this should only be used in cases where a Channel is being recreated from a backup/separate source. */
dateCreated?: Date;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. The default value is `null`. Note that this parameter should only be used in cases where a Channel is being recreated from a backup/separate source and where a Message was previously updated. */
dateUpdated?: Date;
/** The `identity` of the User that created the channel. Default is: `system`. */
createdBy?: string;
}
/**
* Options to pass to each
*/
export interface ChannelListInstanceEachOptions {
/** The visibility of the Channels to read. Can be: `public` or `private` and defaults to `public`. */
type?: Array<ChannelChannelType>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: ChannelInstance, 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 ChannelListInstanceOptions {
/** The visibility of the Channels to read. Can be: `public` or `private` and defaults to `public`. */
type?: Array<ChannelChannelType>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
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 ChannelListInstancePageOptions {
/** The visibility of the Channels to read. Can be: `public` or `private` and defaults to `public`. */
type?: Array<ChannelChannelType>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface ChannelContext {
invites: InviteListInstance;
members: MemberListInstance;
messages: MessageListInstance;
webhooks: WebhookListInstance;
/**
* Remove a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
remove(params: ChannelContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ChannelInstance 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>>;
/**
* Remove a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
removeWithHttpInfo(params: ChannelContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
fetch(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Fetch a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface ChannelContextSolution {
serviceSid: string;
sid: string;
}
export declare class ChannelContextImpl implements ChannelContext {
protected _version: V2;
protected _solution: ChannelContextSolution;
protected _uri: string;
protected _invites?: InviteListInstance;
protected _members?: MemberListInstance;
protected _messages?: MessageListInstance;
protected _webhooks?: WebhookListInstance;
constructor(_version: V2, serviceSid: string, sid: string);
get invites(): InviteListInstance;
get members(): MemberListInstance;
get messages(): MessageListInstance;
get webhooks(): WebhookListInstance;
remove(params?: ChannelContextRemoveOptions | ((error: Error | null, item?: boolean) => any), callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(params?: ChannelContextRemoveOptions | ((error: Error | null, item?: ApiResponse<boolean>) => any), callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
update(params?: ChannelContextUpdateOptions | ((error: Error | null, item?: ChannelInstance) => any), callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
updateWithHttpInfo(params?: ChannelContextUpdateOptions | ((error: Error | null, item?: ApiResponse<ChannelInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ChannelContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ChannelPayload extends TwilioResponsePayload {
channels: ChannelResource[];
}
interface ChannelResource {
sid: string;
account_sid: string;
service_sid: string;
friendly_name: string;
unique_name: string;
attributes: string;
type: ChannelChannelType;
date_created: Date;
date_updated: Date;
created_by: string;
members_count: number;
messages_count: number;
url: string;
links: Record<string, string>;
}
export declare class ChannelInstance {
protected _version: V2;
protected _solution: ChannelContextSolution;
protected _context?: ChannelContext;
constructor(_version: V2, payload: ChannelResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Channel resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Channel resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the Channel resource is associated with.
*/
serviceSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
/**
* An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource\'s `sid` in the URL.
*/
uniqueName: string;
/**
* The JSON string that stores application-specific data. If attributes have not been set, `{}` is returned.
*/
attributes: string;
type: ChannelChannelType;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The `identity` of the User that created the channel. If the Channel was created by using the API, the value is `system`.
*/
createdBy: string;
/**
* The number of Members in the Channel.
*/
membersCount: number;
/**
* The number of Messages that have been passed in the Channel.
*/
messagesCount: number;
/**
* The absolute URL of the Channel resource.
*/
url: string;
/**
* The absolute URLs of the [Members](https://www.twilio.com/docs/chat/rest/member-resource), [Messages](https://www.twilio.com/docs/chat/rest/message-resource), [Invites](https://www.twilio.com/docs/chat/rest/invite-resource), Webhooks and, if it exists, the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) for the Channel.
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
remove(params: ChannelContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ChannelInstance 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>>;
/**
* Remove a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
removeWithHttpInfo(params: ChannelContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
fetch(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Fetch a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Access the invites.
*/
invites(): InviteListInstance;
/**
* Access the members.
*/
members(): MemberListInstance;
/**
* Access the messages.
*/
messages(): MessageListInstance;
/**
* Access the webhooks.
*/
webhooks(): WebhookListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
friendlyName: string;
uniqueName: string;
attributes: string;
type: ChannelChannelType;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
membersCount: number;
messagesCount: number;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface ChannelSolution {
serviceSid: string;
}
export interface ChannelListInstance {
_version: V2;
_solution: ChannelSolution;
_uri: string;
(sid: string): ChannelContext;
get(sid: string): ChannelContext;
/**
* Create a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
create(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Create a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
create(params: ChannelListInstanceCreateOptions, callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Create a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Create a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
createWithHttpInfo(params: ChannelListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Streams ChannelInstance 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 { ChannelListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: ChannelInstance, done: (err?: Error) => void) => void): void;
each(params: ChannelListInstanceEachOptions, callback?: (item: ChannelInstance, done: (err?: Error) => void) => void): void;
/**
* Streams ChannelInstance 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 { ChannelListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: ChannelInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: ChannelListInstanceEachOptions, callback?: (item: ChannelInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of ChannelInstance 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: ChannelPage) => any): Promise<ChannelPage>;
/**
* Retrieve a single target page of ChannelInstance 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<ChannelPage>) => any): Promise<ApiResponse<ChannelPage>>;
/**
* Lists ChannelInstance 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 { ChannelListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: ChannelInstance[]) => any): Promise<ChannelInstance[]>;
list(params: ChannelListInstanceOptions, callback?: (error: Error | null, items: ChannelInstance[]) => any): Promise<ChannelInstance[]>;
/**
* Lists ChannelInstance 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 { ChannelListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ChannelInstance[]>) => any): Promise<ApiResponse<ChannelInstance[]>>;
listWithHttpInfo(params: ChannelListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<ChannelInstance[]>) => any): Promise<ApiResponse<ChannelInstance[]>>;
/**
* Retrieve a single page of ChannelInstance 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 { ChannelListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: ChannelPage) => any): Promise<ChannelPage>;
page(params: ChannelListInstancePageOptions, callback?: (error: Error | null, items: ChannelPage) => any): Promise<ChannelPage>;
/**
* Retrieve a single page of ChannelInstance 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 { ChannelListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ChannelPage>) => any): Promise<ApiResponse<ChannelPage>>;
pageWithHttpInfo(params: ChannelListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<ChannelPage>) => any): Promise<ApiResponse<ChannelPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function ChannelListInstance(version: V2, serviceSid: string): ChannelListInstance;
export declare class ChannelPage extends Page<V2, ChannelPayload, ChannelResource, ChannelInstance> {
/**
* Initialize the ChannelPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: ChannelSolution);
/**
* Build an instance of ChannelInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: ChannelResource): ChannelInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

565
node_modules/twilio/lib/rest/chat/v2/service/channel.js generated vendored Normal file
View File

@@ -0,0 +1,565 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.ChannelPage = exports.ChannelInstance = exports.ChannelContextImpl = void 0;
exports.ChannelListInstance = ChannelListInstance;
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 invite_1 = require("./channel/invite");
const member_1 = require("./channel/member");
const message_1 = require("./channel/message");
const webhook_1 = require("./channel/webhook");
class ChannelContextImpl {
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}/Channels/${sid}`;
}
get invites() {
this._invites =
this._invites ||
(0, invite_1.InviteListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._invites;
}
get members() {
this._members =
this._members ||
(0, member_1.MemberListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._members;
}
get messages() {
this._messages =
this._messages ||
(0, message_1.MessageListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._messages;
}
get webhooks() {
this._webhooks =
this._webhooks ||
(0, webhook_1.WebhookListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._webhooks;
}
remove(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
params: data,
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({
uri: instance._uri,
method: "delete",
params: data,
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 ChannelInstance(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 ChannelInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["createdBy"] !== undefined)
data["CreatedBy"] = params["createdBy"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ChannelInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["createdBy"] !== undefined)
data["CreatedBy"] = params["createdBy"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
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 ChannelInstance(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.ChannelContextImpl = ChannelContextImpl;
class ChannelInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.friendlyName = payload.friendly_name;
this.uniqueName = payload.unique_name;
this.attributes = payload.attributes;
this.type = payload.type;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this.membersCount = deserialize.integer(payload.members_count);
this.messagesCount = deserialize.integer(payload.messages_count);
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new ChannelContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
remove(params, callback) {
return this._proxy.remove(params, callback);
}
removeWithHttpInfo(params, callback) {
return this._proxy.removeWithHttpInfo(params, callback);
}
/**
* Fetch a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance 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 invites.
*/
invites() {
return this._proxy.invites;
}
/**
* Access the members.
*/
members() {
return this._proxy.members;
}
/**
* Access the messages.
*/
messages() {
return this._proxy.messages;
}
/**
* Access the webhooks.
*/
webhooks() {
return this._proxy.webhooks;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
friendlyName: this.friendlyName,
uniqueName: this.uniqueName,
attributes: this.attributes,
type: this.type,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
membersCount: this.membersCount,
messagesCount: this.messagesCount,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ChannelInstance = ChannelInstance;
function ChannelListInstance(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 ChannelContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Channels`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["type"] !== undefined)
data["Type"] = params["type"];
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["createdBy"] !== undefined)
data["CreatedBy"] = params["createdBy"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ChannelInstance(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["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["type"] !== undefined)
data["Type"] = params["type"];
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["createdBy"] !== undefined)
data["CreatedBy"] = params["createdBy"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ChannelInstance(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["type"] !== undefined)
data["Type"] = serialize.map(params["type"], (e) => e);
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 ChannelPage(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 ChannelPage(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["type"] !== undefined)
data["Type"] = serialize.map(params["type"], (e) => e);
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 ChannelPage(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 ChannelPage(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 ChannelPage extends Page_1.default {
/**
* Initialize the ChannelPage
*
* @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 ChannelInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new ChannelInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ChannelPage = ChannelPage;

View File

@@ -0,0 +1,381 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
/**
* Options to pass to create a InviteInstance
*/
export interface InviteListInstanceCreateOptions {
/** The `identity` value that uniquely identifies the new resource\\\'s [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info. */
identity: string;
/** The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) assigned to the new member. */
roleSid?: string;
}
/**
* Options to pass to each
*/
export interface InviteListInstanceEachOptions {
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: InviteInstance, 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 InviteListInstanceOptions {
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
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 InviteListInstancePageOptions {
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface InviteContext {
/**
* Remove a InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a InviteInstance 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 InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance
*/
fetch(callback?: (error: Error | null, item?: InviteInstance) => any): Promise<InviteInstance>;
/**
* Fetch a InviteInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InviteInstance>) => any): Promise<ApiResponse<InviteInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface InviteContextSolution {
serviceSid: string;
channelSid: string;
sid: string;
}
export declare class InviteContextImpl implements InviteContext {
protected _version: V2;
protected _solution: InviteContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, channelSid: 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?: InviteInstance) => any): Promise<InviteInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InviteInstance>) => any): Promise<ApiResponse<InviteInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): InviteContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface InvitePayload extends TwilioResponsePayload {
invites: InviteResource[];
}
interface InviteResource {
sid: string;
account_sid: string;
channel_sid: string;
service_sid: string;
identity: string;
date_created: Date;
date_updated: Date;
role_sid: string;
created_by: string;
url: string;
}
export declare class InviteInstance {
protected _version: V2;
protected _solution: InviteContextSolution;
protected _context?: InviteContext;
constructor(_version: V2, payload: InviteResource, serviceSid: string, channelSid: string, sid?: string);
/**
* The unique string that we created to identify the Invite resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Invite resource.
*/
accountSid: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/chat/channels) the Invite resource belongs to.
*/
channelSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the Invite resource is associated with.
*/
serviceSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info.
*/
identity: string;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) assigned to the resource.
*/
roleSid: string;
/**
* The `identity` of the User that created the invite.
*/
createdBy: string;
/**
* The absolute URL of the Invite resource.
*/
url: string;
private get _proxy();
/**
* Remove a InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a InviteInstance 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 InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance
*/
fetch(callback?: (error: Error | null, item?: InviteInstance) => any): Promise<InviteInstance>;
/**
* Fetch a InviteInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<InviteInstance>) => any): Promise<ApiResponse<InviteInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
channelSid: string;
serviceSid: string;
identity: string;
dateCreated: Date;
dateUpdated: Date;
roleSid: string;
createdBy: string;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface InviteSolution {
serviceSid: string;
channelSid: string;
}
export interface InviteListInstance {
_version: V2;
_solution: InviteSolution;
_uri: string;
(sid: string): InviteContext;
get(sid: string): InviteContext;
/**
* Create a InviteInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance
*/
create(params: InviteListInstanceCreateOptions, callback?: (error: Error | null, item?: InviteInstance) => any): Promise<InviteInstance>;
/**
* Create a InviteInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance with HTTP metadata
*/
createWithHttpInfo(params: InviteListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<InviteInstance>) => any): Promise<ApiResponse<InviteInstance>>;
/**
* Streams InviteInstance 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 { InviteListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: InviteInstance, done: (err?: Error) => void) => void): void;
each(params: InviteListInstanceEachOptions, callback?: (item: InviteInstance, done: (err?: Error) => void) => void): void;
/**
* Streams InviteInstance 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 { InviteListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: InviteInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: InviteListInstanceEachOptions, callback?: (item: InviteInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of InviteInstance 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: InvitePage) => any): Promise<InvitePage>;
/**
* Retrieve a single target page of InviteInstance 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<InvitePage>) => any): Promise<ApiResponse<InvitePage>>;
/**
* Lists InviteInstance 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 { InviteListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: InviteInstance[]) => any): Promise<InviteInstance[]>;
list(params: InviteListInstanceOptions, callback?: (error: Error | null, items: InviteInstance[]) => any): Promise<InviteInstance[]>;
/**
* Lists InviteInstance 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 { InviteListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<InviteInstance[]>) => any): Promise<ApiResponse<InviteInstance[]>>;
listWithHttpInfo(params: InviteListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<InviteInstance[]>) => any): Promise<ApiResponse<InviteInstance[]>>;
/**
* Retrieve a single page of InviteInstance 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 { InviteListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: InvitePage) => any): Promise<InvitePage>;
page(params: InviteListInstancePageOptions, callback?: (error: Error | null, items: InvitePage) => any): Promise<InvitePage>;
/**
* Retrieve a single page of InviteInstance 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 { InviteListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<InvitePage>) => any): Promise<ApiResponse<InvitePage>>;
pageWithHttpInfo(params: InviteListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<InvitePage>) => any): Promise<ApiResponse<InvitePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function InviteListInstance(version: V2, serviceSid: string, channelSid: string): InviteListInstance;
export declare class InvitePage extends Page<V2, InvitePayload, InviteResource, InviteInstance> {
/**
* Initialize the InvitePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: InviteSolution);
/**
* Build an instance of InviteInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: InviteResource): InviteInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,385 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.InvitePage = exports.InviteInstance = exports.InviteContextImpl = void 0;
exports.InviteListInstance = InviteListInstance;
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 InviteContextImpl {
constructor(_version, serviceSid, channelSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, channelSid, sid };
this._uri = `/Services/${serviceSid}/Channels/${channelSid}/Invites/${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 InviteInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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 InviteInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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.InviteContextImpl = InviteContextImpl;
class InviteInstance {
constructor(_version, payload, serviceSid, channelSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.channelSid = payload.channel_sid;
this.serviceSid = payload.service_sid;
this.identity = payload.identity;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.roleSid = payload.role_sid;
this.createdBy = payload.created_by;
this.url = payload.url;
this._solution = { serviceSid, channelSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new InviteContextImpl(this._version, this._solution.serviceSid, this._solution.channelSid, this._solution.sid);
return this._context;
}
/**
* Remove a InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a InviteInstance 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 InviteInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a InviteInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed InviteInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
channelSid: this.channelSid,
serviceSid: this.serviceSid,
identity: this.identity,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
roleSid: this.roleSid,
createdBy: this.createdBy,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.InviteInstance = InviteInstance;
function InviteListInstance(version, serviceSid, channelSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new InviteContextImpl(version, serviceSid, channelSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, channelSid };
instance._uri = `/Services/${serviceSid}/Channels/${channelSid}/Invites`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
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 InviteInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid));
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["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
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 InviteInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid),
}));
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["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 InvitePage(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 InvitePage(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["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 InvitePage(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 InvitePage(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 InvitePage extends Page_1.default {
/**
* Initialize the InvitePage
*
* @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 InviteInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new InviteInstance(this._version, payload, this._solution.serviceSid, this._solution.channelSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.InvitePage = InvitePage;

View File

@@ -0,0 +1,538 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
export type MemberWebhookEnabledType = "true" | "false";
/**
* Options to pass to remove a MemberInstance
*/
export interface MemberContextRemoveOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: MemberWebhookEnabledType;
}
/**
* Options to pass to update a MemberInstance
*/
export interface MemberContextUpdateOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: MemberWebhookEnabledType;
/** The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/rest/service-resource). */
roleSid?: string;
/** The index of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) that the Member has read within the [Channel](https://www.twilio.com/docs/chat/channels). */
lastConsumedMessageIndex?: number;
/** The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) read event for the Member within the [Channel](https://www.twilio.com/docs/chat/channels). */
lastConsumptionTimestamp?: Date;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this parameter should only be used when a Member is being recreated from a backup/separate source. */
dateCreated?: Date;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. */
dateUpdated?: Date;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
}
/**
* Options to pass to create a MemberInstance
*/
export interface MemberListInstanceCreateOptions {
/** The `identity` value that uniquely identifies the new resource\\\'s [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info. */
identity: string;
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: MemberWebhookEnabledType;
/** The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the member. The default roles are those specified on the [Service](https://www.twilio.com/docs/chat/rest/service-resource). */
roleSid?: string;
/** The index of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) in the [Channel](https://www.twilio.com/docs/chat/channels) that the Member has read. This parameter should only be used when recreating a Member from a backup/separate source. */
lastConsumedMessageIndex?: number;
/** The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) read event for the Member within the [Channel](https://www.twilio.com/docs/chat/channels). */
lastConsumptionTimestamp?: Date;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this parameter should only be used when a Member is being recreated from a backup/separate source. */
dateCreated?: Date;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. The default value is `null`. Note that this parameter should only be used when a Member is being recreated from a backup/separate source and where a Member was previously updated. */
dateUpdated?: Date;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
}
/**
* Options to pass to each
*/
export interface MemberListInstanceEachOptions {
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the Member resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: MemberInstance, 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 MemberListInstanceOptions {
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the Member resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
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 MemberListInstancePageOptions {
/** The [User](https://www.twilio.com/docs/chat/rest/user-resource)\'s `identity` value of the Member resources to read. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more details. */
identity?: Array<string>;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface MemberContext {
/**
* Remove a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MemberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
remove(params: MemberContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MemberInstance 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>>;
/**
* Remove a MemberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
removeWithHttpInfo(params: MemberContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
fetch(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Fetch a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Update a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
update(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Update a MemberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
update(params: MemberContextUpdateOptions, callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Update a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Update a MemberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
updateWithHttpInfo(params: MemberContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface MemberContextSolution {
serviceSid: string;
channelSid: string;
sid: string;
}
export declare class MemberContextImpl implements MemberContext {
protected _version: V2;
protected _solution: MemberContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, channelSid: string, sid: string);
remove(params?: MemberContextRemoveOptions | ((error: Error | null, item?: boolean) => any), callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(params?: MemberContextRemoveOptions | ((error: Error | null, item?: ApiResponse<boolean>) => any), callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
update(params?: MemberContextUpdateOptions | ((error: Error | null, item?: MemberInstance) => any), callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
updateWithHttpInfo(params?: MemberContextUpdateOptions | ((error: Error | null, item?: ApiResponse<MemberInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): MemberContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface MemberPayload extends TwilioResponsePayload {
members: MemberResource[];
}
interface MemberResource {
sid: string;
account_sid: string;
channel_sid: string;
service_sid: string;
identity: string;
date_created: Date;
date_updated: Date;
role_sid: string;
last_consumed_message_index: number;
last_consumption_timestamp: Date;
url: string;
attributes: string;
}
export declare class MemberInstance {
protected _version: V2;
protected _solution: MemberContextSolution;
protected _context?: MemberContext;
constructor(_version: V2, payload: MemberResource, serviceSid: string, channelSid: string, sid?: string);
/**
* The unique string that we created to identify the Member resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Member resource.
*/
accountSid: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/chat/channels) the Member resource belongs to.
*/
channelSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the Member resource is associated with.
*/
serviceSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info.
*/
identity: string;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) assigned to the member.
*/
roleSid: string;
/**
* The index of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) in the [Channel](https://www.twilio.com/docs/chat/channels) that the Member has read.
*/
lastConsumedMessageIndex: number;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) read event for the Member within the [Channel](https://www.twilio.com/docs/chat/channels).
*/
lastConsumptionTimestamp: Date;
/**
* The absolute URL of the Member resource.
*/
url: string;
/**
* The JSON string that stores application-specific data. If attributes have not been set, `{}` is returned.
*/
attributes: string;
private get _proxy();
/**
* Remove a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MemberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
remove(params: MemberContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MemberInstance 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>>;
/**
* Remove a MemberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
removeWithHttpInfo(params: MemberContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
fetch(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Fetch a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Update a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
update(callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Update a MemberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
update(params: MemberContextUpdateOptions, callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Update a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Update a MemberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
updateWithHttpInfo(params: MemberContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
channelSid: string;
serviceSid: string;
identity: string;
dateCreated: Date;
dateUpdated: Date;
roleSid: string;
lastConsumedMessageIndex: number;
lastConsumptionTimestamp: Date;
url: string;
attributes: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface MemberSolution {
serviceSid: string;
channelSid: string;
}
export interface MemberListInstance {
_version: V2;
_solution: MemberSolution;
_uri: string;
(sid: string): MemberContext;
get(sid: string): MemberContext;
/**
* Create a MemberInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
create(params: MemberListInstanceCreateOptions, callback?: (error: Error | null, item?: MemberInstance) => any): Promise<MemberInstance>;
/**
* Create a MemberInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance with HTTP metadata
*/
createWithHttpInfo(params: MemberListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<MemberInstance>) => any): Promise<ApiResponse<MemberInstance>>;
/**
* Streams MemberInstance 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 { MemberListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: MemberInstance, done: (err?: Error) => void) => void): void;
each(params: MemberListInstanceEachOptions, callback?: (item: MemberInstance, done: (err?: Error) => void) => void): void;
/**
* Streams MemberInstance 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 { MemberListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: MemberInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: MemberListInstanceEachOptions, callback?: (item: MemberInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of MemberInstance 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: MemberPage) => any): Promise<MemberPage>;
/**
* Retrieve a single target page of MemberInstance 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<MemberPage>) => any): Promise<ApiResponse<MemberPage>>;
/**
* Lists MemberInstance 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 { MemberListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: MemberInstance[]) => any): Promise<MemberInstance[]>;
list(params: MemberListInstanceOptions, callback?: (error: Error | null, items: MemberInstance[]) => any): Promise<MemberInstance[]>;
/**
* Lists MemberInstance 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 { MemberListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MemberInstance[]>) => any): Promise<ApiResponse<MemberInstance[]>>;
listWithHttpInfo(params: MemberListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<MemberInstance[]>) => any): Promise<ApiResponse<MemberInstance[]>>;
/**
* Retrieve a single page of MemberInstance 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 { MemberListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: MemberPage) => any): Promise<MemberPage>;
page(params: MemberListInstancePageOptions, callback?: (error: Error | null, items: MemberPage) => any): Promise<MemberPage>;
/**
* Retrieve a single page of MemberInstance 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 { MemberListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MemberPage>) => any): Promise<ApiResponse<MemberPage>>;
pageWithHttpInfo(params: MemberListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<MemberPage>) => any): Promise<ApiResponse<MemberPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function MemberListInstance(version: V2, serviceSid: string, channelSid: string): MemberListInstance;
export declare class MemberPage extends Page<V2, MemberPayload, MemberResource, MemberInstance> {
/**
* Initialize the MemberPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: MemberSolution);
/**
* Build an instance of MemberInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: MemberResource): MemberInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,511 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.MemberPage = exports.MemberInstance = exports.MemberContextImpl = void 0;
exports.MemberListInstance = MemberListInstance;
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 MemberContextImpl {
constructor(_version, serviceSid, channelSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, channelSid, sid };
this._uri = `/Services/${serviceSid}/Channels/${channelSid}/Members/${sid}`;
}
remove(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
params: data,
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({
uri: instance._uri,
method: "delete",
params: data,
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 MemberInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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 MemberInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["lastConsumedMessageIndex"] !== undefined)
data["LastConsumedMessageIndex"] = params["lastConsumedMessageIndex"];
if (params["lastConsumptionTimestamp"] !== undefined)
data["LastConsumptionTimestamp"] = serialize.iso8601DateTime(params["lastConsumptionTimestamp"]);
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new MemberInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["lastConsumedMessageIndex"] !== undefined)
data["LastConsumedMessageIndex"] = params["lastConsumedMessageIndex"];
if (params["lastConsumptionTimestamp"] !== undefined)
data["LastConsumptionTimestamp"] = serialize.iso8601DateTime(params["lastConsumptionTimestamp"]);
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
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 MemberInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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.MemberContextImpl = MemberContextImpl;
class MemberInstance {
constructor(_version, payload, serviceSid, channelSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.channelSid = payload.channel_sid;
this.serviceSid = payload.service_sid;
this.identity = payload.identity;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.roleSid = payload.role_sid;
this.lastConsumedMessageIndex = deserialize.integer(payload.last_consumed_message_index);
this.lastConsumptionTimestamp = deserialize.iso8601DateTime(payload.last_consumption_timestamp);
this.url = payload.url;
this.attributes = payload.attributes;
this._solution = { serviceSid, channelSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new MemberContextImpl(this._version, this._solution.serviceSid, this._solution.channelSid, this._solution.sid);
return this._context;
}
remove(params, callback) {
return this._proxy.remove(params, callback);
}
removeWithHttpInfo(params, callback) {
return this._proxy.removeWithHttpInfo(params, callback);
}
/**
* Fetch a MemberInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a MemberInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MemberInstance 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,
channelSid: this.channelSid,
serviceSid: this.serviceSid,
identity: this.identity,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
roleSid: this.roleSid,
lastConsumedMessageIndex: this.lastConsumedMessageIndex,
lastConsumptionTimestamp: this.lastConsumptionTimestamp,
url: this.url,
attributes: this.attributes,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MemberInstance = MemberInstance;
function MemberListInstance(version, serviceSid, channelSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new MemberContextImpl(version, serviceSid, channelSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, channelSid };
instance._uri = `/Services/${serviceSid}/Channels/${channelSid}/Members`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["lastConsumedMessageIndex"] !== undefined)
data["LastConsumedMessageIndex"] = params["lastConsumedMessageIndex"];
if (params["lastConsumptionTimestamp"] !== undefined)
data["LastConsumptionTimestamp"] = serialize.iso8601DateTime(params["lastConsumptionTimestamp"]);
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new MemberInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid));
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["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["lastConsumedMessageIndex"] !== undefined)
data["LastConsumedMessageIndex"] = params["lastConsumedMessageIndex"];
if (params["lastConsumptionTimestamp"] !== undefined)
data["LastConsumptionTimestamp"] = serialize.iso8601DateTime(params["lastConsumptionTimestamp"]);
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new MemberInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid),
}));
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["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 MemberPage(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 MemberPage(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["identity"] !== undefined)
data["Identity"] = serialize.map(params["identity"], (e) => e);
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 MemberPage(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 MemberPage(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 MemberPage extends Page_1.default {
/**
* Initialize the MemberPage
*
* @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 MemberInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new MemberInstance(this._version, payload, this._solution.serviceSid, this._solution.channelSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MemberPage = MemberPage;

View File

@@ -0,0 +1,579 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
export type MessageOrderType = "asc" | "desc";
export type MessageWebhookEnabledType = "true" | "false";
/**
* Options to pass to remove a MessageInstance
*/
export interface MessageContextRemoveOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: MessageWebhookEnabledType;
}
/**
* Options to pass to update a MessageInstance
*/
export interface MessageContextUpdateOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: MessageWebhookEnabledType;
/** The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. */
body?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat\\\'s history is being recreated from a backup/separate source. */
dateCreated?: Date;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. */
dateUpdated?: Date;
/** The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable. */
lastUpdatedBy?: string;
/** The [Identity](https://www.twilio.com/docs/chat/identity) of the message\\\'s author. */
from?: string;
}
/**
* Options to pass to create a MessageInstance
*/
export interface MessageListInstanceCreateOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: MessageWebhookEnabledType;
/** The [Identity](https://www.twilio.com/docs/chat/identity) of the new message\\\'s author. The default value is `system`. */
from?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat\\\'s history is being recreated from a backup/separate source. */
dateCreated?: Date;
/** The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated. */
dateUpdated?: Date;
/** The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable. */
lastUpdatedBy?: string;
/** The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string. */
body?: string;
/** The SID of the [Media](https://www.twilio.com/docs/chat/rest/media) to attach to the new Message. */
mediaSid?: string;
}
/**
* Options to pass to each
*/
export interface MessageListInstanceEachOptions {
/** The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default. */
order?: MessageOrderType;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: MessageInstance, 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 MessageListInstanceOptions {
/** The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default. */
order?: MessageOrderType;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
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 MessageListInstancePageOptions {
/** The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default. */
order?: MessageOrderType;
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface MessageContext {
/**
* Remove a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
remove(params: MessageContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MessageInstance 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>>;
/**
* Remove a MessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
removeWithHttpInfo(params: MessageContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
fetch(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Fetch a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Update a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
update(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Update a MessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
update(params: MessageContextUpdateOptions, callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Update a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Update a MessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
updateWithHttpInfo(params: MessageContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface MessageContextSolution {
serviceSid: string;
channelSid: string;
sid: string;
}
export declare class MessageContextImpl implements MessageContext {
protected _version: V2;
protected _solution: MessageContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, channelSid: string, sid: string);
remove(params?: MessageContextRemoveOptions | ((error: Error | null, item?: boolean) => any), callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(params?: MessageContextRemoveOptions | ((error: Error | null, item?: ApiResponse<boolean>) => any), callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
update(params?: MessageContextUpdateOptions | ((error: Error | null, item?: MessageInstance) => any), callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
updateWithHttpInfo(params?: MessageContextUpdateOptions | ((error: Error | null, item?: ApiResponse<MessageInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): MessageContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface MessagePayload extends TwilioResponsePayload {
messages: MessageResource[];
}
interface MessageResource {
sid: string;
account_sid: string;
attributes: string;
service_sid: string;
to: string;
channel_sid: string;
date_created: Date;
date_updated: Date;
last_updated_by: string;
was_edited: boolean;
from: string;
body: string;
index: number;
type: string;
media: any;
url: string;
}
export declare class MessageInstance {
protected _version: V2;
protected _solution: MessageContextSolution;
protected _context?: MessageContext;
constructor(_version: V2, payload: MessageResource, serviceSid: string, channelSid: string, sid?: string);
/**
* The unique string that we created to identify the Message resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Message resource.
*/
accountSid: string;
/**
* The JSON string that stores application-specific data. If attributes have not been set, `{}` is returned.
*/
attributes: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the Message resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/chat/channels) that the message was sent to.
*/
to: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/chat/channels) the Message resource belongs to.
*/
channelSid: string;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable.
*/
lastUpdatedBy: string;
/**
* Whether the message has been edited since it was created.
*/
wasEdited: boolean;
/**
* The [Identity](https://www.twilio.com/docs/chat/identity) of the message\'s author. The default value is `system`.
*/
from: string;
/**
* The content of the message.
*/
body: string;
/**
* The index of the message within the [Channel](https://www.twilio.com/docs/chat/channels). Indices may skip numbers, but will always be in order of when the message was received.
*/
index: number;
/**
* The Message type. Can be: `text` or `media`.
*/
type: string;
/**
* An object that describes the Message\'s media, if the message contains media. The object contains these fields: `content_type` with the MIME type of the media, `filename` with the name of the media, `sid` with the SID of the Media resource, and `size` with the media object\'s file size in bytes. If the Message has no media, this value is `null`.
*/
media: any;
/**
* The absolute URL of the Message resource.
*/
url: string;
private get _proxy();
/**
* Remove a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
remove(params: MessageContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MessageInstance 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>>;
/**
* Remove a MessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
removeWithHttpInfo(params: MessageContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
fetch(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Fetch a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Update a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
update(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Update a MessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
update(params: MessageContextUpdateOptions, callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Update a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Update a MessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
updateWithHttpInfo(params: MessageContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
attributes: string;
serviceSid: string;
to: string;
channelSid: string;
dateCreated: Date;
dateUpdated: Date;
lastUpdatedBy: string;
wasEdited: boolean;
from: string;
body: string;
index: number;
type: string;
media: any;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface MessageSolution {
serviceSid: string;
channelSid: string;
}
export interface MessageListInstance {
_version: V2;
_solution: MessageSolution;
_uri: string;
(sid: string): MessageContext;
get(sid: string): MessageContext;
/**
* Create a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
create(callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Create a MessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
create(params: MessageListInstanceCreateOptions, callback?: (error: Error | null, item?: MessageInstance) => any): Promise<MessageInstance>;
/**
* Create a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Create a MessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance with HTTP metadata
*/
createWithHttpInfo(params: MessageListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<MessageInstance>) => any): Promise<ApiResponse<MessageInstance>>;
/**
* Streams MessageInstance 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 { MessageListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: MessageInstance, done: (err?: Error) => void) => void): void;
each(params: MessageListInstanceEachOptions, callback?: (item: MessageInstance, done: (err?: Error) => void) => void): void;
/**
* Streams MessageInstance 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 { MessageListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: MessageInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: MessageListInstanceEachOptions, callback?: (item: MessageInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of MessageInstance 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: MessagePage) => any): Promise<MessagePage>;
/**
* Retrieve a single target page of MessageInstance 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<MessagePage>) => any): Promise<ApiResponse<MessagePage>>;
/**
* Lists MessageInstance 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 { MessageListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: MessageInstance[]) => any): Promise<MessageInstance[]>;
list(params: MessageListInstanceOptions, callback?: (error: Error | null, items: MessageInstance[]) => any): Promise<MessageInstance[]>;
/**
* Lists MessageInstance 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 { MessageListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MessageInstance[]>) => any): Promise<ApiResponse<MessageInstance[]>>;
listWithHttpInfo(params: MessageListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<MessageInstance[]>) => any): Promise<ApiResponse<MessageInstance[]>>;
/**
* Retrieve a single page of MessageInstance 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 { MessageListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: MessagePage) => any): Promise<MessagePage>;
page(params: MessageListInstancePageOptions, callback?: (error: Error | null, items: MessagePage) => any): Promise<MessagePage>;
/**
* Retrieve a single page of MessageInstance 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 { MessageListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MessagePage>) => any): Promise<ApiResponse<MessagePage>>;
pageWithHttpInfo(params: MessageListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<MessagePage>) => any): Promise<ApiResponse<MessagePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function MessageListInstance(version: V2, serviceSid: string, channelSid: string): MessageListInstance;
export declare class MessagePage extends Page<V2, MessagePayload, MessageResource, MessageInstance> {
/**
* Initialize the MessagePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: MessageSolution);
/**
* Build an instance of MessageInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: MessageResource): MessageInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,523 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.MessagePage = exports.MessageInstance = exports.MessageContextImpl = void 0;
exports.MessageListInstance = MessageListInstance;
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 MessageContextImpl {
constructor(_version, serviceSid, channelSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, channelSid, sid };
this._uri = `/Services/${serviceSid}/Channels/${channelSid}/Messages/${sid}`;
}
remove(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
params: data,
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({
uri: instance._uri,
method: "delete",
params: data,
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 MessageInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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 MessageInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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["body"] !== undefined)
data["Body"] = params["body"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["lastUpdatedBy"] !== undefined)
data["LastUpdatedBy"] = params["lastUpdatedBy"];
if (params["from"] !== undefined)
data["From"] = params["from"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new MessageInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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["body"] !== undefined)
data["Body"] = params["body"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["lastUpdatedBy"] !== undefined)
data["LastUpdatedBy"] = params["lastUpdatedBy"];
if (params["from"] !== undefined)
data["From"] = params["from"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
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 MessageInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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.MessageContextImpl = MessageContextImpl;
class MessageInstance {
constructor(_version, payload, serviceSid, channelSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.attributes = payload.attributes;
this.serviceSid = payload.service_sid;
this.to = payload.to;
this.channelSid = payload.channel_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.lastUpdatedBy = payload.last_updated_by;
this.wasEdited = payload.was_edited;
this.from = payload.from;
this.body = payload.body;
this.index = deserialize.integer(payload.index);
this.type = payload.type;
this.media = payload.media;
this.url = payload.url;
this._solution = { serviceSid, channelSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new MessageContextImpl(this._version, this._solution.serviceSid, this._solution.channelSid, this._solution.sid);
return this._context;
}
remove(params, callback) {
return this._proxy.remove(params, callback);
}
removeWithHttpInfo(params, callback) {
return this._proxy.removeWithHttpInfo(params, callback);
}
/**
* Fetch a MessageInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a MessageInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessageInstance 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,
attributes: this.attributes,
serviceSid: this.serviceSid,
to: this.to,
channelSid: this.channelSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
lastUpdatedBy: this.lastUpdatedBy,
wasEdited: this.wasEdited,
from: this.from,
body: this.body,
index: this.index,
type: this.type,
media: this.media,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessageInstance = MessageInstance;
function MessageListInstance(version, serviceSid, channelSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new MessageContextImpl(version, serviceSid, channelSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, channelSid };
instance._uri = `/Services/${serviceSid}/Channels/${channelSid}/Messages`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["from"] !== undefined)
data["From"] = params["from"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["lastUpdatedBy"] !== undefined)
data["LastUpdatedBy"] = params["lastUpdatedBy"];
if (params["body"] !== undefined)
data["Body"] = params["body"];
if (params["mediaSid"] !== undefined)
data["MediaSid"] = params["mediaSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new MessageInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid));
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["from"] !== undefined)
data["From"] = params["from"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["dateCreated"] !== undefined)
data["DateCreated"] = serialize.iso8601DateTime(params["dateCreated"]);
if (params["dateUpdated"] !== undefined)
data["DateUpdated"] = serialize.iso8601DateTime(params["dateUpdated"]);
if (params["lastUpdatedBy"] !== undefined)
data["LastUpdatedBy"] = params["lastUpdatedBy"];
if (params["body"] !== undefined)
data["Body"] = params["body"];
if (params["mediaSid"] !== undefined)
data["MediaSid"] = params["mediaSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new MessageInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid),
}));
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["order"] !== undefined)
data["Order"] = params["order"];
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 MessagePage(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 MessagePage(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["order"] !== undefined)
data["Order"] = params["order"];
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 MessagePage(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 MessagePage(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 MessagePage extends Page_1.default {
/**
* Initialize the MessagePage
*
* @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 MessageInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new MessageInstance(this._version, payload, this._solution.serviceSid, this._solution.channelSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessagePage = MessagePage;

View File

@@ -0,0 +1,471 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
export type WebhookMethod = "GET" | "POST";
/**
* The type of webhook. Can be: `webhook`, `studio`, or `trigger`.
*/
export type WebhookType = "webhook" | "trigger" | "studio";
/**
* Options to pass to update a WebhookInstance
*/
export interface WebhookContextUpdateOptions {
/** The URL of the webhook to call using the `configuration.method`. */
"configuration.url"?: string;
/** */
"configuration.method"?: WebhookMethod;
/** The events that cause us to call the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see [Webhook Event Triggers](https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger). */
"configuration.filters"?: Array<string>;
/** A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`. */
"configuration.triggers"?: Array<string>;
/** The SID of the Studio [Flow](https://www.twilio.com/docs/studio/rest-api/flow) to call when an event in `configuration.filters` occurs. Used only when `type` = `studio`. */
"configuration.flowSid"?: string;
/** The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0. */
"configuration.retryCount"?: number;
}
/**
* Options to pass to create a WebhookInstance
*/
export interface WebhookListInstanceCreateOptions {
/** */
type: WebhookType;
/** The URL of the webhook to call using the `configuration.method`. */
"configuration.url"?: string;
/** */
"configuration.method"?: WebhookMethod;
/** The events that cause us to call the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see [Webhook Event Triggers](https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger). */
"configuration.filters"?: Array<string>;
/** A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`. */
"configuration.triggers"?: Array<string>;
/** The SID of the Studio [Flow](https://www.twilio.com/docs/studio/rest-api/flow) to call when an event in `configuration.filters` occurs. Used only when `type` is `studio`. */
"configuration.flowSid"?: string;
/** The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0. */
"configuration.retryCount"?: number;
}
/**
* Options to pass to each
*/
export interface WebhookListInstanceEachOptions {
/** How many resources to return in each list page. The default is 5, and the maximum is 5. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: WebhookInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface WebhookListInstanceOptions {
/** How many resources to return in each list page. The default is 5, and the maximum is 5. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface WebhookListInstancePageOptions {
/** How many resources to return in each list page. The default is 5, and the maximum is 5. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface WebhookContext {
/**
* Remove a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a WebhookInstance 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 WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
fetch(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Fetch a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Update a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
update(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Update a WebhookInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
update(params: WebhookContextUpdateOptions, callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Update a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Update a WebhookInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
updateWithHttpInfo(params: WebhookContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface WebhookContextSolution {
serviceSid: string;
channelSid: string;
sid: string;
}
export declare class WebhookContextImpl implements WebhookContext {
protected _version: V2;
protected _solution: WebhookContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, channelSid: 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?: WebhookInstance) => any): Promise<WebhookInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
update(params?: WebhookContextUpdateOptions | ((error: Error | null, item?: WebhookInstance) => any), callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
updateWithHttpInfo(params?: WebhookContextUpdateOptions | ((error: Error | null, item?: ApiResponse<WebhookInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): WebhookContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface WebhookPayload extends TwilioResponsePayload {
webhooks: WebhookResource[];
}
interface WebhookResource {
sid: string;
account_sid: string;
service_sid: string;
channel_sid: string;
type: string;
url: string;
configuration: any;
date_created: Date;
date_updated: Date;
}
export declare class WebhookInstance {
protected _version: V2;
protected _solution: WebhookContextSolution;
protected _context?: WebhookContext;
constructor(_version: V2, payload: WebhookResource, serviceSid: string, channelSid: string, sid?: string);
/**
* The unique string that we created to identify the Channel Webhook resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Channel Webhook resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the Channel Webhook resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/chat/channels) the Channel Webhook resource belongs to.
*/
channelSid: string;
/**
* The type of webhook. Can be: `webhook`, `studio`, or `trigger`.
*/
type: string;
/**
* The absolute URL of the Channel Webhook resource.
*/
url: string;
/**
* The JSON string that describes how the channel webhook is configured. The configuration object contains the `url`, `method`, `filters`, and `retry_count` values that are configured by the create and update actions.
*/
configuration: any;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
private get _proxy();
/**
* Remove a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a WebhookInstance 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 WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
fetch(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Fetch a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Update a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
update(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Update a WebhookInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
update(params: WebhookContextUpdateOptions, callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Update a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Update a WebhookInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
updateWithHttpInfo(params: WebhookContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
channelSid: string;
type: string;
url: string;
configuration: any;
dateCreated: Date;
dateUpdated: Date;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface WebhookSolution {
serviceSid: string;
channelSid: string;
}
export interface WebhookListInstance {
_version: V2;
_solution: WebhookSolution;
_uri: string;
(sid: string): WebhookContext;
get(sid: string): WebhookContext;
/**
* Create a WebhookInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
create(params: WebhookListInstanceCreateOptions, callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Create a WebhookInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
createWithHttpInfo(params: WebhookListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Streams WebhookInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: WebhookInstance, done: (err?: Error) => void) => void): void;
each(params: WebhookListInstanceEachOptions, callback?: (item: WebhookInstance, done: (err?: Error) => void) => void): void;
/**
* Streams WebhookInstance 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 { WebhookListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: WebhookInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: WebhookListInstanceEachOptions, callback?: (item: WebhookInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of WebhookInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: WebhookPage) => any): Promise<WebhookPage>;
/**
* Retrieve a single target page of WebhookInstance 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<WebhookPage>) => any): Promise<ApiResponse<WebhookPage>>;
/**
* Lists WebhookInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: WebhookInstance[]) => any): Promise<WebhookInstance[]>;
list(params: WebhookListInstanceOptions, callback?: (error: Error | null, items: WebhookInstance[]) => any): Promise<WebhookInstance[]>;
/**
* Lists WebhookInstance 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 { WebhookListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<WebhookInstance[]>) => any): Promise<ApiResponse<WebhookInstance[]>>;
listWithHttpInfo(params: WebhookListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<WebhookInstance[]>) => any): Promise<ApiResponse<WebhookInstance[]>>;
/**
* Retrieve a single page of WebhookInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: WebhookPage) => any): Promise<WebhookPage>;
page(params: WebhookListInstancePageOptions, callback?: (error: Error | null, items: WebhookPage) => any): Promise<WebhookPage>;
/**
* Retrieve a single page of WebhookInstance 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 { WebhookListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<WebhookPage>) => any): Promise<ApiResponse<WebhookPage>>;
pageWithHttpInfo(params: WebhookListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<WebhookPage>) => any): Promise<ApiResponse<WebhookPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function WebhookListInstance(version: V2, serviceSid: string, channelSid: string): WebhookListInstance;
export declare class WebhookPage extends Page<V2, WebhookPayload, WebhookResource, WebhookInstance> {
/**
* Initialize the WebhookPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: WebhookSolution);
/**
* Build an instance of WebhookInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: WebhookResource): WebhookInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,481 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.WebhookPage = exports.WebhookInstance = exports.WebhookContextImpl = void 0;
exports.WebhookListInstance = WebhookListInstance;
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 WebhookContextImpl {
constructor(_version, serviceSid, channelSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, channelSid, sid };
this._uri = `/Services/${serviceSid}/Channels/${channelSid}/Webhooks/${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 WebhookInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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 WebhookInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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["configuration.url"] !== undefined)
data["Configuration.Url"] = params["configuration.url"];
if (params["configuration.method"] !== undefined)
data["Configuration.Method"] = params["configuration.method"];
if (params["configuration.filters"] !== undefined)
data["Configuration.Filters"] = serialize.map(params["configuration.filters"], (e) => e);
if (params["configuration.triggers"] !== undefined)
data["Configuration.Triggers"] = serialize.map(params["configuration.triggers"], (e) => e);
if (params["configuration.flowSid"] !== undefined)
data["Configuration.FlowSid"] = params["configuration.flowSid"];
if (params["configuration.retryCount"] !== undefined)
data["Configuration.RetryCount"] = params["configuration.retryCount"];
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 WebhookInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid, 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["configuration.url"] !== undefined)
data["Configuration.Url"] = params["configuration.url"];
if (params["configuration.method"] !== undefined)
data["Configuration.Method"] = params["configuration.method"];
if (params["configuration.filters"] !== undefined)
data["Configuration.Filters"] = serialize.map(params["configuration.filters"], (e) => e);
if (params["configuration.triggers"] !== undefined)
data["Configuration.Triggers"] = serialize.map(params["configuration.triggers"], (e) => e);
if (params["configuration.flowSid"] !== undefined)
data["Configuration.FlowSid"] = params["configuration.flowSid"];
if (params["configuration.retryCount"] !== undefined)
data["Configuration.RetryCount"] = params["configuration.retryCount"];
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 WebhookInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid, 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.WebhookContextImpl = WebhookContextImpl;
class WebhookInstance {
constructor(_version, payload, serviceSid, channelSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.channelSid = payload.channel_sid;
this.type = payload.type;
this.url = payload.url;
this.configuration = payload.configuration;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this._solution = { serviceSid, channelSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new WebhookContextImpl(this._version, this._solution.serviceSid, this._solution.channelSid, this._solution.sid);
return this._context;
}
/**
* Remove a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a WebhookInstance 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 WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance 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,
channelSid: this.channelSid,
type: this.type,
url: this.url,
configuration: this.configuration,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.WebhookInstance = WebhookInstance;
function WebhookListInstance(version, serviceSid, channelSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new WebhookContextImpl(version, serviceSid, channelSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, channelSid };
instance._uri = `/Services/${serviceSid}/Channels/${channelSid}/Webhooks`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
let data = {};
data["Type"] = params["type"];
if (params["configuration.url"] !== undefined)
data["Configuration.Url"] = params["configuration.url"];
if (params["configuration.method"] !== undefined)
data["Configuration.Method"] = params["configuration.method"];
if (params["configuration.filters"] !== undefined)
data["Configuration.Filters"] = serialize.map(params["configuration.filters"], (e) => e);
if (params["configuration.triggers"] !== undefined)
data["Configuration.Triggers"] = serialize.map(params["configuration.triggers"], (e) => e);
if (params["configuration.flowSid"] !== undefined)
data["Configuration.FlowSid"] = params["configuration.flowSid"];
if (params["configuration.retryCount"] !== undefined)
data["Configuration.RetryCount"] = params["configuration.retryCount"];
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 WebhookInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.channelSid));
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["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
let data = {};
data["Type"] = params["type"];
if (params["configuration.url"] !== undefined)
data["Configuration.Url"] = params["configuration.url"];
if (params["configuration.method"] !== undefined)
data["Configuration.Method"] = params["configuration.method"];
if (params["configuration.filters"] !== undefined)
data["Configuration.Filters"] = serialize.map(params["configuration.filters"], (e) => e);
if (params["configuration.triggers"] !== undefined)
data["Configuration.Triggers"] = serialize.map(params["configuration.triggers"], (e) => e);
if (params["configuration.flowSid"] !== undefined)
data["Configuration.FlowSid"] = params["configuration.flowSid"];
if (params["configuration.retryCount"] !== undefined)
data["Configuration.RetryCount"] = params["configuration.retryCount"];
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 WebhookInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.channelSid),
}));
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 WebhookPage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new WebhookPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.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 WebhookPage(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 WebhookPage(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 WebhookPage extends Page_1.default {
/**
* Initialize the WebhookPage
*
* @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 WebhookInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new WebhookInstance(this._version, payload, this._solution.serviceSid, this._solution.channelSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.WebhookPage = WebhookPage;

415
node_modules/twilio/lib/rest/chat/v2/service/role.d.ts generated vendored Normal file
View File

@@ -0,0 +1,415 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
/**
* The type of role. Can be: `channel` for [Channel](https://www.twilio.com/docs/chat/channels) roles or `deployment` for [Service](https://www.twilio.com/docs/chat/rest/service-resource) roles.
*/
export type RoleRoleType = "channel" | "deployment";
/**
* Options to pass to update a RoleInstance
*/
export interface RoleContextUpdateOptions {
/** A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role\\\'s `type`. */
permission: Array<string>;
}
/**
* Options to pass to create a RoleInstance
*/
export interface RoleListInstanceCreateOptions {
/** A descriptive string that you create to describe the new resource. It can be up to 64 characters long. */
friendlyName: string;
/** */
type: RoleRoleType;
/** A permission that you grant to the new role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. The values for this parameter depend on the role\\\'s `type`. */
permission: Array<string>;
}
/**
* Options to pass to each
*/
export interface RoleListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: RoleInstance, 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 RoleListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
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 RoleListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface RoleContext {
/**
* Remove a RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a RoleInstance 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 RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
fetch(callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Fetch a RoleInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Update a RoleInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
update(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Update a RoleInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
updateWithHttpInfo(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface RoleContextSolution {
serviceSid: string;
sid: string;
}
export declare class RoleContextImpl implements RoleContext {
protected _version: V2;
protected _solution: RoleContextSolution;
protected _uri: string;
constructor(_version: V2, 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?: RoleInstance) => any): Promise<RoleInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
update(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
updateWithHttpInfo(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): RoleContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface RolePayload extends TwilioResponsePayload {
roles: RoleResource[];
}
interface RoleResource {
sid: string;
account_sid: string;
service_sid: string;
friendly_name: string;
type: RoleRoleType;
permissions: Array<string>;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class RoleInstance {
protected _version: V2;
protected _solution: RoleContextSolution;
protected _context?: RoleContext;
constructor(_version: V2, payload: RoleResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Role resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Role resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the Role resource is associated with.
*/
serviceSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
type: RoleRoleType;
/**
* An array of the permissions the role has been granted.
*/
permissions: Array<string>;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The absolute URL of the Role resource.
*/
url: string;
private get _proxy();
/**
* Remove a RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a RoleInstance 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 RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
fetch(callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Fetch a RoleInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Update a RoleInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
update(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Update a RoleInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
updateWithHttpInfo(params: RoleContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
friendlyName: string;
type: RoleRoleType;
permissions: string[];
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface RoleSolution {
serviceSid: string;
}
export interface RoleListInstance {
_version: V2;
_solution: RoleSolution;
_uri: string;
(sid: string): RoleContext;
get(sid: string): RoleContext;
/**
* Create a RoleInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
create(params: RoleListInstanceCreateOptions, callback?: (error: Error | null, item?: RoleInstance) => any): Promise<RoleInstance>;
/**
* Create a RoleInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance with HTTP metadata
*/
createWithHttpInfo(params: RoleListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<RoleInstance>) => any): Promise<ApiResponse<RoleInstance>>;
/**
* Streams RoleInstance 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 { RoleListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: RoleInstance, done: (err?: Error) => void) => void): void;
each(params: RoleListInstanceEachOptions, callback?: (item: RoleInstance, done: (err?: Error) => void) => void): void;
/**
* Streams RoleInstance 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 { RoleListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: RoleInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: RoleListInstanceEachOptions, callback?: (item: RoleInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of RoleInstance 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: RolePage) => any): Promise<RolePage>;
/**
* Retrieve a single target page of RoleInstance 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<RolePage>) => any): Promise<ApiResponse<RolePage>>;
/**
* Lists RoleInstance 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 { RoleListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: RoleInstance[]) => any): Promise<RoleInstance[]>;
list(params: RoleListInstanceOptions, callback?: (error: Error | null, items: RoleInstance[]) => any): Promise<RoleInstance[]>;
/**
* Lists RoleInstance 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 { RoleListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<RoleInstance[]>) => any): Promise<ApiResponse<RoleInstance[]>>;
listWithHttpInfo(params: RoleListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<RoleInstance[]>) => any): Promise<ApiResponse<RoleInstance[]>>;
/**
* Retrieve a single page of RoleInstance 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 { RoleListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: RolePage) => any): Promise<RolePage>;
page(params: RoleListInstancePageOptions, callback?: (error: Error | null, items: RolePage) => any): Promise<RolePage>;
/**
* Retrieve a single page of RoleInstance 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 { RoleListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<RolePage>) => any): Promise<ApiResponse<RolePage>>;
pageWithHttpInfo(params: RoleListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<RolePage>) => any): Promise<ApiResponse<RolePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function RoleListInstance(version: V2, serviceSid: string): RoleListInstance;
export declare class RolePage extends Page<V2, RolePayload, RoleResource, RoleInstance> {
/**
* Initialize the RolePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: RoleSolution);
/**
* Build an instance of RoleInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: RoleResource): RoleInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

445
node_modules/twilio/lib/rest/chat/v2/service/role.js generated vendored Normal file
View File

@@ -0,0 +1,445 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.RolePage = exports.RoleInstance = exports.RoleContextImpl = void 0;
exports.RoleListInstance = RoleListInstance;
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 RoleContextImpl {
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}/Roles/${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 RoleInstance(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 RoleInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["permission"] === null || params["permission"] === undefined) {
throw new Error("Required parameter \"params['permission']\" missing.");
}
let data = {};
data["Permission"] = serialize.map(params["permission"], (e) => e);
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 RoleInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["permission"] === null || params["permission"] === undefined) {
throw new Error("Required parameter \"params['permission']\" missing.");
}
let data = {};
data["Permission"] = serialize.map(params["permission"], (e) => e);
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 RoleInstance(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.RoleContextImpl = RoleContextImpl;
class RoleInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.friendlyName = payload.friendly_name;
this.type = payload.type;
this.permissions = payload.permissions;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new RoleContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a RoleInstance 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 RoleInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a RoleInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RoleInstance 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,
friendlyName: this.friendlyName,
type: this.type,
permissions: this.permissions,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.RoleInstance = RoleInstance;
function RoleListInstance(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 RoleContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Roles`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
if (params["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
if (params["permission"] === null || params["permission"] === undefined) {
throw new Error("Required parameter \"params['permission']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
data["Type"] = params["type"];
data["Permission"] = serialize.map(params["permission"], (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 RoleInstance(operationVersion, payload, instance._solution.serviceSid));
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["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
if (params["type"] === null || params["type"] === undefined) {
throw new Error("Required parameter \"params['type']\" missing.");
}
if (params["permission"] === null || params["permission"] === undefined) {
throw new Error("Required parameter \"params['permission']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
data["Type"] = params["type"];
data["Permission"] = serialize.map(params["permission"], (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 RoleInstance(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 RolePage(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 RolePage(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 RolePage(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 RolePage(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 RolePage extends Page_1.default {
/**
* Initialize the RolePage
*
* @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 RoleInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new RoleInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.RolePage = RolePage;

503
node_modules/twilio/lib/rest/chat/v2/service/user.d.ts generated vendored Normal file
View File

@@ -0,0 +1,503 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
import { UserBindingListInstance } from "./user/userBinding";
import { UserChannelListInstance } from "./user/userChannel";
export type UserWebhookEnabledType = "true" | "false";
/**
* Options to pass to update a UserInstance
*/
export interface UserContextUpdateOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: UserWebhookEnabledType;
/** The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the User. */
roleSid?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** A descriptive string that you create to describe the resource. It is often used for display purposes. */
friendlyName?: string;
}
/**
* Options to pass to create a UserInstance
*/
export interface UserListInstanceCreateOptions {
/** The `identity` value that uniquely identifies the new resource\\\'s [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). This value is often a username or email address. See the Identity documentation for more info. */
identity: string;
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: UserWebhookEnabledType;
/** The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the new User. */
roleSid?: string;
/** A valid JSON string that contains application-specific data. */
attributes?: string;
/** A descriptive string that you create to describe the new resource. This value is often used for display purposes. */
friendlyName?: string;
}
/**
* Options to pass to each
*/
export interface UserListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: UserInstance, 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 UserListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
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 UserListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 100. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface UserContext {
userBindings: UserBindingListInstance;
userChannels: UserChannelListInstance;
/**
* Remove a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserInstance 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 UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
fetch(callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Fetch a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Update a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
update(callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Update a UserInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
update(params: UserContextUpdateOptions, callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Update a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Update a UserInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
updateWithHttpInfo(params: UserContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface UserContextSolution {
serviceSid: string;
sid: string;
}
export declare class UserContextImpl implements UserContext {
protected _version: V2;
protected _solution: UserContextSolution;
protected _uri: string;
protected _userBindings?: UserBindingListInstance;
protected _userChannels?: UserChannelListInstance;
constructor(_version: V2, serviceSid: string, sid: string);
get userBindings(): UserBindingListInstance;
get userChannels(): UserChannelListInstance;
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?: UserInstance) => any): Promise<UserInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
update(params?: UserContextUpdateOptions | ((error: Error | null, item?: UserInstance) => any), callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
updateWithHttpInfo(params?: UserContextUpdateOptions | ((error: Error | null, item?: ApiResponse<UserInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): UserContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface UserPayload extends TwilioResponsePayload {
users: UserResource[];
}
interface UserResource {
sid: string;
account_sid: string;
service_sid: string;
attributes: string;
friendly_name: string;
role_sid: string;
identity: string;
is_online: boolean;
is_notifiable: boolean;
date_created: Date;
date_updated: Date;
joined_channels_count: number;
links: Record<string, string>;
url: string;
}
export declare class UserInstance {
protected _version: V2;
protected _solution: UserContextSolution;
protected _context?: UserContext;
constructor(_version: V2, payload: UserResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the User resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the User resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the User resource is associated with.
*/
serviceSid: string;
/**
* The JSON string that stores application-specific data. If attributes have not been set, `{}` is returned.
*/
attributes: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
/**
* The SID of the [Role](https://www.twilio.com/docs/chat/rest/role-resource) assigned to the user.
*/
roleSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s User within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). This value is often a username or an email address, and is case-sensitive. See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info.
*/
identity: string;
/**
* Whether the User is actively connected to the Service instance and online. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service\'s `reachability_enabled` is `false`, if the User has never been online for the Service instance, even if the Service\'s `reachability_enabled` is `true`.
*/
isOnline: boolean;
/**
* Whether the User has a potentially valid Push Notification registration (APN or GCM) for the Service instance. If at least one registration exists, `true`; otherwise `false`. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service\'s `reachability_enabled` is `false`, and if the User has never had a notification registration, even if the Service\'s `reachability_enabled` is `true`.
*/
isNotifiable: boolean;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The number of Channels the User is a Member of.
*/
joinedChannelsCount: number;
/**
* The absolute URLs of the [Channel](https://www.twilio.com/docs/chat/channels) and [Binding](https://www.twilio.com/docs/chat/rest/binding-resource) resources related to the user.
*/
links: Record<string, string>;
/**
* The absolute URL of the User resource.
*/
url: string;
private get _proxy();
/**
* Remove a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserInstance 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 UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
fetch(callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Fetch a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Update a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
update(callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Update a UserInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
update(params: UserContextUpdateOptions, callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Update a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Update a UserInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
updateWithHttpInfo(params: UserContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Access the userBindings.
*/
userBindings(): UserBindingListInstance;
/**
* Access the userChannels.
*/
userChannels(): UserChannelListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
attributes: string;
friendlyName: string;
roleSid: string;
identity: string;
isOnline: boolean;
isNotifiable: boolean;
dateCreated: Date;
dateUpdated: Date;
joinedChannelsCount: number;
links: Record<string, string>;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface UserSolution {
serviceSid: string;
}
export interface UserListInstance {
_version: V2;
_solution: UserSolution;
_uri: string;
(sid: string): UserContext;
get(sid: string): UserContext;
/**
* Create a UserInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
create(params: UserListInstanceCreateOptions, callback?: (error: Error | null, item?: UserInstance) => any): Promise<UserInstance>;
/**
* Create a UserInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance with HTTP metadata
*/
createWithHttpInfo(params: UserListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<UserInstance>) => any): Promise<ApiResponse<UserInstance>>;
/**
* Streams UserInstance 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 { UserListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: UserInstance, done: (err?: Error) => void) => void): void;
each(params: UserListInstanceEachOptions, callback?: (item: UserInstance, done: (err?: Error) => void) => void): void;
/**
* Streams UserInstance 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 { UserListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: UserInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: UserListInstanceEachOptions, callback?: (item: UserInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of UserInstance 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: UserPage) => any): Promise<UserPage>;
/**
* Retrieve a single target page of UserInstance 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<UserPage>) => any): Promise<ApiResponse<UserPage>>;
/**
* Lists UserInstance 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 { UserListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: UserInstance[]) => any): Promise<UserInstance[]>;
list(params: UserListInstanceOptions, callback?: (error: Error | null, items: UserInstance[]) => any): Promise<UserInstance[]>;
/**
* Lists UserInstance 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 { UserListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserInstance[]>) => any): Promise<ApiResponse<UserInstance[]>>;
listWithHttpInfo(params: UserListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<UserInstance[]>) => any): Promise<ApiResponse<UserInstance[]>>;
/**
* Retrieve a single page of UserInstance 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 { UserListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: UserPage) => any): Promise<UserPage>;
page(params: UserListInstancePageOptions, callback?: (error: Error | null, items: UserPage) => any): Promise<UserPage>;
/**
* Retrieve a single page of UserInstance 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 { UserListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserPage>) => any): Promise<ApiResponse<UserPage>>;
pageWithHttpInfo(params: UserListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<UserPage>) => any): Promise<ApiResponse<UserPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function UserListInstance(version: V2, serviceSid: string): UserListInstance;
export declare class UserPage extends Page<V2, UserPayload, UserResource, UserInstance> {
/**
* Initialize the UserPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: UserSolution);
/**
* Build an instance of UserInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: UserResource): UserInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

495
node_modules/twilio/lib/rest/chat/v2/service/user.js generated vendored Normal file
View File

@@ -0,0 +1,495 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.UserPage = exports.UserInstance = exports.UserContextImpl = void 0;
exports.UserListInstance = UserListInstance;
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 userBinding_1 = require("./user/userBinding");
const userChannel_1 = require("./user/userChannel");
class UserContextImpl {
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}/Users/${sid}`;
}
get userBindings() {
this._userBindings =
this._userBindings ||
(0, userBinding_1.UserBindingListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._userBindings;
}
get userChannels() {
this._userChannels =
this._userChannels ||
(0, userChannel_1.UserChannelListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._userChannels;
}
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 UserInstance(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 UserInstance(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["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new UserInstance(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["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
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 UserInstance(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.UserContextImpl = UserContextImpl;
class UserInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.attributes = payload.attributes;
this.friendlyName = payload.friendly_name;
this.roleSid = payload.role_sid;
this.identity = payload.identity;
this.isOnline = payload.is_online;
this.isNotifiable = payload.is_notifiable;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.joinedChannelsCount = deserialize.integer(payload.joined_channels_count);
this.links = payload.links;
this.url = payload.url;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new UserContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a UserInstance 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 UserInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a UserInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserInstance 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 userBindings.
*/
userBindings() {
return this._proxy.userBindings;
}
/**
* Access the userChannels.
*/
userChannels() {
return this._proxy.userChannels;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
attributes: this.attributes,
friendlyName: this.friendlyName,
roleSid: this.roleSid,
identity: this.identity,
isOnline: this.isOnline,
isNotifiable: this.isNotifiable,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
joinedChannelsCount: this.joinedChannelsCount,
links: this.links,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserInstance = UserInstance;
function UserListInstance(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 UserContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Users`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new UserInstance(operationVersion, payload, instance._solution.serviceSid));
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["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
if (params["roleSid"] !== undefined)
data["RoleSid"] = params["roleSid"];
if (params["attributes"] !== undefined)
data["Attributes"] = params["attributes"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new UserInstance(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 UserPage(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 UserPage(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 UserPage(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 UserPage(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 UserPage extends Page_1.default {
/**
* Initialize the UserPage
*
* @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 UserInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new UserInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserPage = UserPage;

View File

@@ -0,0 +1,367 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
/**
* The push technology to use for the User Binding. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
*/
export type UserBindingBindingType = "gcm" | "apn" | "fcm";
/**
* Options to pass to each
*/
export interface UserBindingListInstanceEachOptions {
/** The push technology used by the User Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. */
bindingType?: Array<UserBindingBindingType>;
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: UserBindingInstance, 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 UserBindingListInstanceOptions {
/** The push technology used by the User Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. */
bindingType?: Array<UserBindingBindingType>;
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
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 UserBindingListInstancePageOptions {
/** The push technology used by the User Binding resources to read. Can be: `apn`, `gcm`, or `fcm`. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info. */
bindingType?: Array<UserBindingBindingType>;
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface UserBindingContext {
/**
* Remove a UserBindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserBindingInstance 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 UserBindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserBindingInstance
*/
fetch(callback?: (error: Error | null, item?: UserBindingInstance) => any): Promise<UserBindingInstance>;
/**
* Fetch a UserBindingInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserBindingInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserBindingInstance>) => any): Promise<ApiResponse<UserBindingInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface UserBindingContextSolution {
serviceSid: string;
userSid: string;
sid: string;
}
export declare class UserBindingContextImpl implements UserBindingContext {
protected _version: V2;
protected _solution: UserBindingContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, userSid: 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?: UserBindingInstance) => any): Promise<UserBindingInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserBindingInstance>) => any): Promise<ApiResponse<UserBindingInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): UserBindingContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface UserBindingPayload extends TwilioResponsePayload {
bindings: UserBindingResource[];
}
interface UserBindingResource {
sid: string;
account_sid: string;
service_sid: string;
date_created: Date;
date_updated: Date;
endpoint: string;
identity: string;
user_sid: string;
credential_sid: string;
binding_type: UserBindingBindingType;
message_types: Array<string>;
url: string;
}
export declare class UserBindingInstance {
protected _version: V2;
protected _solution: UserBindingContextSolution;
protected _context?: UserBindingContext;
constructor(_version: V2, payload: UserBindingResource, serviceSid: string, userSid: string, sid?: string);
/**
* The unique string that we created to identify the User Binding resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the User Binding resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the User Binding resource is associated with.
*/
serviceSid: string;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The unique endpoint identifier for the User Binding. The format of the value depends on the `binding_type`.
*/
endpoint: string;
/**
* The application-defined string that uniquely identifies the resource\'s [User](https://www.twilio.com/docs/chat/rest/user-resource) within the [Service](https://www.twilio.com/docs/chat/rest/service-resource). See [access tokens](https://www.twilio.com/docs/chat/create-tokens) for more info.
*/
identity: string;
/**
* The SID of the [User](https://www.twilio.com/docs/chat/rest/user-resource) with the User Binding resource. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
*/
userSid: string;
/**
* The SID of the [Credential](https://www.twilio.com/docs/chat/rest/credential-resource) for the binding. See [push notification configuration](https://www.twilio.com/docs/chat/push-notification-configuration) for more info.
*/
credentialSid: string;
bindingType: UserBindingBindingType;
/**
* The [Programmable Chat message types](https://www.twilio.com/docs/chat/push-notification-configuration#push-types) the binding is subscribed to.
*/
messageTypes: Array<string>;
/**
* The absolute URL of the User Binding resource.
*/
url: string;
private get _proxy();
/**
* Remove a UserBindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserBindingInstance 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 UserBindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserBindingInstance
*/
fetch(callback?: (error: Error | null, item?: UserBindingInstance) => any): Promise<UserBindingInstance>;
/**
* Fetch a UserBindingInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserBindingInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserBindingInstance>) => any): Promise<ApiResponse<UserBindingInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
dateCreated: Date;
dateUpdated: Date;
endpoint: string;
identity: string;
userSid: string;
credentialSid: string;
bindingType: UserBindingBindingType;
messageTypes: string[];
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface UserBindingSolution {
serviceSid: string;
userSid: string;
}
export interface UserBindingListInstance {
_version: V2;
_solution: UserBindingSolution;
_uri: string;
(sid: string): UserBindingContext;
get(sid: string): UserBindingContext;
/**
* Streams UserBindingInstance 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 { UserBindingListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: UserBindingInstance, done: (err?: Error) => void) => void): void;
each(params: UserBindingListInstanceEachOptions, callback?: (item: UserBindingInstance, done: (err?: Error) => void) => void): void;
/**
* Streams UserBindingInstance 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 { UserBindingListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: UserBindingInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: UserBindingListInstanceEachOptions, callback?: (item: UserBindingInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of UserBindingInstance 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: UserBindingPage) => any): Promise<UserBindingPage>;
/**
* Retrieve a single target page of UserBindingInstance 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<UserBindingPage>) => any): Promise<ApiResponse<UserBindingPage>>;
/**
* Lists UserBindingInstance 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 { UserBindingListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: UserBindingInstance[]) => any): Promise<UserBindingInstance[]>;
list(params: UserBindingListInstanceOptions, callback?: (error: Error | null, items: UserBindingInstance[]) => any): Promise<UserBindingInstance[]>;
/**
* Lists UserBindingInstance 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 { UserBindingListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserBindingInstance[]>) => any): Promise<ApiResponse<UserBindingInstance[]>>;
listWithHttpInfo(params: UserBindingListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<UserBindingInstance[]>) => any): Promise<ApiResponse<UserBindingInstance[]>>;
/**
* Retrieve a single page of UserBindingInstance 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 { UserBindingListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: UserBindingPage) => any): Promise<UserBindingPage>;
page(params: UserBindingListInstancePageOptions, callback?: (error: Error | null, items: UserBindingPage) => any): Promise<UserBindingPage>;
/**
* Retrieve a single page of UserBindingInstance 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 { UserBindingListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserBindingPage>) => any): Promise<ApiResponse<UserBindingPage>>;
pageWithHttpInfo(params: UserBindingListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<UserBindingPage>) => any): Promise<ApiResponse<UserBindingPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function UserBindingListInstance(version: V2, serviceSid: string, userSid: string): UserBindingListInstance;
export declare class UserBindingPage extends Page<V2, UserBindingPayload, UserBindingResource, UserBindingInstance> {
/**
* Initialize the UserBindingPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: UserBindingSolution);
/**
* Build an instance of UserBindingInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: UserBindingResource): UserBindingInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,335 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.UserBindingPage = exports.UserBindingInstance = exports.UserBindingContextImpl = void 0;
exports.UserBindingListInstance = UserBindingListInstance;
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 UserBindingContextImpl {
constructor(_version, serviceSid, userSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(userSid)) {
throw new Error("Parameter 'userSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, userSid, sid };
this._uri = `/Services/${serviceSid}/Users/${userSid}/Bindings/${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 UserBindingInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.userSid, 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 UserBindingInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.userSid, 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.UserBindingContextImpl = UserBindingContextImpl;
class UserBindingInstance {
constructor(_version, payload, serviceSid, userSid, 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.endpoint = payload.endpoint;
this.identity = payload.identity;
this.userSid = payload.user_sid;
this.credentialSid = payload.credential_sid;
this.bindingType = payload.binding_type;
this.messageTypes = payload.message_types;
this.url = payload.url;
this._solution = { serviceSid, userSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new UserBindingContextImpl(this._version, this._solution.serviceSid, this._solution.userSid, this._solution.sid);
return this._context;
}
/**
* Remove a UserBindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a UserBindingInstance 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 UserBindingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserBindingInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a UserBindingInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserBindingInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(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,
endpoint: this.endpoint,
identity: this.identity,
userSid: this.userSid,
credentialSid: this.credentialSid,
bindingType: this.bindingType,
messageTypes: this.messageTypes,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserBindingInstance = UserBindingInstance;
function UserBindingListInstance(version, serviceSid, userSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(userSid)) {
throw new Error("Parameter 'userSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new UserBindingContextImpl(version, serviceSid, userSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, userSid };
instance._uri = `/Services/${serviceSid}/Users/${userSid}/Bindings`;
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["bindingType"] !== undefined)
data["BindingType"] = serialize.map(params["bindingType"], (e) => e);
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 UserBindingPage(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 UserBindingPage(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["bindingType"] !== undefined)
data["BindingType"] = serialize.map(params["bindingType"], (e) => e);
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 UserBindingPage(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 UserBindingPage(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 UserBindingPage extends Page_1.default {
/**
* Initialize the UserBindingPage
*
* @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 UserBindingInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new UserBindingInstance(this._version, payload, this._solution.serviceSid, this._solution.userSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserBindingPage = UserBindingPage;

View File

@@ -0,0 +1,481 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
/**
* The status of the User on the Channel. Can be: `joined`, `invited`, or `notParticipating`.
*/
export type UserChannelChannelStatus = "joined" | "invited" | "notParticipating";
/**
* The push notification level of the User for the Channel. Can be: `default` or `muted`.
*/
export type UserChannelNotificationLevel = "default" | "muted";
export type UserChannelWebhookEnabledType = "true" | "false";
/**
* Options to pass to remove a UserChannelInstance
*/
export interface UserChannelContextRemoveOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: UserChannelWebhookEnabledType;
}
/**
* Options to pass to update a UserChannelInstance
*/
export interface UserChannelContextUpdateOptions {
/** */
notificationLevel?: UserChannelNotificationLevel;
/** The index of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) in the [Channel](https://www.twilio.com/docs/chat/channels) that the Member has read. */
lastConsumedMessageIndex?: number;
/** The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) read event for the Member within the [Channel](https://www.twilio.com/docs/chat/channels). */
lastConsumptionTimestamp?: Date;
}
/**
* Options to pass to each
*/
export interface UserChannelListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: UserChannelInstance, 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 UserChannelListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
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 UserChannelListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 50. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface UserChannelContext {
/**
* Remove a UserChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
remove(params: UserChannelContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserChannelInstance 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>>;
/**
* Remove a UserChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance with HTTP metadata
*/
removeWithHttpInfo(params: UserChannelContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a UserChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
fetch(callback?: (error: Error | null, item?: UserChannelInstance) => any): Promise<UserChannelInstance>;
/**
* Fetch a UserChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserChannelInstance>) => any): Promise<ApiResponse<UserChannelInstance>>;
/**
* Update a UserChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
update(callback?: (error: Error | null, item?: UserChannelInstance) => any): Promise<UserChannelInstance>;
/**
* Update a UserChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
update(params: UserChannelContextUpdateOptions, callback?: (error: Error | null, item?: UserChannelInstance) => any): Promise<UserChannelInstance>;
/**
* Update a UserChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserChannelInstance>) => any): Promise<ApiResponse<UserChannelInstance>>;
/**
* Update a UserChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance with HTTP metadata
*/
updateWithHttpInfo(params: UserChannelContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<UserChannelInstance>) => any): Promise<ApiResponse<UserChannelInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface UserChannelContextSolution {
serviceSid: string;
userSid: string;
channelSid: string;
}
export declare class UserChannelContextImpl implements UserChannelContext {
protected _version: V2;
protected _solution: UserChannelContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, userSid: string, channelSid: string);
remove(params?: UserChannelContextRemoveOptions | ((error: Error | null, item?: boolean) => any), callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(params?: UserChannelContextRemoveOptions | ((error: Error | null, item?: ApiResponse<boolean>) => any), callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: UserChannelInstance) => any): Promise<UserChannelInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserChannelInstance>) => any): Promise<ApiResponse<UserChannelInstance>>;
update(params?: UserChannelContextUpdateOptions | ((error: Error | null, item?: UserChannelInstance) => any), callback?: (error: Error | null, item?: UserChannelInstance) => any): Promise<UserChannelInstance>;
updateWithHttpInfo(params?: UserChannelContextUpdateOptions | ((error: Error | null, item?: ApiResponse<UserChannelInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<UserChannelInstance>) => any): Promise<ApiResponse<UserChannelInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): UserChannelContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface UserChannelPayload extends TwilioResponsePayload {
channels: UserChannelResource[];
}
interface UserChannelResource {
account_sid: string;
service_sid: string;
channel_sid: string;
user_sid: string;
member_sid: string;
status: UserChannelChannelStatus;
last_consumed_message_index: number;
unread_messages_count: number;
links: Record<string, string>;
url: string;
notification_level: UserChannelNotificationLevel;
}
export declare class UserChannelInstance {
protected _version: V2;
protected _solution: UserChannelContextSolution;
protected _context?: UserChannelContext;
constructor(_version: V2, payload: UserChannelResource, serviceSid: string, userSid: string, channelSid?: string);
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the User Channel resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the User Channel resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Channel](https://www.twilio.com/docs/chat/channels) the User Channel resource belongs to.
*/
channelSid: string;
/**
* The SID of the [User](https://www.twilio.com/docs/chat/rest/user-resource) the User Channel belongs to.
*/
userSid: string;
/**
* The SID of a [Member](https://www.twilio.com/docs/chat/rest/member-resource) that represents the User on the Channel.
*/
memberSid: string;
status: UserChannelChannelStatus;
/**
* The index of the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) in the [Channel](https://www.twilio.com/docs/chat/channels) that the Member has read.
*/
lastConsumedMessageIndex: number;
/**
* The number of unread Messages in the Channel for the User. Note that retrieving messages on a client endpoint does not mean that messages are consumed or read. See [Consumption Horizon feature](https://www.twilio.com/docs/chat/consumption-horizon) to learn how to mark messages as consumed.
*/
unreadMessagesCount: number;
/**
* The absolute URLs of the [Members](https://www.twilio.com/docs/chat/rest/member-resource), [Messages](https://www.twilio.com/docs/chat/rest/message-resource) , [Invites](https://www.twilio.com/docs/chat/rest/invite-resource) and, if it exists, the last [Message](https://www.twilio.com/docs/chat/rest/message-resource) for the Channel.
*/
links: Record<string, string>;
/**
* The absolute URL of the User Channel resource.
*/
url: string;
notificationLevel: UserChannelNotificationLevel;
private get _proxy();
/**
* Remove a UserChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
remove(params: UserChannelContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a UserChannelInstance 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>>;
/**
* Remove a UserChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance with HTTP metadata
*/
removeWithHttpInfo(params: UserChannelContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a UserChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
fetch(callback?: (error: Error | null, item?: UserChannelInstance) => any): Promise<UserChannelInstance>;
/**
* Fetch a UserChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserChannelInstance>) => any): Promise<ApiResponse<UserChannelInstance>>;
/**
* Update a UserChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
update(callback?: (error: Error | null, item?: UserChannelInstance) => any): Promise<UserChannelInstance>;
/**
* Update a UserChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
update(params: UserChannelContextUpdateOptions, callback?: (error: Error | null, item?: UserChannelInstance) => any): Promise<UserChannelInstance>;
/**
* Update a UserChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<UserChannelInstance>) => any): Promise<ApiResponse<UserChannelInstance>>;
/**
* Update a UserChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance with HTTP metadata
*/
updateWithHttpInfo(params: UserChannelContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<UserChannelInstance>) => any): Promise<ApiResponse<UserChannelInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
accountSid: string;
serviceSid: string;
channelSid: string;
userSid: string;
memberSid: string;
status: UserChannelChannelStatus;
lastConsumedMessageIndex: number;
unreadMessagesCount: number;
links: Record<string, string>;
url: string;
notificationLevel: UserChannelNotificationLevel;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface UserChannelSolution {
serviceSid: string;
userSid: string;
}
export interface UserChannelListInstance {
_version: V2;
_solution: UserChannelSolution;
_uri: string;
(channelSid: string): UserChannelContext;
get(channelSid: string): UserChannelContext;
/**
* Streams UserChannelInstance 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 { UserChannelListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: UserChannelInstance, done: (err?: Error) => void) => void): void;
each(params: UserChannelListInstanceEachOptions, callback?: (item: UserChannelInstance, done: (err?: Error) => void) => void): void;
/**
* Streams UserChannelInstance 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 { UserChannelListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: UserChannelInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: UserChannelListInstanceEachOptions, callback?: (item: UserChannelInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of UserChannelInstance 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: UserChannelPage) => any): Promise<UserChannelPage>;
/**
* Retrieve a single target page of UserChannelInstance 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<UserChannelPage>) => any): Promise<ApiResponse<UserChannelPage>>;
/**
* Lists UserChannelInstance 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 { UserChannelListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: UserChannelInstance[]) => any): Promise<UserChannelInstance[]>;
list(params: UserChannelListInstanceOptions, callback?: (error: Error | null, items: UserChannelInstance[]) => any): Promise<UserChannelInstance[]>;
/**
* Lists UserChannelInstance 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 { UserChannelListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserChannelInstance[]>) => any): Promise<ApiResponse<UserChannelInstance[]>>;
listWithHttpInfo(params: UserChannelListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<UserChannelInstance[]>) => any): Promise<ApiResponse<UserChannelInstance[]>>;
/**
* Retrieve a single page of UserChannelInstance 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 { UserChannelListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: UserChannelPage) => any): Promise<UserChannelPage>;
page(params: UserChannelListInstancePageOptions, callback?: (error: Error | null, items: UserChannelPage) => any): Promise<UserChannelPage>;
/**
* Retrieve a single page of UserChannelInstance 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 { UserChannelListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<UserChannelPage>) => any): Promise<ApiResponse<UserChannelPage>>;
pageWithHttpInfo(params: UserChannelListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<UserChannelPage>) => any): Promise<ApiResponse<UserChannelPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function UserChannelListInstance(version: V2, serviceSid: string, userSid: string): UserChannelListInstance;
export declare class UserChannelPage extends Page<V2, UserChannelPayload, UserChannelResource, UserChannelInstance> {
/**
* Initialize the UserChannelPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: UserChannelSolution);
/**
* Build an instance of UserChannelInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: UserChannelResource): UserChannelInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,415 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.UserChannelPage = exports.UserChannelInstance = exports.UserChannelContextImpl = void 0;
exports.UserChannelListInstance = UserChannelListInstance;
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 UserChannelContextImpl {
constructor(_version, serviceSid, userSid, channelSid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(userSid)) {
throw new Error("Parameter 'userSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(channelSid)) {
throw new Error("Parameter 'channelSid' is not valid.");
}
this._solution = { serviceSid, userSid, channelSid };
this._uri = `/Services/${serviceSid}/Users/${userSid}/Channels/${channelSid}`;
}
remove(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
params: data,
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({
uri: instance._uri,
method: "delete",
params: data,
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 UserChannelInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.userSid, instance._solution.channelSid));
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 UserChannelInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.userSid, instance._solution.channelSid),
}));
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["notificationLevel"] !== undefined)
data["NotificationLevel"] = params["notificationLevel"];
if (params["lastConsumedMessageIndex"] !== undefined)
data["LastConsumedMessageIndex"] = params["lastConsumedMessageIndex"];
if (params["lastConsumptionTimestamp"] !== undefined)
data["LastConsumptionTimestamp"] = serialize.iso8601DateTime(params["lastConsumptionTimestamp"]);
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 UserChannelInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.userSid, instance._solution.channelSid));
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["notificationLevel"] !== undefined)
data["NotificationLevel"] = params["notificationLevel"];
if (params["lastConsumedMessageIndex"] !== undefined)
data["LastConsumedMessageIndex"] = params["lastConsumedMessageIndex"];
if (params["lastConsumptionTimestamp"] !== undefined)
data["LastConsumptionTimestamp"] = serialize.iso8601DateTime(params["lastConsumptionTimestamp"]);
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 UserChannelInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.userSid, instance._solution.channelSid),
}));
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.UserChannelContextImpl = UserChannelContextImpl;
class UserChannelInstance {
constructor(_version, payload, serviceSid, userSid, channelSid) {
this._version = _version;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.channelSid = payload.channel_sid;
this.userSid = payload.user_sid;
this.memberSid = payload.member_sid;
this.status = payload.status;
this.lastConsumedMessageIndex = deserialize.integer(payload.last_consumed_message_index);
this.unreadMessagesCount = deserialize.integer(payload.unread_messages_count);
this.links = payload.links;
this.url = payload.url;
this.notificationLevel = payload.notification_level;
this._solution = {
serviceSid,
userSid,
channelSid: channelSid || this.channelSid,
};
}
get _proxy() {
this._context =
this._context ||
new UserChannelContextImpl(this._version, this._solution.serviceSid, this._solution.userSid, this._solution.channelSid);
return this._context;
}
remove(params, callback) {
return this._proxy.remove(params, callback);
}
removeWithHttpInfo(params, callback) {
return this._proxy.removeWithHttpInfo(params, callback);
}
/**
* Fetch a UserChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a UserChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed UserChannelInstance 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 {
accountSid: this.accountSid,
serviceSid: this.serviceSid,
channelSid: this.channelSid,
userSid: this.userSid,
memberSid: this.memberSid,
status: this.status,
lastConsumedMessageIndex: this.lastConsumedMessageIndex,
unreadMessagesCount: this.unreadMessagesCount,
links: this.links,
url: this.url,
notificationLevel: this.notificationLevel,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserChannelInstance = UserChannelInstance;
function UserChannelListInstance(version, serviceSid, userSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(userSid)) {
throw new Error("Parameter 'userSid' is not valid.");
}
const instance = ((channelSid) => instance.get(channelSid));
instance.get = function get(channelSid) {
return new UserChannelContextImpl(version, serviceSid, userSid, channelSid);
};
instance._version = version;
instance._solution = { serviceSid, userSid };
instance._uri = `/Services/${serviceSid}/Users/${userSid}/Channels`;
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 UserChannelPage(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 UserChannelPage(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 UserChannelPage(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 UserChannelPage(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 UserChannelPage extends Page_1.default {
/**
* Initialize the UserChannelPage
*
* @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 UserChannelInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new UserChannelInstance(this._version, payload, this._solution.serviceSid, this._solution.userSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.UserChannelPage = UserChannelPage;

227
node_modules/twilio/lib/rest/chat/v3/channel.d.ts generated vendored Normal file
View File

@@ -0,0 +1,227 @@
import { inspect, InspectOptions } from "util";
import V3 from "../V3";
import { ApiResponse } from "../../../base/ApiResponse";
/**
* The visibility of the channel. Can be: `public` or `private`.
*/
export type ChannelChannelType = "public" | "private";
export type ChannelWebhookEnabledType = "true" | "false";
/**
* Options to pass to update a ChannelInstance
*/
export interface ChannelContextUpdateOptions {
/** The X-Twilio-Webhook-Enabled HTTP request header */
xTwilioWebhookEnabled?: ChannelWebhookEnabledType;
/** */
type?: ChannelChannelType;
/** The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to. */
messagingServiceSid?: string;
}
export interface ChannelContext {
/**
* Update a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface ChannelContextSolution {
serviceSid: string;
sid: string;
}
export declare class ChannelContextImpl implements ChannelContext {
protected _version: V3;
protected _solution: ChannelContextSolution;
protected _uri: string;
constructor(_version: V3, serviceSid: string, sid: string);
update(params?: ChannelContextUpdateOptions | ((error: Error | null, item?: ChannelInstance) => any), callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
updateWithHttpInfo(params?: ChannelContextUpdateOptions | ((error: Error | null, item?: ApiResponse<ChannelInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ChannelContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ChannelResource {
sid: string;
account_sid: string;
service_sid: string;
friendly_name: string;
unique_name: string;
attributes: string;
type: ChannelChannelType;
date_created: Date;
date_updated: Date;
created_by: string;
members_count: number;
messages_count: number;
messaging_service_sid: string;
url: string;
}
export declare class ChannelInstance {
protected _version: V3;
protected _solution: ChannelContextSolution;
protected _context?: ChannelContext;
constructor(_version: V3, payload: ChannelResource, serviceSid?: string, sid?: string);
/**
* The unique string that we created to identify the Channel resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Channel resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the Channel resource is associated with.
*/
serviceSid: string;
/**
* The string that you assigned to describe the resource.
*/
friendlyName: string;
/**
* An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource\'s `sid` in the URL.
*/
uniqueName: string;
/**
* The JSON string that stores application-specific data. If attributes have not been set, `{}` is returned.
*/
attributes: string;
type: ChannelChannelType;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The `identity` of the User that created the channel. If the Channel was created by using the API, the value is `system`.
*/
createdBy: string;
/**
* The number of Members in the Channel.
*/
membersCount: number;
/**
* The number of Messages that have been passed in the Channel.
*/
messagesCount: number;
/**
* The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to.
*/
messagingServiceSid: string;
/**
* The absolute URL of the Channel resource.
*/
url: string;
private get _proxy();
/**
* Update a ChannelInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance
*/
update(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ChannelInstance) => any): Promise<ChannelInstance>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Update a ChannelInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChannelInstance with HTTP metadata
*/
updateWithHttpInfo(params: ChannelContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ChannelInstance>) => any): Promise<ApiResponse<ChannelInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
friendlyName: string;
uniqueName: string;
attributes: string;
type: ChannelChannelType;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
membersCount: number;
messagesCount: number;
messagingServiceSid: string;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface ChannelSolution {
}
export interface ChannelListInstance {
_version: V3;
_solution: ChannelSolution;
_uri: string;
(serviceSid: string, sid: string): ChannelContext;
get(serviceSid: string, sid: string): ChannelContext;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function ChannelListInstance(version: V3): ChannelListInstance;
export {};

188
node_modules/twilio/lib/rest/chat/v3/channel.js generated vendored Normal file
View File

@@ -0,0 +1,188 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Chat
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChannelInstance = exports.ChannelContextImpl = void 0;
exports.ChannelListInstance = ChannelListInstance;
const util_1 = require("util");
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
const utility_1 = require("../../../base/utility");
class ChannelContextImpl {
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}/Channels/${sid}`;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["type"] !== undefined)
data["Type"] = params["type"];
if (params["messagingServiceSid"] !== undefined)
data["MessagingServiceSid"] = params["messagingServiceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ChannelInstance(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["type"] !== undefined)
data["Type"] = params["type"];
if (params["messagingServiceSid"] !== undefined)
data["MessagingServiceSid"] = params["messagingServiceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["xTwilioWebhookEnabled"] !== undefined)
headers["X-Twilio-Webhook-Enabled"] = params["xTwilioWebhookEnabled"];
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 ChannelInstance(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.ChannelContextImpl = ChannelContextImpl;
class ChannelInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.friendlyName = payload.friendly_name;
this.uniqueName = payload.unique_name;
this.attributes = payload.attributes;
this.type = payload.type;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this.membersCount = deserialize.integer(payload.members_count);
this.messagesCount = deserialize.integer(payload.messages_count);
this.messagingServiceSid = payload.messaging_service_sid;
this.url = payload.url;
this._solution = {
serviceSid: serviceSid || this.serviceSid,
sid: sid || this.sid,
};
}
get _proxy() {
this._context =
this._context ||
new ChannelContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
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,
friendlyName: this.friendlyName,
uniqueName: this.uniqueName,
attributes: this.attributes,
type: this.type,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
membersCount: this.membersCount,
messagesCount: this.messagesCount,
messagingServiceSid: this.messagingServiceSid,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ChannelInstance = ChannelInstance;
function ChannelListInstance(version) {
const instance = ((serviceSid, sid) => instance.get(serviceSid, sid));
instance.get = function get(serviceSid, sid) {
return new ChannelContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = {};
instance._uri = ``;
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;
}