"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileMini = void 0;
exports.serializeFileMini = serializeFileMini;
exports.deserializeFileMini = deserializeFileMini;
const fileBase_1 = require("./fileBase");
const fileBase_2 = require("./fileBase");
const fileVersionMini_1 = require("./fileVersionMini");
const fileVersionMini_2 = require("./fileVersionMini");
const fileBase_3 = require("./fileBase");
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
const json_2 = require("../serialization/json");
class FileMini extends fileBase_3.FileBase {
    sequenceId;
    name;
    sha1;
    fileVersion;
    constructor(fields) {
        super(fields);
        if (fields.sequenceId !== undefined) {
            this.sequenceId = fields.sequenceId;
        }
        if (fields.name !== undefined) {
            this.name = fields.name;
        }
        if (fields.sha1 !== undefined) {
            this.sha1 = fields.sha1;
        }
        if (fields.fileVersion !== undefined) {
            this.fileVersion = fields.fileVersion;
        }
    }
}
exports.FileMini = FileMini;
function serializeFileMini(val) {
    const base = (0, fileBase_2.serializeFileBase)(val);
    if (!(0, json_2.sdIsMap)(base)) {
        throw new errors_1.BoxSdkError({ message: 'Expecting a map for "FileMini"' });
    }
    return {
        ...base,
        ...{
            ['sequence_id']: val.sequenceId,
            ['name']: val.name,
            ['sha1']: val.sha1,
            ['file_version']: val.fileVersion == void 0
                ? val.fileVersion
                : (0, fileVersionMini_1.serializeFileVersionMini)(val.fileVersion),
        },
    };
}
function deserializeFileMini(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({ message: 'Expecting a map for "FileMini"' });
    }
    if (!(val.sequence_id == void 0) && !(0, json_1.sdIsString)(val.sequence_id)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "sequence_id" of type "FileMini"',
        });
    }
    const sequenceId = val.sequence_id == void 0 ? void 0 : val.sequence_id;
    if (!(val.name == void 0) && !(0, json_1.sdIsString)(val.name)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "name" of type "FileMini"',
        });
    }
    const name = val.name == void 0 ? void 0 : val.name;
    if (!(val.sha1 == void 0) && !(0, json_1.sdIsString)(val.sha1)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "sha1" of type "FileMini"',
        });
    }
    const sha1 = val.sha1 == void 0 ? void 0 : val.sha1;
    const fileVersion = val.file_version == void 0
        ? void 0
        : (0, fileVersionMini_2.deserializeFileVersionMini)(val.file_version);
    if (val.id == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "id" of type "FileMini" to be defined',
        });
    }
    if (!(0, json_1.sdIsString)(val.id)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "id" of type "FileMini"',
        });
    }
    const id = val.id;
    if (!(val.etag == void 0) && !(0, json_1.sdIsString)(val.etag)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "etag" of type "FileMini"',
        });
    }
    const etag = val.etag == void 0 ? void 0 : val.etag;
    if (val.type == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "type" of type "FileMini" to be defined',
        });
    }
    const type = (0, fileBase_1.deserializeFileBaseTypeField)(val.type);
    return {
        sequenceId: sequenceId,
        name: name,
        sha1: sha1,
        fileVersion: fileVersion,
        id: id,
        etag: etag,
        type: type,
    };
}
//# sourceMappingURL=fileMini.js.map