LCOV - code coverage report
Current view: top level - lib/api/routes - exercises.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 25 0
Test Date: 2025-05-10 20:26:13 Functions: - 0 0

            Line data    Source code
       1              : import 'package:amadeus_proto/api/utils/api_base.dart';
       2              : import 'package:amadeus_proto/api/utils/api_error.dart';
       3              : import 'package:amadeus_proto/api/models/exercise_info.dart';
       4              : import 'package:amadeus_proto/pages/language/language_provider.dart';
       5              : import 'package:either_dart/either.dart';
       6              : import 'package:provider/provider.dart';
       7              : 
       8              : extension Exercises on ApiBase {
       9              :   static const String _exercisesRoutesPrefix = "/exercises";
      10              : 
      11            0 :   Future<Either<ApiError, Map<String, dynamic>>> getUserExercise() =>
      12            0 :       get("$_exercisesRoutesPrefix/me", (json) => json as Map<String, dynamic>);
      13              : 
      14            0 :   Future<Either<ApiError, Map<String, dynamic>>> completeExercise(String id) =>
      15            0 :       patch(
      16              :           "$_exercisesRoutesPrefix/complete",
      17            0 :           queryParameters: {"exerciseID": id},
      18            0 :           (json) => json as Map<String, dynamic>);
      19              : 
      20            0 :   Future<Either<ApiError, List<ExerciseInfo>>> getExercisesByType(
      21              :           String category, String? type) =>
      22            0 :       get(
      23              :           "$_exercisesRoutesPrefix/by-category-and-type",
      24            0 :           queryParameters: {
      25            0 :             "exerciseCategory": category,
      26            0 :             if (type != null) "exerciseType": type
      27              :           },
      28            0 :           (json) => (json as List<dynamic>)
      29            0 :               .map((e) => ExerciseInfo.fromJson(e as Map<String, dynamic>))
      30            0 :               .toList());
      31              : 
      32            0 :   Future<Either<ApiError, void>> assignExercise(String id) => put(
      33              :       "$_exercisesRoutesPrefix/assign",
      34            0 :       queryParameters: {"exerciseID": id},
      35            0 :       (_) {});
      36              : 
      37            0 :   Future<Either<ApiError, void>> unassignExercise(String id) => delete(
      38              :       "$_exercisesRoutesPrefix/assign",
      39            0 :       queryParameters: {"exerciseID": id},
      40            0 :       (_) {});
      41              : 
      42            0 :   Future<Either<ApiError, dynamic>> getExercise(String id) => get(
      43            0 :         "$_exercisesRoutesPrefix/$id",
      44            0 :         queryParameters: {
      45              :           "language":
      46            0 :               context?.read<LanguageProvider>().locale?.languageCode ?? "fr"
      47              :         },
      48            0 :         (json) => json,
      49              :       );
      50              : }
        

Generated by: LCOV version 2.3-1