import 'package:project_telephony/constants/api.dart';
import 'package:project_telephony/model/network/api_client.dart';
import 'package:project_telephony/model/network/base_model.dart';
import 'package:project_telephony/utils/inner_model/base_list_model.dart';

import '../../../../model/exclude_phone_model.dart';
import '../../../../model/exclude_pn_model.dart';
import '../../../../utils/toast/cloud_toast.dart';

class ExcludeFunc {
//  查看手机号码
  static Future<List<ExcludePhoneModel>> getContacts() async {
    BaseListModel res = await apiClient.requestList(
      API.exclude.find,
    );
    if (res.code == 0) {
      return res.nullSafetyList
          .map((e) => ExcludePhoneModel.fromJson(e))
          .toList();
    } else {
      CloudToast.show(res.msg);
      return [];
    }
  }

  //添加手机号码
  static Future<bool> getContactsList(List numList) async {
    BaseModel res =
        await apiClient.request(API.exclude.add, data: {"exclude": numList});
    if (res.code == 0) {
      return true;
    } else {
      CloudToast.show(res.msg);
      return false;
    }
  }

  static Future<bool> getUpdate(int id, String phone, String remark) async {
    BaseModel res = await apiClient.request(API.exclude.update,
        data: {"id": id, "phone": phone, "remark": remark});
    if(res.code==0){
      return true;
    }else{
      CloudToast.show(res.msg);
      return false;
    }
  }

}
