twilio
Version:
A Twilio helper library
230 lines (229 loc) • 8.96 kB
JavaScript
"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.IdentityResolutionSettingInstance = exports.IdentityResolutionSettingContextImpl = exports.IdentityResolutionSettingsCore = exports.IdentifierConfig = void 0;
exports.IdentityResolutionSettingListInstance = IdentityResolutionSettingListInstance;
const util_1 = require("util");
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
const utility_1 = require("../../../base/utility");
class IdentifierConfig {
constructor(payload) {
this.idType = payload["idType"];
this.matchingAlgo = payload["matchingAlgo"];
this.matchingThreshold = payload["matchingThreshold"];
this.limit = payload["limit"];
this.limitPolicy = payload["limitPolicy"];
this.enforceUnique = payload["enforceUnique"];
this.normalization = payload["normalization"];
}
}
exports.IdentifierConfig = IdentifierConfig;
/**
* Identity Resolution settings help determine if a new profile should be created, or if the incoming conversation should be added to an existing profile. These settings resolve how profiles are looked up and which profiles should merge together.
*/
class IdentityResolutionSettingsCore {
constructor(payload) {
this.identifierConfigs = payload["identifierConfigs"];
this.matchingRules = payload["matchingRules"];
}
}
exports.IdentityResolutionSettingsCore = IdentityResolutionSettingsCore;
class IdentityResolutionSettingContextImpl {
constructor(_version, storeId) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(storeId)) {
throw new Error("Parameter 'storeId' is not valid.");
}
this._solution = { storeId };
this._uri = `/ControlPlane/Stores/${storeId}/IdentityResolutionSettings`;
}
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 IdentityResolutionSettingInstance(operationVersion, payload, instance._solution.storeId));
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 IdentityResolutionSettingInstance(operationVersion, response.body, instance._solution.storeId),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "put",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new IdentityResolutionSettingInstance(operationVersion, payload, instance._solution.storeId));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "put",
data,
headers,
})
.then((response) => ({
...response,
body: new IdentityResolutionSettingInstance(operationVersion, response.body, instance._solution.storeId),
}));
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.IdentityResolutionSettingContextImpl = IdentityResolutionSettingContextImpl;
class IdentityResolutionSettingInstance {
constructor(_version, _payload, storeId) {
this._version = _version;
const payload = _payload;
this.identifierConfigs =
payload.identifierConfigs !== null &&
payload.identifierConfigs !== undefined
? payload.identifierConfigs.map((payload) => new IdentifierConfig(payload))
: null;
this.matchingRules = payload.matchingRules;
this.version = deserialize.integer(payload.version);
this.message = payload.message;
this.statusUrl = payload.statusUrl;
this._solution = { storeId: storeId };
}
get _proxy() {
this._context =
this._context ||
new IdentityResolutionSettingContextImpl(this._version, this._solution.storeId);
return this._context;
}
/**
* Fetch a IdentityResolutionSettingInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed IdentityResolutionSettingInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a IdentityResolutionSettingInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed IdentityResolutionSettingInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
identifierConfigs: this.identifierConfigs,
matchingRules: this.matchingRules,
version: this.version,
message: this.message,
statusUrl: this.statusUrl,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.IdentityResolutionSettingInstance = IdentityResolutionSettingInstance;
function IdentityResolutionSettingListInstance(version) {
const instance = ((storeId) => instance.get(storeId));
instance.get = function get(storeId) {
return new IdentityResolutionSettingContextImpl(version, storeId);
};
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;
}