"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeFileVersionLegalHoldTypeField = serializeFileVersionLegalHoldTypeField;
exports.deserializeFileVersionLegalHoldTypeField = deserializeFileVersionLegalHoldTypeField;
exports.serializeFileVersionLegalHold = serializeFileVersionLegalHold;
exports.deserializeFileVersionLegalHold = deserializeFileVersionLegalHold;
const fileVersionMini_1 = require("./fileVersionMini");
const fileVersionMini_2 = require("./fileVersionMini");
const fileMini_1 = require("./fileMini");
const fileMini_2 = require("./fileMini");
const legalHoldPolicyAssignment_1 = require("./legalHoldPolicyAssignment");
const legalHoldPolicyAssignment_2 = require("./legalHoldPolicyAssignment");
const utils_1 = require("../internal/utils");
const utils_2 = require("../internal/utils");
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 serializeFileVersionLegalHoldTypeField(val) {
    return val;
}
function deserializeFileVersionLegalHoldTypeField(val) {
    if (val == 'file_version_legal_hold') {
        return val;
    }
    throw new errors_1.BoxSdkError({
        message: "Can't deserialize FileVersionLegalHoldTypeField",
    });
}
function serializeFileVersionLegalHold(val) {
    return {
        ['id']: val.id,
        ['type']: val.type == void 0
            ? val.type
            : serializeFileVersionLegalHoldTypeField(val.type),
        ['file_version']: val.fileVersion == void 0
            ? val.fileVersion
            : (0, fileVersionMini_1.serializeFileVersionMini)(val.fileVersion),
        ['file']: val.file == void 0 ? val.file : (0, fileMini_1.serializeFileMini)(val.file),
        ['legal_hold_policy_assignments']: val.legalHoldPolicyAssignments == void 0
            ? val.legalHoldPolicyAssignments
            : val.legalHoldPolicyAssignments.map(function (item) {
                return (0, legalHoldPolicyAssignment_1.serializeLegalHoldPolicyAssignment)(item);
            }),
        ['deleted_at']: val.deletedAt == void 0
            ? val.deletedAt
            : (0, utils_1.serializeDateTime)(val.deletedAt),
    };
}
function deserializeFileVersionLegalHold(val) {
    if (!(0, json_3.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "FileVersionLegalHold"',
        });
    }
    if (!(val.id == void 0) && !(0, json_1.sdIsString)(val.id)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "id" of type "FileVersionLegalHold"',
        });
    }
    const id = val.id == void 0 ? void 0 : val.id;
    const type = val.type == void 0
        ? void 0
        : deserializeFileVersionLegalHoldTypeField(val.type);
    const fileVersion = val.file_version == void 0
        ? void 0
        : (0, fileVersionMini_2.deserializeFileVersionMini)(val.file_version);
    const file = val.file == void 0 ? void 0 : (0, fileMini_2.deserializeFileMini)(val.file);
    if (!(val.legal_hold_policy_assignments == void 0) &&
        !(0, json_2.sdIsList)(val.legal_hold_policy_assignments)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting array for "legal_hold_policy_assignments" of type "FileVersionLegalHold"',
        });
    }
    const legalHoldPolicyAssignments = val.legal_hold_policy_assignments == void 0
        ? void 0
        : (0, json_2.sdIsList)(val.legal_hold_policy_assignments)
            ? val.legal_hold_policy_assignments.map(function (itm) {
                return (0, legalHoldPolicyAssignment_2.deserializeLegalHoldPolicyAssignment)(itm);
            })
            : [];
    if (!(val.deleted_at == void 0) && !(0, json_1.sdIsString)(val.deleted_at)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "deleted_at" of type "FileVersionLegalHold"',
        });
    }
    const deletedAt = val.deleted_at == void 0 ? void 0 : (0, utils_2.deserializeDateTime)(val.deleted_at);
    return {
        id: id,
        type: type,
        fileVersion: fileVersion,
        file: file,
        legalHoldPolicyAssignments: legalHoldPolicyAssignments,
        deletedAt: deletedAt,
    };
}
//# sourceMappingURL=fileVersionLegalHold.js.map