/// Sample Project Repository Implementation
///
/// Implements the sample project repository interface.
library;

import 'package:worker/features/showrooms/data/datasources/sample_project_remote_datasource.dart';
import 'package:worker/features/showrooms/domain/entities/sample_project.dart';
import 'package:worker/features/showrooms/domain/repositories/sample_project_repository.dart';

/// Sample Project Repository Implementation
class SampleProjectRepositoryImpl implements SampleProjectRepository {
  const SampleProjectRepositoryImpl(this._remoteDataSource);

  final SampleProjectRemoteDataSource _remoteDataSource;

  @override
  Future<List<SampleProject>> getSampleProjects({
    int limitStart = 0,
    int limitPageLength = 0,
  }) async {
    try {
      final models = await _remoteDataSource.getSampleProjects(
        limitStart: limitStart,
        limitPageLength: limitPageLength,
      );
      return models.map((model) => model.toEntity()).toList();
    } catch (e) {
      rethrow;
    }
  }

  @override
  Future<SampleProject> getSampleProjectDetail(String name) async {
    try {
      final model = await _remoteDataSource.getSampleProjectDetail(name);
      return model.toEntity();
    } catch (e) {
      rethrow;
    }
  }
}
