"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeResource = serializeResource;
exports.deserializeResource = deserializeResource;
const folderMini_1 = require("./folderMini");
const folderMini_2 = require("./folderMini");
const fileMini_1 = require("./fileMini");
const fileMini_2 = require("./fileMini");
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
function serializeResource(val) {
    if (val.type == 'folder') {
        return (0, folderMini_1.serializeFolderMini)(val);
    }
    if (val.type == 'file') {
        return (0, fileMini_1.serializeFileMini)(val);
    }
    throw new errors_1.BoxSdkError({ message: 'unknown type' });
}
function deserializeResource(val) {
    if (!(0, json_1.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({ message: 'Expecting a map for "Resource"' });
    }
    if (val.type == 'folder') {
        return (0, folderMini_2.deserializeFolderMini)(val);
    }
    if (val.type == 'file') {
        return (0, fileMini_2.deserializeFileMini)(val);
    }
    throw new errors_1.BoxSdkError({ message: "Can't deserialize Resource" });
}
//# sourceMappingURL=resource.js.map