58 lines
1.4 KiB
Dart
58 lines
1.4 KiB
Dart
|
|
import 'package:equatable/equatable.dart';
|
||
|
|
|
||
|
|
class FinServiceModel extends Equatable {
|
||
|
|
final String? id;
|
||
|
|
final DateTime? createdAt;
|
||
|
|
final DateTime expiration;
|
||
|
|
final String? serviceId;
|
||
|
|
final String? modelId; // FK verso model (es. iPhone, Samsung, ecc.)
|
||
|
|
|
||
|
|
const FinServiceModel({
|
||
|
|
this.id,
|
||
|
|
this.createdAt,
|
||
|
|
required this.expiration,
|
||
|
|
this.serviceId,
|
||
|
|
this.modelId,
|
||
|
|
});
|
||
|
|
|
||
|
|
FinServiceModel copyWith({
|
||
|
|
String? id,
|
||
|
|
DateTime? createdAt,
|
||
|
|
DateTime? expiration,
|
||
|
|
String? serviceId,
|
||
|
|
String? modelId,
|
||
|
|
}) {
|
||
|
|
return FinServiceModel(
|
||
|
|
id: id ?? this.id,
|
||
|
|
createdAt: createdAt ?? this.createdAt,
|
||
|
|
expiration: expiration ?? this.expiration,
|
||
|
|
serviceId: serviceId ?? this.serviceId,
|
||
|
|
modelId: modelId ?? this.modelId,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
List<Object?> get props => [id, createdAt, expiration, serviceId, modelId];
|
||
|
|
|
||
|
|
factory FinServiceModel.fromMap(Map<String, dynamic> map) {
|
||
|
|
return FinServiceModel(
|
||
|
|
id: map['id'],
|
||
|
|
createdAt: map['created_at'] != null
|
||
|
|
? DateTime.parse(map['created_at'])
|
||
|
|
: null,
|
||
|
|
expiration: DateTime.parse(map['expiration']),
|
||
|
|
serviceId: map['service_id'],
|
||
|
|
modelId: map['model_id'],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Map<String, dynamic> toMap() {
|
||
|
|
return {
|
||
|
|
if (id != null) 'id': id,
|
||
|
|
'expiration': expiration.toIso8601String(),
|
||
|
|
'service_id': serviceId,
|
||
|
|
'model_id': modelId,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|