import 'package:dartz/dartz.dart';
import 'package:afterwork/domain/entities/user.dart';
import 'package:afterwork/domain/repositories/user_repository.dart';
import 'package:afterwork/core/errors/failures.dart';

class GetUser {
  final UserRepository repository;

  GetUser(this.repository);

  Future<Either<Failure, User>> call(String id) async {
    try {
      final user = await repository.getUser(id);
      return Right(user);
    } catch (e) {
      return Left(ServerFailure());
    }
  }
}
