UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

57 lines 2.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.serializeAiExtract = serializeAiExtract; exports.deserializeAiExtract = deserializeAiExtract; const aiItemBase_1 = require("./aiItemBase"); const aiItemBase_2 = require("./aiItemBase"); const aiExtractAgent_1 = require("./aiExtractAgent"); const aiExtractAgent_2 = require("./aiExtractAgent"); const errors_1 = require("../box/errors"); const json_1 = require("../serialization/json"); const json_2 = require("../serialization/json"); const json_3 = require("../serialization/json"); function serializeAiExtract(val) { return { ['prompt']: val.prompt, ['items']: val.items.map(function (item) { return (0, aiItemBase_1.serializeAiItemBase)(item); }), ['ai_agent']: val.aiAgent == void 0 ? val.aiAgent : (0, aiExtractAgent_1.serializeAiExtractAgent)(val.aiAgent), }; } function deserializeAiExtract(val) { if (!(0, json_3.sdIsMap)(val)) { throw new errors_1.BoxSdkError({ message: 'Expecting a map for "AiExtract"' }); } if (val.prompt == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "prompt" of type "AiExtract" to be defined', }); } if (!(0, json_1.sdIsString)(val.prompt)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "prompt" of type "AiExtract"', }); } const prompt = val.prompt; if (val.items == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "items" of type "AiExtract" to be defined', }); } if (!(0, json_2.sdIsList)(val.items)) { throw new errors_1.BoxSdkError({ message: 'Expecting array for "items" of type "AiExtract"', }); } const items = (0, json_2.sdIsList)(val.items) ? val.items.map(function (itm) { return (0, aiItemBase_2.deserializeAiItemBase)(itm); }) : []; const aiAgent = val.ai_agent == void 0 ? void 0 : (0, aiExtractAgent_2.deserializeAiExtractAgent)(val.ai_agent); return { prompt: prompt, items: items, aiAgent: aiAgent }; } //# sourceMappingURL=aiExtract.js.map