mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Refactor RemoteRangeOfAqiService to update API endpoint to match what the actual endpoint is.
This commit is contained in:
@ -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')}';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user