"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeTasks = serializeTasks;
exports.deserializeTasks = deserializeTasks;
const task_1 = require("./task");
const task_2 = require("./task");
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
const json_2 = require("../serialization/json");
const json_3 = require("../serialization/json");
function serializeTasks(val) {
    return {
        ['total_count']: val.totalCount,
        ['entries']: val.entries == void 0
            ? val.entries
            : val.entries.map(function (item) {
                return (0, task_1.serializeTask)(item);
            }),
    };
}
function deserializeTasks(val) {
    if (!(0, json_3.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({ message: 'Expecting a map for "Tasks"' });
    }
    if (!(val.total_count == void 0) && !(0, json_1.sdIsNumber)(val.total_count)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting number for "total_count" of type "Tasks"',
        });
    }
    const totalCount = val.total_count == void 0 ? void 0 : val.total_count;
    if (!(val.entries == void 0) && !(0, json_2.sdIsList)(val.entries)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting array for "entries" of type "Tasks"',
        });
    }
    const entries = val.entries == void 0
        ? void 0
        : (0, json_2.sdIsList)(val.entries)
            ? val.entries.map(function (itm) {
                return (0, task_2.deserializeTask)(itm);
            })
            : [];
    return { totalCount: totalCount, entries: entries };
}
//# sourceMappingURL=tasks.js.map