"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeAiExtractStructuredResponse = serializeAiExtractStructuredResponse;
exports.deserializeAiExtractStructuredResponse = deserializeAiExtractStructuredResponse;
const aiExtractResponse_1 = require("./aiExtractResponse.js");
const aiExtractResponse_2 = require("./aiExtractResponse.js");
const aiAgentInfo_1 = require("./aiAgentInfo.js");
const aiAgentInfo_2 = require("./aiAgentInfo.js");
const utils_1 = require("../internal/utils.js");
const utils_2 = require("../internal/utils.js");
const errors_1 = require("../box/errors.js");
const json_1 = require("../serialization/json.js");
const json_2 = require("../serialization/json.js");
function serializeAiExtractStructuredResponse(val) {
    return {
        ['answer']: (0, aiExtractResponse_1.serializeAiExtractResponse)(val.answer),
        ['created_at']: (0, utils_1.serializeDateTime)(val.createdAt),
        ['completion_reason']: val.completionReason,
        ['confidence_score']: val.confidenceScore == void 0
            ? val.confidenceScore
            : Object.fromEntries(Object.entries(val.confidenceScore).map(([k, v]) => [
                k,
                (function (v) {
                    return v;
                })(v),
            ])),
        ['reference']: val.reference == void 0
            ? val.reference
            : Object.fromEntries(Object.entries(val.reference).map(([k, v]) => [
                k,
                (function (v) {
                    return v;
                })(v),
            ])),
        ['ai_agent_info']: val.aiAgentInfo == void 0
            ? val.aiAgentInfo
            : (0, aiAgentInfo_1.serializeAiAgentInfo)(val.aiAgentInfo),
    };
}
function deserializeAiExtractStructuredResponse(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "AiExtractStructuredResponse"',
        });
    }
    if (val.answer == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "answer" of type "AiExtractStructuredResponse" to be defined',
        });
    }
    const answer = (0, aiExtractResponse_2.deserializeAiExtractResponse)(val.answer);
    if (val.created_at == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "created_at" of type "AiExtractStructuredResponse" to be defined',
        });
    }
    if (!(0, json_1.sdIsString)(val.created_at)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "created_at" of type "AiExtractStructuredResponse"',
        });
    }
    const createdAt = (0, utils_2.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 "AiExtractStructuredResponse"',
        });
    }
    const completionReason = val.completion_reason == void 0 ? void 0 : val.completion_reason;
    if (!(val.confidence_score == void 0) && !(0, json_2.sdIsMap)(val.confidence_score)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting object for "confidence_score" of type "AiExtractStructuredResponse"',
        });
    }
    const confidenceScore = val.confidence_score == void 0
        ? void 0
        : (0, json_2.sdIsMap)(val.confidence_score)
            ? Object.fromEntries(Object.entries(val.confidence_score).map(([k, v]) => [
                k,
                (function (v) {
                    return v;
                })(v),
            ]))
            : {};
    if (!(val.reference == void 0) && !(0, json_2.sdIsMap)(val.reference)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting object for "reference" of type "AiExtractStructuredResponse"',
        });
    }
    const reference = val.reference == void 0
        ? void 0
        : (0, json_2.sdIsMap)(val.reference)
            ? Object.fromEntries(Object.entries(val.reference).map(([k, v]) => [
                k,
                (function (v) {
                    return v;
                })(v),
            ]))
            : {};
    const aiAgentInfo = val.ai_agent_info == void 0
        ? void 0
        : (0, aiAgentInfo_2.deserializeAiAgentInfo)(val.ai_agent_info);
    return {
        answer: answer,
        createdAt: createdAt,
        completionReason: completionReason,
        confidenceScore: confidenceScore,
        reference: reference,
        aiAgentInfo: aiAgentInfo,
    };
}
//# sourceMappingURL=aiExtractStructuredResponse.js.map