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 {
try {
final response = await _httpService.get(
path: 'endpoint',
queryParameters: {
'spaceUuid': param.spaceUuid,
'date': param.date.toIso8601String(),
},
path: '/aqi/range/space/${param.spaceUuid}',
queryParameters: {'monthDate': _formatDate(param.date)},
expectedResponseModel: (data) {
final json = data as Map<String, dynamic>? ?? {};
final mappedData = json['data'] as List<dynamic>? ?? [];
@ -28,7 +25,11 @@ final class RemoteRangeOfAqiService implements RangeOfAqiService {
);
return response;
} 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')}';
}
}