import 'package:dio/dio.dart';
import '../../domain/repositories/scenario_repository.dart';
import '../datasources/scenario_remote_datasource.dart';

class ScenarioRepositoryImpl implements ScenarioRepository {
  final ScenarioRemoteDatasource remote;

  ScenarioRepositoryImpl(this.remote);

  @override
  Future<ScenarioPageModel> getScenarios({
    int page = 1,
    int limit = 12,
    String? difficulty,
    String? category,
    String? risk,
  }) async {
    try {
      return await remote.getScenarios(
        page: page,
        limit: limit,
        difficulty: difficulty,
        category: category,
        risk: risk,
      );
    } on DioException catch (e) {
      throw e.error ?? e;
    }
  }

  @override
  Future<ScenarioDetailModel> getDetail(String id) async {
    try {
      return await remote.getDetail(id);
    } on DioException catch (e) {
      throw e.error ?? e;
    }
  }
}