import 'package:dio/dio.dart';
import '../utils/Request.dart';
import 'package:fluttertoast/fluttertoast.dart';

/// 作业列表
/// @param {*} data
/// @returns
Future getJobList(params) async {
  return request('/work-job',
          options: Options(method: 'GET'), queryParameters: params)
      .catchError((error) =>
          {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
}

/// 作业详情
/// @param {*} data
/// @returns
Future getJobDetail(String id) async {
  return request('/work-job/$id', options: Options(method: 'GET'))
      .catchError((error) => {
            Fluttertoast.showToast(msg: error.error['message']),
          });
}

/**
 * 开始作业
 * @param {*}
 * @returns
 */
Future startJob(String id, params) async {
  return request('/work-job/$id/pause',
          options: Options(method: 'PUT'), queryParameters: params)
      .catchError((error) => {
            Fluttertoast.showToast(msg: error.error['message']),
          });
}
/// 开始作业
/// @param {*}
/// @returns
Future overJob(String id, data) async {
  return request('/work-job/$id/stop',
      options: Options(method: 'PUT'), data: data)
      .catchError((error) => {
    Fluttertoast.showToast(msg: error.error['message']),
  });
}