25 lines
562 B
Dart
25 lines
562 B
Dart
class Customer {
|
|
const Customer({
|
|
required this.id,
|
|
required this.name,
|
|
required this.documentMasked,
|
|
});
|
|
|
|
final int id;
|
|
final String name;
|
|
final String documentMasked;
|
|
|
|
factory Customer.fromJson(Map<String, dynamic> json) {
|
|
final id = json['id'];
|
|
final name = json['name'];
|
|
if (id is! num || name is! String) {
|
|
throw const FormatException('Resposta de cliente inválida.');
|
|
}
|
|
return Customer(
|
|
id: id.toInt(),
|
|
name: name,
|
|
documentMasked: json['document_masked']?.toString() ?? '',
|
|
);
|
|
}
|
|
}
|