feat : auth for new module
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
|
||||
import 'package:rasadyar_auth/data/models/response/user_info/user_info_model.dart';
|
||||
|
||||
import '../models/response/auth/auth_response_model.dart';
|
||||
import '../models/response/captcha/captcha_response_model.dart';
|
||||
import '../models/response/user_profile_model/user_profile_model.dart';
|
||||
|
||||
abstract class AuthRepository {
|
||||
Future<AuthResponseModel?> login({
|
||||
required Map<String, dynamic> authRequest,
|
||||
});
|
||||
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest});
|
||||
|
||||
Future<CaptchaResponseModel?> captcha();
|
||||
|
||||
@@ -14,10 +13,9 @@ abstract class AuthRepository {
|
||||
|
||||
Future<bool> hasAuthenticated();
|
||||
|
||||
|
||||
Future<AuthResponseModel?> loginWithRefreshToken({
|
||||
required Map<String, dynamic> authRequest,
|
||||
});
|
||||
|
||||
|
||||
Future<UserInfoModel?> getUserInfo(String phoneNumber);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:rasadyar_auth/data/models/response/user_info/user_info_model.dart';
|
||||
import 'package:rasadyar_auth/data/models/response/user_profile_model/user_profile_model.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../models/response/auth/auth_response_model.dart';
|
||||
@@ -11,13 +13,13 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
AuthRepositoryImpl(this._httpClient);
|
||||
|
||||
@override
|
||||
Future<AuthResponseModel?> login({
|
||||
Future<UserProfileModel?> login({
|
||||
required Map<String, dynamic> authRequest,
|
||||
}) async {
|
||||
var res = await _httpClient.post<AuthResponseModel>(
|
||||
'$_BASE_URL/login/',
|
||||
var res = await _httpClient.post<UserProfileModel?>(
|
||||
'/api/login/',
|
||||
data: authRequest,
|
||||
fromJson: AuthResponseModel.fromJson,
|
||||
fromJson: UserProfileModel.fromJson,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
return res.data;
|
||||
@@ -59,4 +61,19 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
|
||||
return response.data ?? false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UserInfoModel?> getUserInfo(String phoneNumber) async {
|
||||
var res = await _httpClient.post<UserInfoModel?>(
|
||||
'https://userbackend.rasadyaar.ir/api/send_otp/',
|
||||
data: {
|
||||
"mobile": phoneNumber,
|
||||
"state": ""
|
||||
},
|
||||
fromJson: UserInfoModel.fromJson,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
return res.data;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user