Auto-commit 2026-04-29 16:31

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

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

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

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

@@ -0,0 +1,36 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Version_1 = __importDefault(require("../../base/Version"));
const service_1 = require("./v1/service");
class V1 extends Version_1.default {
/**
* Initialize the V1 version of Sync
*
* @param domain - The Twilio (Twilio.Sync) domain
*/
constructor(domain) {
super(domain, "v1");
}
/** Getter for services resource */
get services() {
this._services = this._services || (0, service_1.ServiceListInstance)(this);
return this._services;
}
}
exports.default = V1;

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

@@ -0,0 +1,542 @@
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 { 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>;
/**
* 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 _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>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
update(params?: ServiceContextUpdateOptions | ((error: Error | null, item?: ServiceInstance) => any), callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
updateWithHttpInfo(params?: ServiceContextUpdateOptions | ((error: Error | null, item?: ApiResponse<ServiceInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ServiceContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ServicePayload extends TwilioResponsePayload {
services: ServiceResource[];
}
interface ServiceResource {
sid: string;
unique_name: string;
account_sid: string;
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>;
/**
* 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 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>;
/**
* Create a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<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 {};

543
node_modules/twilio/lib/rest/sync/v1/service.js generated vendored Normal file
View File

@@ -0,0 +1,543 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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 document_1 = require("./service/document");
const syncList_1 = require("./service/syncList");
const syncMap_1 = require("./service/syncMap");
const syncStream_1 = require("./service/syncStream");
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 documents() {
this._documents =
this._documents ||
(0, document_1.DocumentListInstance)(this._version, this._solution.sid);
return this._documents;
}
get syncLists() {
this._syncLists =
this._syncLists ||
(0, syncList_1.SyncListListInstance)(this._version, this._solution.sid);
return this._syncLists;
}
get syncMaps() {
this._syncMaps =
this._syncMaps || (0, syncMap_1.SyncMapListInstance)(this._version, this._solution.sid);
return this._syncMaps;
}
get syncStreams() {
this._syncStreams =
this._syncStreams ||
(0, syncStream_1.SyncStreamListInstance)(this._version, this._solution.sid);
return this._syncStreams;
}
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["webhookUrl"] !== undefined)
data["WebhookUrl"] = params["webhookUrl"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["reachabilityWebhooksEnabled"] !== undefined)
data["ReachabilityWebhooksEnabled"] = serialize.bool(params["reachabilityWebhooksEnabled"]);
if (params["aclEnabled"] !== undefined)
data["AclEnabled"] = serialize.bool(params["aclEnabled"]);
if (params["reachabilityDebouncingEnabled"] !== undefined)
data["ReachabilityDebouncingEnabled"] = serialize.bool(params["reachabilityDebouncingEnabled"]);
if (params["reachabilityDebouncingWindow"] !== undefined)
data["ReachabilityDebouncingWindow"] =
params["reachabilityDebouncingWindow"];
if (params["webhooksFromRestEnabled"] !== undefined)
data["WebhooksFromRestEnabled"] = serialize.bool(params["webhooksFromRestEnabled"]);
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["webhookUrl"] !== undefined)
data["WebhookUrl"] = params["webhookUrl"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["reachabilityWebhooksEnabled"] !== undefined)
data["ReachabilityWebhooksEnabled"] = serialize.bool(params["reachabilityWebhooksEnabled"]);
if (params["aclEnabled"] !== undefined)
data["AclEnabled"] = serialize.bool(params["aclEnabled"]);
if (params["reachabilityDebouncingEnabled"] !== undefined)
data["ReachabilityDebouncingEnabled"] = serialize.bool(params["reachabilityDebouncingEnabled"]);
if (params["reachabilityDebouncingWindow"] !== undefined)
data["ReachabilityDebouncingWindow"] =
params["reachabilityDebouncingWindow"];
if (params["webhooksFromRestEnabled"] !== undefined)
data["WebhooksFromRestEnabled"] = serialize.bool(params["webhooksFromRestEnabled"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ServiceInstance(operationVersion, response.body, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ServiceContextImpl = ServiceContextImpl;
class ServiceInstance {
constructor(_version, payload, sid) {
this._version = _version;
this.sid = payload.sid;
this.uniqueName = payload.unique_name;
this.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this.webhookUrl = payload.webhook_url;
this.webhooksFromRestEnabled = payload.webhooks_from_rest_enabled;
this.reachabilityWebhooksEnabled = payload.reachability_webhooks_enabled;
this.aclEnabled = payload.acl_enabled;
this.reachabilityDebouncingEnabled =
payload.reachability_debouncing_enabled;
this.reachabilityDebouncingWindow = deserialize.integer(payload.reachability_debouncing_window);
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 documents.
*/
documents() {
return this._proxy.documents;
}
/**
* Access the syncLists.
*/
syncLists() {
return this._proxy.syncLists;
}
/**
* Access the syncMaps.
*/
syncMaps() {
return this._proxy.syncMaps;
}
/**
* Access the syncStreams.
*/
syncStreams() {
return this._proxy.syncStreams;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
uniqueName: this.uniqueName,
accountSid: this.accountSid,
friendlyName: this.friendlyName,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
webhookUrl: this.webhookUrl,
webhooksFromRestEnabled: this.webhooksFromRestEnabled,
reachabilityWebhooksEnabled: this.reachabilityWebhooksEnabled,
aclEnabled: this.aclEnabled,
reachabilityDebouncingEnabled: this.reachabilityDebouncingEnabled,
reachabilityDebouncingWindow: this.reachabilityDebouncingWindow,
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 instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["webhookUrl"] !== undefined)
data["WebhookUrl"] = params["webhookUrl"];
if (params["reachabilityWebhooksEnabled"] !== undefined)
data["ReachabilityWebhooksEnabled"] = serialize.bool(params["reachabilityWebhooksEnabled"]);
if (params["aclEnabled"] !== undefined)
data["AclEnabled"] = serialize.bool(params["aclEnabled"]);
if (params["reachabilityDebouncingEnabled"] !== undefined)
data["ReachabilityDebouncingEnabled"] = serialize.bool(params["reachabilityDebouncingEnabled"]);
if (params["reachabilityDebouncingWindow"] !== undefined)
data["ReachabilityDebouncingWindow"] =
params["reachabilityDebouncingWindow"];
if (params["webhooksFromRestEnabled"] !== undefined)
data["WebhooksFromRestEnabled"] = serialize.bool(params["webhooksFromRestEnabled"]);
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 instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["webhookUrl"] !== undefined)
data["WebhookUrl"] = params["webhookUrl"];
if (params["reachabilityWebhooksEnabled"] !== undefined)
data["ReachabilityWebhooksEnabled"] = serialize.bool(params["reachabilityWebhooksEnabled"]);
if (params["aclEnabled"] !== undefined)
data["AclEnabled"] = serialize.bool(params["aclEnabled"]);
if (params["reachabilityDebouncingEnabled"] !== undefined)
data["ReachabilityDebouncingEnabled"] = serialize.bool(params["reachabilityDebouncingEnabled"]);
if (params["reachabilityDebouncingWindow"] !== undefined)
data["ReachabilityDebouncingWindow"] =
params["reachabilityDebouncingWindow"];
if (params["webhooksFromRestEnabled"] !== undefined)
data["WebhooksFromRestEnabled"] = serialize.bool(params["webhooksFromRestEnabled"]);
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,492 @@
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 { DocumentPermissionListInstance } from "./document/documentPermission";
/**
* Options to pass to update a DocumentInstance
*/
export interface DocumentContextUpdateOptions {
/** The If-Match HTTP request header */
ifMatch?: string;
/** A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length. */
data?: any;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Document expires and is deleted (time-to-live). */
ttl?: number;
}
/**
* Options to pass to create a DocumentInstance
*/
export interface DocumentListInstanceCreateOptions {
/** An application-defined string that uniquely identifies the Sync Document */
uniqueName?: string;
/** A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length. */
data?: any;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Document expires and is deleted (the Sync Document\\\'s time-to-live). */
ttl?: number;
}
/**
* Options to pass to each
*/
export interface DocumentListInstanceEachOptions {
/** 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: DocumentInstance, 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 DocumentListInstanceOptions {
/** 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 DocumentListInstancePageOptions {
/** 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 DocumentContext {
documentPermissions: DocumentPermissionListInstance;
/**
* Remove a DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a DocumentInstance 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 DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
fetch(callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
/**
* Fetch a DocumentInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Update a DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
update(callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
/**
* Update a DocumentInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
update(params: DocumentContextUpdateOptions, callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
/**
* Update a DocumentInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Update a DocumentInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance with HTTP metadata
*/
updateWithHttpInfo(params: DocumentContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface DocumentContextSolution {
serviceSid: string;
sid: string;
}
export declare class DocumentContextImpl implements DocumentContext {
protected _version: V1;
protected _solution: DocumentContextSolution;
protected _uri: string;
protected _documentPermissions?: DocumentPermissionListInstance;
constructor(_version: V1, serviceSid: string, sid: string);
get documentPermissions(): DocumentPermissionListInstance;
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?: DocumentInstance) => any): Promise<DocumentInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
update(params?: DocumentContextUpdateOptions | ((error: Error | null, item?: DocumentInstance) => any), callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
updateWithHttpInfo(params?: DocumentContextUpdateOptions | ((error: Error | null, item?: ApiResponse<DocumentInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): DocumentContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface DocumentPayload extends TwilioResponsePayload {
documents: DocumentResource[];
}
interface DocumentResource {
sid: string;
unique_name: string;
account_sid: string;
service_sid: string;
url: string;
links: Record<string, string>;
revision: string;
data: any;
date_expires: Date;
date_created: Date;
date_updated: Date;
created_by: string;
}
export declare class DocumentInstance {
protected _version: V1;
protected _solution: DocumentContextSolution;
protected _context?: DocumentContext;
constructor(_version: V1, payload: DocumentResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Document 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 and can be up to 320 characters long.
*/
uniqueName: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Document resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The absolute URL of the Document resource.
*/
url: string;
/**
* The URLs of resources related to the Sync Document.
*/
links: Record<string, string>;
/**
* The current revision of the Sync Document, represented as a string. The `revision` property is used with conditional updates to ensure data consistency.
*/
revision: string;
/**
* An arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length.
*/
data: any;
/**
* The date and time in GMT when the Sync Document expires and will be deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the Sync Document does not expire, this value is `null`. The Document resource might not be deleted immediately after it expires.
*/
dateExpires: Date;
/**
* 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 Sync Document\'s creator. If the Sync Document is created from the client SDK, the value matches the Access Token\'s `identity` field. If the Sync Document was created from the REST API, the value is `system`.
*/
createdBy: string;
private get _proxy();
/**
* Remove a DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a DocumentInstance 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 DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
fetch(callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
/**
* Fetch a DocumentInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Update a DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
update(callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
/**
* Update a DocumentInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
update(params: DocumentContextUpdateOptions, callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
/**
* Update a DocumentInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Update a DocumentInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance with HTTP metadata
*/
updateWithHttpInfo(params: DocumentContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Access the documentPermissions.
*/
documentPermissions(): DocumentPermissionListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
uniqueName: string;
accountSid: string;
serviceSid: string;
url: string;
links: Record<string, string>;
revision: string;
data: any;
dateExpires: Date;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface DocumentSolution {
serviceSid: string;
}
export interface DocumentListInstance {
_version: V1;
_solution: DocumentSolution;
_uri: string;
(sid: string): DocumentContext;
get(sid: string): DocumentContext;
/**
* Create a DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
create(callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
/**
* Create a DocumentInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
create(params: DocumentListInstanceCreateOptions, callback?: (error: Error | null, item?: DocumentInstance) => any): Promise<DocumentInstance>;
/**
* Create a DocumentInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Create a DocumentInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance with HTTP metadata
*/
createWithHttpInfo(params: DocumentListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<DocumentInstance>) => any): Promise<ApiResponse<DocumentInstance>>;
/**
* Streams DocumentInstance 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 { DocumentListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: DocumentInstance, done: (err?: Error) => void) => void): void;
each(params: DocumentListInstanceEachOptions, callback?: (item: DocumentInstance, done: (err?: Error) => void) => void): void;
/**
* Streams DocumentInstance 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 { DocumentListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: DocumentInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: DocumentListInstanceEachOptions, callback?: (item: DocumentInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of DocumentInstance 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: DocumentPage) => any): Promise<DocumentPage>;
/**
* Retrieve a single target page of DocumentInstance 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<DocumentPage>) => any): Promise<ApiResponse<DocumentPage>>;
/**
* Lists DocumentInstance 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 { DocumentListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: DocumentInstance[]) => any): Promise<DocumentInstance[]>;
list(params: DocumentListInstanceOptions, callback?: (error: Error | null, items: DocumentInstance[]) => any): Promise<DocumentInstance[]>;
/**
* Lists DocumentInstance 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 { DocumentListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<DocumentInstance[]>) => any): Promise<ApiResponse<DocumentInstance[]>>;
listWithHttpInfo(params: DocumentListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<DocumentInstance[]>) => any): Promise<ApiResponse<DocumentInstance[]>>;
/**
* Retrieve a single page of DocumentInstance 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 { DocumentListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: DocumentPage) => any): Promise<DocumentPage>;
page(params: DocumentListInstancePageOptions, callback?: (error: Error | null, items: DocumentPage) => any): Promise<DocumentPage>;
/**
* Retrieve a single page of DocumentInstance 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 { DocumentListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<DocumentPage>) => any): Promise<ApiResponse<DocumentPage>>;
pageWithHttpInfo(params: DocumentListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<DocumentPage>) => any): Promise<ApiResponse<DocumentPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function DocumentListInstance(version: V1, serviceSid: string): DocumentListInstance;
export declare class DocumentPage extends Page<V1, DocumentPayload, DocumentResource, DocumentInstance> {
/**
* Initialize the DocumentPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: DocumentSolution);
/**
* Build an instance of DocumentInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: DocumentResource): DocumentInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,470 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.DocumentPage = exports.DocumentInstance = exports.DocumentContextImpl = void 0;
exports.DocumentListInstance = DocumentListInstance;
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 documentPermission_1 = require("./document/documentPermission");
class DocumentContextImpl {
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}/Documents/${sid}`;
}
get documentPermissions() {
this._documentPermissions =
this._documentPermissions ||
(0, documentPermission_1.DocumentPermissionListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._documentPermissions;
}
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 DocumentInstance(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 DocumentInstance(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["data"] !== undefined)
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new DocumentInstance(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["data"] !== undefined)
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
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 DocumentInstance(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.DocumentContextImpl = DocumentContextImpl;
class DocumentInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.uniqueName = payload.unique_name;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.url = payload.url;
this.links = payload.links;
this.revision = payload.revision;
this.data = payload.data;
this.dateExpires = deserialize.iso8601DateTime(payload.date_expires);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new DocumentContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a DocumentInstance 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 DocumentInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a DocumentInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentInstance 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 documentPermissions.
*/
documentPermissions() {
return this._proxy.documentPermissions;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
uniqueName: this.uniqueName,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
url: this.url,
links: this.links,
revision: this.revision,
data: this.data,
dateExpires: this.dateExpires,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.DocumentInstance = DocumentInstance;
function DocumentListInstance(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 DocumentContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Documents`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["data"] !== undefined)
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
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 DocumentInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["data"] !== undefined)
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
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 DocumentInstance(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 DocumentPage(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 DocumentPage(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 DocumentPage(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 DocumentPage(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 DocumentPage extends Page_1.default {
/**
* Initialize the DocumentPage
*
* @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 DocumentInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new DocumentInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.DocumentPage = DocumentPage;

View File

@@ -0,0 +1,385 @@
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 DocumentPermissionInstance
*/
export interface DocumentPermissionContextUpdateOptions {
/** Whether the identity can read the Sync Document. Default value is `false`. */
read: boolean;
/** Whether the identity can update the Sync Document. Default value is `false`. */
write: boolean;
/** Whether the identity can delete the Sync Document. Default value is `false`. */
manage: boolean;
}
/**
* Options to pass to each
*/
export interface DocumentPermissionListInstanceEachOptions {
/** 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: DocumentPermissionInstance, 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 DocumentPermissionListInstanceOptions {
/** 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 DocumentPermissionListInstancePageOptions {
/** 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 DocumentPermissionContext {
/**
* Remove a DocumentPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a DocumentPermissionInstance 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 DocumentPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance
*/
fetch(callback?: (error: Error | null, item?: DocumentPermissionInstance) => any): Promise<DocumentPermissionInstance>;
/**
* Fetch a DocumentPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentPermissionInstance>) => any): Promise<ApiResponse<DocumentPermissionInstance>>;
/**
* Update a DocumentPermissionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance
*/
update(params: DocumentPermissionContextUpdateOptions, callback?: (error: Error | null, item?: DocumentPermissionInstance) => any): Promise<DocumentPermissionInstance>;
/**
* Update a DocumentPermissionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance with HTTP metadata
*/
updateWithHttpInfo(params: DocumentPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<DocumentPermissionInstance>) => any): Promise<ApiResponse<DocumentPermissionInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface DocumentPermissionContextSolution {
serviceSid: string;
documentSid: string;
identity: string;
}
export declare class DocumentPermissionContextImpl implements DocumentPermissionContext {
protected _version: V1;
protected _solution: DocumentPermissionContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, documentSid: string, identity: 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?: DocumentPermissionInstance) => any): Promise<DocumentPermissionInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentPermissionInstance>) => any): Promise<ApiResponse<DocumentPermissionInstance>>;
update(params: DocumentPermissionContextUpdateOptions, callback?: (error: Error | null, item?: DocumentPermissionInstance) => any): Promise<DocumentPermissionInstance>;
updateWithHttpInfo(params: DocumentPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<DocumentPermissionInstance>) => any): Promise<ApiResponse<DocumentPermissionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): DocumentPermissionContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface DocumentPermissionPayload extends TwilioResponsePayload {
permissions: DocumentPermissionResource[];
}
interface DocumentPermissionResource {
account_sid: string;
service_sid: string;
document_sid: string;
identity: string;
read: boolean;
write: boolean;
manage: boolean;
url: string;
}
export declare class DocumentPermissionInstance {
protected _version: V1;
protected _solution: DocumentPermissionContextSolution;
protected _context?: DocumentPermissionContext;
constructor(_version: V1, payload: DocumentPermissionResource, serviceSid: string, documentSid: string, identity?: string);
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Document Permission resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the Sync Document to which the Document Permission applies.
*/
documentSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s User within the Service to an FPA token.
*/
identity: string;
/**
* Whether the identity can read the Sync Document.
*/
read: boolean;
/**
* Whether the identity can update the Sync Document.
*/
write: boolean;
/**
* Whether the identity can delete the Sync Document.
*/
manage: boolean;
/**
* The absolute URL of the Sync Document Permission resource.
*/
url: string;
private get _proxy();
/**
* Remove a DocumentPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a DocumentPermissionInstance 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 DocumentPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance
*/
fetch(callback?: (error: Error | null, item?: DocumentPermissionInstance) => any): Promise<DocumentPermissionInstance>;
/**
* Fetch a DocumentPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<DocumentPermissionInstance>) => any): Promise<ApiResponse<DocumentPermissionInstance>>;
/**
* Update a DocumentPermissionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance
*/
update(params: DocumentPermissionContextUpdateOptions, callback?: (error: Error | null, item?: DocumentPermissionInstance) => any): Promise<DocumentPermissionInstance>;
/**
* Update a DocumentPermissionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance with HTTP metadata
*/
updateWithHttpInfo(params: DocumentPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<DocumentPermissionInstance>) => any): Promise<ApiResponse<DocumentPermissionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
accountSid: string;
serviceSid: string;
documentSid: string;
identity: string;
read: boolean;
write: boolean;
manage: boolean;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface DocumentPermissionSolution {
serviceSid: string;
documentSid: string;
}
export interface DocumentPermissionListInstance {
_version: V1;
_solution: DocumentPermissionSolution;
_uri: string;
(identity: string): DocumentPermissionContext;
get(identity: string): DocumentPermissionContext;
/**
* Streams DocumentPermissionInstance 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 { DocumentPermissionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: DocumentPermissionInstance, done: (err?: Error) => void) => void): void;
each(params: DocumentPermissionListInstanceEachOptions, callback?: (item: DocumentPermissionInstance, done: (err?: Error) => void) => void): void;
/**
* Streams DocumentPermissionInstance 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 { DocumentPermissionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: DocumentPermissionInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: DocumentPermissionListInstanceEachOptions, callback?: (item: DocumentPermissionInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of DocumentPermissionInstance 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: DocumentPermissionPage) => any): Promise<DocumentPermissionPage>;
/**
* Retrieve a single target page of DocumentPermissionInstance 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<DocumentPermissionPage>) => any): Promise<ApiResponse<DocumentPermissionPage>>;
/**
* Lists DocumentPermissionInstance 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 { DocumentPermissionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: DocumentPermissionInstance[]) => any): Promise<DocumentPermissionInstance[]>;
list(params: DocumentPermissionListInstanceOptions, callback?: (error: Error | null, items: DocumentPermissionInstance[]) => any): Promise<DocumentPermissionInstance[]>;
/**
* Lists DocumentPermissionInstance 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 { DocumentPermissionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<DocumentPermissionInstance[]>) => any): Promise<ApiResponse<DocumentPermissionInstance[]>>;
listWithHttpInfo(params: DocumentPermissionListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<DocumentPermissionInstance[]>) => any): Promise<ApiResponse<DocumentPermissionInstance[]>>;
/**
* Retrieve a single page of DocumentPermissionInstance 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 { DocumentPermissionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: DocumentPermissionPage) => any): Promise<DocumentPermissionPage>;
page(params: DocumentPermissionListInstancePageOptions, callback?: (error: Error | null, items: DocumentPermissionPage) => any): Promise<DocumentPermissionPage>;
/**
* Retrieve a single page of DocumentPermissionInstance 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 { DocumentPermissionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<DocumentPermissionPage>) => any): Promise<ApiResponse<DocumentPermissionPage>>;
pageWithHttpInfo(params: DocumentPermissionListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<DocumentPermissionPage>) => any): Promise<ApiResponse<DocumentPermissionPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function DocumentPermissionListInstance(version: V1, serviceSid: string, documentSid: string): DocumentPermissionListInstance;
export declare class DocumentPermissionPage extends Page<V1, DocumentPermissionPayload, DocumentPermissionResource, DocumentPermissionInstance> {
/**
* Initialize the DocumentPermissionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: DocumentPermissionSolution);
/**
* Build an instance of DocumentPermissionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: DocumentPermissionResource): DocumentPermissionInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,401 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.DocumentPermissionPage = exports.DocumentPermissionInstance = exports.DocumentPermissionContextImpl = void 0;
exports.DocumentPermissionListInstance = DocumentPermissionListInstance;
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 DocumentPermissionContextImpl {
constructor(_version, serviceSid, documentSid, identity) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(documentSid)) {
throw new Error("Parameter 'documentSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
this._solution = { serviceSid, documentSid, identity };
this._uri = `/Services/${serviceSid}/Documents/${documentSid}/Permissions/${identity}`;
}
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 DocumentPermissionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.documentSid, instance._solution.identity));
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 DocumentPermissionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.documentSid, instance._solution.identity),
}));
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["read"] === null || params["read"] === undefined) {
throw new Error("Required parameter \"params['read']\" missing.");
}
if (params["write"] === null || params["write"] === undefined) {
throw new Error("Required parameter \"params['write']\" missing.");
}
if (params["manage"] === null || params["manage"] === undefined) {
throw new Error("Required parameter \"params['manage']\" missing.");
}
let data = {};
data["Read"] = serialize.bool(params["read"]);
data["Write"] = serialize.bool(params["write"]);
data["Manage"] = serialize.bool(params["manage"]);
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 DocumentPermissionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.documentSid, instance._solution.identity));
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["read"] === null || params["read"] === undefined) {
throw new Error("Required parameter \"params['read']\" missing.");
}
if (params["write"] === null || params["write"] === undefined) {
throw new Error("Required parameter \"params['write']\" missing.");
}
if (params["manage"] === null || params["manage"] === undefined) {
throw new Error("Required parameter \"params['manage']\" missing.");
}
let data = {};
data["Read"] = serialize.bool(params["read"]);
data["Write"] = serialize.bool(params["write"]);
data["Manage"] = serialize.bool(params["manage"]);
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 DocumentPermissionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.documentSid, instance._solution.identity),
}));
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.DocumentPermissionContextImpl = DocumentPermissionContextImpl;
class DocumentPermissionInstance {
constructor(_version, payload, serviceSid, documentSid, identity) {
this._version = _version;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.documentSid = payload.document_sid;
this.identity = payload.identity;
this.read = payload.read;
this.write = payload.write;
this.manage = payload.manage;
this.url = payload.url;
this._solution = {
serviceSid,
documentSid,
identity: identity || this.identity,
};
}
get _proxy() {
this._context =
this._context ||
new DocumentPermissionContextImpl(this._version, this._solution.serviceSid, this._solution.documentSid, this._solution.identity);
return this._context;
}
/**
* Remove a DocumentPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a DocumentPermissionInstance 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 DocumentPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a DocumentPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed DocumentPermissionInstance 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,
documentSid: this.documentSid,
identity: this.identity,
read: this.read,
write: this.write,
manage: this.manage,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.DocumentPermissionInstance = DocumentPermissionInstance;
function DocumentPermissionListInstance(version, serviceSid, documentSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(documentSid)) {
throw new Error("Parameter 'documentSid' is not valid.");
}
const instance = ((identity) => instance.get(identity));
instance.get = function get(identity) {
return new DocumentPermissionContextImpl(version, serviceSid, documentSid, identity);
};
instance._version = version;
instance._solution = { serviceSid, documentSid };
instance._uri = `/Services/${serviceSid}/Documents/${documentSid}/Permissions`;
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 DocumentPermissionPage(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 DocumentPermissionPage(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 DocumentPermissionPage(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 DocumentPermissionPage(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 DocumentPermissionPage extends Page_1.default {
/**
* Initialize the DocumentPermissionPage
*
* @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 DocumentPermissionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new DocumentPermissionInstance(this._version, payload, this._solution.serviceSid, this._solution.documentSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.DocumentPermissionPage = DocumentPermissionPage;

View File

@@ -0,0 +1,492 @@
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 { SyncListItemListInstance } from "./syncList/syncListItem";
import { SyncListPermissionListInstance } from "./syncList/syncListPermission";
/**
* Options to pass to update a SyncListInstance
*/
export interface SyncListContextUpdateOptions {
/** An alias for `collection_ttl`. If both are provided, this value is ignored. */
ttl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync List expires (time-to-live) and is deleted. */
collectionTtl?: number;
}
/**
* Options to pass to create a SyncListInstance
*/
export interface SyncListListInstanceCreateOptions {
/** An application-defined string that uniquely identifies the resource. This value must be unique within its Service and it can be up to 320 characters long. The `unique_name` value can be used as an alternative to the `sid` in the URL path to address the resource. */
uniqueName?: string;
/** Alias for collection_ttl. If both are provided, this value is ignored. */
ttl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync List expires (time-to-live) and is deleted. */
collectionTtl?: number;
}
/**
* Options to pass to each
*/
export interface SyncListListInstanceEachOptions {
/** 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: SyncListInstance, 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 SyncListListInstanceOptions {
/** 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 SyncListListInstancePageOptions {
/** 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 SyncListContext {
syncListItems: SyncListItemListInstance;
syncListPermissions: SyncListPermissionListInstance;
/**
* Remove a SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncListInstance 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 SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
fetch(callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
/**
* Fetch a SyncListInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Update a SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
update(callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
/**
* Update a SyncListInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
update(params: SyncListContextUpdateOptions, callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
/**
* Update a SyncListInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Update a SyncListInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncListContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SyncListContextSolution {
serviceSid: string;
sid: string;
}
export declare class SyncListContextImpl implements SyncListContext {
protected _version: V1;
protected _solution: SyncListContextSolution;
protected _uri: string;
protected _syncListItems?: SyncListItemListInstance;
protected _syncListPermissions?: SyncListPermissionListInstance;
constructor(_version: V1, serviceSid: string, sid: string);
get syncListItems(): SyncListItemListInstance;
get syncListPermissions(): SyncListPermissionListInstance;
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?: SyncListInstance) => any): Promise<SyncListInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
update(params?: SyncListContextUpdateOptions | ((error: Error | null, item?: SyncListInstance) => any), callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
updateWithHttpInfo(params?: SyncListContextUpdateOptions | ((error: Error | null, item?: ApiResponse<SyncListInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SyncListContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SyncListPayload extends TwilioResponsePayload {
lists: SyncListResource[];
}
interface SyncListResource {
sid: string;
unique_name: string;
account_sid: string;
service_sid: string;
url: string;
links: Record<string, string>;
revision: string;
date_expires: Date;
date_created: Date;
date_updated: Date;
created_by: string;
}
export declare class SyncListInstance {
protected _version: V1;
protected _solution: SyncListContextSolution;
protected _context?: SyncListContext;
constructor(_version: V1, payload: SyncListResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Sync List 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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sync List resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The absolute URL of the Sync List resource.
*/
url: string;
/**
* The URLs of the Sync List\'s nested resources.
*/
links: Record<string, string>;
/**
* The current revision of the Sync List, represented as a string.
*/
revision: string;
/**
* The date and time in GMT when the Sync List expires and will be deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the Sync List does not expire, this value is `null`. The Sync List might not be deleted immediately after it expires.
*/
dateExpires: Date;
/**
* 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 Sync List\'s creator. If the Sync List is created from the client SDK, the value matches the Access Token\'s `identity` field. If the Sync List was created from the REST API, the value is `system`.
*/
createdBy: string;
private get _proxy();
/**
* Remove a SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncListInstance 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 SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
fetch(callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
/**
* Fetch a SyncListInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Update a SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
update(callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
/**
* Update a SyncListInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
update(params: SyncListContextUpdateOptions, callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
/**
* Update a SyncListInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Update a SyncListInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncListContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Access the syncListItems.
*/
syncListItems(): SyncListItemListInstance;
/**
* Access the syncListPermissions.
*/
syncListPermissions(): SyncListPermissionListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
uniqueName: string;
accountSid: string;
serviceSid: string;
url: string;
links: Record<string, string>;
revision: string;
dateExpires: Date;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SyncListSolution {
serviceSid: string;
}
export interface SyncListListInstance {
_version: V1;
_solution: SyncListSolution;
_uri: string;
(sid: string): SyncListContext;
get(sid: string): SyncListContext;
/**
* Create a SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
create(callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
/**
* Create a SyncListInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
create(params: SyncListListInstanceCreateOptions, callback?: (error: Error | null, item?: SyncListInstance) => any): Promise<SyncListInstance>;
/**
* Create a SyncListInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Create a SyncListInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance with HTTP metadata
*/
createWithHttpInfo(params: SyncListListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListInstance>) => any): Promise<ApiResponse<SyncListInstance>>;
/**
* Streams SyncListInstance 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 { SyncListListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: SyncListInstance, done: (err?: Error) => void) => void): void;
each(params: SyncListListInstanceEachOptions, callback?: (item: SyncListInstance, done: (err?: Error) => void) => void): void;
/**
* Streams SyncListInstance 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 { SyncListListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: SyncListInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: SyncListListInstanceEachOptions, callback?: (item: SyncListInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of SyncListInstance 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: SyncListPage) => any): Promise<SyncListPage>;
/**
* Retrieve a single target page of SyncListInstance 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<SyncListPage>) => any): Promise<ApiResponse<SyncListPage>>;
/**
* Lists SyncListInstance 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 { SyncListListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: SyncListInstance[]) => any): Promise<SyncListInstance[]>;
list(params: SyncListListInstanceOptions, callback?: (error: Error | null, items: SyncListInstance[]) => any): Promise<SyncListInstance[]>;
/**
* Lists SyncListInstance 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 { SyncListListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncListInstance[]>) => any): Promise<ApiResponse<SyncListInstance[]>>;
listWithHttpInfo(params: SyncListListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<SyncListInstance[]>) => any): Promise<ApiResponse<SyncListInstance[]>>;
/**
* Retrieve a single page of SyncListInstance 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 { SyncListListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: SyncListPage) => any): Promise<SyncListPage>;
page(params: SyncListListInstancePageOptions, callback?: (error: Error | null, items: SyncListPage) => any): Promise<SyncListPage>;
/**
* Retrieve a single page of SyncListInstance 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 { SyncListListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncListPage>) => any): Promise<ApiResponse<SyncListPage>>;
pageWithHttpInfo(params: SyncListListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<SyncListPage>) => any): Promise<ApiResponse<SyncListPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SyncListListInstance(version: V1, serviceSid: string): SyncListListInstance;
export declare class SyncListPage extends Page<V1, SyncListPayload, SyncListResource, SyncListInstance> {
/**
* Initialize the SyncListPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: SyncListSolution);
/**
* Build an instance of SyncListInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: SyncListResource): SyncListInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,477 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.SyncListPage = exports.SyncListInstance = exports.SyncListContextImpl = void 0;
exports.SyncListListInstance = SyncListListInstance;
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 syncListItem_1 = require("./syncList/syncListItem");
const syncListPermission_1 = require("./syncList/syncListPermission");
class SyncListContextImpl {
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}/Lists/${sid}`;
}
get syncListItems() {
this._syncListItems =
this._syncListItems ||
(0, syncListItem_1.SyncListItemListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._syncListItems;
}
get syncListPermissions() {
this._syncListPermissions =
this._syncListPermissions ||
(0, syncListPermission_1.SyncListPermissionListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._syncListPermissions;
}
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 SyncListInstance(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 SyncListInstance(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["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncListInstance(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["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncListInstance(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.SyncListContextImpl = SyncListContextImpl;
class SyncListInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.uniqueName = payload.unique_name;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.url = payload.url;
this.links = payload.links;
this.revision = payload.revision;
this.dateExpires = deserialize.iso8601DateTime(payload.date_expires);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new SyncListContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a SyncListInstance 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 SyncListInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SyncListInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListInstance 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 syncListItems.
*/
syncListItems() {
return this._proxy.syncListItems;
}
/**
* Access the syncListPermissions.
*/
syncListPermissions() {
return this._proxy.syncListPermissions;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
uniqueName: this.uniqueName,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
url: this.url,
links: this.links,
revision: this.revision,
dateExpires: this.dateExpires,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncListInstance = SyncListInstance;
function SyncListListInstance(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 SyncListContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Lists`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncListInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncListInstance(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 SyncListPage(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 SyncListPage(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 SyncListPage(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 SyncListPage(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 SyncListPage extends Page_1.default {
/**
* Initialize the SyncListPage
*
* @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 SyncListInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new SyncListInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncListPage = SyncListPage;

View File

@@ -0,0 +1,533 @@
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 SyncListItemQueryFromBoundType = "inclusive" | "exclusive";
export type SyncListItemQueryResultOrder = "asc" | "desc";
/**
* Options to pass to remove a SyncListItemInstance
*/
export interface SyncListItemContextRemoveOptions {
/** If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). */
ifMatch?: string;
}
/**
* Options to pass to update a SyncListItemInstance
*/
export interface SyncListItemContextUpdateOptions {
/** If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). */
ifMatch?: string;
/** A JSON string that represents an arbitrary, schema-less object that the List Item stores. Can be up to 16 KiB in length. */
data?: any;
/** An alias for `item_ttl`. If both parameters are provided, this value is ignored. */
ttl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item expires (time-to-live) and is deleted. */
itemTtl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item\\\'s parent Sync List expires (time-to-live) and is deleted. This parameter can only be used when the List Item\\\'s `data` or `ttl` is updated in the same request. */
collectionTtl?: number;
}
/**
* Options to pass to create a SyncListItemInstance
*/
export interface SyncListItemListInstanceCreateOptions {
/** A JSON string that represents an arbitrary, schema-less object that the List Item stores. Can be up to 16 KiB in length. */
data: any;
/** An alias for `item_ttl`. If both parameters are provided, this value is ignored. */
ttl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item expires (time-to-live) and is deleted. */
itemTtl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item\\\'s parent Sync List expires (time-to-live) and is deleted. */
collectionTtl?: number;
}
/**
* Options to pass to each
*/
export interface SyncListItemListInstanceEachOptions {
/** How to order the List Items returned by their `index` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. */
order?: SyncListItemQueryResultOrder;
/** The `index` of the first Sync List Item resource to read. See also `bounds`. */
from?: string;
/** Whether to include the List Item referenced by the `from` parameter. Can be: `inclusive` to include the List Item referenced by the `from` parameter or `exclusive` to start with the next List Item. The default value is `inclusive`. */
bounds?: SyncListItemQueryFromBoundType;
/** 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: SyncListItemInstance, 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 SyncListItemListInstanceOptions {
/** How to order the List Items returned by their `index` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. */
order?: SyncListItemQueryResultOrder;
/** The `index` of the first Sync List Item resource to read. See also `bounds`. */
from?: string;
/** Whether to include the List Item referenced by the `from` parameter. Can be: `inclusive` to include the List Item referenced by the `from` parameter or `exclusive` to start with the next List Item. The default value is `inclusive`. */
bounds?: SyncListItemQueryFromBoundType;
/** 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 SyncListItemListInstancePageOptions {
/** How to order the List Items returned by their `index` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. */
order?: SyncListItemQueryResultOrder;
/** The `index` of the first Sync List Item resource to read. See also `bounds`. */
from?: string;
/** Whether to include the List Item referenced by the `from` parameter. Can be: `inclusive` to include the List Item referenced by the `from` parameter or `exclusive` to start with the next List Item. The default value is `inclusive`. */
bounds?: SyncListItemQueryFromBoundType;
/** 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 SyncListItemContext {
/**
* Remove a SyncListItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncListItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
remove(params: SyncListItemContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncListItemInstance 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 SyncListItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
removeWithHttpInfo(params: SyncListItemContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a SyncListItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
fetch(callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
/**
* Fetch a SyncListItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
/**
* Update a SyncListItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
update(callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
/**
* Update a SyncListItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
update(params: SyncListItemContextUpdateOptions, callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
/**
* Update a SyncListItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
/**
* Update a SyncListItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncListItemContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SyncListItemContextSolution {
serviceSid: string;
listSid: string;
index: number;
}
export declare class SyncListItemContextImpl implements SyncListItemContext {
protected _version: V1;
protected _solution: SyncListItemContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, listSid: string, index: number);
remove(params?: SyncListItemContextRemoveOptions | ((error: Error | null, item?: boolean) => any), callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(params?: SyncListItemContextRemoveOptions | ((error: Error | null, item?: ApiResponse<boolean>) => any), callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
update(params?: SyncListItemContextUpdateOptions | ((error: Error | null, item?: SyncListItemInstance) => any), callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
updateWithHttpInfo(params?: SyncListItemContextUpdateOptions | ((error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SyncListItemContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SyncListItemPayload extends TwilioResponsePayload {
items: SyncListItemResource[];
}
interface SyncListItemResource {
index: number;
account_sid: string;
service_sid: string;
list_sid: string;
url: string;
revision: string;
data: any;
date_expires: Date;
date_created: Date;
date_updated: Date;
created_by: string;
}
export declare class SyncListItemInstance {
protected _version: V1;
protected _solution: SyncListItemContextSolution;
protected _context?: SyncListItemContext;
constructor(_version: V1, payload: SyncListItemResource, serviceSid: string, listSid: string, index?: number);
/**
* The automatically generated index of the List Item. The `index` values of the List Items in a Sync List can have gaps in their sequence.
*/
index: number;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the List Item resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the Sync List that contains the List Item.
*/
listSid: string;
/**
* The absolute URL of the List Item resource.
*/
url: string;
/**
* The current revision of the item, represented as a string.
*/
revision: string;
/**
* An arbitrary, schema-less object that the List Item stores. Can be up to 16 KiB in length.
*/
data: any;
/**
* The date and time in GMT when the List Item expires and will be deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the List Item does not expire, this value is `null`. The List Item resource might not be deleted immediately after it expires.
*/
dateExpires: Date;
/**
* 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 List Item\'s creator. If the item is created from the client SDK, the value matches the Access Token\'s `identity` field. If the item was created from the REST API, the value is `system`.
*/
createdBy: string;
private get _proxy();
/**
* Remove a SyncListItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncListItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
remove(params: SyncListItemContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncListItemInstance 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 SyncListItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
removeWithHttpInfo(params: SyncListItemContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a SyncListItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
fetch(callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
/**
* Fetch a SyncListItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
/**
* Update a SyncListItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
update(callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
/**
* Update a SyncListItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
update(params: SyncListItemContextUpdateOptions, callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
/**
* Update a SyncListItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
/**
* Update a SyncListItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncListItemContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
index: number;
accountSid: string;
serviceSid: string;
listSid: string;
url: string;
revision: string;
data: any;
dateExpires: Date;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SyncListItemSolution {
serviceSid: string;
listSid: string;
}
export interface SyncListItemListInstance {
_version: V1;
_solution: SyncListItemSolution;
_uri: string;
(index: number): SyncListItemContext;
get(index: number): SyncListItemContext;
/**
* Create a SyncListItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
create(params: SyncListItemListInstanceCreateOptions, callback?: (error: Error | null, item?: SyncListItemInstance) => any): Promise<SyncListItemInstance>;
/**
* Create a SyncListItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance with HTTP metadata
*/
createWithHttpInfo(params: SyncListItemListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListItemInstance>) => any): Promise<ApiResponse<SyncListItemInstance>>;
/**
* Streams SyncListItemInstance 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 { SyncListItemListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: SyncListItemInstance, done: (err?: Error) => void) => void): void;
each(params: SyncListItemListInstanceEachOptions, callback?: (item: SyncListItemInstance, done: (err?: Error) => void) => void): void;
/**
* Streams SyncListItemInstance 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 { SyncListItemListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: SyncListItemInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: SyncListItemListInstanceEachOptions, callback?: (item: SyncListItemInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of SyncListItemInstance 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: SyncListItemPage) => any): Promise<SyncListItemPage>;
/**
* Retrieve a single target page of SyncListItemInstance 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<SyncListItemPage>) => any): Promise<ApiResponse<SyncListItemPage>>;
/**
* Lists SyncListItemInstance 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 { SyncListItemListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: SyncListItemInstance[]) => any): Promise<SyncListItemInstance[]>;
list(params: SyncListItemListInstanceOptions, callback?: (error: Error | null, items: SyncListItemInstance[]) => any): Promise<SyncListItemInstance[]>;
/**
* Lists SyncListItemInstance 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 { SyncListItemListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncListItemInstance[]>) => any): Promise<ApiResponse<SyncListItemInstance[]>>;
listWithHttpInfo(params: SyncListItemListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<SyncListItemInstance[]>) => any): Promise<ApiResponse<SyncListItemInstance[]>>;
/**
* Retrieve a single page of SyncListItemInstance 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 { SyncListItemListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: SyncListItemPage) => any): Promise<SyncListItemPage>;
page(params: SyncListItemListInstancePageOptions, callback?: (error: Error | null, items: SyncListItemPage) => any): Promise<SyncListItemPage>;
/**
* Retrieve a single page of SyncListItemInstance 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 { SyncListItemListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncListItemPage>) => any): Promise<ApiResponse<SyncListItemPage>>;
pageWithHttpInfo(params: SyncListItemListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<SyncListItemPage>) => any): Promise<ApiResponse<SyncListItemPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SyncListItemListInstance(version: V1, serviceSid: string, listSid: string): SyncListItemListInstance;
export declare class SyncListItemPage extends Page<V1, SyncListItemPayload, SyncListItemResource, SyncListItemInstance> {
/**
* Initialize the SyncListItemPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: SyncListItemSolution);
/**
* Build an instance of SyncListItemInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: SyncListItemResource): SyncListItemInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,493 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.SyncListItemPage = exports.SyncListItemInstance = exports.SyncListItemContextImpl = void 0;
exports.SyncListItemListInstance = SyncListItemListInstance;
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 SyncListItemContextImpl {
constructor(_version, serviceSid, listSid, index) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(listSid)) {
throw new Error("Parameter 'listSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(index)) {
throw new Error("Parameter 'index' is not valid.");
}
this._solution = { serviceSid, listSid, index };
this._uri = `/Services/${serviceSid}/Lists/${listSid}/Items/${index}`;
}
remove(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
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["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
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 SyncListItemInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.listSid, instance._solution.index));
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 SyncListItemInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.listSid, instance._solution.index),
}));
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["data"] !== undefined)
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["itemTtl"] !== undefined)
data["ItemTtl"] = params["itemTtl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new SyncListItemInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.listSid, instance._solution.index));
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["data"] !== undefined)
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["itemTtl"] !== undefined)
data["ItemTtl"] = params["itemTtl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
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 SyncListItemInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.listSid, instance._solution.index),
}));
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.SyncListItemContextImpl = SyncListItemContextImpl;
class SyncListItemInstance {
constructor(_version, payload, serviceSid, listSid, index) {
this._version = _version;
this.index = deserialize.integer(payload.index);
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.listSid = payload.list_sid;
this.url = payload.url;
this.revision = payload.revision;
this.data = payload.data;
this.dateExpires = deserialize.iso8601DateTime(payload.date_expires);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this._solution = { serviceSid, listSid, index: index || this.index };
}
get _proxy() {
this._context =
this._context ||
new SyncListItemContextImpl(this._version, this._solution.serviceSid, this._solution.listSid, this._solution.index);
return this._context;
}
remove(params, callback) {
return this._proxy.remove(params, callback);
}
removeWithHttpInfo(params, callback) {
return this._proxy.removeWithHttpInfo(params, callback);
}
/**
* Fetch a SyncListItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SyncListItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListItemInstance 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 {
index: this.index,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
listSid: this.listSid,
url: this.url,
revision: this.revision,
data: this.data,
dateExpires: this.dateExpires,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncListItemInstance = SyncListItemInstance;
function SyncListItemListInstance(version, serviceSid, listSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(listSid)) {
throw new Error("Parameter 'listSid' is not valid.");
}
const instance = ((index) => instance.get(index));
instance.get = function get(index) {
return new SyncListItemContextImpl(version, serviceSid, listSid, index);
};
instance._version = version;
instance._solution = { serviceSid, listSid };
instance._uri = `/Services/${serviceSid}/Lists/${listSid}/Items`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["data"] === null || params["data"] === undefined) {
throw new Error("Required parameter \"params['data']\" missing.");
}
let data = {};
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["itemTtl"] !== undefined)
data["ItemTtl"] = params["itemTtl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncListItemInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.listSid));
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["data"] === null || params["data"] === undefined) {
throw new Error("Required parameter \"params['data']\" missing.");
}
let data = {};
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["itemTtl"] !== undefined)
data["ItemTtl"] = params["itemTtl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncListItemInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.listSid),
}));
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["from"] !== undefined)
data["From"] = params["from"];
if (params["bounds"] !== undefined)
data["Bounds"] = params["bounds"];
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 SyncListItemPage(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 SyncListItemPage(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["from"] !== undefined)
data["From"] = params["from"];
if (params["bounds"] !== undefined)
data["Bounds"] = params["bounds"];
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 SyncListItemPage(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 SyncListItemPage(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 SyncListItemPage extends Page_1.default {
/**
* Initialize the SyncListItemPage
*
* @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 SyncListItemInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new SyncListItemInstance(this._version, payload, this._solution.serviceSid, this._solution.listSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncListItemPage = SyncListItemPage;

View File

@@ -0,0 +1,385 @@
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 SyncListPermissionInstance
*/
export interface SyncListPermissionContextUpdateOptions {
/** Whether the identity can read the Sync List and its Items. Default value is `false`. */
read: boolean;
/** Whether the identity can create, update, and delete Items in the Sync List. Default value is `false`. */
write: boolean;
/** Whether the identity can delete the Sync List. Default value is `false`. */
manage: boolean;
}
/**
* Options to pass to each
*/
export interface SyncListPermissionListInstanceEachOptions {
/** 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: SyncListPermissionInstance, 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 SyncListPermissionListInstanceOptions {
/** 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 SyncListPermissionListInstancePageOptions {
/** 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 SyncListPermissionContext {
/**
* Remove a SyncListPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncListPermissionInstance 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 SyncListPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance
*/
fetch(callback?: (error: Error | null, item?: SyncListPermissionInstance) => any): Promise<SyncListPermissionInstance>;
/**
* Fetch a SyncListPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListPermissionInstance>) => any): Promise<ApiResponse<SyncListPermissionInstance>>;
/**
* Update a SyncListPermissionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance
*/
update(params: SyncListPermissionContextUpdateOptions, callback?: (error: Error | null, item?: SyncListPermissionInstance) => any): Promise<SyncListPermissionInstance>;
/**
* Update a SyncListPermissionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncListPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListPermissionInstance>) => any): Promise<ApiResponse<SyncListPermissionInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SyncListPermissionContextSolution {
serviceSid: string;
listSid: string;
identity: string;
}
export declare class SyncListPermissionContextImpl implements SyncListPermissionContext {
protected _version: V1;
protected _solution: SyncListPermissionContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, listSid: string, identity: 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?: SyncListPermissionInstance) => any): Promise<SyncListPermissionInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListPermissionInstance>) => any): Promise<ApiResponse<SyncListPermissionInstance>>;
update(params: SyncListPermissionContextUpdateOptions, callback?: (error: Error | null, item?: SyncListPermissionInstance) => any): Promise<SyncListPermissionInstance>;
updateWithHttpInfo(params: SyncListPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListPermissionInstance>) => any): Promise<ApiResponse<SyncListPermissionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SyncListPermissionContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SyncListPermissionPayload extends TwilioResponsePayload {
permissions: SyncListPermissionResource[];
}
interface SyncListPermissionResource {
account_sid: string;
service_sid: string;
list_sid: string;
identity: string;
read: boolean;
write: boolean;
manage: boolean;
url: string;
}
export declare class SyncListPermissionInstance {
protected _version: V1;
protected _solution: SyncListPermissionContextSolution;
protected _context?: SyncListPermissionContext;
constructor(_version: V1, payload: SyncListPermissionResource, serviceSid: string, listSid: string, identity?: string);
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sync List Permission resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the Sync List to which the Permission applies.
*/
listSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s User within the Service to an FPA token.
*/
identity: string;
/**
* Whether the identity can read the Sync List and its Items.
*/
read: boolean;
/**
* Whether the identity can create, update, and delete Items in the Sync List.
*/
write: boolean;
/**
* Whether the identity can delete the Sync List.
*/
manage: boolean;
/**
* The absolute URL of the Sync List Permission resource.
*/
url: string;
private get _proxy();
/**
* Remove a SyncListPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncListPermissionInstance 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 SyncListPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance
*/
fetch(callback?: (error: Error | null, item?: SyncListPermissionInstance) => any): Promise<SyncListPermissionInstance>;
/**
* Fetch a SyncListPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncListPermissionInstance>) => any): Promise<ApiResponse<SyncListPermissionInstance>>;
/**
* Update a SyncListPermissionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance
*/
update(params: SyncListPermissionContextUpdateOptions, callback?: (error: Error | null, item?: SyncListPermissionInstance) => any): Promise<SyncListPermissionInstance>;
/**
* Update a SyncListPermissionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncListPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncListPermissionInstance>) => any): Promise<ApiResponse<SyncListPermissionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
accountSid: string;
serviceSid: string;
listSid: string;
identity: string;
read: boolean;
write: boolean;
manage: boolean;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SyncListPermissionSolution {
serviceSid: string;
listSid: string;
}
export interface SyncListPermissionListInstance {
_version: V1;
_solution: SyncListPermissionSolution;
_uri: string;
(identity: string): SyncListPermissionContext;
get(identity: string): SyncListPermissionContext;
/**
* Streams SyncListPermissionInstance 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 { SyncListPermissionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: SyncListPermissionInstance, done: (err?: Error) => void) => void): void;
each(params: SyncListPermissionListInstanceEachOptions, callback?: (item: SyncListPermissionInstance, done: (err?: Error) => void) => void): void;
/**
* Streams SyncListPermissionInstance 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 { SyncListPermissionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: SyncListPermissionInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: SyncListPermissionListInstanceEachOptions, callback?: (item: SyncListPermissionInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of SyncListPermissionInstance 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: SyncListPermissionPage) => any): Promise<SyncListPermissionPage>;
/**
* Retrieve a single target page of SyncListPermissionInstance 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<SyncListPermissionPage>) => any): Promise<ApiResponse<SyncListPermissionPage>>;
/**
* Lists SyncListPermissionInstance 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 { SyncListPermissionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: SyncListPermissionInstance[]) => any): Promise<SyncListPermissionInstance[]>;
list(params: SyncListPermissionListInstanceOptions, callback?: (error: Error | null, items: SyncListPermissionInstance[]) => any): Promise<SyncListPermissionInstance[]>;
/**
* Lists SyncListPermissionInstance 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 { SyncListPermissionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncListPermissionInstance[]>) => any): Promise<ApiResponse<SyncListPermissionInstance[]>>;
listWithHttpInfo(params: SyncListPermissionListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<SyncListPermissionInstance[]>) => any): Promise<ApiResponse<SyncListPermissionInstance[]>>;
/**
* Retrieve a single page of SyncListPermissionInstance 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 { SyncListPermissionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: SyncListPermissionPage) => any): Promise<SyncListPermissionPage>;
page(params: SyncListPermissionListInstancePageOptions, callback?: (error: Error | null, items: SyncListPermissionPage) => any): Promise<SyncListPermissionPage>;
/**
* Retrieve a single page of SyncListPermissionInstance 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 { SyncListPermissionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncListPermissionPage>) => any): Promise<ApiResponse<SyncListPermissionPage>>;
pageWithHttpInfo(params: SyncListPermissionListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<SyncListPermissionPage>) => any): Promise<ApiResponse<SyncListPermissionPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SyncListPermissionListInstance(version: V1, serviceSid: string, listSid: string): SyncListPermissionListInstance;
export declare class SyncListPermissionPage extends Page<V1, SyncListPermissionPayload, SyncListPermissionResource, SyncListPermissionInstance> {
/**
* Initialize the SyncListPermissionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: SyncListPermissionSolution);
/**
* Build an instance of SyncListPermissionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: SyncListPermissionResource): SyncListPermissionInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,401 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.SyncListPermissionPage = exports.SyncListPermissionInstance = exports.SyncListPermissionContextImpl = void 0;
exports.SyncListPermissionListInstance = SyncListPermissionListInstance;
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 SyncListPermissionContextImpl {
constructor(_version, serviceSid, listSid, identity) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(listSid)) {
throw new Error("Parameter 'listSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
this._solution = { serviceSid, listSid, identity };
this._uri = `/Services/${serviceSid}/Lists/${listSid}/Permissions/${identity}`;
}
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 SyncListPermissionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.listSid, instance._solution.identity));
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 SyncListPermissionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.listSid, instance._solution.identity),
}));
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["read"] === null || params["read"] === undefined) {
throw new Error("Required parameter \"params['read']\" missing.");
}
if (params["write"] === null || params["write"] === undefined) {
throw new Error("Required parameter \"params['write']\" missing.");
}
if (params["manage"] === null || params["manage"] === undefined) {
throw new Error("Required parameter \"params['manage']\" missing.");
}
let data = {};
data["Read"] = serialize.bool(params["read"]);
data["Write"] = serialize.bool(params["write"]);
data["Manage"] = serialize.bool(params["manage"]);
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 SyncListPermissionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.listSid, instance._solution.identity));
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["read"] === null || params["read"] === undefined) {
throw new Error("Required parameter \"params['read']\" missing.");
}
if (params["write"] === null || params["write"] === undefined) {
throw new Error("Required parameter \"params['write']\" missing.");
}
if (params["manage"] === null || params["manage"] === undefined) {
throw new Error("Required parameter \"params['manage']\" missing.");
}
let data = {};
data["Read"] = serialize.bool(params["read"]);
data["Write"] = serialize.bool(params["write"]);
data["Manage"] = serialize.bool(params["manage"]);
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 SyncListPermissionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.listSid, instance._solution.identity),
}));
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.SyncListPermissionContextImpl = SyncListPermissionContextImpl;
class SyncListPermissionInstance {
constructor(_version, payload, serviceSid, listSid, identity) {
this._version = _version;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.listSid = payload.list_sid;
this.identity = payload.identity;
this.read = payload.read;
this.write = payload.write;
this.manage = payload.manage;
this.url = payload.url;
this._solution = {
serviceSid,
listSid,
identity: identity || this.identity,
};
}
get _proxy() {
this._context =
this._context ||
new SyncListPermissionContextImpl(this._version, this._solution.serviceSid, this._solution.listSid, this._solution.identity);
return this._context;
}
/**
* Remove a SyncListPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a SyncListPermissionInstance 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 SyncListPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SyncListPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncListPermissionInstance 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,
listSid: this.listSid,
identity: this.identity,
read: this.read,
write: this.write,
manage: this.manage,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncListPermissionInstance = SyncListPermissionInstance;
function SyncListPermissionListInstance(version, serviceSid, listSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(listSid)) {
throw new Error("Parameter 'listSid' is not valid.");
}
const instance = ((identity) => instance.get(identity));
instance.get = function get(identity) {
return new SyncListPermissionContextImpl(version, serviceSid, listSid, identity);
};
instance._version = version;
instance._solution = { serviceSid, listSid };
instance._uri = `/Services/${serviceSid}/Lists/${listSid}/Permissions`;
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 SyncListPermissionPage(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 SyncListPermissionPage(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 SyncListPermissionPage(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 SyncListPermissionPage(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 SyncListPermissionPage extends Page_1.default {
/**
* Initialize the SyncListPermissionPage
*
* @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 SyncListPermissionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new SyncListPermissionInstance(this._version, payload, this._solution.serviceSid, this._solution.listSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncListPermissionPage = SyncListPermissionPage;

View File

@@ -0,0 +1,492 @@
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 { SyncMapItemListInstance } from "./syncMap/syncMapItem";
import { SyncMapPermissionListInstance } from "./syncMap/syncMapPermission";
/**
* Options to pass to update a SyncMapInstance
*/
export interface SyncMapContextUpdateOptions {
/** An alias for `collection_ttl`. If both parameters are provided, this value is ignored. */
ttl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Map expires (time-to-live) and is deleted. */
collectionTtl?: number;
}
/**
* Options to pass to create a SyncMapInstance
*/
export interface SyncMapListInstanceCreateOptions {
/** An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. */
uniqueName?: string;
/** An alias for `collection_ttl`. If both parameters are provided, this value is ignored. */
ttl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Map expires (time-to-live) and is deleted. */
collectionTtl?: number;
}
/**
* Options to pass to each
*/
export interface SyncMapListInstanceEachOptions {
/** 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: SyncMapInstance, 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 SyncMapListInstanceOptions {
/** 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 SyncMapListInstancePageOptions {
/** 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 SyncMapContext {
syncMapItems: SyncMapItemListInstance;
syncMapPermissions: SyncMapPermissionListInstance;
/**
* Remove a SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncMapInstance 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 SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
fetch(callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
/**
* Fetch a SyncMapInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Update a SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
update(callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
/**
* Update a SyncMapInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
update(params: SyncMapContextUpdateOptions, callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
/**
* Update a SyncMapInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Update a SyncMapInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncMapContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SyncMapContextSolution {
serviceSid: string;
sid: string;
}
export declare class SyncMapContextImpl implements SyncMapContext {
protected _version: V1;
protected _solution: SyncMapContextSolution;
protected _uri: string;
protected _syncMapItems?: SyncMapItemListInstance;
protected _syncMapPermissions?: SyncMapPermissionListInstance;
constructor(_version: V1, serviceSid: string, sid: string);
get syncMapItems(): SyncMapItemListInstance;
get syncMapPermissions(): SyncMapPermissionListInstance;
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?: SyncMapInstance) => any): Promise<SyncMapInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
update(params?: SyncMapContextUpdateOptions | ((error: Error | null, item?: SyncMapInstance) => any), callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
updateWithHttpInfo(params?: SyncMapContextUpdateOptions | ((error: Error | null, item?: ApiResponse<SyncMapInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SyncMapContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SyncMapPayload extends TwilioResponsePayload {
maps: SyncMapResource[];
}
interface SyncMapResource {
sid: string;
unique_name: string;
account_sid: string;
service_sid: string;
url: string;
links: Record<string, string>;
revision: string;
date_expires: Date;
date_created: Date;
date_updated: Date;
created_by: string;
}
export declare class SyncMapInstance {
protected _version: V1;
protected _solution: SyncMapContextSolution;
protected _context?: SyncMapContext;
constructor(_version: V1, payload: SyncMapResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Sync Map 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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sync Map resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The absolute URL of the Sync Map resource.
*/
url: string;
/**
* The URLs of the Sync Map\'s nested resources.
*/
links: Record<string, string>;
/**
* The current revision of the Sync Map, represented as a string.
*/
revision: string;
/**
* The date and time in GMT when the Sync Map expires and will be deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the Sync Map does not expire, this value is `null`. The Sync Map might not be deleted immediately after it expires.
*/
dateExpires: Date;
/**
* 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 Sync Map\'s creator. If the Sync Map is created from the client SDK, the value matches the Access Token\'s `identity` field. If the Sync Map was created from the REST API, the value is `system`.
*/
createdBy: string;
private get _proxy();
/**
* Remove a SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncMapInstance 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 SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
fetch(callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
/**
* Fetch a SyncMapInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Update a SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
update(callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
/**
* Update a SyncMapInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
update(params: SyncMapContextUpdateOptions, callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
/**
* Update a SyncMapInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Update a SyncMapInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncMapContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Access the syncMapItems.
*/
syncMapItems(): SyncMapItemListInstance;
/**
* Access the syncMapPermissions.
*/
syncMapPermissions(): SyncMapPermissionListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
uniqueName: string;
accountSid: string;
serviceSid: string;
url: string;
links: Record<string, string>;
revision: string;
dateExpires: Date;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SyncMapSolution {
serviceSid: string;
}
export interface SyncMapListInstance {
_version: V1;
_solution: SyncMapSolution;
_uri: string;
(sid: string): SyncMapContext;
get(sid: string): SyncMapContext;
/**
* Create a SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
create(callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
/**
* Create a SyncMapInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
create(params: SyncMapListInstanceCreateOptions, callback?: (error: Error | null, item?: SyncMapInstance) => any): Promise<SyncMapInstance>;
/**
* Create a SyncMapInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Create a SyncMapInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance with HTTP metadata
*/
createWithHttpInfo(params: SyncMapListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapInstance>) => any): Promise<ApiResponse<SyncMapInstance>>;
/**
* Streams SyncMapInstance 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 { SyncMapListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: SyncMapInstance, done: (err?: Error) => void) => void): void;
each(params: SyncMapListInstanceEachOptions, callback?: (item: SyncMapInstance, done: (err?: Error) => void) => void): void;
/**
* Streams SyncMapInstance 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 { SyncMapListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: SyncMapInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: SyncMapListInstanceEachOptions, callback?: (item: SyncMapInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of SyncMapInstance 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: SyncMapPage) => any): Promise<SyncMapPage>;
/**
* Retrieve a single target page of SyncMapInstance 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<SyncMapPage>) => any): Promise<ApiResponse<SyncMapPage>>;
/**
* Lists SyncMapInstance 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 { SyncMapListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: SyncMapInstance[]) => any): Promise<SyncMapInstance[]>;
list(params: SyncMapListInstanceOptions, callback?: (error: Error | null, items: SyncMapInstance[]) => any): Promise<SyncMapInstance[]>;
/**
* Lists SyncMapInstance 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 { SyncMapListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncMapInstance[]>) => any): Promise<ApiResponse<SyncMapInstance[]>>;
listWithHttpInfo(params: SyncMapListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<SyncMapInstance[]>) => any): Promise<ApiResponse<SyncMapInstance[]>>;
/**
* Retrieve a single page of SyncMapInstance 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 { SyncMapListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: SyncMapPage) => any): Promise<SyncMapPage>;
page(params: SyncMapListInstancePageOptions, callback?: (error: Error | null, items: SyncMapPage) => any): Promise<SyncMapPage>;
/**
* Retrieve a single page of SyncMapInstance 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 { SyncMapListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncMapPage>) => any): Promise<ApiResponse<SyncMapPage>>;
pageWithHttpInfo(params: SyncMapListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<SyncMapPage>) => any): Promise<ApiResponse<SyncMapPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SyncMapListInstance(version: V1, serviceSid: string): SyncMapListInstance;
export declare class SyncMapPage extends Page<V1, SyncMapPayload, SyncMapResource, SyncMapInstance> {
/**
* Initialize the SyncMapPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: SyncMapSolution);
/**
* Build an instance of SyncMapInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: SyncMapResource): SyncMapInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

477
node_modules/twilio/lib/rest/sync/v1/service/syncMap.js generated vendored Normal file
View File

@@ -0,0 +1,477 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.SyncMapPage = exports.SyncMapInstance = exports.SyncMapContextImpl = void 0;
exports.SyncMapListInstance = SyncMapListInstance;
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 syncMapItem_1 = require("./syncMap/syncMapItem");
const syncMapPermission_1 = require("./syncMap/syncMapPermission");
class SyncMapContextImpl {
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}/Maps/${sid}`;
}
get syncMapItems() {
this._syncMapItems =
this._syncMapItems ||
(0, syncMapItem_1.SyncMapItemListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._syncMapItems;
}
get syncMapPermissions() {
this._syncMapPermissions =
this._syncMapPermissions ||
(0, syncMapPermission_1.SyncMapPermissionListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._syncMapPermissions;
}
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 SyncMapInstance(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 SyncMapInstance(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["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncMapInstance(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["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncMapInstance(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.SyncMapContextImpl = SyncMapContextImpl;
class SyncMapInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.uniqueName = payload.unique_name;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.url = payload.url;
this.links = payload.links;
this.revision = payload.revision;
this.dateExpires = deserialize.iso8601DateTime(payload.date_expires);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new SyncMapContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a SyncMapInstance 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 SyncMapInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SyncMapInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapInstance 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 syncMapItems.
*/
syncMapItems() {
return this._proxy.syncMapItems;
}
/**
* Access the syncMapPermissions.
*/
syncMapPermissions() {
return this._proxy.syncMapPermissions;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
uniqueName: this.uniqueName,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
url: this.url,
links: this.links,
revision: this.revision,
dateExpires: this.dateExpires,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncMapInstance = SyncMapInstance;
function SyncMapListInstance(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 SyncMapContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Maps`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncMapInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncMapInstance(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 SyncMapPage(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 SyncMapPage(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 SyncMapPage(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 SyncMapPage(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 SyncMapPage extends Page_1.default {
/**
* Initialize the SyncMapPage
*
* @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 SyncMapInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new SyncMapInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncMapPage = SyncMapPage;

View File

@@ -0,0 +1,535 @@
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 SyncMapItemQueryFromBoundType = "inclusive" | "exclusive";
export type SyncMapItemQueryResultOrder = "asc" | "desc";
/**
* Options to pass to remove a SyncMapItemInstance
*/
export interface SyncMapItemContextRemoveOptions {
/** If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). */
ifMatch?: string;
}
/**
* Options to pass to update a SyncMapItemInstance
*/
export interface SyncMapItemContextUpdateOptions {
/** If provided, applies this mutation if (and only if) the “revision” field of this [map item] matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match). */
ifMatch?: string;
/** A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length. */
data?: any;
/** An alias for `item_ttl`. If both parameters are provided, this value is ignored. */
ttl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Map Item expires (time-to-live) and is deleted. */
itemTtl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Map Item\\\'s parent Sync Map expires (time-to-live) and is deleted. This parameter can only be used when the Map Item\\\'s `data` or `ttl` is updated in the same request. */
collectionTtl?: number;
}
/**
* Options to pass to create a SyncMapItemInstance
*/
export interface SyncMapItemListInstanceCreateOptions {
/** The unique, user-defined key for the Map Item. Can be up to 320 characters long. */
key: string;
/** A JSON string that represents an arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length. */
data: any;
/** An alias for `item_ttl`. If both parameters are provided, this value is ignored. */
ttl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Map Item expires (time-to-live) and is deleted. */
itemTtl?: number;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Map Item\\\'s parent Sync Map expires (time-to-live) and is deleted. */
collectionTtl?: number;
}
/**
* Options to pass to each
*/
export interface SyncMapItemListInstanceEachOptions {
/** How to order the Map Items returned by their `key` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. Map Items are [ordered lexicographically](https://en.wikipedia.org/wiki/Lexicographical_order) by Item key. */
order?: SyncMapItemQueryResultOrder;
/** The `key` of the first Sync Map Item resource to read. See also `bounds`. */
from?: string;
/** Whether to include the Map Item referenced by the `from` parameter. Can be: `inclusive` to include the Map Item referenced by the `from` parameter or `exclusive` to start with the next Map Item. The default value is `inclusive`. */
bounds?: SyncMapItemQueryFromBoundType;
/** 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: SyncMapItemInstance, 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 SyncMapItemListInstanceOptions {
/** How to order the Map Items returned by their `key` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. Map Items are [ordered lexicographically](https://en.wikipedia.org/wiki/Lexicographical_order) by Item key. */
order?: SyncMapItemQueryResultOrder;
/** The `key` of the first Sync Map Item resource to read. See also `bounds`. */
from?: string;
/** Whether to include the Map Item referenced by the `from` parameter. Can be: `inclusive` to include the Map Item referenced by the `from` parameter or `exclusive` to start with the next Map Item. The default value is `inclusive`. */
bounds?: SyncMapItemQueryFromBoundType;
/** 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 SyncMapItemListInstancePageOptions {
/** How to order the Map Items returned by their `key` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. Map Items are [ordered lexicographically](https://en.wikipedia.org/wiki/Lexicographical_order) by Item key. */
order?: SyncMapItemQueryResultOrder;
/** The `key` of the first Sync Map Item resource to read. See also `bounds`. */
from?: string;
/** Whether to include the Map Item referenced by the `from` parameter. Can be: `inclusive` to include the Map Item referenced by the `from` parameter or `exclusive` to start with the next Map Item. The default value is `inclusive`. */
bounds?: SyncMapItemQueryFromBoundType;
/** 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 SyncMapItemContext {
/**
* Remove a SyncMapItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncMapItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
remove(params: SyncMapItemContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncMapItemInstance 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 SyncMapItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
removeWithHttpInfo(params: SyncMapItemContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a SyncMapItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
fetch(callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
/**
* Fetch a SyncMapItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
/**
* Update a SyncMapItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
update(callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
/**
* Update a SyncMapItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
update(params: SyncMapItemContextUpdateOptions, callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
/**
* Update a SyncMapItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
/**
* Update a SyncMapItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncMapItemContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SyncMapItemContextSolution {
serviceSid: string;
mapSid: string;
key: string;
}
export declare class SyncMapItemContextImpl implements SyncMapItemContext {
protected _version: V1;
protected _solution: SyncMapItemContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, mapSid: string, key: string);
remove(params?: SyncMapItemContextRemoveOptions | ((error: Error | null, item?: boolean) => any), callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(params?: SyncMapItemContextRemoveOptions | ((error: Error | null, item?: ApiResponse<boolean>) => any), callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
update(params?: SyncMapItemContextUpdateOptions | ((error: Error | null, item?: SyncMapItemInstance) => any), callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
updateWithHttpInfo(params?: SyncMapItemContextUpdateOptions | ((error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SyncMapItemContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SyncMapItemPayload extends TwilioResponsePayload {
items: SyncMapItemResource[];
}
interface SyncMapItemResource {
key: string;
account_sid: string;
service_sid: string;
map_sid: string;
url: string;
revision: string;
data: any;
date_expires: Date;
date_created: Date;
date_updated: Date;
created_by: string;
}
export declare class SyncMapItemInstance {
protected _version: V1;
protected _solution: SyncMapItemContextSolution;
protected _context?: SyncMapItemContext;
constructor(_version: V1, payload: SyncMapItemResource, serviceSid: string, mapSid: string, key?: string);
/**
* The unique, user-defined key for the Map Item.
*/
key: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Map Item resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the Sync Map that contains the Map Item.
*/
mapSid: string;
/**
* The absolute URL of the Map Item resource.
*/
url: string;
/**
* The current revision of the Map Item, represented as a string.
*/
revision: string;
/**
* An arbitrary, schema-less object that the Map Item stores. Can be up to 16 KiB in length.
*/
data: any;
/**
* The date and time in GMT when the Map Item expires and will be deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the Map Item does not expire, this value is `null`. The Map Item might not be deleted immediately after it expires.
*/
dateExpires: Date;
/**
* 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 Map Item\'s creator. If the Map Item is created from the client SDK, the value matches the Access Token\'s `identity` field. If the Map Item was created from the REST API, the value is `system`.
*/
createdBy: string;
private get _proxy();
/**
* Remove a SyncMapItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncMapItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
remove(params: SyncMapItemContextRemoveOptions, callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncMapItemInstance 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 SyncMapItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
removeWithHttpInfo(params: SyncMapItemContextRemoveOptions, callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a SyncMapItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
fetch(callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
/**
* Fetch a SyncMapItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
/**
* Update a SyncMapItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
update(callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
/**
* Update a SyncMapItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
update(params: SyncMapItemContextUpdateOptions, callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
/**
* Update a SyncMapItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
/**
* Update a SyncMapItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncMapItemContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
key: string;
accountSid: string;
serviceSid: string;
mapSid: string;
url: string;
revision: string;
data: any;
dateExpires: Date;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SyncMapItemSolution {
serviceSid: string;
mapSid: string;
}
export interface SyncMapItemListInstance {
_version: V1;
_solution: SyncMapItemSolution;
_uri: string;
(key: string): SyncMapItemContext;
get(key: string): SyncMapItemContext;
/**
* Create a SyncMapItemInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
create(params: SyncMapItemListInstanceCreateOptions, callback?: (error: Error | null, item?: SyncMapItemInstance) => any): Promise<SyncMapItemInstance>;
/**
* Create a SyncMapItemInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance with HTTP metadata
*/
createWithHttpInfo(params: SyncMapItemListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapItemInstance>) => any): Promise<ApiResponse<SyncMapItemInstance>>;
/**
* Streams SyncMapItemInstance 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 { SyncMapItemListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: SyncMapItemInstance, done: (err?: Error) => void) => void): void;
each(params: SyncMapItemListInstanceEachOptions, callback?: (item: SyncMapItemInstance, done: (err?: Error) => void) => void): void;
/**
* Streams SyncMapItemInstance 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 { SyncMapItemListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: SyncMapItemInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: SyncMapItemListInstanceEachOptions, callback?: (item: SyncMapItemInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of SyncMapItemInstance 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: SyncMapItemPage) => any): Promise<SyncMapItemPage>;
/**
* Retrieve a single target page of SyncMapItemInstance 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<SyncMapItemPage>) => any): Promise<ApiResponse<SyncMapItemPage>>;
/**
* Lists SyncMapItemInstance 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 { SyncMapItemListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: SyncMapItemInstance[]) => any): Promise<SyncMapItemInstance[]>;
list(params: SyncMapItemListInstanceOptions, callback?: (error: Error | null, items: SyncMapItemInstance[]) => any): Promise<SyncMapItemInstance[]>;
/**
* Lists SyncMapItemInstance 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 { SyncMapItemListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncMapItemInstance[]>) => any): Promise<ApiResponse<SyncMapItemInstance[]>>;
listWithHttpInfo(params: SyncMapItemListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<SyncMapItemInstance[]>) => any): Promise<ApiResponse<SyncMapItemInstance[]>>;
/**
* Retrieve a single page of SyncMapItemInstance 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 { SyncMapItemListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: SyncMapItemPage) => any): Promise<SyncMapItemPage>;
page(params: SyncMapItemListInstancePageOptions, callback?: (error: Error | null, items: SyncMapItemPage) => any): Promise<SyncMapItemPage>;
/**
* Retrieve a single page of SyncMapItemInstance 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 { SyncMapItemListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncMapItemPage>) => any): Promise<ApiResponse<SyncMapItemPage>>;
pageWithHttpInfo(params: SyncMapItemListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<SyncMapItemPage>) => any): Promise<ApiResponse<SyncMapItemPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SyncMapItemListInstance(version: V1, serviceSid: string, mapSid: string): SyncMapItemListInstance;
export declare class SyncMapItemPage extends Page<V1, SyncMapItemPayload, SyncMapItemResource, SyncMapItemInstance> {
/**
* Initialize the SyncMapItemPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: SyncMapItemSolution);
/**
* Build an instance of SyncMapItemInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: SyncMapItemResource): SyncMapItemInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,501 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.SyncMapItemPage = exports.SyncMapItemInstance = exports.SyncMapItemContextImpl = void 0;
exports.SyncMapItemListInstance = SyncMapItemListInstance;
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 SyncMapItemContextImpl {
constructor(_version, serviceSid, mapSid, key) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(mapSid)) {
throw new Error("Parameter 'mapSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(key)) {
throw new Error("Parameter 'key' is not valid.");
}
this._solution = { serviceSid, mapSid, key };
this._uri = `/Services/${serviceSid}/Maps/${mapSid}/Items/${key}`;
}
remove(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
const headers = {};
if (params["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
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["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
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 SyncMapItemInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.mapSid, instance._solution.key));
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 SyncMapItemInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.mapSid, instance._solution.key),
}));
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["data"] !== undefined)
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["itemTtl"] !== undefined)
data["ItemTtl"] = params["itemTtl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new SyncMapItemInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.mapSid, instance._solution.key));
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["data"] !== undefined)
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["itemTtl"] !== undefined)
data["ItemTtl"] = params["itemTtl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
if (params["ifMatch"] !== undefined)
headers["If-Match"] = params["ifMatch"];
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 SyncMapItemInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.mapSid, instance._solution.key),
}));
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.SyncMapItemContextImpl = SyncMapItemContextImpl;
class SyncMapItemInstance {
constructor(_version, payload, serviceSid, mapSid, key) {
this._version = _version;
this.key = payload.key;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.mapSid = payload.map_sid;
this.url = payload.url;
this.revision = payload.revision;
this.data = payload.data;
this.dateExpires = deserialize.iso8601DateTime(payload.date_expires);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this._solution = { serviceSid, mapSid, key: key || this.key };
}
get _proxy() {
this._context =
this._context ||
new SyncMapItemContextImpl(this._version, this._solution.serviceSid, this._solution.mapSid, this._solution.key);
return this._context;
}
remove(params, callback) {
return this._proxy.remove(params, callback);
}
removeWithHttpInfo(params, callback) {
return this._proxy.removeWithHttpInfo(params, callback);
}
/**
* Fetch a SyncMapItemInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SyncMapItemInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapItemInstance 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 {
key: this.key,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
mapSid: this.mapSid,
url: this.url,
revision: this.revision,
data: this.data,
dateExpires: this.dateExpires,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncMapItemInstance = SyncMapItemInstance;
function SyncMapItemListInstance(version, serviceSid, mapSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(mapSid)) {
throw new Error("Parameter 'mapSid' is not valid.");
}
const instance = ((key) => instance.get(key));
instance.get = function get(key) {
return new SyncMapItemContextImpl(version, serviceSid, mapSid, key);
};
instance._version = version;
instance._solution = { serviceSid, mapSid };
instance._uri = `/Services/${serviceSid}/Maps/${mapSid}/Items`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["key"] === null || params["key"] === undefined) {
throw new Error("Required parameter \"params['key']\" missing.");
}
if (params["data"] === null || params["data"] === undefined) {
throw new Error("Required parameter \"params['data']\" missing.");
}
let data = {};
data["Key"] = params["key"];
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["itemTtl"] !== undefined)
data["ItemTtl"] = params["itemTtl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncMapItemInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.mapSid));
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["key"] === null || params["key"] === undefined) {
throw new Error("Required parameter \"params['key']\" missing.");
}
if (params["data"] === null || params["data"] === undefined) {
throw new Error("Required parameter \"params['data']\" missing.");
}
let data = {};
data["Key"] = params["key"];
data["Data"] = serialize.object(params["data"]);
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
if (params["itemTtl"] !== undefined)
data["ItemTtl"] = params["itemTtl"];
if (params["collectionTtl"] !== undefined)
data["CollectionTtl"] = params["collectionTtl"];
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 SyncMapItemInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.mapSid),
}));
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["from"] !== undefined)
data["From"] = params["from"];
if (params["bounds"] !== undefined)
data["Bounds"] = params["bounds"];
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 SyncMapItemPage(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 SyncMapItemPage(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["from"] !== undefined)
data["From"] = params["from"];
if (params["bounds"] !== undefined)
data["Bounds"] = params["bounds"];
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 SyncMapItemPage(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 SyncMapItemPage(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 SyncMapItemPage extends Page_1.default {
/**
* Initialize the SyncMapItemPage
*
* @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 SyncMapItemInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new SyncMapItemInstance(this._version, payload, this._solution.serviceSid, this._solution.mapSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncMapItemPage = SyncMapItemPage;

View File

@@ -0,0 +1,385 @@
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 SyncMapPermissionInstance
*/
export interface SyncMapPermissionContextUpdateOptions {
/** Whether the identity can read the Sync Map and its Items. Default value is `false`. */
read: boolean;
/** Whether the identity can create, update, and delete Items in the Sync Map. Default value is `false`. */
write: boolean;
/** Whether the identity can delete the Sync Map. Default value is `false`. */
manage: boolean;
}
/**
* Options to pass to each
*/
export interface SyncMapPermissionListInstanceEachOptions {
/** 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: SyncMapPermissionInstance, 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 SyncMapPermissionListInstanceOptions {
/** 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 SyncMapPermissionListInstancePageOptions {
/** 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 SyncMapPermissionContext {
/**
* Remove a SyncMapPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncMapPermissionInstance 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 SyncMapPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance
*/
fetch(callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any): Promise<SyncMapPermissionInstance>;
/**
* Fetch a SyncMapPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapPermissionInstance>) => any): Promise<ApiResponse<SyncMapPermissionInstance>>;
/**
* Update a SyncMapPermissionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance
*/
update(params: SyncMapPermissionContextUpdateOptions, callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any): Promise<SyncMapPermissionInstance>;
/**
* Update a SyncMapPermissionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncMapPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapPermissionInstance>) => any): Promise<ApiResponse<SyncMapPermissionInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SyncMapPermissionContextSolution {
serviceSid: string;
mapSid: string;
identity: string;
}
export declare class SyncMapPermissionContextImpl implements SyncMapPermissionContext {
protected _version: V1;
protected _solution: SyncMapPermissionContextSolution;
protected _uri: string;
constructor(_version: V1, serviceSid: string, mapSid: string, identity: 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?: SyncMapPermissionInstance) => any): Promise<SyncMapPermissionInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapPermissionInstance>) => any): Promise<ApiResponse<SyncMapPermissionInstance>>;
update(params: SyncMapPermissionContextUpdateOptions, callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any): Promise<SyncMapPermissionInstance>;
updateWithHttpInfo(params: SyncMapPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapPermissionInstance>) => any): Promise<ApiResponse<SyncMapPermissionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SyncMapPermissionContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SyncMapPermissionPayload extends TwilioResponsePayload {
permissions: SyncMapPermissionResource[];
}
interface SyncMapPermissionResource {
account_sid: string;
service_sid: string;
map_sid: string;
identity: string;
read: boolean;
write: boolean;
manage: boolean;
url: string;
}
export declare class SyncMapPermissionInstance {
protected _version: V1;
protected _solution: SyncMapPermissionContextSolution;
protected _context?: SyncMapPermissionContext;
constructor(_version: V1, payload: SyncMapPermissionResource, serviceSid: string, mapSid: string, identity?: string);
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sync Map Permission resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the Sync Map to which the Permission applies.
*/
mapSid: string;
/**
* The application-defined string that uniquely identifies the resource\'s User within the Service to an FPA token.
*/
identity: string;
/**
* Whether the identity can read the Sync Map and its Items.
*/
read: boolean;
/**
* Whether the identity can create, update, and delete Items in the Sync Map.
*/
write: boolean;
/**
* Whether the identity can delete the Sync Map.
*/
manage: boolean;
/**
* The absolute URL of the Sync Map Permission resource.
*/
url: string;
private get _proxy();
/**
* Remove a SyncMapPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncMapPermissionInstance 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 SyncMapPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance
*/
fetch(callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any): Promise<SyncMapPermissionInstance>;
/**
* Fetch a SyncMapPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncMapPermissionInstance>) => any): Promise<ApiResponse<SyncMapPermissionInstance>>;
/**
* Update a SyncMapPermissionInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance
*/
update(params: SyncMapPermissionContextUpdateOptions, callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any): Promise<SyncMapPermissionInstance>;
/**
* Update a SyncMapPermissionInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncMapPermissionContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncMapPermissionInstance>) => any): Promise<ApiResponse<SyncMapPermissionInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
accountSid: string;
serviceSid: string;
mapSid: string;
identity: string;
read: boolean;
write: boolean;
manage: boolean;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SyncMapPermissionSolution {
serviceSid: string;
mapSid: string;
}
export interface SyncMapPermissionListInstance {
_version: V1;
_solution: SyncMapPermissionSolution;
_uri: string;
(identity: string): SyncMapPermissionContext;
get(identity: string): SyncMapPermissionContext;
/**
* Streams SyncMapPermissionInstance 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 { SyncMapPermissionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: SyncMapPermissionInstance, done: (err?: Error) => void) => void): void;
each(params: SyncMapPermissionListInstanceEachOptions, callback?: (item: SyncMapPermissionInstance, done: (err?: Error) => void) => void): void;
/**
* Streams SyncMapPermissionInstance 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 { SyncMapPermissionListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: SyncMapPermissionInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: SyncMapPermissionListInstanceEachOptions, callback?: (item: SyncMapPermissionInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of SyncMapPermissionInstance 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: SyncMapPermissionPage) => any): Promise<SyncMapPermissionPage>;
/**
* Retrieve a single target page of SyncMapPermissionInstance 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<SyncMapPermissionPage>) => any): Promise<ApiResponse<SyncMapPermissionPage>>;
/**
* Lists SyncMapPermissionInstance 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 { SyncMapPermissionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: SyncMapPermissionInstance[]) => any): Promise<SyncMapPermissionInstance[]>;
list(params: SyncMapPermissionListInstanceOptions, callback?: (error: Error | null, items: SyncMapPermissionInstance[]) => any): Promise<SyncMapPermissionInstance[]>;
/**
* Lists SyncMapPermissionInstance 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 { SyncMapPermissionListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncMapPermissionInstance[]>) => any): Promise<ApiResponse<SyncMapPermissionInstance[]>>;
listWithHttpInfo(params: SyncMapPermissionListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<SyncMapPermissionInstance[]>) => any): Promise<ApiResponse<SyncMapPermissionInstance[]>>;
/**
* Retrieve a single page of SyncMapPermissionInstance 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 { SyncMapPermissionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: SyncMapPermissionPage) => any): Promise<SyncMapPermissionPage>;
page(params: SyncMapPermissionListInstancePageOptions, callback?: (error: Error | null, items: SyncMapPermissionPage) => any): Promise<SyncMapPermissionPage>;
/**
* Retrieve a single page of SyncMapPermissionInstance 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 { SyncMapPermissionListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncMapPermissionPage>) => any): Promise<ApiResponse<SyncMapPermissionPage>>;
pageWithHttpInfo(params: SyncMapPermissionListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<SyncMapPermissionPage>) => any): Promise<ApiResponse<SyncMapPermissionPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SyncMapPermissionListInstance(version: V1, serviceSid: string, mapSid: string): SyncMapPermissionListInstance;
export declare class SyncMapPermissionPage extends Page<V1, SyncMapPermissionPayload, SyncMapPermissionResource, SyncMapPermissionInstance> {
/**
* Initialize the SyncMapPermissionPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: SyncMapPermissionSolution);
/**
* Build an instance of SyncMapPermissionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: SyncMapPermissionResource): SyncMapPermissionInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,401 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.SyncMapPermissionPage = exports.SyncMapPermissionInstance = exports.SyncMapPermissionContextImpl = void 0;
exports.SyncMapPermissionListInstance = SyncMapPermissionListInstance;
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 SyncMapPermissionContextImpl {
constructor(_version, serviceSid, mapSid, identity) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(mapSid)) {
throw new Error("Parameter 'mapSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
this._solution = { serviceSid, mapSid, identity };
this._uri = `/Services/${serviceSid}/Maps/${mapSid}/Permissions/${identity}`;
}
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 SyncMapPermissionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.mapSid, instance._solution.identity));
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 SyncMapPermissionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.mapSid, instance._solution.identity),
}));
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["read"] === null || params["read"] === undefined) {
throw new Error("Required parameter \"params['read']\" missing.");
}
if (params["write"] === null || params["write"] === undefined) {
throw new Error("Required parameter \"params['write']\" missing.");
}
if (params["manage"] === null || params["manage"] === undefined) {
throw new Error("Required parameter \"params['manage']\" missing.");
}
let data = {};
data["Read"] = serialize.bool(params["read"]);
data["Write"] = serialize.bool(params["write"]);
data["Manage"] = serialize.bool(params["manage"]);
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 SyncMapPermissionInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.mapSid, instance._solution.identity));
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["read"] === null || params["read"] === undefined) {
throw new Error("Required parameter \"params['read']\" missing.");
}
if (params["write"] === null || params["write"] === undefined) {
throw new Error("Required parameter \"params['write']\" missing.");
}
if (params["manage"] === null || params["manage"] === undefined) {
throw new Error("Required parameter \"params['manage']\" missing.");
}
let data = {};
data["Read"] = serialize.bool(params["read"]);
data["Write"] = serialize.bool(params["write"]);
data["Manage"] = serialize.bool(params["manage"]);
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 SyncMapPermissionInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.mapSid, instance._solution.identity),
}));
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.SyncMapPermissionContextImpl = SyncMapPermissionContextImpl;
class SyncMapPermissionInstance {
constructor(_version, payload, serviceSid, mapSid, identity) {
this._version = _version;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.mapSid = payload.map_sid;
this.identity = payload.identity;
this.read = payload.read;
this.write = payload.write;
this.manage = payload.manage;
this.url = payload.url;
this._solution = {
serviceSid,
mapSid,
identity: identity || this.identity,
};
}
get _proxy() {
this._context =
this._context ||
new SyncMapPermissionContextImpl(this._version, this._solution.serviceSid, this._solution.mapSid, this._solution.identity);
return this._context;
}
/**
* Remove a SyncMapPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a SyncMapPermissionInstance 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 SyncMapPermissionInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SyncMapPermissionInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncMapPermissionInstance 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,
mapSid: this.mapSid,
identity: this.identity,
read: this.read,
write: this.write,
manage: this.manage,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncMapPermissionInstance = SyncMapPermissionInstance;
function SyncMapPermissionListInstance(version, serviceSid, mapSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(mapSid)) {
throw new Error("Parameter 'mapSid' is not valid.");
}
const instance = ((identity) => instance.get(identity));
instance.get = function get(identity) {
return new SyncMapPermissionContextImpl(version, serviceSid, mapSid, identity);
};
instance._version = version;
instance._solution = { serviceSid, mapSid };
instance._uri = `/Services/${serviceSid}/Maps/${mapSid}/Permissions`;
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 SyncMapPermissionPage(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 SyncMapPermissionPage(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 SyncMapPermissionPage(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 SyncMapPermissionPage(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 SyncMapPermissionPage extends Page_1.default {
/**
* Initialize the SyncMapPermissionPage
*
* @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 SyncMapPermissionInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new SyncMapPermissionInstance(this._version, payload, this._solution.serviceSid, this._solution.mapSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncMapPermissionPage = SyncMapPermissionPage;

View File

@@ -0,0 +1,474 @@
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 { StreamMessageListInstance } from "./syncStream/streamMessage";
/**
* Options to pass to update a SyncStreamInstance
*/
export interface SyncStreamContextUpdateOptions {
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Stream expires and is deleted (time-to-live). */
ttl?: number;
}
/**
* Options to pass to create a SyncStreamInstance
*/
export interface SyncStreamListInstanceCreateOptions {
/** An application-defined string that uniquely identifies the resource. This value must be unique within its Service and it can be up to 320 characters long. The `unique_name` value can be used as an alternative to the `sid` in the URL path to address the resource. */
uniqueName?: string;
/** How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Stream expires and is deleted (time-to-live). */
ttl?: number;
}
/**
* Options to pass to each
*/
export interface SyncStreamListInstanceEachOptions {
/** 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: SyncStreamInstance, 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 SyncStreamListInstanceOptions {
/** 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 SyncStreamListInstancePageOptions {
/** 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 SyncStreamContext {
streamMessages: StreamMessageListInstance;
/**
* Remove a SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncStreamInstance 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 SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
fetch(callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
/**
* Fetch a SyncStreamInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Update a SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
update(callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
/**
* Update a SyncStreamInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
update(params: SyncStreamContextUpdateOptions, callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
/**
* Update a SyncStreamInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Update a SyncStreamInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncStreamContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SyncStreamContextSolution {
serviceSid: string;
sid: string;
}
export declare class SyncStreamContextImpl implements SyncStreamContext {
protected _version: V1;
protected _solution: SyncStreamContextSolution;
protected _uri: string;
protected _streamMessages?: StreamMessageListInstance;
constructor(_version: V1, serviceSid: string, sid: string);
get streamMessages(): StreamMessageListInstance;
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?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
update(params?: SyncStreamContextUpdateOptions | ((error: Error | null, item?: SyncStreamInstance) => any), callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
updateWithHttpInfo(params?: SyncStreamContextUpdateOptions | ((error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SyncStreamContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SyncStreamPayload extends TwilioResponsePayload {
streams: SyncStreamResource[];
}
interface SyncStreamResource {
sid: string;
unique_name: string;
account_sid: string;
service_sid: string;
url: string;
links: Record<string, string>;
date_expires: Date;
date_created: Date;
date_updated: Date;
created_by: string;
}
export declare class SyncStreamInstance {
protected _version: V1;
protected _solution: SyncStreamContextSolution;
protected _context?: SyncStreamContext;
constructor(_version: V1, payload: SyncStreamResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Sync Stream 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 SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sync Stream resource.
*/
accountSid: string;
/**
* The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The absolute URL of the Message Stream resource.
*/
url: string;
/**
* The URLs of the Stream\'s nested resources.
*/
links: Record<string, string>;
/**
* The date and time in GMT when the Message Stream expires and will be deleted, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the Message Stream does not expire, this value is `null`. The Stream might not be deleted immediately after it expires.
*/
dateExpires: Date;
/**
* 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 Stream\'s creator. If the Stream is created from the client SDK, the value matches the Access Token\'s `identity` field. If the Stream was created from the REST API, the value is \'system\'.
*/
createdBy: string;
private get _proxy();
/**
* Remove a SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SyncStreamInstance 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 SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
fetch(callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
/**
* Fetch a SyncStreamInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Update a SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
update(callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
/**
* Update a SyncStreamInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
update(params: SyncStreamContextUpdateOptions, callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
/**
* Update a SyncStreamInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Update a SyncStreamInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance with HTTP metadata
*/
updateWithHttpInfo(params: SyncStreamContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Access the streamMessages.
*/
streamMessages(): StreamMessageListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
uniqueName: string;
accountSid: string;
serviceSid: string;
url: string;
links: Record<string, string>;
dateExpires: Date;
dateCreated: Date;
dateUpdated: Date;
createdBy: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SyncStreamSolution {
serviceSid: string;
}
export interface SyncStreamListInstance {
_version: V1;
_solution: SyncStreamSolution;
_uri: string;
(sid: string): SyncStreamContext;
get(sid: string): SyncStreamContext;
/**
* Create a SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
create(callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
/**
* Create a SyncStreamInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
create(params: SyncStreamListInstanceCreateOptions, callback?: (error: Error | null, item?: SyncStreamInstance) => any): Promise<SyncStreamInstance>;
/**
* Create a SyncStreamInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Create a SyncStreamInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance with HTTP metadata
*/
createWithHttpInfo(params: SyncStreamListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<SyncStreamInstance>) => any): Promise<ApiResponse<SyncStreamInstance>>;
/**
* Streams SyncStreamInstance 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 { SyncStreamListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: SyncStreamInstance, done: (err?: Error) => void) => void): void;
each(params: SyncStreamListInstanceEachOptions, callback?: (item: SyncStreamInstance, done: (err?: Error) => void) => void): void;
/**
* Streams SyncStreamInstance 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 { SyncStreamListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: SyncStreamInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: SyncStreamListInstanceEachOptions, callback?: (item: SyncStreamInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of SyncStreamInstance 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: SyncStreamPage) => any): Promise<SyncStreamPage>;
/**
* Retrieve a single target page of SyncStreamInstance 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<SyncStreamPage>) => any): Promise<ApiResponse<SyncStreamPage>>;
/**
* Lists SyncStreamInstance 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 { SyncStreamListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: SyncStreamInstance[]) => any): Promise<SyncStreamInstance[]>;
list(params: SyncStreamListInstanceOptions, callback?: (error: Error | null, items: SyncStreamInstance[]) => any): Promise<SyncStreamInstance[]>;
/**
* Lists SyncStreamInstance 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 { SyncStreamListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncStreamInstance[]>) => any): Promise<ApiResponse<SyncStreamInstance[]>>;
listWithHttpInfo(params: SyncStreamListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<SyncStreamInstance[]>) => any): Promise<ApiResponse<SyncStreamInstance[]>>;
/**
* Retrieve a single page of SyncStreamInstance 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 { SyncStreamListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: SyncStreamPage) => any): Promise<SyncStreamPage>;
page(params: SyncStreamListInstancePageOptions, callback?: (error: Error | null, items: SyncStreamPage) => any): Promise<SyncStreamPage>;
/**
* Retrieve a single page of SyncStreamInstance 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 { SyncStreamListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<SyncStreamPage>) => any): Promise<ApiResponse<SyncStreamPage>>;
pageWithHttpInfo(params: SyncStreamListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<SyncStreamPage>) => any): Promise<ApiResponse<SyncStreamPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SyncStreamListInstance(version: V1, serviceSid: string): SyncStreamListInstance;
export declare class SyncStreamPage extends Page<V1, SyncStreamPayload, SyncStreamResource, SyncStreamInstance> {
/**
* Initialize the SyncStreamPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V1, response: Response<string>, solution: SyncStreamSolution);
/**
* Build an instance of SyncStreamInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: SyncStreamResource): SyncStreamInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,454 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.SyncStreamPage = exports.SyncStreamInstance = exports.SyncStreamContextImpl = void 0;
exports.SyncStreamListInstance = SyncStreamListInstance;
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 streamMessage_1 = require("./syncStream/streamMessage");
class SyncStreamContextImpl {
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}/Streams/${sid}`;
}
get streamMessages() {
this._streamMessages =
this._streamMessages ||
(0, streamMessage_1.StreamMessageListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._streamMessages;
}
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 SyncStreamInstance(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 SyncStreamInstance(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["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
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 SyncStreamInstance(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["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
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 SyncStreamInstance(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.SyncStreamContextImpl = SyncStreamContextImpl;
class SyncStreamInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.uniqueName = payload.unique_name;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.url = payload.url;
this.links = payload.links;
this.dateExpires = deserialize.iso8601DateTime(payload.date_expires);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.createdBy = payload.created_by;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new SyncStreamContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a SyncStreamInstance 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 SyncStreamInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SyncStreamInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SyncStreamInstance 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 streamMessages.
*/
streamMessages() {
return this._proxy.streamMessages;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
uniqueName: this.uniqueName,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
url: this.url,
links: this.links,
dateExpires: this.dateExpires,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
createdBy: this.createdBy,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncStreamInstance = SyncStreamInstance;
function SyncStreamListInstance(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 SyncStreamContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Streams`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
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 SyncStreamInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["uniqueName"] !== undefined)
data["UniqueName"] = params["uniqueName"];
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
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 SyncStreamInstance(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 SyncStreamPage(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 SyncStreamPage(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 SyncStreamPage(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 SyncStreamPage(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 SyncStreamPage extends Page_1.default {
/**
* Initialize the SyncStreamPage
*
* @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 SyncStreamInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new SyncStreamInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SyncStreamPage = SyncStreamPage;

View File

@@ -0,0 +1,70 @@
import { inspect, InspectOptions } from "util";
import V1 from "../../../V1";
import { ApiResponse } from "../../../../../base/ApiResponse";
/**
* Options to pass to create a StreamMessageInstance
*/
export interface StreamMessageListInstanceCreateOptions {
/** A JSON string that represents an arbitrary, schema-less object that makes up the Stream Message body. Can be up to 4 KiB in length. */
data: any;
}
export interface StreamMessageSolution {
serviceSid: string;
streamSid: string;
}
export interface StreamMessageListInstance {
_version: V1;
_solution: StreamMessageSolution;
_uri: string;
/**
* Create a StreamMessageInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed StreamMessageInstance
*/
create(params: StreamMessageListInstanceCreateOptions, callback?: (error: Error | null, item?: StreamMessageInstance) => any): Promise<StreamMessageInstance>;
/**
* Create a StreamMessageInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed StreamMessageInstance with HTTP metadata
*/
createWithHttpInfo(params: StreamMessageListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<StreamMessageInstance>) => any): Promise<ApiResponse<StreamMessageInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function StreamMessageListInstance(version: V1, serviceSid: string, streamSid: string): StreamMessageListInstance;
interface StreamMessageResource {
sid: string;
data: any;
}
export declare class StreamMessageInstance {
protected _version: V1;
constructor(_version: V1, payload: StreamMessageResource, serviceSid: string, streamSid: string);
/**
* The unique string that we created to identify the Stream Message resource.
*/
sid: string;
/**
* An arbitrary, schema-less object that contains the Stream Message body. Can be up to 4 KiB in length.
*/
data: any;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
data: any;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,112 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Sync
* 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.StreamMessageInstance = void 0;
exports.StreamMessageListInstance = StreamMessageListInstance;
const util_1 = require("util");
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
const utility_1 = require("../../../../../base/utility");
function StreamMessageListInstance(version, serviceSid, streamSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(streamSid)) {
throw new Error("Parameter 'streamSid' is not valid.");
}
const instance = {};
instance._version = version;
instance._solution = { serviceSid, streamSid };
instance._uri = `/Services/${serviceSid}/Streams/${streamSid}/Messages`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["data"] === null || params["data"] === undefined) {
throw new Error("Required parameter \"params['data']\" missing.");
}
let data = {};
data["Data"] = serialize.object(params["data"]);
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 StreamMessageInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.streamSid));
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["data"] === null || params["data"] === undefined) {
throw new Error("Required parameter \"params['data']\" missing.");
}
let data = {};
data["Data"] = serialize.object(params["data"]);
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 StreamMessageInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.streamSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
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 StreamMessageInstance {
constructor(_version, payload, serviceSid, streamSid) {
this._version = _version;
this.sid = payload.sid;
this.data = payload.data;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
data: this.data,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.StreamMessageInstance = StreamMessageInstance;