UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

139 lines 5.41 kB
import { serializeQueryAncestorReferenceV2026R0 } from './queryAncestorReferenceV2026R0.js'; import { deserializeQueryAncestorReferenceV2026R0 } from './queryAncestorReferenceV2026R0.js'; import { serializeQueryInsightsGroupByV2026R0 } from './queryInsightsGroupByV2026R0.js'; import { deserializeQueryInsightsGroupByV2026R0 } from './queryInsightsGroupByV2026R0.js'; import { serializeQueryInsightsMetricDefinitionV2026R0 } from './queryInsightsMetricDefinitionV2026R0.js'; import { deserializeQueryInsightsMetricDefinitionV2026R0 } from './queryInsightsMetricDefinitionV2026R0.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 serializeQueryInsightsRequestBodyV2026R0QueryField(val) { return { ['predicate']: val.predicate, ['params']: val.params == void 0 ? val.params : Object.fromEntries(Object.entries(val.params).map(([k, v]) => [ k, (function (v) { return v; })(v), ])), ['ancestors']: val.ancestors == void 0 ? val.ancestors : val.ancestors.map(function (item) { return serializeQueryAncestorReferenceV2026R0(item); }), ['group_by']: val.groupBy == void 0 ? val.groupBy : val.groupBy.map(function (item) { return serializeQueryInsightsGroupByV2026R0(item); }), }; } export function deserializeQueryInsightsRequestBodyV2026R0QueryField(val) { if (!sdIsMap(val)) { throw new BoxSdkError({ message: 'Expecting a map for "QueryInsightsRequestBodyV2026R0QueryField"', }); } if (val.predicate == void 0) { throw new BoxSdkError({ message: 'Expecting "predicate" of type "QueryInsightsRequestBodyV2026R0QueryField" to be defined', }); } if (!sdIsString(val.predicate)) { throw new BoxSdkError({ message: 'Expecting string for "predicate" of type "QueryInsightsRequestBodyV2026R0QueryField"', }); } const predicate = val.predicate; if (!(val.params == void 0) && !sdIsMap(val.params)) { throw new BoxSdkError({ message: 'Expecting object for "params" of type "QueryInsightsRequestBodyV2026R0QueryField"', }); } const params = val.params == void 0 ? void 0 : sdIsMap(val.params) ? Object.fromEntries(Object.entries(val.params).map(([k, v]) => [ k, (function (v) { return v; })(v), ])) : {}; if (!(val.ancestors == void 0) && !sdIsList(val.ancestors)) { throw new BoxSdkError({ message: 'Expecting array for "ancestors" of type "QueryInsightsRequestBodyV2026R0QueryField"', }); } const ancestors = val.ancestors == void 0 ? void 0 : sdIsList(val.ancestors) ? val.ancestors.map(function (itm) { return deserializeQueryAncestorReferenceV2026R0(itm); }) : []; if (!(val.group_by == void 0) && !sdIsList(val.group_by)) { throw new BoxSdkError({ message: 'Expecting array for "group_by" of type "QueryInsightsRequestBodyV2026R0QueryField"', }); } const groupBy = val.group_by == void 0 ? void 0 : sdIsList(val.group_by) ? val.group_by.map(function (itm) { return deserializeQueryInsightsGroupByV2026R0(itm); }) : []; return { predicate: predicate, params: params, ancestors: ancestors, groupBy: groupBy, }; } export function serializeQueryInsightsRequestBodyV2026R0(val) { return { ['query']: serializeQueryInsightsRequestBodyV2026R0QueryField(val.query), ['metrics']: Object.fromEntries(Object.entries(val.metrics).map(([k, v]) => [ k, serializeQueryInsightsMetricDefinitionV2026R0(v), ])), }; } export function deserializeQueryInsightsRequestBodyV2026R0(val) { if (!sdIsMap(val)) { throw new BoxSdkError({ message: 'Expecting a map for "QueryInsightsRequestBodyV2026R0"', }); } if (val.query == void 0) { throw new BoxSdkError({ message: 'Expecting "query" of type "QueryInsightsRequestBodyV2026R0" to be defined', }); } const query = deserializeQueryInsightsRequestBodyV2026R0QueryField(val.query); if (val.metrics == void 0) { throw new BoxSdkError({ message: 'Expecting "metrics" of type "QueryInsightsRequestBodyV2026R0" to be defined', }); } if (!sdIsMap(val.metrics)) { throw new BoxSdkError({ message: 'Expecting object for "metrics" of type "QueryInsightsRequestBodyV2026R0"', }); } const metrics = sdIsMap(val.metrics) ? Object.fromEntries(Object.entries(val.metrics).map(([k, v]) => [ k, deserializeQueryInsightsMetricDefinitionV2026R0(v), ])) : {}; return { query: query, metrics: metrics, }; } //# sourceMappingURL=queryInsightsRequestBodyV2026R0.js.map