UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

145 lines 6.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.serializeQueryInsightsRequestBodyV2026R0QueryField = serializeQueryInsightsRequestBodyV2026R0QueryField; exports.deserializeQueryInsightsRequestBodyV2026R0QueryField = deserializeQueryInsightsRequestBodyV2026R0QueryField; exports.serializeQueryInsightsRequestBodyV2026R0 = serializeQueryInsightsRequestBodyV2026R0; exports.deserializeQueryInsightsRequestBodyV2026R0 = deserializeQueryInsightsRequestBodyV2026R0; const queryAncestorReferenceV2026R0_1 = require("./queryAncestorReferenceV2026R0.js"); const queryAncestorReferenceV2026R0_2 = require("./queryAncestorReferenceV2026R0.js"); const queryInsightsGroupByV2026R0_1 = require("./queryInsightsGroupByV2026R0.js"); const queryInsightsGroupByV2026R0_2 = require("./queryInsightsGroupByV2026R0.js"); const queryInsightsMetricDefinitionV2026R0_1 = require("./queryInsightsMetricDefinitionV2026R0.js"); const queryInsightsMetricDefinitionV2026R0_2 = require("./queryInsightsMetricDefinitionV2026R0.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 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 (0, queryAncestorReferenceV2026R0_1.serializeQueryAncestorReferenceV2026R0)(item); }), ['group_by']: val.groupBy == void 0 ? val.groupBy : val.groupBy.map(function (item) { return (0, queryInsightsGroupByV2026R0_1.serializeQueryInsightsGroupByV2026R0)(item); }), }; } function deserializeQueryInsightsRequestBodyV2026R0QueryField(val) { if (!(0, json_3.sdIsMap)(val)) { throw new errors_1.BoxSdkError({ message: 'Expecting a map for "QueryInsightsRequestBodyV2026R0QueryField"', }); } if (val.predicate == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "predicate" of type "QueryInsightsRequestBodyV2026R0QueryField" to be defined', }); } if (!(0, json_1.sdIsString)(val.predicate)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "predicate" of type "QueryInsightsRequestBodyV2026R0QueryField"', }); } const predicate = val.predicate; if (!(val.params == void 0) && !(0, json_3.sdIsMap)(val.params)) { throw new errors_1.BoxSdkError({ message: 'Expecting object for "params" of type "QueryInsightsRequestBodyV2026R0QueryField"', }); } const params = val.params == void 0 ? void 0 : (0, json_3.sdIsMap)(val.params) ? Object.fromEntries(Object.entries(val.params).map(([k, v]) => [ k, (function (v) { return v; })(v), ])) : {}; if (!(val.ancestors == void 0) && !(0, json_2.sdIsList)(val.ancestors)) { throw new errors_1.BoxSdkError({ message: 'Expecting array for "ancestors" of type "QueryInsightsRequestBodyV2026R0QueryField"', }); } const ancestors = val.ancestors == void 0 ? void 0 : (0, json_2.sdIsList)(val.ancestors) ? val.ancestors.map(function (itm) { return (0, queryAncestorReferenceV2026R0_2.deserializeQueryAncestorReferenceV2026R0)(itm); }) : []; if (!(val.group_by == void 0) && !(0, json_2.sdIsList)(val.group_by)) { throw new errors_1.BoxSdkError({ message: 'Expecting array for "group_by" of type "QueryInsightsRequestBodyV2026R0QueryField"', }); } const groupBy = val.group_by == void 0 ? void 0 : (0, json_2.sdIsList)(val.group_by) ? val.group_by.map(function (itm) { return (0, queryInsightsGroupByV2026R0_2.deserializeQueryInsightsGroupByV2026R0)(itm); }) : []; return { predicate: predicate, params: params, ancestors: ancestors, groupBy: groupBy, }; } function serializeQueryInsightsRequestBodyV2026R0(val) { return { ['query']: serializeQueryInsightsRequestBodyV2026R0QueryField(val.query), ['metrics']: Object.fromEntries(Object.entries(val.metrics).map(([k, v]) => [ k, (0, queryInsightsMetricDefinitionV2026R0_1.serializeQueryInsightsMetricDefinitionV2026R0)(v), ])), }; } function deserializeQueryInsightsRequestBodyV2026R0(val) { if (!(0, json_3.sdIsMap)(val)) { throw new errors_1.BoxSdkError({ message: 'Expecting a map for "QueryInsightsRequestBodyV2026R0"', }); } if (val.query == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "query" of type "QueryInsightsRequestBodyV2026R0" to be defined', }); } const query = deserializeQueryInsightsRequestBodyV2026R0QueryField(val.query); if (val.metrics == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "metrics" of type "QueryInsightsRequestBodyV2026R0" to be defined', }); } if (!(0, json_3.sdIsMap)(val.metrics)) { throw new errors_1.BoxSdkError({ message: 'Expecting object for "metrics" of type "QueryInsightsRequestBodyV2026R0"', }); } const metrics = (0, json_3.sdIsMap)(val.metrics) ? Object.fromEntries(Object.entries(val.metrics).map(([k, v]) => [ k, (0, queryInsightsMetricDefinitionV2026R0_2.deserializeQueryInsightsMetricDefinitionV2026R0)(v), ])) : {}; return { query: query, metrics: metrics, }; } //# sourceMappingURL=queryInsightsRequestBodyV2026R0.js.map