From 3ae47408aadd6addfc121319a486fcf92d58ce44 Mon Sep 17 00:00:00 2001 From: Valentin REVERSAT Date: Mon, 13 May 2024 15:55:25 +0200 Subject: [PATCH] fix(api): rename 'bateau' to 'bateaux' Following a change into the Bordeaux Metropole API, change the field name to get the boat name from 'bateau' to 'bateaux' --- lib/bloc/forecast/forecast_bloc.dart | 2 +- lib/models/boat_forecast.dart | 2 +- test/units/boat_forecast_test.dart | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/bloc/forecast/forecast_bloc.dart b/lib/bloc/forecast/forecast_bloc.dart index f1f40a54..5186ecc5 100644 --- a/lib/bloc/forecast/forecast_bloc.dart +++ b/lib/bloc/forecast/forecast_bloc.dart @@ -68,7 +68,7 @@ class ForecastBloc extends Bloc { final body = json.decode(response.body); return (body['records'] as List).map((json) { - if (json['fields']['bateau'].toString().toLowerCase() == + if (json['fields']['bateaux'].toString().toLowerCase() == 'maintenance') { final maintenanceForecast = MaintenanceForecast.fromJSON(json); diff --git a/lib/models/boat_forecast.dart b/lib/models/boat_forecast.dart index 5ebb7bb6..327bf2e5 100644 --- a/lib/models/boat_forecast.dart +++ b/lib/models/boat_forecast.dart @@ -61,7 +61,7 @@ class BoatForecast extends AbstractForecast { List boats = []; bool isLeaving = false; - final rawBoatName = json['fields']['bateau'] as String; + final rawBoatName = json['fields']['bateaux'] as String; final boatNames = rawBoatName.split(RegExp(r'/')); for (final boatName in boatNames) { final trimmedBoatName = boatName.trim(); diff --git a/test/units/boat_forecast_test.dart b/test/units/boat_forecast_test.dart index f2ada957..0348f6dc 100644 --- a/test/units/boat_forecast_test.dart +++ b/test/units/boat_forecast_test.dart @@ -49,7 +49,7 @@ void main() { 'recordid': '82c316d304b1adef7eeef9edc9ab7b257f766086', 'fields': { 'fermeture_totale': 'oui', - 'bateau': 'MARITE', + 'bateaux': 'MARITE', 'date_passage': '2023-03-02', 're_ouverture_a_la_circulation': '16:49', 'fermeture_a_la_circulation': '15:49', @@ -62,7 +62,7 @@ void main() { 'recordid': '82c316d304b1adef7eeef9edc9ab7b257f766086', 'fields': { 'fermeture_totale': 'oui', - 'bateau': 'MARITE', + 'bateaux': 'MARITE', 'date_passage': '2023-03-15', 're_ouverture_a_la_circulation': '16:49', 'fermeture_a_la_circulation': '15:49',