import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; import '../login/register/entity/SendValidationCodeEntity.dart'; import 'api_provider.dart'; class ApiRepository { final ApiProvider apiProvider; static ApiRepository get to => Get.find(); ApiRepository(this.apiProvider); // 发送验证码 1注册,2找回密码,3绑定手机号,4解绑(换绑),5删除账号 Future sendValidationCode( String countryCode, String account, String channel, String codeType, String uniqueid, String xWidth) async { final res = await apiProvider.getVerificationCode( countryCode, account, channel, codeType, uniqueid, xWidth); return SendValidationCodeEntity.fromJson(res.body); } // 注册 Future register( String countryCode, String countryId, String mobile, String password, String uniqueid, String verificationCode) async { final res = await apiProvider.register( countryCode, countryId, mobile, password, uniqueid, verificationCode); return LoginEntity.fromJson(res.body); } // 获取图片验证码 Future getSliderVerifyImg( String countryCode, String account) async { final res = await apiProvider.getSliderVerifyImg(countryCode, account); return SafetyVerificationEntity.fromJson(res.body); } // 检验图片验证码 Future checkSliderVerifyImg( String countryCode, String account, String xWidth) async { final res = await apiProvider.checkSliderVerifyImg(countryCode, account, xWidth); return CheckSafetyVerificationEntity.fromJson(res.body); } //登录 Future login(String loginType, String password, String countryCode, String username) async { final res = await apiProvider.login(loginType, password, countryCode, username); return LoginEntity.fromJson(res.body); } //重置密码 Future resetPassword( String countryCode, String account, String date, String newPassword, String uniqueid, String verificationCode) async { final res = await apiProvider.resetPassword( countryCode, account, date, newPassword, uniqueid, verificationCode); return LoginEntity.fromJson(res.body); } //获取国家或地区 json文件 Future getCountryRegion(String type) async { final res = await apiProvider.getCountryRegion(type); return LoginEntity.fromJson(res.body); } //电子钥匙列表 Future electronicKeyList( String endDate, String keyId, String keyStatus, String lockId, String operatorUid, String pageNo, String pageSize, String startDate) async { final res = await apiProvider.electronicKeyList(endDate, keyId, keyStatus, lockId, operatorUid, pageNo, pageSize, startDate); return ElectronicKeyListEntity.fromJson(res.body); } //发送电子钥匙 Future sendElectronicKey( String createUser, String countryCode, String usernameType, String endDate, String faceAuthentication, String isCameraEnable, String isRemoteUnlock, String keyNameForAdmin, String keyRight, String keyType, String lockId, String operatorUid, String receiverUsername, String remarks, String startDate, List weekDays) async { final res = await apiProvider.sendElectronicKey( createUser, countryCode, usernameType, endDate, faceAuthentication, isCameraEnable, isRemoteUnlock, keyNameForAdmin, keyRight, keyType, lockId, operatorUid, receiverUsername, remarks, startDate, weekDays); return ElectronicKeyListEntity.fromJson(res.body); } //重置电子钥匙 Future resetElectronicKey( String lockId, String operatorUid) async { final res = await apiProvider.resetElectronicKey(lockId, operatorUid); return ElectronicKeyListEntity.fromJson(res.body); } //钥匙详情-操作记录 Future lockRecordList( String endDate, String keyId, String keyStatus, String lockId, String operatorUid, String pageNo, String pageSize, String startDate, String recordType, String searchStr, String timezoneRawOffSet) async { final res = await apiProvider.lockRecordList( endDate, keyId, keyStatus, lockId, operatorUid, pageNo, pageSize, startDate, recordType, searchStr, timezoneRawOffSet); return KeyOperationRecordEntity.fromJson(res.body); } //锁电量更新 Future uploadElectricQuantity( String electricQuantity, String lockId) async { final res = await apiProvider.uploadElectricQuantity(electricQuantity, lockId); return KeyOperationRecordEntity.fromJson(res.body); } //锁名称修改 Future modifyKeyName( String keyId, String lockId, String keyName, String operatorUid, ) async { final res = await apiProvider.modifyKeyName(keyId, lockId, keyName, operatorUid); return KeyOperationRecordEntity.fromJson(res.body); } }