Externalized API and models as own package

This commit is contained in:
Anton Stubenbord
2022-12-02 01:48:13 +01:00
parent 60d1a2e62a
commit ec7707e4a4
143 changed files with 1496 additions and 1339 deletions

View File

@@ -1,55 +0,0 @@
class ErrorMessage implements Exception {
final ErrorCode code;
final String? details;
final StackTrace? stackTrace;
final int? httpStatusCode;
const ErrorMessage(
this.code, {
this.details,
this.stackTrace,
this.httpStatusCode,
});
const ErrorMessage.unknown() : this(ErrorCode.unknown);
@override
String toString() {
return "ErrorMessage(code: $code${stackTrace != null ? ', stackTrace: ${stackTrace.toString()}' : ''}${httpStatusCode != null ? ', httpStatusCode: $httpStatusCode' : ''})";
}
}
enum ErrorCode {
unknown,
authenticationFailed,
notAuthenticated,
documentUploadFailed,
documentUpdateFailed,
documentLoadFailed,
documentDeleteFailed,
documentBulkActionFailed,
documentPreviewFailed,
documentAsnQueryFailed,
tagCreateFailed,
tagLoadFailed,
documentTypeCreateFailed,
documentTypeLoadFailed,
correspondentCreateFailed,
correspondentLoadFailed,
scanRemoveFailed,
invalidClientCertificateConfiguration,
biometricsNotSupported,
biometricAuthenticationFailed,
deviceOffline,
serverUnreachable,
similarQueryError,
autocompleteQueryError,
storagePathLoadFailed,
storagePathCreateFailed,
loadSavedViewsError,
createSavedViewError,
deleteSavedViewError,
requestTimedOut,
unsupportedFileFormat,
missingClientCertificate;
}

View File

@@ -1,15 +0,0 @@
class PaperlessServerInformation {
static const String versionHeader = 'x-version';
static const String apiVersionHeader = 'x-api-version';
static const String hostHeader = 'x-served-by';
final String? version;
final int? apiVersion;
final String? username;
final String? host;
PaperlessServerInformation({
this.host,
this.username,
this.version = 'unknown',
this.apiVersion = 1,
});
}

View File

@@ -1,15 +0,0 @@
import 'package:paperless_mobile/core/type/types.dart';
class PaperlessStatistics {
final int documentsTotal;
final int documentsInInbox;
PaperlessStatistics({
required this.documentsTotal,
required this.documentsInInbox,
});
PaperlessStatistics.fromJson(JSON json)
: documentsTotal = json['documents_total'],
documentsInInbox = json['documents_inbox'];
}

View File

@@ -1,8 +1,8 @@
import 'package:paperless_mobile/core/model/paperless_statistics.dart';
import 'package:paperless_api/paperless_api.dart';
class PaperlessStatisticsState {
final bool isLoaded;
final PaperlessStatistics? statistics;
final PaperlessServerStatisticsModel? statistics;
PaperlessStatisticsState({
required this.isLoaded,