import '../../domain/entities/server.dart';
import '../../domain/repositories/servers_repository.dart';
import '../datasources/servers_datasource.dart';

class ServersRepositoryImpl implements ServersRepository {
  final ServersDatasource _datasource;

  ServersRepositoryImpl(this._datasource);

  @override
  Future<List<Server>> getAll({String? environment, String? status}) async {
    final models = await _datasource.fetchAll(
      environment: environment,
      status: status,
    );
    return models.map((m) => m.toEntity()).toList();
  }

  @override
  Future<Server> getById(String id) async {
    final model = await _datasource.fetchById(id);
    return model.toEntity();
  }
}
