twilio
Version:
A Twilio helper library
215 lines (214 loc) • 8.06 kB
JavaScript
;
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Insights
* Insights Domain V3 API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryInstance = exports.QueryDefinitionOrderBy = exports.QueryDefinitionFiltersExpressions = exports.QueryDefinitionFilters = exports.QueryDefinition = exports.PaginationMeta = exports.InsightsQueryRequest = void 0;
exports.QueryListInstance = QueryListInstance;
const util_1 = require("util");
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
class InsightsQueryRequest {
constructor(payload) {
this.domain = payload["domain"];
this.query = payload["query"];
}
}
exports.InsightsQueryRequest = InsightsQueryRequest;
/**
* Pagination metadata containing navigation tokens and result information, this schema should according to convention be added to the response payload\'s \'meta\' attribute
*/
class PaginationMeta {
constructor(payload) {
this.key = payload["key"];
this.pageSize = payload["pageSize"];
this.previousToken = payload["previousToken"];
this.nextToken = payload["nextToken"];
}
}
exports.PaginationMeta = PaginationMeta;
/**
* Structured query definition that specifies what data to retrieve and how to filter, group, and order it
*/
class QueryDefinition {
constructor(payload) {
this.measures = payload["measures"];
this.dimensions = payload["dimensions"];
this.filters = payload["filters"];
this.orderBy = payload["orderBy"];
}
}
exports.QueryDefinition = QueryDefinition;
class QueryDefinitionFilters {
constructor(payload) {
this.op = payload["op"];
this.expressions = payload["expressions"];
}
}
exports.QueryDefinitionFilters = QueryDefinitionFilters;
class QueryDefinitionFiltersExpressions {
constructor(payload) {
this.op = payload["op"];
this.field = payload["field"];
this.values = payload["values"];
}
}
exports.QueryDefinitionFiltersExpressions = QueryDefinitionFiltersExpressions;
class QueryDefinitionOrderBy {
constructor(payload) {
this.field = payload["field"];
this.direction = payload["direction"];
}
}
exports.QueryDefinitionOrderBy = QueryDefinitionOrderBy;
function QueryListInstance(version) {
const instance = {};
instance._version = version;
instance._solution = {};
instance._uri = `/InsightsDomains/Conversations/Query`;
instance.create = function create(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
if (params["pageSize"] !== undefined)
data["pageSize"] = params["pageSize"];
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 QueryInstance(operationVersion, payload));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
if (params["pageSize"] !== undefined)
data["pageSize"] = params["pageSize"];
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 QueryInstance(operationVersion, response.body),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.fetch = function fetch(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["pageToken"] === null || params["pageToken"] === undefined) {
throw new Error("Required parameter \"params['pageToken']\" missing.");
}
let data = {};
data["pageToken"] = params["pageToken"];
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new QueryInstance(operationVersion, payload));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.fetchWithHttpInfo = function fetchWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["pageToken"] === null || params["pageToken"] === undefined) {
throw new Error("Required parameter \"params['pageToken']\" missing.");
}
let data = {};
data["pageToken"] = params["pageToken"];
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
params: data,
headers,
})
.then((response) => ({
...response,
body: new QueryInstance(operationVersion, response.body),
}));
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 QueryInstance {
constructor(_version, _payload) {
this._version = _version;
const payload = _payload;
this.domain = payload.domain;
this.items = payload.items;
this.meta =
payload.meta !== null && payload.meta !== undefined
? new PaginationMeta(payload.meta)
: null;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
domain: this.domain,
items: this.items,
meta: this.meta,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.QueryInstance = QueryInstance;