UNPKG

twilio

Version:
160 lines (159 loc) 5.97 kB
"use strict"; /* * This code was generated by * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ * * Twilio Memory API * APIs for managing memory stores, profiles, events, and conversational intelligence capabilities. * * 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.EventInstance = exports.ProfileEventRequestEvents = exports.ProfileEventRequest = exports.CommunicationLifecycleEventSender = exports.CommunicationLifecycleEventRecipient = void 0; exports.EventListInstance = EventListInstance; const util_1 = require("util"); const deserialize = require("../../../base/deserialize"); const serialize = require("../../../base/serialize"); const utility_1 = require("../../../base/utility"); class CommunicationLifecycleEventRecipient { constructor(payload) { this.address = payload["address"]; this.participantId = payload["participantId"]; } } exports.CommunicationLifecycleEventRecipient = CommunicationLifecycleEventRecipient; class CommunicationLifecycleEventSender { constructor(payload) { this.address = payload["address"]; this.participantId = payload["participantId"]; } } exports.CommunicationLifecycleEventSender = CommunicationLifecycleEventSender; /** * Request body for adding events to a specific profile. This request can contain multiple events. */ class ProfileEventRequest { constructor(payload) { this.type = payload["type"]; this.events = payload["events"]; } } exports.ProfileEventRequest = ProfileEventRequest; class ProfileEventRequestEvents { constructor(payload) { this.timestamp = payload["timestamp"]; this.lifecycle = payload["lifecycle"]; this.conversationId = payload["conversationId"]; this.communicationId = payload["communicationId"]; this.communicationType = payload["communicationType"]; this.communicationStatus = payload["communicationStatus"]; this.direction = payload["direction"]; this.sender = payload["sender"]; this.recipient = payload["recipient"]; this.errorCode = payload["errorCode"]; this.errorMessage = payload["errorMessage"]; } } exports.ProfileEventRequestEvents = ProfileEventRequestEvents; function EventListInstance(version, storeId, profileId) { if (!(0, utility_1.isValidPathParam)(storeId)) { throw new Error("Parameter 'storeId' is not valid."); } if (!(0, utility_1.isValidPathParam)(profileId)) { throw new Error("Parameter 'profileId' is not valid."); } const instance = {}; instance._version = version; instance._solution = { storeId, profileId }; instance._uri = `/Stores/${storeId}/Profiles/${profileId}/Events`; instance.create = function create(params, headers, callback) { if (params instanceof Function) { callback = params; params = {}; } else { params = params || {}; } let data = {}; data = params; if (headers === null || headers === undefined) { headers = {}; } headers["Content-Type"] = "application/json"; headers["Accept"] = "application/json"; let operationVersion = version, operationPromise = operationVersion.create({ uri: instance._uri, method: "post", data, headers, }); operationPromise = operationPromise.then((payload) => new EventInstance(operationVersion, payload, instance._solution.storeId, instance._solution.profileId)); operationPromise = instance._version.setPromiseCallback(operationPromise, callback); return operationPromise; }; instance.createWithHttpInfo = function createWithHttpInfo(params, headers, callback) { if (params instanceof Function) { callback = params; params = {}; } else { params = params || {}; } let data = {}; data = params; if (headers === null || headers === undefined) { headers = {}; } headers["Content-Type"] = "application/json"; headers["Accept"] = "application/json"; let operationVersion = version; // CREATE, FETCH, UPDATE operations let operationPromise = operationVersion .createWithResponseInfo({ uri: instance._uri, method: "post", data, headers, }) .then((response) => ({ ...response, body: new EventInstance(operationVersion, response.body, instance._solution.storeId, instance._solution.profileId), })); operationPromise = instance._version.setPromiseCallback(operationPromise, callback); return operationPromise; }; instance.toJSON = function toJSON() { return instance._solution; }; instance[util_1.inspect.custom] = function inspectImpl(_depth, options) { return (0, util_1.inspect)(instance.toJSON(), options); }; return instance; } class EventInstance { constructor(_version, _payload, storeId, profileId) { this._version = _version; const payload = _payload; this.message = payload.message; } /** * Provide a user-friendly representation * * @returns Object */ toJSON() { return { message: this.message, }; } [util_1.inspect.custom](_depth, options) { return (0, util_1.inspect)(this.toJSON(), options); } } exports.EventInstance = EventInstance;