Refactor RemoteRangeOfAqiService to update API endpoint to match what the actual endpoint is.

This commit is contained in:
Faris Armoush
2025-06-16 09:29:31 +03:00
parent 5b3152e833
commit 5591c78d88

View File

@ -12,11 +12,8 @@ final class RemoteRangeOfAqiService implements RangeOfAqiService {
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param) async { Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param) async {
try { try {
final response = await _httpService.get( final response = await _httpService.get(
path: 'endpoint', path: '/aqi/range/space/${param.spaceUuid}',
queryParameters: { queryParameters: {'monthDate': _formatDate(param.date)},
'spaceUuid': param.spaceUuid,
'date': param.date.toIso8601String(),
},
expectedResponseModel: (data) { expectedResponseModel: (data) {
final json = data as Map<String, dynamic>? ?? {}; final json = data as Map<String, dynamic>? ?? {};
final mappedData = json['data'] as List<dynamic>? ?? []; final mappedData = json['data'] as List<dynamic>? ?? [];
@ -28,7 +25,11 @@ final class RemoteRangeOfAqiService implements RangeOfAqiService {
); );
return response; return response;
} catch (e) { } catch (e) {
throw Exception('Failed to load energy consumption per phase: $e'); throw Exception('Failed to load range of aqi: $e');
} }
} }
static String _formatDate(DateTime date) {
return '${date.year}-${date.month.toString().padLeft(2, '0')}';
}
} }