feat : new auth in chicken

This commit is contained in:
2025-08-02 15:09:06 +03:30
parent fae6703d8d
commit 8b698a8498
27 changed files with 1115 additions and 109 deletions

View File

@@ -0,0 +1,13 @@
import 'package:rasadyar_chicken/data/models/response/captcha/captcha_response_model.dart';
import 'package:rasadyar_chicken/data/models/response/user_info/user_info_model.dart';
import 'package:rasadyar_chicken/data/models/response/user_profile_model/user_profile_model.dart';
abstract class AuthRemoteDataSource {
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest});
Future<void> logout();
Future<bool> hasAuthenticated();
Future<UserInfoModel?> getUserInfo(String phoneNumber);
}

View File

@@ -0,0 +1,50 @@
import 'package:rasadyar_chicken/data/models/response/user_info/user_info_model.dart';
import 'package:rasadyar_chicken/data/models/response/user_profile_model/user_profile_model.dart';
import 'package:rasadyar_core/core.dart';
import 'auth_remote.dart';
class AuthRemoteDataSourceImp extends AuthRemoteDataSource {
final DioRemote _httpClient;
final String _BASE_URL = 'auth/api/v1/';
AuthRemoteDataSourceImp(this._httpClient);
@override
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest}) async {
var res = await _httpClient.post<UserProfileModel?>(
'/api/login/',
data: authRequest,
fromJson: UserProfileModel.fromJson,
headers: {'Content-Type': 'application/json'},
);
return res.data;
}
@override
Future<void> logout() {
// TODO: implement logout
throw UnimplementedError();
}
@override
Future<bool> hasAuthenticated() async {
final response = await _httpClient.get<bool>(
'$_BASE_URL/login/',
headers: {'Content-Type': 'application/json'},
);
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;
}
}