twilio
Version:
A Twilio helper library
404 lines (403 loc) • 17.7 kB
TypeScript
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../base/Page";
import Response from "../../../http/response";
import V1 from "../V1";
import { DocumentListInstance } from "./service/document";
import { SyncListListInstance } from "./service/syncList";
import { SyncMapListInstance } from "./service/syncMap";
import { SyncStreamListInstance } from "./service/syncStream";
/**
* Options to pass to update a ServiceInstance
*/
export interface ServiceContextUpdateOptions {
/** The URL we should call when Sync objects are manipulated. */
webhookUrl?: string;
/** A string that you assign to describe the resource. */
friendlyName?: string;
/** Whether the service instance should call `webhook_url` when client endpoints connect to Sync. The default is `false`. */
reachabilityWebhooksEnabled?: boolean;
/** Whether token identities in the Service must be granted access to Sync objects by using the [Permissions](https://www.twilio.com/docs/sync/api/sync-permissions) resource. */
aclEnabled?: boolean;
/** Whether every `endpoint_disconnected` event should occur after a configurable delay. The default is `false`, where the `endpoint_disconnected` event occurs immediately after disconnection. When `true`, intervening reconnections can prevent the `endpoint_disconnected` event. */
reachabilityDebouncingEnabled?: boolean;
/** The reachability event delay in milliseconds if `reachability_debouncing_enabled` = `true`. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before the webhook is called if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the webhook from being called. */
reachabilityDebouncingWindow?: number;
/** Whether the Service instance should call `webhook_url` when the REST API is used to update Sync objects. The default is `false`. */
webhooksFromRestEnabled?: boolean;
}
/**
* Options to pass to create a ServiceInstance
*/
export interface ServiceListInstanceCreateOptions {
/** A string that you assign to describe the resource. */
friendlyName?: string;
/** The URL we should call when Sync objects are manipulated. */
webhookUrl?: string;
/** Whether the service instance should call `webhook_url` when client endpoints connect to Sync. The default is `false`. */
reachabilityWebhooksEnabled?: boolean;
/** Whether token identities in the Service must be granted access to Sync objects by using the [Permissions](https://www.twilio.com/docs/sync/api/sync-permissions) resource. */
aclEnabled?: boolean;
/** Whether every `endpoint_disconnected` event should occur after a configurable delay. The default is `false`, where the `endpoint_disconnected` event occurs immediately after disconnection. When `true`, intervening reconnections can prevent the `endpoint_disconnected` event. */
reachabilityDebouncingEnabled?: boolean;
/** The reachability event delay in milliseconds if `reachability_debouncing_enabled` = `true`. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before the `webhook_url` is called if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the call to `webhook_url`. */
reachabilityDebouncingWindow?: number;
/** Whether the Service instance should call `webhook_url` when the REST API is used to update Sync objects. The default is `false`. */
webhooksFromRestEnabled?: boolean;
}
/**
* 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 {
documents: DocumentListInstance;
syncLists: SyncListListInstance;
syncMaps: SyncMapListInstance;
syncStreams: SyncStreamListInstance;
/**
* 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>;
/**
* 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>;
/**
* 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>;
/**
* 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 _documents?: DocumentListInstance;
protected _syncLists?: SyncListListInstance;
protected _syncMaps?: SyncMapListInstance;
protected _syncStreams?: SyncStreamListInstance;
constructor(_version: V1, sid: string);
get documents(): DocumentListInstance;
get syncLists(): SyncListListInstance;
get syncMaps(): SyncMapListInstance;
get syncStreams(): SyncStreamListInstance;
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
fetch(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
update(params?: ServiceContextUpdateOptions | ((error: Error | null, item?: ServiceInstance) => any), callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ServiceContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ServicePayload extends TwilioResponsePayload {
services: ServiceResource[];
}
interface ServiceResource {
sid: string;
unique_name: string;
account_sid: string;
friendly_name: string;
date_created: Date;
date_updated: Date;
url: string;
webhook_url: string;
webhooks_from_rest_enabled: boolean;
reachability_webhooks_enabled: boolean;
acl_enabled: boolean;
reachability_debouncing_enabled: boolean;
reachability_debouncing_window: number;
links: Record<string, string>;
}
export declare class ServiceInstance {
protected _version: V1;
protected _solution: ServiceContextSolution;
protected _context?: ServiceContext;
constructor(_version: V1, payload: ServiceResource, sid?: string);
/**
* The unique string that we created to identify the Service resource.
*/
sid: string;
/**
* An application-defined string that uniquely identifies the resource. It can be used in place of the resource\'s `sid` in the URL to address the resource. It is a read-only property, it cannot be assigned using REST API.
*/
uniqueName: 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 absolute URL of the Service resource.
*/
url: string;
/**
* The URL we call when Sync objects are manipulated.
*/
webhookUrl: string;
/**
* Whether the Service instance should call `webhook_url` when the REST API is used to update Sync objects. The default is `false`.
*/
webhooksFromRestEnabled: boolean;
/**
* Whether the service instance calls `webhook_url` when client endpoints connect to Sync. The default is `false`.
*/
reachabilityWebhooksEnabled: boolean;
/**
* Whether token identities in the Service must be granted access to Sync objects by using the [Permissions](https://www.twilio.com/docs/sync/api/sync-permissions) resource. It is disabled (false) by default.
*/
aclEnabled: boolean;
/**
* Whether every `endpoint_disconnected` event should occur after a configurable delay. The default is `false`, where the `endpoint_disconnected` event occurs immediately after disconnection. When `true`, intervening reconnections can prevent the `endpoint_disconnected` event.
*/
reachabilityDebouncingEnabled: boolean;
/**
* The reachability event delay in milliseconds if `reachability_debouncing_enabled` = `true`. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before `webhook_url` is called, if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the reachability event from occurring.
*/
reachabilityDebouncingWindow: number;
/**
* The URLs of related resources.
*/
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>;
/**
* 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>;
/**
* 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>;
/**
* Access the documents.
*/
documents(): DocumentListInstance;
/**
* Access the syncLists.
*/
syncLists(): SyncListListInstance;
/**
* Access the syncMaps.
*/
syncMaps(): SyncMapListInstance;
/**
* Access the syncStreams.
*/
syncStreams(): SyncStreamListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
uniqueName: string;
accountSid: string;
friendlyName: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
webhookUrl: string;
webhooksFromRestEnabled: boolean;
reachabilityWebhooksEnabled: boolean;
aclEnabled: boolean;
reachabilityDebouncingEnabled: boolean;
reachabilityDebouncingWindow: number;
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 callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
create(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* 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>;
/**
* 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;
/**
* 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>;
/**
* 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[]>;
/**
* 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>;
/**
* 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 {};