box-node-sdk
Version:
Official SDK for Box Platform APIs
90 lines • 3.04 kB
JavaScript
import { serializeQueryInsightMetricResultV2026R0 } from './queryInsightMetricResultV2026R0.js';
import { deserializeQueryInsightMetricResultV2026R0 } from './queryInsightMetricResultV2026R0.js';
import { BoxSdkError } from '../../box/errors.js';
import { sdIsString } from '../../serialization/json.js';
import { sdIsList } from '../../serialization/json.js';
import { sdIsMap } from '../../serialization/json.js';
export function serializeQueryInsightEntryV2026R0TypeField(val) {
return val;
}
export function deserializeQueryInsightEntryV2026R0TypeField(val) {
if (val == 'group') {
return val;
}
if (val == 'overall') {
return val;
}
if (val == 'other') {
return val;
}
throw new BoxSdkError({
message: "Can't deserialize QueryInsightEntryV2026R0TypeField",
});
}
export 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,
serializeQueryInsightMetricResultV2026R0(v),
])),
};
}
export function deserializeQueryInsightEntryV2026R0(val) {
if (!sdIsMap(val)) {
throw new BoxSdkError({
message: 'Expecting a map for "QueryInsightEntryV2026R0"',
});
}
if (val.key == void 0) {
throw new BoxSdkError({
message: 'Expecting "key" of type "QueryInsightEntryV2026R0" to be defined',
});
}
if (!sdIsList(val.key)) {
throw new BoxSdkError({
message: 'Expecting array for "key" of type "QueryInsightEntryV2026R0"',
});
}
const key = sdIsList(val.key)
? val.key.map(function (itm) {
if (!sdIsString(itm)) {
throw new BoxSdkError({
message: 'Expecting string for "QueryInsightEntryV2026R0"',
});
}
return itm;
})
: [];
if (val.type == void 0) {
throw new BoxSdkError({
message: 'Expecting "type" of type "QueryInsightEntryV2026R0" to be defined',
});
}
const type = deserializeQueryInsightEntryV2026R0TypeField(val.type);
if (val.metrics == void 0) {
throw new BoxSdkError({
message: 'Expecting "metrics" of type "QueryInsightEntryV2026R0" to be defined',
});
}
if (!sdIsMap(val.metrics)) {
throw new BoxSdkError({
message: 'Expecting object for "metrics" of type "QueryInsightEntryV2026R0"',
});
}
const metrics = sdIsMap(val.metrics)
? Object.fromEntries(Object.entries(val.metrics).map(([k, v]) => [
k,
deserializeQueryInsightMetricResultV2026R0(v),
]))
: {};
return {
key: key,
type: type,
metrics: metrics,
};
}
//# sourceMappingURL=queryInsightEntryV2026R0.js.map