"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeLegalHoldPolicyAssignment = serializeLegalHoldPolicyAssignment;
exports.deserializeLegalHoldPolicyAssignment = deserializeLegalHoldPolicyAssignment;
const legalHoldPolicyAssignmentBase_1 = require("./legalHoldPolicyAssignmentBase");
const legalHoldPolicyAssignmentBase_2 = require("./legalHoldPolicyAssignmentBase");
const legalHoldPolicyMini_1 = require("./legalHoldPolicyMini");
const legalHoldPolicyMini_2 = require("./legalHoldPolicyMini");
const legalHoldPolicyAssignedItem_1 = require("./legalHoldPolicyAssignedItem");
const legalHoldPolicyAssignedItem_2 = require("./legalHoldPolicyAssignedItem");
const userMini_1 = require("./userMini");
const userMini_2 = require("./userMini");
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");
function serializeLegalHoldPolicyAssignment(val) {
    const base = (0, legalHoldPolicyAssignmentBase_2.serializeLegalHoldPolicyAssignmentBase)(val);
    if (!(0, json_2.sdIsMap)(base)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "LegalHoldPolicyAssignment"',
        });
    }
    return {
        ...base,
        ...{
            ['legal_hold_policy']: val.legalHoldPolicy == void 0
                ? val.legalHoldPolicy
                : (0, legalHoldPolicyMini_1.serializeLegalHoldPolicyMini)(val.legalHoldPolicy),
            ['assigned_to']: val.assignedTo == void 0
                ? val.assignedTo
                : (0, legalHoldPolicyAssignedItem_1.serializeLegalHoldPolicyAssignedItem)(val.assignedTo),
            ['assigned_by']: val.assignedBy == void 0
                ? val.assignedBy
                : (0, userMini_1.serializeUserMini)(val.assignedBy),
            ['assigned_at']: val.assignedAt == void 0
                ? val.assignedAt
                : (0, utils_1.serializeDateTime)(val.assignedAt),
            ['deleted_at']: val.deletedAt == void 0
                ? val.deletedAt
                : (0, utils_1.serializeDateTime)(val.deletedAt),
        },
    };
}
function deserializeLegalHoldPolicyAssignment(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "LegalHoldPolicyAssignment"',
        });
    }
    const legalHoldPolicy = val.legal_hold_policy == void 0
        ? void 0
        : (0, legalHoldPolicyMini_2.deserializeLegalHoldPolicyMini)(val.legal_hold_policy);
    const assignedTo = val.assigned_to == void 0
        ? void 0
        : (0, legalHoldPolicyAssignedItem_2.deserializeLegalHoldPolicyAssignedItem)(val.assigned_to);
    const assignedBy = val.assigned_by == void 0 ? void 0 : (0, userMini_2.deserializeUserMini)(val.assigned_by);
    if (!(val.assigned_at == void 0) && !(0, json_1.sdIsString)(val.assigned_at)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "assigned_at" of type "LegalHoldPolicyAssignment"',
        });
    }
    const assignedAt = val.assigned_at == void 0 ? void 0 : (0, utils_2.deserializeDateTime)(val.assigned_at);
    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 "LegalHoldPolicyAssignment"',
        });
    }
    const deletedAt = val.deleted_at == void 0 ? void 0 : (0, utils_2.deserializeDateTime)(val.deleted_at);
    if (!(val.id == void 0) && !(0, json_1.sdIsString)(val.id)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "id" of type "LegalHoldPolicyAssignment"',
        });
    }
    const id = val.id == void 0 ? void 0 : val.id;
    const type = val.type == void 0
        ? void 0
        : (0, legalHoldPolicyAssignmentBase_1.deserializeLegalHoldPolicyAssignmentBaseTypeField)(val.type);
    return {
        legalHoldPolicy: legalHoldPolicy,
        assignedTo: assignedTo,
        assignedBy: assignedBy,
        assignedAt: assignedAt,
        deletedAt: deletedAt,
        id: id,
        type: type,
    };
}
//# sourceMappingURL=legalHoldPolicyAssignment.js.map