box-node-sdk
Version:
Official SDK for Box Platform APIs
96 lines • 3.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeQueryInsightEntryV2026R0TypeField = serializeQueryInsightEntryV2026R0TypeField;
exports.deserializeQueryInsightEntryV2026R0TypeField = deserializeQueryInsightEntryV2026R0TypeField;
exports.serializeQueryInsightEntryV2026R0 = serializeQueryInsightEntryV2026R0;
exports.deserializeQueryInsightEntryV2026R0 = deserializeQueryInsightEntryV2026R0;
const queryInsightMetricResultV2026R0_1 = require("./queryInsightMetricResultV2026R0.js");
const queryInsightMetricResultV2026R0_2 = require("./queryInsightMetricResultV2026R0.js");
const errors_1 = require("../../box/errors.js");
const json_1 = require("../../serialization/json.js");
const json_2 = require("../../serialization/json.js");
const json_3 = require("../../serialization/json.js");
function serializeQueryInsightEntryV2026R0TypeField(val) {
return val;
}
function deserializeQueryInsightEntryV2026R0TypeField(val) {
if (val == 'group') {
return val;
}
if (val == 'overall') {
return val;
}
if (val == 'other') {
return val;
}
throw new errors_1.BoxSdkError({
message: "Can't deserialize QueryInsightEntryV2026R0TypeField",
});
}
function serializeQueryInsightEntryV2026R0(val) {
return {
['key']: val.key.map(function (item) {
return item;
}),
['type']: serializeQueryInsightEntryV2026R0TypeField(val.type),
['metrics']: Object.fromEntries(Object.entries(val.metrics).map(([k, v]) => [
k,
(0, queryInsightMetricResultV2026R0_1.serializeQueryInsightMetricResultV2026R0)(v),
])),
};
}
function deserializeQueryInsightEntryV2026R0(val) {
if (!(0, json_3.sdIsMap)(val)) {
throw new errors_1.BoxSdkError({
message: 'Expecting a map for "QueryInsightEntryV2026R0"',
});
}
if (val.key == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "key" of type "QueryInsightEntryV2026R0" to be defined',
});
}
if (!(0, json_2.sdIsList)(val.key)) {
throw new errors_1.BoxSdkError({
message: 'Expecting array for "key" of type "QueryInsightEntryV2026R0"',
});
}
const key = (0, json_2.sdIsList)(val.key)
? val.key.map(function (itm) {
if (!(0, json_1.sdIsString)(itm)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "QueryInsightEntryV2026R0"',
});
}
return itm;
})
: [];
if (val.type == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "type" of type "QueryInsightEntryV2026R0" to be defined',
});
}
const type = deserializeQueryInsightEntryV2026R0TypeField(val.type);
if (val.metrics == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "metrics" of type "QueryInsightEntryV2026R0" to be defined',
});
}
if (!(0, json_3.sdIsMap)(val.metrics)) {
throw new errors_1.BoxSdkError({
message: 'Expecting object for "metrics" of type "QueryInsightEntryV2026R0"',
});
}
const metrics = (0, json_3.sdIsMap)(val.metrics)
? Object.fromEntries(Object.entries(val.metrics).map(([k, v]) => [
k,
(0, queryInsightMetricResultV2026R0_2.deserializeQueryInsightMetricResultV2026R0)(v),
]))
: {};
return {
key: key,
type: type,
metrics: metrics,
};
}
//# sourceMappingURL=queryInsightEntryV2026R0.js.map