"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeEventSourceResource = serializeEventSourceResource;
exports.deserializeEventSourceResource = deserializeEventSourceResource;
const user_1 = require("./user");
const user_2 = require("./user");
const eventSource_1 = require("./eventSource");
const eventSource_2 = require("./eventSource");
const file_1 = require("./file");
const file_2 = require("./file");
const folder_1 = require("./folder");
const folder_2 = require("./folder");
const genericSource_1 = require("./genericSource");
const genericSource_2 = require("./genericSource");
const appItemEventSource_1 = require("./appItemEventSource");
const appItemEventSource_2 = require("./appItemEventSource");
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
function serializeEventSourceResource(val) {
    if (val.type == 'user') {
        return (0, user_1.serializeUser)(val);
    }
    if (val.type == 'file') {
        return (0, file_1.serializeFile)(val);
    }
    if (val.type == 'folder') {
        return (0, folder_1.serializeFolder)(val);
    }
    if (val.type == 'app_item') {
        return (0, appItemEventSource_1.serializeAppItemEventSource)(val);
    }
    if (val.itemType == 'file') {
        return (0, eventSource_1.serializeEventSource)(val);
    }
    if (val.itemType == 'folder') {
        return (0, eventSource_1.serializeEventSource)(val);
    }
    return (0, genericSource_1.serializeGenericSource)(val);
}
function deserializeEventSourceResource(val) {
    if (!(0, json_1.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "EventSourceResource"',
        });
    }
    if (val.type == 'user') {
        return (0, user_2.deserializeUser)(val);
    }
    if (val.type == 'file') {
        return (0, file_2.deserializeFile)(val);
    }
    if (val.type == 'folder') {
        return (0, folder_2.deserializeFolder)(val);
    }
    if (val.type == 'app_item') {
        return (0, appItemEventSource_2.deserializeAppItemEventSource)(val);
    }
    if (!(0, json_1.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "EventSourceResource"',
        });
    }
    if (val.item_type == 'file') {
        return (0, eventSource_2.deserializeEventSource)(val);
    }
    if (val.item_type == 'folder') {
        return (0, eventSource_2.deserializeEventSource)(val);
    }
    try {
        return (0, genericSource_2.deserializeGenericSource)(val);
    }
    catch (error) {
        void 0;
    }
    finally {
    }
    throw new errors_1.BoxSdkError({ message: "Can't deserialize EventSourceResource" });
}
//# sourceMappingURL=eventSourceResource.js.map