diff --git a/src/rest/Preview.ts b/src/rest/Preview.ts index aacf2e6e37..81a7735e7d 100644 --- a/src/rest/Preview.ts +++ b/src/rest/Preview.ts @@ -2,7 +2,6 @@ import { AuthorizationDocumentListInstance } from "./preview/hosted_numbers/auth import { HostedNumberOrderListInstance } from "./preview/hosted_numbers/hostedNumberOrder"; import { AvailableAddOnListInstance } from "./preview/marketplace/availableAddOn"; import { InstalledAddOnListInstance } from "./preview/marketplace/installedAddOn"; -import { ServiceListInstance } from "./preview/sync/service"; import { CommandListInstance } from "./preview/wireless/command"; import { RatePlanListInstance } from "./preview/wireless/ratePlan"; import { SimListInstance } from "./preview/wireless/sim"; @@ -49,14 +48,6 @@ class Preview extends PreviewBase { return this.marketplace.installedAddOns; } - /** - * @deprecated - Use sync.services instead - */ - get services(): ServiceListInstance { - console.warn("services is deprecated. Use sync.services instead."); - return this.sync.services; - } - /** * @deprecated - Use wireless.commands instead */ diff --git a/src/rest/PreviewBase.ts b/src/rest/PreviewBase.ts index 059903ee1b..b000cdce5c 100644 --- a/src/rest/PreviewBase.ts +++ b/src/rest/PreviewBase.ts @@ -11,13 +11,11 @@ import Domain from "../base/Domain"; import HostedNumbers from "./preview/HostedNumbers"; -import Sync from "./preview/Sync"; import Marketplace from "./preview/Marketplace"; import Wireless from "./preview/Wireless"; class PreviewBase extends Domain { _hosted_numbers?: HostedNumbers; - _sync?: Sync; _marketplace?: Marketplace; _wireless?: Wireless; @@ -34,10 +32,6 @@ class PreviewBase extends Domain { this._hosted_numbers = this._hosted_numbers || new HostedNumbers(this); return this._hosted_numbers; } - get sync(): Sync { - this._sync = this._sync || new Sync(this); - return this._sync; - } get marketplace(): Marketplace { this._marketplace = this._marketplace || new Marketplace(this); return this._marketplace; diff --git a/src/rest/preview/Sync.ts b/src/rest/preview/Sync.ts deleted file mode 100644 index e1d5708ca2..0000000000 --- a/src/rest/preview/Sync.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import PreviewBase from "../PreviewBase"; -import Version from "../../base/Version"; -import { ServiceListInstance } from "./sync/service"; - -export default class Sync extends Version { - /** - * Initialize the Sync version of Preview - * - * @param domain - The Twilio (Twilio.Preview) domain - */ - constructor(domain: PreviewBase) { - super(domain, "Sync"); - } - - /** services - { Twilio.Preview.Sync.ServiceListInstance } resource */ - protected _services?: ServiceListInstance; - - /** Getter for services resource */ - get services(): ServiceListInstance { - this._services = this._services || ServiceListInstance(this); - return this._services; - } -} diff --git a/src/rest/preview/sync/service.ts b/src/rest/preview/sync/service.ts deleted file mode 100644 index 29992cbd07..0000000000 --- a/src/rest/preview/sync/service.ts +++ /dev/null @@ -1,726 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../base/Page"; -import Response from "../../../http/response"; -import Sync from "../Sync"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; -import { DocumentListInstance } from "./service/document"; -import { SyncListListInstance } from "./service/syncList"; -import { SyncMapListInstance } from "./service/syncMap"; - -/** - * Options to pass to update a ServiceInstance - */ -export interface ServiceContextUpdateOptions { - /** */ - webhookUrl?: string; - /** */ - friendlyName?: string; - /** */ - reachabilityWebhooksEnabled?: boolean; - /** */ - aclEnabled?: boolean; -} - -/** - * Options to pass to create a ServiceInstance - */ -export interface ServiceListInstanceCreateOptions { - /** */ - friendlyName?: string; - /** */ - webhookUrl?: string; - /** */ - reachabilityWebhooksEnabled?: boolean; - /** */ - aclEnabled?: 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 1000. */ - pageSize?: number; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: (item: ServiceInstance, done: (err?: Error) => void) => void; - /** Function to be called upon completion of streaming */ - done?: Function; - /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to list - */ -export interface ServiceListInstanceOptions { - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface ServiceListInstancePageOptions { - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface ServiceContext { - documents: DocumentListInstance; - syncLists: SyncListListInstance; - syncMaps: SyncMapListInstance; - - /** - * Remove a ServiceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a ServiceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ServiceInstance - */ - fetch( - callback?: (error: Error | null, item?: ServiceInstance) => any - ): Promise; - - /** - * Update a ServiceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ServiceInstance - */ - update( - callback?: (error: Error | null, item?: ServiceInstance) => any - ): Promise; - /** - * 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; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface ServiceContextSolution { - sid: string; -} - -export class ServiceContextImpl implements ServiceContext { - protected _solution: ServiceContextSolution; - protected _uri: string; - - protected _documents?: DocumentListInstance; - protected _syncLists?: SyncListListInstance; - protected _syncMaps?: SyncMapListInstance; - - constructor(protected _version: Sync, sid: string) { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { sid }; - this._uri = `/Services/${sid}`; - } - - get documents(): DocumentListInstance { - this._documents = - this._documents || - DocumentListInstance(this._version, this._solution.sid); - return this._documents; - } - - get syncLists(): SyncListListInstance { - this._syncLists = - this._syncLists || - SyncListListInstance(this._version, this._solution.sid); - return this._syncLists; - } - - get syncMaps(): SyncMapListInstance { - this._syncMaps = - this._syncMaps || SyncMapListInstance(this._version, this._solution.sid); - return this._syncMaps; - } - - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: ServiceInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new ServiceInstance(operationVersion, payload, instance._solution.sid) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | ServiceContextUpdateOptions - | ((error: Error | null, item?: ServiceInstance) => any), - callback?: (error: Error | null, item?: ServiceInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface ServicePayload extends TwilioResponsePayload { - services: ServiceResource[]; -} - -interface ServiceResource { - sid: string; - account_sid: string; - friendly_name: string; - date_created: Date; - date_updated: Date; - url: string; - webhook_url: string; - reachability_webhooks_enabled: boolean; - acl_enabled: boolean; - links: Record; -} - -export class ServiceInstance { - protected _solution: ServiceContextSolution; - protected _context?: ServiceContext; - - constructor( - protected _version: Sync, - payload: ServiceResource, - sid?: string - ) { - this.sid = payload.sid; - this.accountSid = payload.account_sid; - this.friendlyName = payload.friendly_name; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.url = payload.url; - this.webhookUrl = payload.webhook_url; - this.reachabilityWebhooksEnabled = payload.reachability_webhooks_enabled; - this.aclEnabled = payload.acl_enabled; - this.links = payload.links; - - this._solution = { sid: sid || this.sid }; - } - - sid: string; - accountSid: string; - friendlyName: string; - dateCreated: Date; - dateUpdated: Date; - url: string; - webhookUrl: string; - reachabilityWebhooksEnabled: boolean; - aclEnabled: boolean; - links: Record; - - private get _proxy(): ServiceContext { - 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?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a ServiceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ServiceInstance - */ - fetch( - callback?: (error: Error | null, item?: ServiceInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a ServiceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed ServiceInstance - */ - update( - callback?: (error: Error | null, item?: ServiceInstance) => any - ): Promise; - /** - * 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; - - update( - params?: any, - callback?: (error: Error | null, item?: ServiceInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Access the documents. - */ - documents(): DocumentListInstance { - return this._proxy.documents; - } - - /** - * Access the syncLists. - */ - syncLists(): SyncListListInstance { - return this._proxy.syncLists; - } - - /** - * Access the syncMaps. - */ - syncMaps(): SyncMapListInstance { - return this._proxy.syncMaps; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - accountSid: this.accountSid, - friendlyName: this.friendlyName, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - url: this.url, - webhookUrl: this.webhookUrl, - reachabilityWebhooksEnabled: this.reachabilityWebhooksEnabled, - aclEnabled: this.aclEnabled, - links: this.links, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface ServiceSolution {} - -export interface ServiceListInstance { - _version: Sync; - _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; - /** - * 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; - - /** - * Streams ServiceInstance records from the API. - * - * This operation lazily loads records as efficiently as possible until the limit - * is reached. - * - * The results are passed into the callback function, so this operation is memory - * efficient. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { ServiceListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: ServiceInstance, done: (err?: Error) => void) => void - ): void; - each( - params: ServiceListInstanceEachOptions, - callback?: (item: ServiceInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of ServiceInstance records from the API. - * - * The request is executed immediately. - * - * @param { string } [targetUrl] - API-generated URL for the requested results page - * @param { function } [callback] - Callback to handle list of records - */ - getPage( - targetUrl: string, - callback?: (error: Error | null, items: ServicePage) => any - ): Promise; - /** - * 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; - list( - params: ServiceListInstanceOptions, - callback?: (error: Error | null, items: ServiceInstance[]) => any - ): Promise; - /** - * 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; - page( - params: ServiceListInstancePageOptions, - callback?: (error: Error | null, items: ServicePage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function ServiceListInstance(version: Sync): ServiceListInstance { - const instance = ((sid) => instance.get(sid)) as ServiceListInstance; - - instance.get = function get(sid): ServiceContext { - return new ServiceContextImpl(version, sid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = `/Services`; - - instance.create = function create( - params?: - | ServiceListInstanceCreateOptions - | ((error: Error | null, items: ServiceInstance) => any), - callback?: (error: Error | null, items: ServiceInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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.page = function page( - params?: - | ServiceListInstancePageOptions - | ((error: Error | null, items: ServicePage) => any), - callback?: (error: Error | null, items: ServicePage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: ServicePage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class ServicePage extends Page< - Sync, - ServicePayload, - ServiceResource, - ServiceInstance -> { - /** - * Initialize the ServicePage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: ServiceSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of ServiceInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: ServiceResource): ServiceInstance { - return new ServiceInstance(this._version, payload); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/sync/service/document.ts b/src/rest/preview/sync/service/document.ts deleted file mode 100644 index e1f9e02a34..0000000000 --- a/src/rest/preview/sync/service/document.ts +++ /dev/null @@ -1,697 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../base/Page"; -import Response from "../../../../http/response"; -import Sync from "../../Sync"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; -import { DocumentPermissionListInstance } from "./document/documentPermission"; - -/** - * Options to pass to update a DocumentInstance - */ -export interface DocumentContextUpdateOptions { - /** */ - data: any; - /** The If-Match HTTP request header */ - ifMatch?: string; -} - -/** - * Options to pass to create a DocumentInstance - */ -export interface DocumentListInstanceCreateOptions { - /** */ - uniqueName?: string; - /** */ - data?: any; -} -/** - * 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 1000. */ - 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 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface DocumentListInstancePageOptions { - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface 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; - - /** - * Fetch a DocumentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DocumentInstance - */ - fetch( - callback?: (error: Error | null, item?: DocumentInstance) => any - ): Promise; - - /** - * 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; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface DocumentContextSolution { - serviceSid: string; - sid: string; -} - -export class DocumentContextImpl implements DocumentContext { - protected _solution: DocumentContextSolution; - protected _uri: string; - - protected _documentPermissions?: DocumentPermissionListInstance; - - constructor(protected _version: Sync, serviceSid: string, sid: string) { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { serviceSid, sid }; - this._uri = `/Services/${serviceSid}/Documents/${sid}`; - } - - get documentPermissions(): DocumentPermissionListInstance { - this._documentPermissions = - this._documentPermissions || - DocumentPermissionListInstance( - this._version, - this._solution.serviceSid, - this._solution.sid - ); - return this._documentPermissions; - } - - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: DocumentInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new DocumentInstance( - operationVersion, - payload, - instance._solution.serviceSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params: DocumentContextUpdateOptions, - callback?: (error: Error | null, item?: DocumentInstance) => any - ): Promise { - 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: any = {}; - - data["Data"] = serialize.object(params["data"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - 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; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface DocumentPayload extends TwilioResponsePayload { - documents: DocumentResource[]; -} - -interface DocumentResource { - sid: string; - unique_name: string; - account_sid: string; - service_sid: string; - url: string; - links: Record; - revision: string; - data: any; - date_created: Date; - date_updated: Date; - created_by: string; -} - -export class DocumentInstance { - protected _solution: DocumentContextSolution; - protected _context?: DocumentContext; - - constructor( - protected _version: Sync, - payload: DocumentResource, - serviceSid: string, - sid?: string - ) { - 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.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 }; - } - - sid: string; - uniqueName: string; - accountSid: string; - serviceSid: string; - url: string; - links: Record; - revision: string; - data: any; - dateCreated: Date; - dateUpdated: Date; - createdBy: string; - - private get _proxy(): DocumentContext { - 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?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a DocumentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DocumentInstance - */ - fetch( - callback?: (error: Error | null, item?: DocumentInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * 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; - - update( - params?: any, - callback?: (error: Error | null, item?: DocumentInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Access the documentPermissions. - */ - documentPermissions(): DocumentPermissionListInstance { - 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, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - createdBy: this.createdBy, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface DocumentSolution { - serviceSid: string; -} - -export interface DocumentListInstance { - _version: Sync; - _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; - /** - * 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; - - /** - * 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; - /** - * 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; - /** - * 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; - list( - params: DocumentListInstanceOptions, - callback?: (error: Error | null, items: DocumentInstance[]) => any - ): Promise; - /** - * 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; - page( - params: DocumentListInstancePageOptions, - callback?: (error: Error | null, items: DocumentPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function DocumentListInstance( - version: Sync, - serviceSid: string -): DocumentListInstance { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as DocumentListInstance; - - instance.get = function get(sid): DocumentContext { - return new DocumentContextImpl(version, serviceSid, sid); - }; - - instance._version = version; - instance._solution = { serviceSid }; - instance._uri = `/Services/${serviceSid}/Documents`; - - instance.create = function create( - params?: - | DocumentListInstanceCreateOptions - | ((error: Error | null, items: DocumentInstance) => any), - callback?: (error: Error | null, items: DocumentInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - if (params["data"] !== undefined) - data["Data"] = serialize.object(params["data"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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.page = function page( - params?: - | DocumentListInstancePageOptions - | ((error: Error | null, items: DocumentPage) => any), - callback?: (error: Error | null, items: DocumentPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: DocumentPage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class DocumentPage extends Page< - Sync, - DocumentPayload, - DocumentResource, - DocumentInstance -> { - /** - * Initialize the DocumentPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: DocumentSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of DocumentInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: DocumentResource): DocumentInstance { - return new DocumentInstance( - this._version, - payload, - this._solution.serviceSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/sync/service/document/documentPermission.ts b/src/rest/preview/sync/service/document/documentPermission.ts deleted file mode 100644 index ef4c458b76..0000000000 --- a/src/rest/preview/sync/service/document/documentPermission.ts +++ /dev/null @@ -1,668 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../../base/Page"; -import Response from "../../../../../http/response"; -import Sync from "../../../Sync"; -const deserialize = require("../../../../../base/deserialize"); -const serialize = require("../../../../../base/serialize"); -import { isValidPathParam } from "../../../../../base/utility"; - -/** - * Options to pass to update a DocumentPermissionInstance - */ -export interface DocumentPermissionContextUpdateOptions { - /** Boolean flag specifying whether the identity can read the Sync Document. */ - read: boolean; - /** Boolean flag specifying whether the identity can update the Sync Document. */ - write: boolean; - /** Boolean flag specifying whether the identity can delete the Sync Document. */ - 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 1000. */ - 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 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface DocumentPermissionListInstancePageOptions { - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface 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; - - /** - * Fetch a DocumentPermissionInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DocumentPermissionInstance - */ - fetch( - callback?: (error: Error | null, item?: DocumentPermissionInstance) => any - ): Promise; - - /** - * 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; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface DocumentPermissionContextSolution { - serviceSid: string; - documentSid: string; - identity: string; -} - -export class DocumentPermissionContextImpl - implements DocumentPermissionContext -{ - protected _solution: DocumentPermissionContextSolution; - protected _uri: string; - - constructor( - protected _version: Sync, - serviceSid: string, - documentSid: string, - identity: string - ) { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(documentSid)) { - throw new Error("Parameter 'documentSid' is not valid."); - } - - if (!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?: (error: Error | null, item?: boolean) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: DocumentPermissionInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - 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; - } - - update( - params: DocumentPermissionContextUpdateOptions, - callback?: (error: Error | null, item?: DocumentPermissionInstance) => any - ): Promise { - 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: any = {}; - - data["Read"] = serialize.bool(params["read"]); - - data["Write"] = serialize.bool(params["write"]); - - data["Manage"] = serialize.bool(params["manage"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -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 class DocumentPermissionInstance { - protected _solution: DocumentPermissionContextSolution; - protected _context?: DocumentPermissionContext; - - constructor( - protected _version: Sync, - payload: DocumentPermissionResource, - serviceSid: string, - documentSid: string, - identity?: string - ) { - 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, - }; - } - - /** - * The unique SID identifier of the Twilio Account. - */ - accountSid: string; - /** - * The unique SID identifier of the Sync Service Instance. - */ - serviceSid: string; - /** - * The unique SID identifier of the Sync Document to which the Permission applies. - */ - documentSid: string; - /** - * Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - */ - identity: string; - /** - * Boolean flag specifying whether the identity can read the Sync Document. - */ - read: boolean; - /** - * Boolean flag specifying whether the identity can update the Sync Document. - */ - write: boolean; - /** - * Boolean flag specifying whether the identity can delete the Sync Document. - */ - manage: boolean; - /** - * Contains an absolute URL for this Sync Document Permission. - */ - url: string; - - private get _proxy(): DocumentPermissionContext { - 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?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a DocumentPermissionInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DocumentPermissionInstance - */ - fetch( - callback?: (error: Error | null, item?: DocumentPermissionInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * 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; - - update( - params?: any, - callback?: (error: Error | null, item?: DocumentPermissionInstance) => any - ): Promise { - return this._proxy.update(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, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface DocumentPermissionSolution { - serviceSid: string; - documentSid: string; -} - -export interface DocumentPermissionListInstance { - _version: Sync; - _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; - /** - * 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; - /** - * 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; - list( - params: DocumentPermissionListInstanceOptions, - callback?: (error: Error | null, items: DocumentPermissionInstance[]) => any - ): Promise; - /** - * 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; - page( - params: DocumentPermissionListInstancePageOptions, - callback?: (error: Error | null, items: DocumentPermissionPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function DocumentPermissionListInstance( - version: Sync, - serviceSid: string, - documentSid: string -): DocumentPermissionListInstance { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(documentSid)) { - throw new Error("Parameter 'documentSid' is not valid."); - } - - const instance = ((identity) => - instance.get(identity)) as DocumentPermissionListInstance; - - instance.get = function get(identity): DocumentPermissionContext { - 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?: - | DocumentPermissionListInstancePageOptions - | ((error: Error | null, items: DocumentPermissionPage) => any), - callback?: (error: Error | null, items: DocumentPermissionPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: DocumentPermissionPage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class DocumentPermissionPage extends Page< - Sync, - DocumentPermissionPayload, - DocumentPermissionResource, - DocumentPermissionInstance -> { - /** - * Initialize the DocumentPermissionPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: DocumentPermissionSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of DocumentPermissionInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: DocumentPermissionResource): DocumentPermissionInstance { - return new DocumentPermissionInstance( - this._version, - payload, - this._solution.serviceSid, - this._solution.documentSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/sync/service/syncList.ts b/src/rest/preview/sync/service/syncList.ts deleted file mode 100644 index ff60cfcd61..0000000000 --- a/src/rest/preview/sync/service/syncList.ts +++ /dev/null @@ -1,620 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../base/Page"; -import Response from "../../../../http/response"; -import Sync from "../../Sync"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; -import { SyncListItemListInstance } from "./syncList/syncListItem"; -import { SyncListPermissionListInstance } from "./syncList/syncListPermission"; - -/** - * Options to pass to create a SyncListInstance - */ -export interface SyncListListInstanceCreateOptions { - /** */ - uniqueName?: string; -} -/** - * 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 1000. */ - 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 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface SyncListListInstancePageOptions { - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface 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; - - /** - * Fetch a SyncListInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncListInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncListInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface SyncListContextSolution { - serviceSid: string; - sid: string; -} - -export class SyncListContextImpl implements SyncListContext { - protected _solution: SyncListContextSolution; - protected _uri: string; - - protected _syncListItems?: SyncListItemListInstance; - protected _syncListPermissions?: SyncListPermissionListInstance; - - constructor(protected _version: Sync, serviceSid: string, sid: string) { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { serviceSid, sid }; - this._uri = `/Services/${serviceSid}/Lists/${sid}`; - } - - get syncListItems(): SyncListItemListInstance { - this._syncListItems = - this._syncListItems || - SyncListItemListInstance( - this._version, - this._solution.serviceSid, - this._solution.sid - ); - return this._syncListItems; - } - - get syncListPermissions(): SyncListPermissionListInstance { - this._syncListPermissions = - this._syncListPermissions || - SyncListPermissionListInstance( - this._version, - this._solution.serviceSid, - this._solution.sid - ); - return this._syncListPermissions; - } - - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: SyncListInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new SyncListInstance( - operationVersion, - payload, - 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; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface SyncListPayload extends TwilioResponsePayload { - lists: SyncListResource[]; -} - -interface SyncListResource { - sid: string; - unique_name: string; - account_sid: string; - service_sid: string; - url: string; - links: Record; - revision: string; - date_created: Date; - date_updated: Date; - created_by: string; -} - -export class SyncListInstance { - protected _solution: SyncListContextSolution; - protected _context?: SyncListContext; - - constructor( - protected _version: Sync, - payload: SyncListResource, - serviceSid: string, - sid?: string - ) { - 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.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 }; - } - - sid: string; - uniqueName: string; - accountSid: string; - serviceSid: string; - url: string; - links: Record; - revision: string; - dateCreated: Date; - dateUpdated: Date; - createdBy: string; - - private get _proxy(): SyncListContext { - 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?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a SyncListInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncListInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncListInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Access the syncListItems. - */ - syncListItems(): SyncListItemListInstance { - return this._proxy.syncListItems; - } - - /** - * Access the syncListPermissions. - */ - syncListPermissions(): SyncListPermissionListInstance { - 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, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - createdBy: this.createdBy, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface SyncListSolution { - serviceSid: string; -} - -export interface SyncListListInstance { - _version: Sync; - _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; - /** - * 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; - - /** - * 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; - /** - * 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; - /** - * 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; - list( - params: SyncListListInstanceOptions, - callback?: (error: Error | null, items: SyncListInstance[]) => any - ): Promise; - /** - * 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; - page( - params: SyncListListInstancePageOptions, - callback?: (error: Error | null, items: SyncListPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function SyncListListInstance( - version: Sync, - serviceSid: string -): SyncListListInstance { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as SyncListListInstance; - - instance.get = function get(sid): SyncListContext { - return new SyncListContextImpl(version, serviceSid, sid); - }; - - instance._version = version; - instance._solution = { serviceSid }; - instance._uri = `/Services/${serviceSid}/Lists`; - - instance.create = function create( - params?: - | SyncListListInstanceCreateOptions - | ((error: Error | null, items: SyncListInstance) => any), - callback?: (error: Error | null, items: SyncListInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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.page = function page( - params?: - | SyncListListInstancePageOptions - | ((error: Error | null, items: SyncListPage) => any), - callback?: (error: Error | null, items: SyncListPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: SyncListPage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class SyncListPage extends Page< - Sync, - SyncListPayload, - SyncListResource, - SyncListInstance -> { - /** - * Initialize the SyncListPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: SyncListSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of SyncListInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: SyncListResource): SyncListInstance { - return new SyncListInstance( - this._version, - payload, - this._solution.serviceSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/sync/service/syncList/syncListItem.ts b/src/rest/preview/sync/service/syncList/syncListItem.ts deleted file mode 100644 index 2c91e6be62..0000000000 --- a/src/rest/preview/sync/service/syncList/syncListItem.ts +++ /dev/null @@ -1,756 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../../base/Page"; -import Response from "../../../../../http/response"; -import Sync from "../../../Sync"; -const deserialize = require("../../../../../base/deserialize"); -const serialize = require("../../../../../base/serialize"); -import { isValidPathParam } from "../../../../../base/utility"; - -export type SyncListItemQueryFromBoundType = "inclusive" | "exclusive"; - -export type SyncListItemQueryResultOrder = "asc" | "desc"; - -/** - * Options to pass to remove a SyncListItemInstance - */ -export interface SyncListItemContextRemoveOptions { - /** The If-Match HTTP request header */ - ifMatch?: string; -} - -/** - * Options to pass to update a SyncListItemInstance - */ -export interface SyncListItemContextUpdateOptions { - /** */ - data: any; - /** The If-Match HTTP request header */ - ifMatch?: string; -} - -/** - * Options to pass to create a SyncListItemInstance - */ -export interface SyncListItemListInstanceCreateOptions { - /** */ - data: any; -} -/** - * Options to pass to each - */ -export interface SyncListItemListInstanceEachOptions { - /** */ - order?: SyncListItemQueryResultOrder; - /** */ - from?: string; - /** */ - bounds?: SyncListItemQueryFromBoundType; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: (item: 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 { - /** */ - order?: SyncListItemQueryResultOrder; - /** */ - from?: string; - /** */ - bounds?: SyncListItemQueryFromBoundType; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface SyncListItemListInstancePageOptions { - /** */ - order?: SyncListItemQueryResultOrder; - /** */ - from?: string; - /** */ - bounds?: SyncListItemQueryFromBoundType; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface 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; - /** - * 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; - - /** - * Fetch a SyncListItemInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncListItemInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncListItemInstance) => any - ): Promise; - - /** - * 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; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface SyncListItemContextSolution { - serviceSid: string; - listSid: string; - index: number; -} - -export class SyncListItemContextImpl implements SyncListItemContext { - protected _solution: SyncListItemContextSolution; - protected _uri: string; - - constructor( - protected _version: Sync, - serviceSid: string, - listSid: string, - index: number - ) { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(listSid)) { - throw new Error("Parameter 'listSid' is not valid."); - } - - if (!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?: - | SyncListItemContextRemoveOptions - | ((error: Error | null, item?: boolean) => any), - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - const headers: any = {}; - 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; - } - - fetch( - callback?: (error: Error | null, item?: SyncListItemInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - 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; - } - - update( - params: SyncListItemContextUpdateOptions, - callback?: (error: Error | null, item?: SyncListItemInstance) => any - ): Promise { - 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: any = {}; - - data["Data"] = serialize.object(params["data"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - 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; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -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_created: Date; - date_updated: Date; - created_by: string; -} - -export class SyncListItemInstance { - protected _solution: SyncListItemContextSolution; - protected _context?: SyncListItemContext; - - constructor( - protected _version: Sync, - payload: SyncListItemResource, - serviceSid: string, - listSid: string, - index?: number - ) { - 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.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 }; - } - - index: number; - accountSid: string; - serviceSid: string; - listSid: string; - url: string; - revision: string; - data: any; - dateCreated: Date; - dateUpdated: Date; - createdBy: string; - - private get _proxy(): SyncListItemContext { - this._context = - this._context || - new SyncListItemContextImpl( - this._version, - this._solution.serviceSid, - this._solution.listSid, - this._solution.index - ); - return this._context; - } - - /** - * Remove a SyncListItemInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - /** - * 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; - - remove( - params?: any, - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(params, callback); - } - - /** - * Fetch a SyncListItemInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncListItemInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncListItemInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * 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; - - update( - params?: any, - callback?: (error: Error | null, item?: SyncListItemInstance) => any - ): Promise { - return this._proxy.update(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, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - createdBy: this.createdBy, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface SyncListItemSolution { - serviceSid: string; - listSid: string; -} - -export interface SyncListItemListInstance { - _version: Sync; - _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; - - /** - * 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; - /** - * 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; - /** - * 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; - list( - params: SyncListItemListInstanceOptions, - callback?: (error: Error | null, items: SyncListItemInstance[]) => any - ): Promise; - /** - * 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; - page( - params: SyncListItemListInstancePageOptions, - callback?: (error: Error | null, items: SyncListItemPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function SyncListItemListInstance( - version: Sync, - serviceSid: string, - listSid: string -): SyncListItemListInstance { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(listSid)) { - throw new Error("Parameter 'listSid' is not valid."); - } - - const instance = ((index) => instance.get(index)) as SyncListItemListInstance; - - instance.get = function get(index): SyncListItemContext { - 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: SyncListItemListInstanceCreateOptions, - callback?: (error: Error | null, items: SyncListItemInstance) => any - ): Promise { - 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: any = {}; - - data["Data"] = serialize.object(params["data"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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.page = function page( - params?: - | SyncListItemListInstancePageOptions - | ((error: Error | null, items: SyncListItemPage) => any), - callback?: (error: Error | null, items: SyncListItemPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: SyncListItemPage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class SyncListItemPage extends Page< - Sync, - SyncListItemPayload, - SyncListItemResource, - SyncListItemInstance -> { - /** - * Initialize the SyncListItemPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: SyncListItemSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of SyncListItemInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: SyncListItemResource): SyncListItemInstance { - return new SyncListItemInstance( - this._version, - payload, - this._solution.serviceSid, - this._solution.listSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/sync/service/syncList/syncListPermission.ts b/src/rest/preview/sync/service/syncList/syncListPermission.ts deleted file mode 100644 index 556dd378da..0000000000 --- a/src/rest/preview/sync/service/syncList/syncListPermission.ts +++ /dev/null @@ -1,668 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../../base/Page"; -import Response from "../../../../../http/response"; -import Sync from "../../../Sync"; -const deserialize = require("../../../../../base/deserialize"); -const serialize = require("../../../../../base/serialize"); -import { isValidPathParam } from "../../../../../base/utility"; - -/** - * Options to pass to update a SyncListPermissionInstance - */ -export interface SyncListPermissionContextUpdateOptions { - /** Boolean flag specifying whether the identity can read the Sync List. */ - read: boolean; - /** Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. */ - write: boolean; - /** Boolean flag specifying whether the identity can delete the Sync List. */ - 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 1000. */ - 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 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface SyncListPermissionListInstancePageOptions { - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface 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; - - /** - * Fetch a SyncListPermissionInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncListPermissionInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncListPermissionInstance) => any - ): Promise; - - /** - * 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; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface SyncListPermissionContextSolution { - serviceSid: string; - listSid: string; - identity: string; -} - -export class SyncListPermissionContextImpl - implements SyncListPermissionContext -{ - protected _solution: SyncListPermissionContextSolution; - protected _uri: string; - - constructor( - protected _version: Sync, - serviceSid: string, - listSid: string, - identity: string - ) { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(listSid)) { - throw new Error("Parameter 'listSid' is not valid."); - } - - if (!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?: (error: Error | null, item?: boolean) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: SyncListPermissionInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - 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; - } - - update( - params: SyncListPermissionContextUpdateOptions, - callback?: (error: Error | null, item?: SyncListPermissionInstance) => any - ): Promise { - 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: any = {}; - - data["Read"] = serialize.bool(params["read"]); - - data["Write"] = serialize.bool(params["write"]); - - data["Manage"] = serialize.bool(params["manage"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -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 class SyncListPermissionInstance { - protected _solution: SyncListPermissionContextSolution; - protected _context?: SyncListPermissionContext; - - constructor( - protected _version: Sync, - payload: SyncListPermissionResource, - serviceSid: string, - listSid: string, - identity?: string - ) { - 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, - }; - } - - /** - * The unique SID identifier of the Twilio Account. - */ - accountSid: string; - /** - * The unique SID identifier of the Sync Service Instance. - */ - serviceSid: string; - /** - * The unique SID identifier of the Sync List to which the Permission applies. - */ - listSid: string; - /** - * Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - */ - identity: string; - /** - * Boolean flag specifying whether the identity can read the Sync List and its Items. - */ - read: boolean; - /** - * Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - */ - write: boolean; - /** - * Boolean flag specifying whether the identity can delete the Sync List. - */ - manage: boolean; - /** - * Contains an absolute URL for this Sync List Permission. - */ - url: string; - - private get _proxy(): SyncListPermissionContext { - 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?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a SyncListPermissionInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncListPermissionInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncListPermissionInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * 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; - - update( - params?: any, - callback?: (error: Error | null, item?: SyncListPermissionInstance) => any - ): Promise { - return this._proxy.update(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, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface SyncListPermissionSolution { - serviceSid: string; - listSid: string; -} - -export interface SyncListPermissionListInstance { - _version: Sync; - _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; - /** - * 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; - /** - * 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; - list( - params: SyncListPermissionListInstanceOptions, - callback?: (error: Error | null, items: SyncListPermissionInstance[]) => any - ): Promise; - /** - * 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; - page( - params: SyncListPermissionListInstancePageOptions, - callback?: (error: Error | null, items: SyncListPermissionPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function SyncListPermissionListInstance( - version: Sync, - serviceSid: string, - listSid: string -): SyncListPermissionListInstance { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(listSid)) { - throw new Error("Parameter 'listSid' is not valid."); - } - - const instance = ((identity) => - instance.get(identity)) as SyncListPermissionListInstance; - - instance.get = function get(identity): SyncListPermissionContext { - 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?: - | SyncListPermissionListInstancePageOptions - | ((error: Error | null, items: SyncListPermissionPage) => any), - callback?: (error: Error | null, items: SyncListPermissionPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: SyncListPermissionPage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class SyncListPermissionPage extends Page< - Sync, - SyncListPermissionPayload, - SyncListPermissionResource, - SyncListPermissionInstance -> { - /** - * Initialize the SyncListPermissionPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: SyncListPermissionSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of SyncListPermissionInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: SyncListPermissionResource): SyncListPermissionInstance { - return new SyncListPermissionInstance( - this._version, - payload, - this._solution.serviceSid, - this._solution.listSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/sync/service/syncMap.ts b/src/rest/preview/sync/service/syncMap.ts deleted file mode 100644 index e06a62bc93..0000000000 --- a/src/rest/preview/sync/service/syncMap.ts +++ /dev/null @@ -1,620 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../base/Page"; -import Response from "../../../../http/response"; -import Sync from "../../Sync"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; -import { SyncMapItemListInstance } from "./syncMap/syncMapItem"; -import { SyncMapPermissionListInstance } from "./syncMap/syncMapPermission"; - -/** - * Options to pass to create a SyncMapInstance - */ -export interface SyncMapListInstanceCreateOptions { - /** */ - uniqueName?: string; -} -/** - * 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 1000. */ - 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 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface SyncMapListInstancePageOptions { - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface 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; - - /** - * Fetch a SyncMapInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncMapInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncMapInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface SyncMapContextSolution { - serviceSid: string; - sid: string; -} - -export class SyncMapContextImpl implements SyncMapContext { - protected _solution: SyncMapContextSolution; - protected _uri: string; - - protected _syncMapItems?: SyncMapItemListInstance; - protected _syncMapPermissions?: SyncMapPermissionListInstance; - - constructor(protected _version: Sync, serviceSid: string, sid: string) { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { serviceSid, sid }; - this._uri = `/Services/${serviceSid}/Maps/${sid}`; - } - - get syncMapItems(): SyncMapItemListInstance { - this._syncMapItems = - this._syncMapItems || - SyncMapItemListInstance( - this._version, - this._solution.serviceSid, - this._solution.sid - ); - return this._syncMapItems; - } - - get syncMapPermissions(): SyncMapPermissionListInstance { - this._syncMapPermissions = - this._syncMapPermissions || - SyncMapPermissionListInstance( - this._version, - this._solution.serviceSid, - this._solution.sid - ); - return this._syncMapPermissions; - } - - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: SyncMapInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new SyncMapInstance( - operationVersion, - payload, - 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; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface SyncMapPayload extends TwilioResponsePayload { - maps: SyncMapResource[]; -} - -interface SyncMapResource { - sid: string; - unique_name: string; - account_sid: string; - service_sid: string; - url: string; - links: Record; - revision: string; - date_created: Date; - date_updated: Date; - created_by: string; -} - -export class SyncMapInstance { - protected _solution: SyncMapContextSolution; - protected _context?: SyncMapContext; - - constructor( - protected _version: Sync, - payload: SyncMapResource, - serviceSid: string, - sid?: string - ) { - 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.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 }; - } - - sid: string; - uniqueName: string; - accountSid: string; - serviceSid: string; - url: string; - links: Record; - revision: string; - dateCreated: Date; - dateUpdated: Date; - createdBy: string; - - private get _proxy(): SyncMapContext { - 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?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a SyncMapInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncMapInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncMapInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Access the syncMapItems. - */ - syncMapItems(): SyncMapItemListInstance { - return this._proxy.syncMapItems; - } - - /** - * Access the syncMapPermissions. - */ - syncMapPermissions(): SyncMapPermissionListInstance { - 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, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - createdBy: this.createdBy, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface SyncMapSolution { - serviceSid: string; -} - -export interface SyncMapListInstance { - _version: Sync; - _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; - /** - * 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; - - /** - * 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; - /** - * 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; - /** - * 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; - list( - params: SyncMapListInstanceOptions, - callback?: (error: Error | null, items: SyncMapInstance[]) => any - ): Promise; - /** - * 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; - page( - params: SyncMapListInstancePageOptions, - callback?: (error: Error | null, items: SyncMapPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function SyncMapListInstance( - version: Sync, - serviceSid: string -): SyncMapListInstance { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as SyncMapListInstance; - - instance.get = function get(sid): SyncMapContext { - return new SyncMapContextImpl(version, serviceSid, sid); - }; - - instance._version = version; - instance._solution = { serviceSid }; - instance._uri = `/Services/${serviceSid}/Maps`; - - instance.create = function create( - params?: - | SyncMapListInstanceCreateOptions - | ((error: Error | null, items: SyncMapInstance) => any), - callback?: (error: Error | null, items: SyncMapInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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.page = function page( - params?: - | SyncMapListInstancePageOptions - | ((error: Error | null, items: SyncMapPage) => any), - callback?: (error: Error | null, items: SyncMapPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: SyncMapPage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class SyncMapPage extends Page< - Sync, - SyncMapPayload, - SyncMapResource, - SyncMapInstance -> { - /** - * Initialize the SyncMapPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: SyncMapSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of SyncMapInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: SyncMapResource): SyncMapInstance { - return new SyncMapInstance( - this._version, - payload, - this._solution.serviceSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/sync/service/syncMap/syncMapItem.ts b/src/rest/preview/sync/service/syncMap/syncMapItem.ts deleted file mode 100644 index fe03d28a2e..0000000000 --- a/src/rest/preview/sync/service/syncMap/syncMapItem.ts +++ /dev/null @@ -1,764 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../../base/Page"; -import Response from "../../../../../http/response"; -import Sync from "../../../Sync"; -const deserialize = require("../../../../../base/deserialize"); -const serialize = require("../../../../../base/serialize"); -import { isValidPathParam } from "../../../../../base/utility"; - -export type SyncMapItemQueryFromBoundType = "inclusive" | "exclusive"; - -export type SyncMapItemQueryResultOrder = "asc" | "desc"; - -/** - * Options to pass to remove a SyncMapItemInstance - */ -export interface SyncMapItemContextRemoveOptions { - /** The If-Match HTTP request header */ - ifMatch?: string; -} - -/** - * Options to pass to update a SyncMapItemInstance - */ -export interface SyncMapItemContextUpdateOptions { - /** */ - data: any; - /** The If-Match HTTP request header */ - ifMatch?: string; -} - -/** - * Options to pass to create a SyncMapItemInstance - */ -export interface SyncMapItemListInstanceCreateOptions { - /** */ - key: string; - /** */ - data: any; -} -/** - * Options to pass to each - */ -export interface SyncMapItemListInstanceEachOptions { - /** */ - order?: SyncMapItemQueryResultOrder; - /** */ - from?: string; - /** */ - bounds?: SyncMapItemQueryFromBoundType; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: (item: 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 { - /** */ - order?: SyncMapItemQueryResultOrder; - /** */ - from?: string; - /** */ - bounds?: SyncMapItemQueryFromBoundType; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface SyncMapItemListInstancePageOptions { - /** */ - order?: SyncMapItemQueryResultOrder; - /** */ - from?: string; - /** */ - bounds?: SyncMapItemQueryFromBoundType; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface 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; - /** - * 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; - - /** - * Fetch a SyncMapItemInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncMapItemInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncMapItemInstance) => any - ): Promise; - - /** - * 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; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface SyncMapItemContextSolution { - serviceSid: string; - mapSid: string; - key: string; -} - -export class SyncMapItemContextImpl implements SyncMapItemContext { - protected _solution: SyncMapItemContextSolution; - protected _uri: string; - - constructor( - protected _version: Sync, - serviceSid: string, - mapSid: string, - key: string - ) { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(mapSid)) { - throw new Error("Parameter 'mapSid' is not valid."); - } - - if (!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?: - | SyncMapItemContextRemoveOptions - | ((error: Error | null, item?: boolean) => any), - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - const headers: any = {}; - 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; - } - - fetch( - callback?: (error: Error | null, item?: SyncMapItemInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - 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; - } - - update( - params: SyncMapItemContextUpdateOptions, - callback?: (error: Error | null, item?: SyncMapItemInstance) => any - ): Promise { - 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: any = {}; - - data["Data"] = serialize.object(params["data"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - 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; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -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_created: Date; - date_updated: Date; - created_by: string; -} - -export class SyncMapItemInstance { - protected _solution: SyncMapItemContextSolution; - protected _context?: SyncMapItemContext; - - constructor( - protected _version: Sync, - payload: SyncMapItemResource, - serviceSid: string, - mapSid: string, - key?: string - ) { - 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.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 }; - } - - key: string; - accountSid: string; - serviceSid: string; - mapSid: string; - url: string; - revision: string; - data: any; - dateCreated: Date; - dateUpdated: Date; - createdBy: string; - - private get _proxy(): SyncMapItemContext { - this._context = - this._context || - new SyncMapItemContextImpl( - this._version, - this._solution.serviceSid, - this._solution.mapSid, - this._solution.key - ); - return this._context; - } - - /** - * Remove a SyncMapItemInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - /** - * 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; - - remove( - params?: any, - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(params, callback); - } - - /** - * Fetch a SyncMapItemInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncMapItemInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncMapItemInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * 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; - - update( - params?: any, - callback?: (error: Error | null, item?: SyncMapItemInstance) => any - ): Promise { - return this._proxy.update(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, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - createdBy: this.createdBy, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface SyncMapItemSolution { - serviceSid: string; - mapSid: string; -} - -export interface SyncMapItemListInstance { - _version: Sync; - _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; - - /** - * 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; - /** - * 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; - /** - * 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; - list( - params: SyncMapItemListInstanceOptions, - callback?: (error: Error | null, items: SyncMapItemInstance[]) => any - ): Promise; - /** - * 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; - page( - params: SyncMapItemListInstancePageOptions, - callback?: (error: Error | null, items: SyncMapItemPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function SyncMapItemListInstance( - version: Sync, - serviceSid: string, - mapSid: string -): SyncMapItemListInstance { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(mapSid)) { - throw new Error("Parameter 'mapSid' is not valid."); - } - - const instance = ((key) => instance.get(key)) as SyncMapItemListInstance; - - instance.get = function get(key): SyncMapItemContext { - 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: SyncMapItemListInstanceCreateOptions, - callback?: (error: Error | null, items: SyncMapItemInstance) => any - ): Promise { - 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: any = {}; - - data["Key"] = params["key"]; - - data["Data"] = serialize.object(params["data"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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.page = function page( - params?: - | SyncMapItemListInstancePageOptions - | ((error: Error | null, items: SyncMapItemPage) => any), - callback?: (error: Error | null, items: SyncMapItemPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: SyncMapItemPage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class SyncMapItemPage extends Page< - Sync, - SyncMapItemPayload, - SyncMapItemResource, - SyncMapItemInstance -> { - /** - * Initialize the SyncMapItemPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: SyncMapItemSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of SyncMapItemInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: SyncMapItemResource): SyncMapItemInstance { - return new SyncMapItemInstance( - this._version, - payload, - this._solution.serviceSid, - this._solution.mapSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/sync/service/syncMap/syncMapPermission.ts b/src/rest/preview/sync/service/syncMap/syncMapPermission.ts deleted file mode 100644 index e2df61e773..0000000000 --- a/src/rest/preview/sync/service/syncMap/syncMapPermission.ts +++ /dev/null @@ -1,662 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../../../base/Page"; -import Response from "../../../../../http/response"; -import Sync from "../../../Sync"; -const deserialize = require("../../../../../base/deserialize"); -const serialize = require("../../../../../base/serialize"); -import { isValidPathParam } from "../../../../../base/utility"; - -/** - * Options to pass to update a SyncMapPermissionInstance - */ -export interface SyncMapPermissionContextUpdateOptions { - /** Boolean flag specifying whether the identity can read the Sync Map. */ - read: boolean; - /** Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. */ - write: boolean; - /** Boolean flag specifying whether the identity can delete the Sync Map. */ - 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 1000. */ - 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 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface SyncMapPermissionListInstancePageOptions { - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface 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; - - /** - * Fetch a SyncMapPermissionInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncMapPermissionInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any - ): Promise; - - /** - * 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; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface SyncMapPermissionContextSolution { - serviceSid: string; - mapSid: string; - identity: string; -} - -export class SyncMapPermissionContextImpl implements SyncMapPermissionContext { - protected _solution: SyncMapPermissionContextSolution; - protected _uri: string; - - constructor( - protected _version: Sync, - serviceSid: string, - mapSid: string, - identity: string - ) { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(mapSid)) { - throw new Error("Parameter 'mapSid' is not valid."); - } - - if (!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?: (error: Error | null, item?: boolean) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - 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; - } - - update( - params: SyncMapPermissionContextUpdateOptions, - callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any - ): Promise { - 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: any = {}; - - data["Read"] = serialize.bool(params["read"]); - - data["Write"] = serialize.bool(params["write"]); - - data["Manage"] = serialize.bool(params["manage"]); - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - 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; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -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 class SyncMapPermissionInstance { - protected _solution: SyncMapPermissionContextSolution; - protected _context?: SyncMapPermissionContext; - - constructor( - protected _version: Sync, - payload: SyncMapPermissionResource, - serviceSid: string, - mapSid: string, - identity?: string - ) { - 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, - }; - } - - /** - * The unique SID identifier of the Twilio Account. - */ - accountSid: string; - /** - * The unique SID identifier of the Sync Service Instance. - */ - serviceSid: string; - /** - * The unique SID identifier of the Sync Map to which the Permission applies. - */ - mapSid: string; - /** - * Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - */ - identity: string; - /** - * Boolean flag specifying whether the identity can read the Sync Map and its Items. - */ - read: boolean; - /** - * Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - */ - write: boolean; - /** - * Boolean flag specifying whether the identity can delete the Sync Map. - */ - manage: boolean; - /** - * Contains an absolute URL for this Sync Map Permission. - */ - url: string; - - private get _proxy(): SyncMapPermissionContext { - 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?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a SyncMapPermissionInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed SyncMapPermissionInstance - */ - fetch( - callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * 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; - - update( - params?: any, - callback?: (error: Error | null, item?: SyncMapPermissionInstance) => any - ): Promise { - return this._proxy.update(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, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface SyncMapPermissionSolution { - serviceSid: string; - mapSid: string; -} - -export interface SyncMapPermissionListInstance { - _version: Sync; - _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; - /** - * 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; - /** - * 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; - list( - params: SyncMapPermissionListInstanceOptions, - callback?: (error: Error | null, items: SyncMapPermissionInstance[]) => any - ): Promise; - /** - * 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; - page( - params: SyncMapPermissionListInstancePageOptions, - callback?: (error: Error | null, items: SyncMapPermissionPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function SyncMapPermissionListInstance( - version: Sync, - serviceSid: string, - mapSid: string -): SyncMapPermissionListInstance { - if (!isValidPathParam(serviceSid)) { - throw new Error("Parameter 'serviceSid' is not valid."); - } - - if (!isValidPathParam(mapSid)) { - throw new Error("Parameter 'mapSid' is not valid."); - } - - const instance = ((identity) => - instance.get(identity)) as SyncMapPermissionListInstance; - - instance.get = function get(identity): SyncMapPermissionContext { - 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?: - | SyncMapPermissionListInstancePageOptions - | ((error: Error | null, items: SyncMapPermissionPage) => any), - callback?: (error: Error | null, items: SyncMapPermissionPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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: any = {}; - - 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: string, - callback?: (error: Error | null, items: SyncMapPermissionPage) => any - ): Promise { - 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.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class SyncMapPermissionPage extends Page< - Sync, - SyncMapPermissionPayload, - SyncMapPermissionResource, - SyncMapPermissionInstance -> { - /** - * Initialize the SyncMapPermissionPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: Sync, - response: Response, - solution: SyncMapPermissionSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of SyncMapPermissionInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: SyncMapPermissionResource): SyncMapPermissionInstance { - return new SyncMapPermissionInstance( - this._version, - payload, - this._solution.serviceSid, - this._solution.mapSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -}