UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

86 lines 3.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.serializeAiResponseFull = serializeAiResponseFull; exports.deserializeAiResponseFull = deserializeAiResponseFull; const utils_1 = require("../internal/utils"); const aiAgentInfo_1 = require("./aiAgentInfo"); const aiResponse_1 = require("./aiResponse"); const aiCitation_1 = require("./aiCitation"); const aiCitation_2 = require("./aiCitation"); 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 serializeAiResponseFull(val) { const base = (0, aiResponse_1.serializeAiResponse)(val); if (!(0, json_3.sdIsMap)(base)) { throw new errors_1.BoxSdkError({ message: 'Expecting a map for "AiResponseFull"' }); } return { ...base, ...{ ['citations']: val.citations == void 0 ? val.citations : val.citations.map(function (item) { return (0, aiCitation_1.serializeAiCitation)(item); }), }, }; } function deserializeAiResponseFull(val) { if (!(0, json_3.sdIsMap)(val)) { throw new errors_1.BoxSdkError({ message: 'Expecting a map for "AiResponseFull"' }); } if (!(val.citations == void 0) && !(0, json_2.sdIsList)(val.citations)) { throw new errors_1.BoxSdkError({ message: 'Expecting array for "citations" of type "AiResponseFull"', }); } const citations = val.citations == void 0 ? void 0 : (0, json_2.sdIsList)(val.citations) ? val.citations.map(function (itm) { return (0, aiCitation_2.deserializeAiCitation)(itm); }) : []; if (val.answer == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "answer" of type "AiResponseFull" to be defined', }); } if (!(0, json_1.sdIsString)(val.answer)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "answer" of type "AiResponseFull"', }); } const answer = val.answer; if (val.created_at == void 0) { throw new errors_1.BoxSdkError({ message: 'Expecting "created_at" of type "AiResponseFull" to be defined', }); } if (!(0, json_1.sdIsString)(val.created_at)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "created_at" of type "AiResponseFull"', }); } const createdAt = (0, utils_1.deserializeDateTime)(val.created_at); if (!(val.completion_reason == void 0) && !(0, json_1.sdIsString)(val.completion_reason)) { throw new errors_1.BoxSdkError({ message: 'Expecting string for "completion_reason" of type "AiResponseFull"', }); } const completionReason = val.completion_reason == void 0 ? void 0 : val.completion_reason; const aiAgentInfo = val.ai_agent_info == void 0 ? void 0 : (0, aiAgentInfo_1.deserializeAiAgentInfo)(val.ai_agent_info); return { citations: citations, answer: answer, createdAt: createdAt, completionReason: completionReason, aiAgentInfo: aiAgentInfo, }; } //# sourceMappingURL=aiResponseFull.js.map