45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
import 'package:fotodocumentation/dto/picture_dto.dart';
|
|
import 'package:fotodocumentation/utils/date_time_utils.dart';
|
|
|
|
class CustomerListDto {
|
|
final int id;
|
|
final String name;
|
|
final String customerNumber;
|
|
final DateTime? lastUpdateDate;
|
|
|
|
CustomerListDto({required this.id, required this.name, required this.customerNumber, this.lastUpdateDate});
|
|
|
|
/// Create from JSON response
|
|
factory CustomerListDto.fromJson(Map<String, dynamic> json) {
|
|
return CustomerListDto(
|
|
id: json['id'] as int,
|
|
name: json['name'] as String,
|
|
customerNumber: json['customerNumber'] as String,
|
|
lastUpdateDate: DateTimeUtils.toDateTime(json['lastUpdateDate']),
|
|
);
|
|
}
|
|
}
|
|
|
|
class CustomerDto {
|
|
final int id;
|
|
final String name;
|
|
final String customerNumber;
|
|
final String? zip;
|
|
final String? city;
|
|
final List<PictureDto> pictures;
|
|
|
|
CustomerDto({required this.id, required this.name, required this.customerNumber, required this.pictures, this.zip, this.city});
|
|
|
|
/// Create from JSON response
|
|
factory CustomerDto.fromJson(Map<String, dynamic> json) {
|
|
return CustomerDto(
|
|
id: json['id'] as int,
|
|
name: json['name'] as String,
|
|
customerNumber: json['customerNumber'] as String,
|
|
zip: json['zip'] as String?,
|
|
city: json['city'] as String?,
|
|
pictures: List<PictureDto>.from(json["pictures"].map((x) => PictureDto.fromJson(x))),
|
|
);
|
|
}
|
|
}
|