"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeMetadataTaxonomyNode = serializeMetadataTaxonomyNode;
exports.deserializeMetadataTaxonomyNode = deserializeMetadataTaxonomyNode;
const metadataTaxonomyAncestor_1 = require("./metadataTaxonomyAncestor");
const metadataTaxonomyAncestor_2 = require("./metadataTaxonomyAncestor");
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
const json_2 = require("../serialization/json");
const json_3 = require("../serialization/json");
const json_4 = require("../serialization/json");
function serializeMetadataTaxonomyNode(val) {
    return {
        ['id']: val.id,
        ['displayName']: val.displayName,
        ['level']: val.level,
        ['parentId']: val.parentId,
        ['nodePath']: val.nodePath == void 0
            ? val.nodePath
            : val.nodePath.map(function (item) {
                return item;
            }),
        ['ancestors']: val.ancestors == void 0
            ? val.ancestors
            : val.ancestors.map(function (item) {
                return (0, metadataTaxonomyAncestor_1.serializeMetadataTaxonomyAncestor)(item);
            }),
    };
}
function deserializeMetadataTaxonomyNode(val) {
    if (!(0, json_4.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "MetadataTaxonomyNode"',
        });
    }
    if (val.id == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "id" of type "MetadataTaxonomyNode" to be defined',
        });
    }
    if (!(0, json_2.sdIsString)(val.id)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "id" of type "MetadataTaxonomyNode"',
        });
    }
    const id = val.id;
    if (val.displayName == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "displayName" of type "MetadataTaxonomyNode" to be defined',
        });
    }
    if (!(0, json_2.sdIsString)(val.displayName)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "displayName" of type "MetadataTaxonomyNode"',
        });
    }
    const displayName = val.displayName;
    if (val.level == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "level" of type "MetadataTaxonomyNode" to be defined',
        });
    }
    if (!(0, json_1.sdIsNumber)(val.level)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting number for "level" of type "MetadataTaxonomyNode"',
        });
    }
    const level = val.level;
    if (!(val.parentId == void 0) && !(0, json_2.sdIsString)(val.parentId)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "parentId" of type "MetadataTaxonomyNode"',
        });
    }
    const parentId = val.parentId == void 0 ? void 0 : val.parentId;
    if (!(val.nodePath == void 0) && !(0, json_3.sdIsList)(val.nodePath)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting array for "nodePath" of type "MetadataTaxonomyNode"',
        });
    }
    const nodePath = val.nodePath == void 0
        ? void 0
        : (0, json_3.sdIsList)(val.nodePath)
            ? val.nodePath.map(function (itm) {
                if (!(0, json_2.sdIsString)(itm)) {
                    throw new errors_1.BoxSdkError({
                        message: 'Expecting string for "MetadataTaxonomyNode"',
                    });
                }
                return itm;
            })
            : [];
    if (!(val.ancestors == void 0) && !(0, json_3.sdIsList)(val.ancestors)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting array for "ancestors" of type "MetadataTaxonomyNode"',
        });
    }
    const ancestors = val.ancestors == void 0
        ? void 0
        : (0, json_3.sdIsList)(val.ancestors)
            ? val.ancestors.map(function (itm) {
                return (0, metadataTaxonomyAncestor_2.deserializeMetadataTaxonomyAncestor)(itm);
            })
            : [];
    return {
        id: id,
        displayName: displayName,
        level: level,
        parentId: parentId,
        nodePath: nodePath,
        ancestors: ancestors,
    };
}
//# sourceMappingURL=metadataTaxonomyNode.js.map