import { deserializeDocGenJobBaseV2025R0TypeField } from './docGenJobBaseV2025R0.js';
import { serializeDocGenJobBaseV2025R0 } from './docGenJobBaseV2025R0.js';
import { serializeDocGenBatchBaseV2025R0 } from './docGenBatchBaseV2025R0.js';
import { deserializeDocGenBatchBaseV2025R0 } from './docGenBatchBaseV2025R0.js';
import { serializeFileReferenceV2025R0 } from './fileReferenceV2025R0.js';
import { deserializeFileReferenceV2025R0 } from './fileReferenceV2025R0.js';
import { serializeFileVersionBaseV2025R0 } from './fileVersionBaseV2025R0.js';
import { deserializeFileVersionBaseV2025R0 } from './fileVersionBaseV2025R0.js';
import { DocGenJobBaseV2025R0 } from './docGenJobBaseV2025R0.js';
import { BoxSdkError } from '../../box/errors.js';
import { sdIsString } from '../../serialization/json.js';
import { sdIsList } from '../../serialization/json.js';
import { sdIsMap } from '../../serialization/json.js';
export class DocGenJobV2025R0 extends DocGenJobBaseV2025R0 {
    batch;
    templateFile;
    templateFileVersion;
    outputFile;
    outputFileVersion;
    status;
    outputType;
    failures;
    constructor(fields) {
        super(fields);
        if (fields.batch !== undefined) {
            this.batch = fields.batch;
        }
        if (fields.templateFile !== undefined) {
            this.templateFile = fields.templateFile;
        }
        if (fields.templateFileVersion !== undefined) {
            this.templateFileVersion = fields.templateFileVersion;
        }
        if (fields.outputFile !== undefined) {
            this.outputFile = fields.outputFile;
        }
        if (fields.outputFileVersion !== undefined) {
            this.outputFileVersion = fields.outputFileVersion;
        }
        if (fields.status !== undefined) {
            this.status = fields.status;
        }
        if (fields.outputType !== undefined) {
            this.outputType = fields.outputType;
        }
        if (fields.failures !== undefined) {
            this.failures = fields.failures;
        }
    }
}
export function serializeDocGenJobV2025R0StatusField(val) {
    return val;
}
export function deserializeDocGenJobV2025R0StatusField(val) {
    if (val == 'submitted') {
        return val;
    }
    if (val == 'completed') {
        return val;
    }
    if (val == 'failed') {
        return val;
    }
    if (val == 'completed_with_error') {
        return val;
    }
    if (val == 'pending') {
        return val;
    }
    if (sdIsString(val)) {
        return val;
    }
    throw new BoxSdkError({
        message: "Can't deserialize DocGenJobV2025R0StatusField",
    });
}
export function serializeDocGenJobV2025R0FailuresField(val) {
    return {
        ['errors']: val.errors.map(function (item) {
            return item;
        }),
        ['warnings']: val.warnings.map(function (item) {
            return item;
        }),
    };
}
export function deserializeDocGenJobV2025R0FailuresField(val) {
    if (!sdIsMap(val)) {
        throw new BoxSdkError({
            message: 'Expecting a map for "DocGenJobV2025R0FailuresField"',
        });
    }
    if (val.errors == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "errors" of type "DocGenJobV2025R0FailuresField" to be defined',
        });
    }
    if (!sdIsList(val.errors)) {
        throw new BoxSdkError({
            message: 'Expecting array for "errors" of type "DocGenJobV2025R0FailuresField"',
        });
    }
    const errors = sdIsList(val.errors)
        ? val.errors.map(function (itm) {
            if (!sdIsString(itm)) {
                throw new BoxSdkError({
                    message: 'Expecting string for "DocGenJobV2025R0FailuresField"',
                });
            }
            return itm;
        })
        : [];
    if (val.warnings == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "warnings" of type "DocGenJobV2025R0FailuresField" to be defined',
        });
    }
    if (!sdIsList(val.warnings)) {
        throw new BoxSdkError({
            message: 'Expecting array for "warnings" of type "DocGenJobV2025R0FailuresField"',
        });
    }
    const warnings = sdIsList(val.warnings)
        ? val.warnings.map(function (itm) {
            if (!sdIsString(itm)) {
                throw new BoxSdkError({
                    message: 'Expecting string for "DocGenJobV2025R0FailuresField"',
                });
            }
            return itm;
        })
        : [];
    return {
        errors: errors,
        warnings: warnings,
    };
}
export function serializeDocGenJobV2025R0(val) {
    const base = serializeDocGenJobBaseV2025R0(val);
    if (!sdIsMap(base)) {
        throw new BoxSdkError({
            message: 'Expecting a map for "DocGenJobV2025R0"',
        });
    }
    return {
        ...base,
        ...{
            ['batch']: serializeDocGenBatchBaseV2025R0(val.batch),
            ['template_file']: serializeFileReferenceV2025R0(val.templateFile),
            ['template_file_version']: serializeFileVersionBaseV2025R0(val.templateFileVersion),
            ['output_file']: val.outputFile == void 0
                ? val.outputFile
                : serializeFileReferenceV2025R0(val.outputFile),
            ['output_file_version']: val.outputFileVersion == void 0
                ? val.outputFileVersion
                : serializeFileVersionBaseV2025R0(val.outputFileVersion),
            ['status']: serializeDocGenJobV2025R0StatusField(val.status),
            ['output_type']: val.outputType,
            ['failures']: val.failures == void 0
                ? val.failures
                : serializeDocGenJobV2025R0FailuresField(val.failures),
        },
    };
}
export function deserializeDocGenJobV2025R0(val) {
    if (!sdIsMap(val)) {
        throw new BoxSdkError({
            message: 'Expecting a map for "DocGenJobV2025R0"',
        });
    }
    if (val.batch == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "batch" of type "DocGenJobV2025R0" to be defined',
        });
    }
    const batch = deserializeDocGenBatchBaseV2025R0(val.batch);
    if (val.template_file == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "template_file" of type "DocGenJobV2025R0" to be defined',
        });
    }
    const templateFile = deserializeFileReferenceV2025R0(val.template_file);
    if (val.template_file_version == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "template_file_version" of type "DocGenJobV2025R0" to be defined',
        });
    }
    const templateFileVersion = deserializeFileVersionBaseV2025R0(val.template_file_version);
    const outputFile = val.output_file == void 0
        ? void 0
        : deserializeFileReferenceV2025R0(val.output_file);
    const outputFileVersion = val.output_file_version == void 0
        ? void 0
        : deserializeFileVersionBaseV2025R0(val.output_file_version);
    if (val.status == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "status" of type "DocGenJobV2025R0" to be defined',
        });
    }
    const status = deserializeDocGenJobV2025R0StatusField(val.status);
    if (val.output_type == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "output_type" of type "DocGenJobV2025R0" to be defined',
        });
    }
    if (!sdIsString(val.output_type)) {
        throw new BoxSdkError({
            message: 'Expecting string for "output_type" of type "DocGenJobV2025R0"',
        });
    }
    const outputType = val.output_type;
    const failures = val.failures == void 0
        ? void 0
        : deserializeDocGenJobV2025R0FailuresField(val.failures);
    if (val.id == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "id" of type "DocGenJobV2025R0" to be defined',
        });
    }
    if (!sdIsString(val.id)) {
        throw new BoxSdkError({
            message: 'Expecting string for "id" of type "DocGenJobV2025R0"',
        });
    }
    const id = val.id;
    if (val.type == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "type" of type "DocGenJobV2025R0" to be defined',
        });
    }
    const type = deserializeDocGenJobBaseV2025R0TypeField(val.type);
    return {
        batch: batch,
        templateFile: templateFile,
        templateFileVersion: templateFileVersion,
        outputFile: outputFile,
        outputFileVersion: outputFileVersion,
        status: status,
        outputType: outputType,
        failures: failures,
        id: id,
        type: type,
    };
}
//# sourceMappingURL=docGenJobV2025R0.js.map