"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeRecentItemInteractionTypeField = serializeRecentItemInteractionTypeField;
exports.deserializeRecentItemInteractionTypeField = deserializeRecentItemInteractionTypeField;
exports.serializeRecentItem = serializeRecentItem;
exports.deserializeRecentItem = deserializeRecentItem;
const recentItemResource_1 = require("./recentItemResource");
const recentItemResource_2 = require("./recentItemResource");
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 serializeRecentItemInteractionTypeField(val) {
    return val;
}
function deserializeRecentItemInteractionTypeField(val) {
    if (val == 'item_preview') {
        return val;
    }
    if (val == 'item_upload') {
        return val;
    }
    if (val == 'item_comment') {
        return val;
    }
    if (val == 'item_open') {
        return val;
    }
    if (val == 'item_modify') {
        return val;
    }
    if ((0, json_1.sdIsString)(val)) {
        return val;
    }
    throw new errors_1.BoxSdkError({
        message: "Can't deserialize RecentItemInteractionTypeField",
    });
}
function serializeRecentItem(val) {
    return {
        ['type']: val.type,
        ['item']: val.item == void 0 ? val.item : (0, recentItemResource_1.serializeRecentItemResource)(val.item),
        ['interaction_type']: val.interactionType == void 0
            ? val.interactionType
            : serializeRecentItemInteractionTypeField(val.interactionType),
        ['interacted_at']: val.interactedAt == void 0
            ? val.interactedAt
            : (0, utils_1.serializeDateTime)(val.interactedAt),
        ['interaction_shared_link']: val.interactionSharedLink,
    };
}
function deserializeRecentItem(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({ message: 'Expecting a map for "RecentItem"' });
    }
    if (!(val.type == void 0) && !(0, json_1.sdIsString)(val.type)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "type" of type "RecentItem"',
        });
    }
    const type = val.type == void 0 ? void 0 : val.type;
    const item = val.item == void 0 ? void 0 : (0, recentItemResource_2.deserializeRecentItemResource)(val.item);
    const interactionType = val.interaction_type == void 0
        ? void 0
        : deserializeRecentItemInteractionTypeField(val.interaction_type);
    if (!(val.interacted_at == void 0) && !(0, json_1.sdIsString)(val.interacted_at)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "interacted_at" of type "RecentItem"',
        });
    }
    const interactedAt = val.interacted_at == void 0
        ? void 0
        : (0, utils_2.deserializeDateTime)(val.interacted_at);
    if (!(val.interaction_shared_link == void 0) &&
        !(0, json_1.sdIsString)(val.interaction_shared_link)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "interaction_shared_link" of type "RecentItem"',
        });
    }
    const interactionSharedLink = val.interaction_shared_link == void 0
        ? void 0
        : val.interaction_shared_link;
    return {
        type: type,
        item: item,
        interactionType: interactionType,
        interactedAt: interactedAt,
        interactionSharedLink: interactionSharedLink,
    };
}
//# sourceMappingURL=recentItem.js.map