import 'package:dio/dio.dart';
import '../../domain/repositories/akinator_repository.dart';
import '../datasources/akinator_remote_datasource.dart';

class AkinatorRepositoryImpl implements AkinatorRepository {
  final AkinatorRemoteDatasource remote;

  AkinatorRepositoryImpl(this.remote);

  @override
  Future<AkinatorResponseModel> predict({
    required String sessionId,
    required String message,
    bool panelMode = false,
    String? knowledgeBaseId,
  }) async {
    try {
      return await remote.predict(
        sessionId: sessionId,
        message: message,
        panelMode: panelMode,
        knowledgeBaseId: knowledgeBaseId,
      );
    } on DioException catch (e) {
      throw e.error ?? e;
    }
  }
}