2023-07-27 15:29:37 +08:00
|
|
|
|
import 'package:get/get.dart';
|
2023-07-29 18:33:48 +08:00
|
|
|
|
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
|
|
|
|
|
|
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
2023-07-29 09:25:21 +08:00
|
|
|
|
import '../login/login/entity/LoginEntity.dart';
|
2023-08-02 09:22:39 +08:00
|
|
|
|
import '../login/register/entity/SendValidationCodeEntity.dart';
|
2023-07-27 15:29:37 +08:00
|
|
|
|
import 'api_provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class ApiRepository {
|
|
|
|
|
|
final ApiProvider apiProvider;
|
|
|
|
|
|
|
|
|
|
|
|
static ApiRepository get to => Get.find<ApiRepository>();
|
|
|
|
|
|
ApiRepository(this.apiProvider);
|
|
|
|
|
|
|
2023-08-07 10:32:24 +08:00
|
|
|
|
// 发送验证码 1注册,2找回密码,3绑定手机号,4解绑(换绑),5删除账号
|
2023-08-02 09:22:39 +08:00
|
|
|
|
Future<SendValidationCodeEntity> sendValidationCode(
|
|
|
|
|
|
String countryCode,
|
|
|
|
|
|
String account,
|
|
|
|
|
|
String channel,
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String codeType,
|
2023-08-02 09:22:39 +08:00
|
|
|
|
String uniqueid,
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String xWidth) async {
|
|
|
|
|
|
final res = await apiProvider.getVerificationCode(
|
|
|
|
|
|
countryCode, account, channel, codeType, uniqueid, xWidth);
|
2023-08-02 09:22:39 +08:00
|
|
|
|
return SendValidationCodeEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 注册
|
|
|
|
|
|
Future<LoginEntity> register(
|
|
|
|
|
|
String countryCode,
|
|
|
|
|
|
String countryId,
|
|
|
|
|
|
String mobile,
|
|
|
|
|
|
String password,
|
|
|
|
|
|
String uniqueid,
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String verificationCode) async {
|
|
|
|
|
|
final res = await apiProvider.register(
|
|
|
|
|
|
countryCode, countryId, mobile, password, uniqueid, verificationCode);
|
2023-07-29 09:25:21 +08:00
|
|
|
|
return LoginEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-02 09:22:39 +08:00
|
|
|
|
// 获取图片验证码
|
|
|
|
|
|
Future<SafetyVerificationEntity> getSliderVerifyImg(
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String countryCode, String account) async {
|
2023-07-29 18:33:48 +08:00
|
|
|
|
final res = await apiProvider.getSliderVerifyImg(countryCode, account);
|
|
|
|
|
|
return SafetyVerificationEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-02 09:22:39 +08:00
|
|
|
|
// 检验图片验证码
|
|
|
|
|
|
Future<CheckSafetyVerificationEntity> checkSliderVerifyImg(
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String countryCode, String account, String xWidth) async {
|
|
|
|
|
|
final res =
|
|
|
|
|
|
await apiProvider.checkSliderVerifyImg(countryCode, account, xWidth);
|
2023-07-29 18:33:48 +08:00
|
|
|
|
return CheckSafetyVerificationEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-07 10:32:24 +08:00
|
|
|
|
Future<LoginEntity> login(String loginType, String password,
|
|
|
|
|
|
String countryCode, String username) async {
|
|
|
|
|
|
final res =
|
|
|
|
|
|
await apiProvider.login(loginType, password, countryCode, username);
|
2023-08-02 09:22:39 +08:00
|
|
|
|
return LoginEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
2023-07-27 15:29:37 +08:00
|
|
|
|
|
2023-08-07 10:32:24 +08:00
|
|
|
|
//重置密码
|
|
|
|
|
|
Future<LoginEntity> 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);
|
|
|
|
|
|
}
|
2023-07-27 15:29:37 +08:00
|
|
|
|
}
|