46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
class ProstheticProduct {
|
|
const ProstheticProduct({
|
|
required this.id,
|
|
required this.labTenantId,
|
|
required this.name,
|
|
required this.prostheticType,
|
|
this.unitPrice,
|
|
this.currency,
|
|
this.isActive = true,
|
|
this.description,
|
|
});
|
|
|
|
final String id;
|
|
final String labTenantId;
|
|
final String name;
|
|
final String prostheticType;
|
|
final double? unitPrice;
|
|
final String? currency;
|
|
final bool isActive;
|
|
final String? description;
|
|
|
|
factory ProstheticProduct.fromJson(Map<String, dynamic> j) {
|
|
String? _str(dynamic v) { final s = v as String?; return (s == null || s.isEmpty) ? null : s; }
|
|
return ProstheticProduct(
|
|
id: j['id'] as String,
|
|
labTenantId: j['lab_tenant_id'] as String,
|
|
name: j['name'] as String,
|
|
prostheticType: j['prosthetic_type'] as String,
|
|
unitPrice: (j['unit_price'] as num?)?.toDouble(),
|
|
currency: j['currency'] as String? ?? 'TRY',
|
|
isActive: j['is_active'] as bool? ?? true,
|
|
description: _str(j['description']),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'lab_tenant_id': labTenantId,
|
|
'name': name,
|
|
'prosthetic_type': prostheticType,
|
|
if (unitPrice != null) 'unit_price': unitPrice,
|
|
'currency': currency ?? 'TRY',
|
|
'is_active': isActive,
|
|
if (description != null) 'description': description,
|
|
};
|
|
}
|