mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 20:07:51 -06:00
added initial draft of inbox
This commit is contained in:
29
lib/core/service/paperless_statistics_service.dart
Normal file
29
lib/core/service/paperless_statistics_service.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:paperless_mobile/core/model/error_message.dart';
|
||||
import 'package:paperless_mobile/core/model/paperless_statistics.dart';
|
||||
import 'package:paperless_mobile/core/type/types.dart';
|
||||
|
||||
abstract class PaperlessStatisticsService {
|
||||
Future<PaperlessStatistics> getStatistics();
|
||||
}
|
||||
|
||||
@Injectable(as: PaperlessStatisticsService)
|
||||
class PaperlessStatisticsServiceImpl extends PaperlessStatisticsService {
|
||||
final BaseClient client;
|
||||
|
||||
PaperlessStatisticsServiceImpl(@Named('timeoutClient') this.client);
|
||||
|
||||
@override
|
||||
Future<PaperlessStatistics> getStatistics() async {
|
||||
final response = await client.get(Uri.parse('/api/statistics/'));
|
||||
if (response.statusCode == 200) {
|
||||
return PaperlessStatistics.fromJson(
|
||||
jsonDecode(utf8.decode(response.bodyBytes)) as JSON,
|
||||
);
|
||||
}
|
||||
throw const ErrorMessage.unknown();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user