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

/// 银行列表
/// @param {*} data
/// @returns
Future getBankList(params) async {
  return request('/bank',
      options: Options(method: 'GET'), queryParameters: params)
      .catchError((error) =>
  {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
}
/// 银行卡列表
/// @param {*} data
/// @returns
Future getBankCardList(params) async {
  return request('/bankcard',
      options: Options(method: 'GET'), queryParameters: params)
      .catchError((error) =>
  {Fluttertoast.showToast(msg: error.error.toString()), print(error)});
}
/// 银行卡详情
/// @param {*} data
/// @returns
Future getBankCardDetail(String id) async {
  return request('/bankcard/$id', options: Options(method: 'GET'))
      .catchError((error) => {
    Fluttertoast.showToast(msg: error.error['message']),
  });
}

/// 添加银行卡
/// @param {*} data
/// @returns
Future addBankCard(data) async {
  return request(
    '/bankcard',
    options: Options(method: 'POST'),
    data: data,
  ).catchError((error) => {
    Fluttertoast.showToast(msg: error.error['message']),
  });
}

/// 解绑银行卡
/// @param {*}
/// @returns
Future unbindBankCard(String id) async {
  return request('/bankcard/$id/pause',
      options: Options(method: 'DELETE'))
      .catchError((error) => {
    Fluttertoast.showToast(msg: error.error['message']),
  });
}