71 lines
1.8 KiB
Dart
71 lines
1.8 KiB
Dart
|
|
import 'package:equatable/equatable.dart';
|
||
|
|
|
||
|
|
class EntertainmentServiceModel extends Equatable {
|
||
|
|
final String? id;
|
||
|
|
final DateTime? createdAt;
|
||
|
|
final String type; // es. Sky, DAZN, ecc.
|
||
|
|
final bool constrained; // Vincolato?
|
||
|
|
final DateTime constrainExpiration;
|
||
|
|
final String? serviceId;
|
||
|
|
|
||
|
|
const EntertainmentServiceModel({
|
||
|
|
this.id,
|
||
|
|
this.createdAt,
|
||
|
|
required this.type,
|
||
|
|
required this.constrained,
|
||
|
|
required this.constrainExpiration,
|
||
|
|
this.serviceId,
|
||
|
|
});
|
||
|
|
|
||
|
|
EntertainmentServiceModel copyWith({
|
||
|
|
String? id,
|
||
|
|
DateTime? createdAt,
|
||
|
|
String? type,
|
||
|
|
bool? constrained,
|
||
|
|
DateTime? constrainExpiration,
|
||
|
|
String? serviceId,
|
||
|
|
}) {
|
||
|
|
return EntertainmentServiceModel(
|
||
|
|
id: id ?? this.id,
|
||
|
|
createdAt: createdAt ?? this.createdAt,
|
||
|
|
type: type ?? this.type,
|
||
|
|
constrained: constrained ?? this.constrained,
|
||
|
|
constrainExpiration: constrainExpiration ?? this.constrainExpiration,
|
||
|
|
serviceId: serviceId ?? this.serviceId,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
List<Object?> get props => [
|
||
|
|
id,
|
||
|
|
createdAt,
|
||
|
|
type,
|
||
|
|
constrained,
|
||
|
|
constrainExpiration,
|
||
|
|
serviceId,
|
||
|
|
];
|
||
|
|
|
||
|
|
factory EntertainmentServiceModel.fromMap(Map<String, dynamic> map) {
|
||
|
|
return EntertainmentServiceModel(
|
||
|
|
id: map['id'],
|
||
|
|
createdAt: map['created_at'] != null
|
||
|
|
? DateTime.parse(map['created_at'])
|
||
|
|
: null,
|
||
|
|
type: map['type'],
|
||
|
|
constrained: map['constrained'] ?? false,
|
||
|
|
constrainExpiration: DateTime.parse(map['constrain_expiration']),
|
||
|
|
serviceId: map['service_id'],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Map<String, dynamic> toMap() {
|
||
|
|
return {
|
||
|
|
if (id != null) 'id': id,
|
||
|
|
'type': type,
|
||
|
|
'constrained': constrained,
|
||
|
|
'constrain_expiration': constrainExpiration.toIso8601String(),
|
||
|
|
'service_id': serviceId,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|