42 lines
864 B
Dart
42 lines
864 B
Dart
class User {
|
|
final int id;
|
|
final String email;
|
|
final String nome;
|
|
final String cognome;
|
|
final String ruolo;
|
|
final int clienteId;
|
|
|
|
User({
|
|
required this.id,
|
|
required this.email,
|
|
required this.nome,
|
|
required this.cognome,
|
|
required this.ruolo,
|
|
required this.clienteId,
|
|
});
|
|
|
|
factory User.fromJson(Map<String, dynamic> json) {
|
|
return User(
|
|
id: json['id'] as int,
|
|
email: json['email'] as String,
|
|
nome: json['nome'] as String,
|
|
cognome: json['cognome'] as String,
|
|
ruolo: json['ruolo'] as String,
|
|
clienteId: json['cliente_id'] as int,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'email': email,
|
|
'nome': nome,
|
|
'cognome': cognome,
|
|
'ruolo': ruolo,
|
|
'cliente_id': clienteId,
|
|
};
|
|
}
|
|
|
|
String get nomeCompleto => '$nome $cognome';
|
|
}
|