import 'package:json_annotation/json_annotation.dart'; part 'product.g.dart'; /// Catalog product (shared nutrition database entry). @JsonSerializable() class CatalogProduct { final String id; @JsonKey(name: 'canonical_name') final String canonicalName; @JsonKey(name: 'category_name') final String? categoryName; final String? category; @JsonKey(name: 'default_unit') final String? defaultUnit; @JsonKey(name: 'storage_days') final int? storageDays; final String? barcode; @JsonKey(name: 'calories_per_100g') final double? caloriesPer100g; @JsonKey(name: 'protein_per_100g') final double? proteinPer100g; @JsonKey(name: 'fat_per_100g') final double? fatPer100g; @JsonKey(name: 'carbs_per_100g') final double? carbsPer100g; const CatalogProduct({ required this.id, required this.canonicalName, this.categoryName, this.category, this.defaultUnit, this.storageDays, this.barcode, this.caloriesPer100g, this.proteinPer100g, this.fatPer100g, this.carbsPer100g, }); /// Display name is the server-resolved canonical name (language-aware from backend). String get displayName => canonicalName; factory CatalogProduct.fromJson(Map json) => _$CatalogProductFromJson(json); Map toJson() => _$CatalogProductToJson(this); }