mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 08:07:56 -06:00
Added server address validation, success message, localization
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:paperless_api/src/models/paperless_server_exception.dart';
|
||||
import 'package:paperless_api/src/modules/authentication_api/authentication_api.dart';
|
||||
@@ -12,7 +14,6 @@ class PaperlessAuthenticationApiImpl implements PaperlessAuthenticationApi {
|
||||
required String username,
|
||||
required String password,
|
||||
}) async {
|
||||
print(client.hashCode);
|
||||
late Response response;
|
||||
try {
|
||||
response = await client.post(
|
||||
@@ -29,7 +30,11 @@ class PaperlessAuthenticationApiImpl implements PaperlessAuthenticationApi {
|
||||
httpStatusCode: error.response?.statusCode,
|
||||
);
|
||||
} else {
|
||||
throw error.error;
|
||||
log(error.message);
|
||||
throw PaperlessServerException(
|
||||
ErrorCode.authenticationFailed,
|
||||
details: error.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ class PaperlessLabelApiImpl implements PaperlessLabelsApi {
|
||||
data: path.toJson(),
|
||||
);
|
||||
if (response.statusCode == HttpStatus.created) {
|
||||
return StoragePath.fromJson(jsonDecode(response.data));
|
||||
return StoragePath.fromJson(response.data);
|
||||
}
|
||||
throw PaperlessServerException(ErrorCode.storagePathCreateFailed,
|
||||
httpStatusCode: response.statusCode);
|
||||
@@ -282,7 +282,7 @@ class PaperlessLabelApiImpl implements PaperlessLabelsApi {
|
||||
data: path.toJson(),
|
||||
);
|
||||
if (response.statusCode == HttpStatus.ok) {
|
||||
return StoragePath.fromJson(jsonDecode(response.data));
|
||||
return StoragePath.fromJson(response.data);
|
||||
}
|
||||
throw const PaperlessServerException(ErrorCode.unknown);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user