maremma maiala impestata, buonissima base dopo ultra refactor
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
enum EnergyType { luce, gas } // Mappa il tuo public.energy_type
|
||||
|
||||
class EnergyOperationModel extends Equatable {
|
||||
final String? id;
|
||||
final DateTime? createdAt;
|
||||
final EnergyType type;
|
||||
final DateTime expiration;
|
||||
final String providerId;
|
||||
final String? operationId;
|
||||
|
||||
const EnergyOperationModel({
|
||||
this.id,
|
||||
this.createdAt,
|
||||
required this.type,
|
||||
required this.expiration,
|
||||
required this.providerId,
|
||||
this.operationId,
|
||||
});
|
||||
|
||||
EnergyOperationModel copyWith({
|
||||
String? id,
|
||||
DateTime? createdAt,
|
||||
EnergyType? type,
|
||||
DateTime? expiration,
|
||||
String? providerId,
|
||||
String? operationId,
|
||||
}) {
|
||||
return EnergyOperationModel(
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
type: type ?? this.type,
|
||||
expiration: expiration ?? this.expiration,
|
||||
providerId: providerId ?? this.providerId,
|
||||
operationId: operationId ?? this.operationId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
createdAt,
|
||||
type,
|
||||
expiration,
|
||||
providerId,
|
||||
operationId,
|
||||
];
|
||||
|
||||
factory EnergyOperationModel.fromMap(Map<String, dynamic> map) {
|
||||
return EnergyOperationModel(
|
||||
id: map['id'],
|
||||
createdAt: map['created_at'] != null
|
||||
? DateTime.parse(map['created_at'])
|
||||
: null,
|
||||
type: map['type'] == 'gas' ? EnergyType.gas : EnergyType.luce,
|
||||
expiration: DateTime.parse(map['expiration']),
|
||||
providerId: map['provider_id'],
|
||||
operationId: map['operation_id'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'type': type.name, // .name trasforma l'enum in 'luce' o 'gas'
|
||||
'expiration': expiration.toIso8601String(),
|
||||
'provider_id': providerId,
|
||||
'operation_id': operationId,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class EntertainmentOperationModel extends Equatable {
|
||||
final String? id;
|
||||
final DateTime? createdAt;
|
||||
final String type; // es. Sky, DAZN, ecc.
|
||||
final bool constrained; // Vincolato?
|
||||
final DateTime constrainExpiration;
|
||||
final String? operationId;
|
||||
final String? providerId;
|
||||
|
||||
const EntertainmentOperationModel({
|
||||
this.id,
|
||||
this.createdAt,
|
||||
required this.type,
|
||||
required this.constrained,
|
||||
required this.constrainExpiration,
|
||||
this.operationId,
|
||||
this.providerId,
|
||||
});
|
||||
|
||||
EntertainmentOperationModel copyWith({
|
||||
String? id,
|
||||
DateTime? createdAt,
|
||||
String? type,
|
||||
bool? constrained,
|
||||
DateTime? constrainExpiration,
|
||||
String? operationId,
|
||||
String? providerId,
|
||||
}) {
|
||||
return EntertainmentOperationModel(
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
type: type ?? this.type,
|
||||
constrained: constrained ?? this.constrained,
|
||||
constrainExpiration: constrainExpiration ?? this.constrainExpiration,
|
||||
operationId: operationId ?? this.operationId,
|
||||
providerId: providerId ?? this.providerId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
createdAt,
|
||||
type,
|
||||
constrained,
|
||||
constrainExpiration,
|
||||
operationId,
|
||||
providerId,
|
||||
];
|
||||
|
||||
factory EntertainmentOperationModel.fromMap(Map<String, dynamic> map) {
|
||||
return EntertainmentOperationModel(
|
||||
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']),
|
||||
operationId: map['operation_id'],
|
||||
providerId: map['provider_id'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'type': type,
|
||||
'constrained': constrained,
|
||||
'constrain_expiration': constrainExpiration.toIso8601String(),
|
||||
'operation_id': operationId,
|
||||
'provider_id': providerId,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class FinOperationModel extends Equatable {
|
||||
final String? id;
|
||||
final DateTime? createdAt;
|
||||
final DateTime expiration;
|
||||
final String? operationId;
|
||||
final String? modelId; // FK verso model (es. iPhone, Samsung, ecc.)
|
||||
final String? providerId;
|
||||
|
||||
const FinOperationModel({
|
||||
this.id,
|
||||
this.createdAt,
|
||||
required this.expiration,
|
||||
this.operationId,
|
||||
this.modelId,
|
||||
this.providerId,
|
||||
});
|
||||
|
||||
FinOperationModel copyWith({
|
||||
String? id,
|
||||
DateTime? createdAt,
|
||||
DateTime? expiration,
|
||||
String? operationId,
|
||||
String? modelId,
|
||||
String? providerId,
|
||||
}) {
|
||||
return FinOperationModel(
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
expiration: expiration ?? this.expiration,
|
||||
operationId: operationId ?? this.operationId,
|
||||
modelId: modelId ?? this.modelId,
|
||||
providerId: providerId ?? this.providerId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, createdAt, expiration, operationId, modelId];
|
||||
|
||||
factory FinOperationModel.fromMap(Map<String, dynamic> map) {
|
||||
return FinOperationModel(
|
||||
id: map['id'],
|
||||
createdAt: map['created_at'] != null
|
||||
? DateTime.parse(map['created_at'])
|
||||
: null,
|
||||
expiration: DateTime.parse(map['expiration']),
|
||||
operationId: map['operation_id'],
|
||||
modelId: map['model_id'],
|
||||
providerId: map['provider_id'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'expiration': expiration.toIso8601String(),
|
||||
'operation_id': operationId,
|
||||
'model_id': modelId,
|
||||
'provider_id': providerId,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ class OperationModel extends Equatable {
|
||||
final String? id;
|
||||
final DateTime? createdAt;
|
||||
final String type;
|
||||
final String? subType;
|
||||
final String? providerId;
|
||||
final String? providerDisplayName;
|
||||
final String? modelId;
|
||||
@@ -55,6 +56,7 @@ class OperationModel extends Equatable {
|
||||
this.id,
|
||||
this.createdAt,
|
||||
this.type = '',
|
||||
this.subType,
|
||||
this.providerId,
|
||||
this.providerDisplayName,
|
||||
this.modelId,
|
||||
@@ -82,6 +84,7 @@ class OperationModel extends Equatable {
|
||||
String? id,
|
||||
DateTime? createdAt,
|
||||
String? type,
|
||||
String? subtype,
|
||||
String? providerId,
|
||||
String? providerDisplayName,
|
||||
String? modelId,
|
||||
@@ -107,6 +110,7 @@ class OperationModel extends Equatable {
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
type: type ?? this.type,
|
||||
subType: subtype ?? this.subType,
|
||||
providerId: providerId ?? this.providerId,
|
||||
providerDisplayName: providerDisplayName ?? this.providerDisplayName,
|
||||
modelId: modelId ?? this.modelId,
|
||||
@@ -135,6 +139,7 @@ class OperationModel extends Equatable {
|
||||
id,
|
||||
createdAt,
|
||||
type,
|
||||
subType,
|
||||
providerId,
|
||||
providerDisplayName,
|
||||
modelId,
|
||||
@@ -169,6 +174,7 @@ class OperationModel extends Equatable {
|
||||
? DateTime.parse(map['created_at'])
|
||||
: null,
|
||||
type: map['type'] as String? ?? '',
|
||||
subType: map['sub_type'] as String?,
|
||||
providerId: map['provider_id'] as String? ?? '',
|
||||
providerDisplayName: "${map['provider']['name']}".myFormat(),
|
||||
modelId: map['model_id'] as String? ?? '',
|
||||
@@ -206,6 +212,7 @@ class OperationModel extends Equatable {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'type': type,
|
||||
'sub_type': subType,
|
||||
'provider_id': providerId,
|
||||
'model_id': modelId,
|
||||
'description': description,
|
||||
|
||||
Reference in New Issue
Block a user