// @ts-ignore
/* eslint-disable */

// 该文件自动生成，请勿手动修改！

// --------------------------------------------------------------------------
// 导出成绩服务
// --------------------------------------------------------------------------

import { request, RequestOptions } from '@umijs/max';
import contentDisposition from 'content-disposition';

/** 导出TQES输入文件 POST /api/exam-score-export/export-tqes-file */
export async function exportTqesFile(
    data: API.ExamScoreExportTqesFileInput,
    options?: { [key: string]: any },
) {
    const url = '/api/exam-score-export/export-tqes-file';
    const config = {
        method: 'POST',
        data,
        ...(options || {}),
        responseType: 'blob',
        getResponse: true,
    } as RequestOptions;
    const res = await request(url, config);
    const hcd = res.request.getResponseHeader('Content-Disposition');
    if (!hcd) {
        return null;
    }
    let fileName = '';
    const cd = contentDisposition.parse(hcd);
    if (cd?.parameters?.filename) {
        fileName = cd?.parameters?.filename;
    }
    return { fileName, data: res.data as Blob } as API.FileResponse;
}

export default {
    /** 导出TQES输入文件 POST /api/exam-score-export/export-tqes-file */
    exportTqesFile,
};
