feat : login api call
This commit is contained in:
@@ -14,64 +14,34 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
Future<AuthResponseModel?> login({
|
||||
required Map<String, dynamic> authRequest,
|
||||
}) async {
|
||||
final response = await safeCall<DioResponse<AuthResponseModel>>(
|
||||
call:
|
||||
() async => await _httpClient.post<AuthResponseModel>(
|
||||
'$_BASE_URL/login/',
|
||||
data: authRequest,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
),
|
||||
onSuccess: (response) {
|
||||
iLog(response);
|
||||
},
|
||||
onError: (error, trace) {
|
||||
throw Exception('Error during sign in: $error');
|
||||
},
|
||||
var res = await _httpClient.post<AuthResponseModel>(
|
||||
'$_BASE_URL/login/',
|
||||
data: authRequest,
|
||||
fromJson: AuthResponseModel.fromJson,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
|
||||
return response?.data;
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CaptchaResponseModel?> captcha() async {
|
||||
final response = await safeCall<CaptchaResponseModel?>(
|
||||
call: () async {
|
||||
var res = await _httpClient.post<CaptchaResponseModel?>(
|
||||
'captcha/',
|
||||
fromJson: CaptchaResponseModel.fromJson,
|
||||
);
|
||||
return res.data;
|
||||
},
|
||||
onSuccess: (response) {
|
||||
return response;
|
||||
},
|
||||
onError: (error, trace) {
|
||||
throw Exception('Error during captcha : $error');
|
||||
},
|
||||
var res = await _httpClient.post<CaptchaResponseModel?>(
|
||||
'captcha/',
|
||||
fromJson: CaptchaResponseModel.fromJson,
|
||||
);
|
||||
return response;
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<AuthResponseModel?> loginWithRefreshToken({
|
||||
required Map<String, dynamic> authRequest,
|
||||
}) async {
|
||||
final response = await safeCall<DioResponse<AuthResponseModel>>(
|
||||
call:
|
||||
() async => await _httpClient.post<AuthResponseModel>(
|
||||
'$_BASE_URL/login/',
|
||||
data: authRequest,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
),
|
||||
onSuccess: (response) {
|
||||
iLog(response);
|
||||
},
|
||||
onError: (error, trace) {
|
||||
throw Exception('Error during sign in: $error');
|
||||
},
|
||||
var res = await _httpClient.post<AuthResponseModel>(
|
||||
'$_BASE_URL/login/',
|
||||
data: authRequest,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
|
||||
return response?.data;
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -82,20 +52,11 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
|
||||
@override
|
||||
Future<bool> hasAuthenticated() async {
|
||||
final response = await safeCall<DioResponse<bool>>(
|
||||
call:
|
||||
() async => await _httpClient.get<bool>(
|
||||
'$_BASE_URL/login/',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
),
|
||||
onSuccess: (response) {
|
||||
iLog(response);
|
||||
},
|
||||
onError: (error, trace) {
|
||||
throw Exception('Error during sign in: $error');
|
||||
},
|
||||
final response = await _httpClient.get<bool>(
|
||||
'$_BASE_URL/login/',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
|
||||
return response?.data ?? false;
|
||||
return response.data ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user