UNPKG

twilio

Version:
171 lines (170 loc) 6.07 kB
"use strict"; /* * This code was generated by * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ * * Conversation Orchestrator * Manage configurations, conversations, participants, and communications. Create configurations to define capture rules and channel settings, then use conversations to group related communications. * * NOTE: This class is auto generated by OpenAPI Generator. * https://openapi-generator.tech * Do not edit the class manually. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.OperationInstance = exports.OperationContextImpl = exports.FetchOperationStatus200ResponseError = void 0; exports.OperationListInstance = OperationListInstance; const util_1 = require("util"); const deserialize = require("../../../base/deserialize"); const serialize = require("../../../base/serialize"); const utility_1 = require("../../../base/utility"); /** * Error details if the operation failed. Follows RFC 9457 Problem Details. */ class FetchOperationStatus200ResponseError { constructor(payload) { this.type = payload["type"]; this.title = payload["title"]; this.status = payload["status"]; this.detail = payload["detail"]; this.instance = payload["instance"]; } } exports.FetchOperationStatus200ResponseError = FetchOperationStatus200ResponseError; class OperationContextImpl { constructor(_version, sid) { this._version = _version; if (!(0, utility_1.isValidPathParam)(sid)) { throw new Error("Parameter 'sid' is not valid."); } this._solution = { sid }; this._uri = `/ControlPlane/Operations/${sid}`; } fetch(callback) { const headers = {}; headers["Accept"] = "application/json"; const instance = this; let operationVersion = instance._version, operationPromise = operationVersion.fetch({ uri: instance._uri, method: "get", headers, }); operationPromise = operationPromise.then((payload) => new OperationInstance(operationVersion, payload, instance._solution.sid)); operationPromise = instance._version.setPromiseCallback(operationPromise, callback); return operationPromise; } fetchWithHttpInfo(callback) { const headers = {}; headers["Accept"] = "application/json"; const instance = this; let operationVersion = instance._version; // CREATE, FETCH, UPDATE operations let operationPromise = operationVersion .fetchWithResponseInfo({ uri: instance._uri, method: "get", headers, }) .then((response) => ({ ...response, body: new OperationInstance(operationVersion, response.body, instance._solution.sid), })); operationPromise = instance._version.setPromiseCallback(operationPromise, callback); return operationPromise; } /** * Provide a user-friendly representation * * @returns Object */ toJSON() { return this._solution; } [util_1.inspect.custom](_depth, options) { return (0, util_1.inspect)(this.toJSON(), options); } } exports.OperationContextImpl = OperationContextImpl; /** * Status of a long-running operation. */ class OperationInstance { constructor(_version, _payload, sid) { this._version = _version; const payload = _payload; this.operationId = payload.operationId; this.status = payload.status; this.createdAt = deserialize.iso8601DateTime(payload.createdAt); this.completedAt = deserialize.iso8601DateTime(payload.completedAt); this.statusUrl = payload.statusUrl; this.error = payload.error !== null && payload.error !== undefined ? new FetchOperationStatus200ResponseError(payload.error) : null; this.related = payload.related; this._solution = { sid: sid }; } get _proxy() { this._context = this._context || new OperationContextImpl(this._version, this._solution.sid); return this._context; } /** * Fetch a OperationInstance * * @param callback - Callback to handle processed record * * @returns Resolves to processed OperationInstance */ fetch(callback) { return this._proxy.fetch(callback); } /** * Fetch a OperationInstance and return HTTP info * * @param callback - Callback to handle processed record * * @returns Resolves to processed OperationInstance with HTTP metadata */ fetchWithHttpInfo(callback) { return this._proxy.fetchWithHttpInfo(callback); } /** * Provide a user-friendly representation * * @returns Object */ toJSON() { return { operationId: this.operationId, status: this.status, createdAt: this.createdAt, completedAt: this.completedAt, statusUrl: this.statusUrl, error: this.error, related: this.related, }; } [util_1.inspect.custom](_depth, options) { return (0, util_1.inspect)(this.toJSON(), options); } } exports.OperationInstance = OperationInstance; function OperationListInstance(version) { const instance = ((sid) => instance.get(sid)); instance.get = function get(sid) { return new OperationContextImpl(version, sid); }; instance._version = version; instance._solution = {}; instance._uri = ``; instance.toJSON = function toJSON() { return instance._solution; }; instance[util_1.inspect.custom] = function inspectImpl(_depth, options) { return (0, util_1.inspect)(instance.toJSON(), options); }; return instance; }