Initial commit

This commit is contained in:
jahongireshonqulov
2025-10-18 09:40:06 +05:00
commit 1bf3e41abe
352 changed files with 16315 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
import 'package:cargocalculaterapp/core/error/failure.dart';
import 'package:cargocalculaterapp/features/auth/data/model/auth_verification_request.dart';
import 'package:cargocalculaterapp/features/auth/data/model/auth_verification_response.dart';
import 'package:cargocalculaterapp/features/auth/data/model/fcm_add_request.dart';
import 'package:cargocalculaterapp/features/auth/data/model/fcm_add_response.dart';
import 'package:cargocalculaterapp/features/auth/data/model/login_request.dart';
import 'package:cargocalculaterapp/features/auth/data/model/login_response.dart';
import 'package:cargocalculaterapp/features/auth/data/model/sign_up_request.dart';
import 'package:cargocalculaterapp/features/auth/data/model/sign_up_response.dart';
import 'package:dartz/dartz.dart';
import '../../../../core/error/exceptions.dart';
import '../../domain/repository/auth_repository.dart';
import '../data_source/remote/auth_remote_data_source.dart';
class AuthRepositoryImpl extends AuthRepository {
final AuthRemoteDataSource remoteDataSource;
AuthRepositoryImpl(this.remoteDataSource);
@override
Future<Either<Failure, LoginResponse>> login(LoginRequest request) async {
try {
final response = await remoteDataSource.login(request);
return Right(response);
} catch (e) {
if (e is ServerException) {
return Left(ServerFailure(message: e.message));
}
return Left(ServerFailure(message: e.toString()));
}
}
@override
Future<Either<Failure, SignUpResponse>> signUp(SignUpRequest request) async {
try {
final response = await remoteDataSource.signUp(request);
return Right(response);
} catch (e) {
if (e is ServerException) {
return Left(ServerFailure(message: e.message));
}
return Left(ServerFailure(message: e.toString()));
}
}
@override
Future<Either<Failure, AuthVerificationResponse>> verify(
AuthVerificationRequest request,
) async {
try {
final response = await remoteDataSource.verify(request);
return Right(response);
} catch (e) {
if (e is ServerException) {
return Left(ServerFailure(message: e.message));
}
return Left(ServerFailure(message: e.toString()));
}
}
@override
Future<Either<Failure, FcmAddResponse>> fcmAdd(FcmAddRequest request) async {
try {
final response = await remoteDataSource.addFcm(request);
return Right(response);
} catch (e) {
if (e is ServerException) {
return Left(ServerFailure(message: e.message));
}
return Left(ServerFailure(message: e.toString()));
}
}
}