"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeItem = serializeItem;
exports.deserializeItem = deserializeItem;
const fileFull_1 = require("./fileFull");
const fileFull_2 = require("./fileFull");
const folderMini_1 = require("./folderMini");
const folderMini_2 = require("./folderMini");
const webLink_1 = require("./webLink");
const webLink_2 = require("./webLink");
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
function serializeItem(val) {
    if (val.type == 'file') {
        return (0, fileFull_1.serializeFileFull)(val);
    }
    if (val.type == 'folder') {
        return (0, folderMini_1.serializeFolderMini)(val);
    }
    if (val.type == 'web_link') {
        return (0, webLink_1.serializeWebLink)(val);
    }
    throw new errors_1.BoxSdkError({ message: 'unknown type' });
}
function deserializeItem(val) {
    if (!(0, json_1.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({ message: 'Expecting a map for "Item"' });
    }
    if (val.type == 'file') {
        return (0, fileFull_2.deserializeFileFull)(val);
    }
    if (val.type == 'folder') {
        return (0, folderMini_2.deserializeFolderMini)(val);
    }
    if (val.type == 'web_link') {
        return (0, webLink_2.deserializeWebLink)(val);
    }
    throw new errors_1.BoxSdkError({ message: "Can't deserialize Item" });
}
//# sourceMappingURL=item.js.map