import 'package:dio/dio.dart';
import '../../domain/repositories/generator_repository.dart';
import '../datasources/generator_remote_datasource.dart';

class GeneratorRepositoryImpl implements GeneratorRepository {
  final GeneratorRemoteDatasource remote;

  GeneratorRepositoryImpl(this.remote);

  @override
  Future<GenerateResultModel> generate({
    required String stockSymbol,
    required int zscoreWindow,
    required double zscoreTriggerMin,
    required double zscoreTriggerMax,
    String? knowledgeBaseId,
  }) async {
    try {
      return await remote.generate(
        stockSymbol: stockSymbol,
        zscoreWindow: zscoreWindow,
        zscoreTriggerMin: zscoreTriggerMin,
        zscoreTriggerMax: zscoreTriggerMax,
        knowledgeBaseId: knowledgeBaseId,
      );
    } on DioException catch (e) {
      throw e.error ?? e;
    }
  }
}