twilio
Version:
A Twilio helper library
331 lines (330 loc) • 12.7 kB
TypeScript
/// <reference types="node" />
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V1 from "../../V1";
/**
* Options to pass to update a WebhookInstance
*/
export interface WebhookContextUpdateOptions {
/** An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. */
uniqueName?: string;
/** The list of space-separated events that this Webhook will subscribe to. */
events?: string;
/** The URL associated with this Webhook. */
webhookUrl?: string;
/** The method to be used when calling the webhook\\\'s URL. */
webhookMethod?: string;
}
/**
* Options to pass to create a WebhookInstance
*/
export interface WebhookListInstanceCreateOptions {
/** An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. */
uniqueName: string;
/** The list of space-separated events that this Webhook will subscribe to. */
events: string;
/** The URL associated with this Webhook. */
webhookUrl: string;
/** The method to be used when calling the webhook\\\'s URL. */
webhookMethod?: string;
}
/**
* Options to pass to each
*/
export interface WebhookListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: WebhookInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface WebhookListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface WebhookListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface WebhookContext {
/**
* Remove a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<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>;
/**
* 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>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface WebhookContextSolution {
assistantSid: string;
sid: string;
}
export declare class WebhookContextImpl implements WebhookContext {
protected _version: V1;
protected _solution: WebhookContextSolution;
protected _uri: string;
constructor(_version: V1, assistantSid: string, sid: string);
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
fetch(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
update(params?: WebhookContextUpdateOptions | ((error: Error | null, item?: WebhookInstance) => any), callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<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 {
url: string;
account_sid: string;
date_created: Date;
date_updated: Date;
assistant_sid: string;
sid: string;
unique_name: string;
events: string;
webhook_url: string;
webhook_method: string;
}
export declare class WebhookInstance {
protected _version: V1;
protected _solution: WebhookContextSolution;
protected _context?: WebhookContext;
constructor(_version: V1, payload: WebhookResource, assistantSid: string, sid?: string);
/**
* The absolute URL of the Webhook resource.
*/
url: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Webhook resource.
*/
accountSid: string;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.
*/
assistantSid: string;
/**
* The unique string that we created to identify the Webhook resource.
*/
sid: string;
/**
* An application-defined string that uniquely identifies the resource. It can be used in place of the resource\'s `sid` in the URL to address the resource.
*/
uniqueName: string;
/**
* The list of space-separated events that this Webhook is subscribed to.
*/
events: string;
/**
* The URL associated with this Webhook.
*/
webhookUrl: string;
/**
* The method used when calling the webhook\'s URL.
*/
webhookMethod: string;
private get _proxy();
/**
* 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>;
/**
* 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>;
/**
* 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>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
url: string;
accountSid: string;
dateCreated: Date;
dateUpdated: Date;
assistantSid: string;
sid: string;
uniqueName: string;
events: string;
webhookUrl: string;
webhookMethod: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface WebhookSolution {
assistantSid: string;
}
export interface WebhookListInstance {
_version: V1;
_solution: WebhookSolution;
_uri: string;
(sid: string): WebhookContext;
get(sid: string): WebhookContext;
/**
* Create a WebhookInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
create(params: WebhookListInstanceCreateOptions, callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<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;
/**
* 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>;
/**
* 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[]>;
/**
* 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>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function WebhookListInstance(version: V1, assistantSid: string): WebhookListInstance;
export declare class WebhookPage extends Page<V1, WebhookPayload, WebhookResource, WebhookInstance> {
/**
* Initialize the WebhookPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<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 {};