cleanup and added unit tests

This commit is contained in:
verboomp
2026-01-27 14:09:12 +01:00
parent 3d456128b1
commit e4b2dd0462
42 changed files with 1467 additions and 977 deletions

View File

@@ -8,8 +8,3 @@ final class ErrorDto {
: error = json['error'] as int,
message = json['message'];
}
abstract interface class DtoMapAble {
Map<String, dynamic> toMap();
}

View File

@@ -1,3 +1,4 @@
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/utils/date_time_utils.dart';
class CustomerListDto {
@@ -38,28 +39,4 @@ class CustomerDto {
}
}
class PictureDto {
final int id;
final String? comment;
final String? category;
final String image;
final DateTime pictureDate;
final String? username;
final CustomerListDto customerListDto;
PictureDto(
{required this.id, required this.comment, required this.category, required this.image, required this.pictureDate, required this.username, required this.customerListDto});
/// Create from JSON response
factory PictureDto.fromJson(Map<String, dynamic> json) {
return PictureDto(
id: json['id'] as int,
comment: json['comment'] as String?,
category: json['category'] as String?,
image: json['image'] as String,
pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
username: json['username'] as String?,
customerListDto: CustomerListDto.fromJson(json['customer']),
);
}
}

View File

@@ -1,21 +1,3 @@
/// DTO representing a failes login attempt request for 2fa token.
class TokenRequiredDto {
final bool? tokenRequired;
final bool? tokenInValid;
TokenRequiredDto({
required this.tokenRequired,
required this.tokenInValid,
});
/// Create from JSON response
factory TokenRequiredDto.fromJson(Map<String, dynamic> json) {
return TokenRequiredDto(
tokenRequired: json['tokenRequired'] as bool,
tokenInValid: json['tokenInValid'] as bool,
);
}
}
/// DTO representing a pair of JWT tokens from the backend.
class JwtTokenPairDto {
@@ -35,14 +17,6 @@ class JwtTokenPairDto {
);
}
/// Convert to JSON (for serialization if needed)
Map<String, dynamic> toJson() {
return {
'accessToken': accessToken,
'refreshToken': refreshToken,
};
}
@override
String toString() {
return 'JwtTokenPairDto{accessToken: [REDACTED], refreshToken: [REDACTED]}';

View File

@@ -0,0 +1,25 @@
import 'package:fotodocumentation/utils/date_time_utils.dart';
class PictureDto {
final int id;
final String? comment;
final String? category;
final String image;
final DateTime pictureDate;
final String? username;
PictureDto(
{required this.id, required this.comment, required this.category, required this.image, required this.pictureDate, required this.username});
/// Create from JSON response
factory PictureDto.fromJson(Map<String, dynamic> json) {
return PictureDto(
id: json['id'] as int,
comment: json['comment'] as String?,
category: json['category'] as String?,
image: json['image'] as String,
pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
username: json['username'] as String?
);
}
}