Skip to content

Commit

Permalink
fix: 816 - use localized versions of productName and ingredientsText (#…
Browse files Browse the repository at this point in the history
…817)

Impacted files:
* `api_get_save_product_test.dart`: removed tests on productName and ingredientsText; refactored
* `product.dart`: added comments about using rather the localized fields for productName and ingredientsText
  • Loading branch information
monsieurtanuki authored Oct 28, 2023
1 parent df85a38 commit 60f7d1e
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 250 deletions.
11 changes: 11 additions & 0 deletions lib/src/model/product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ enum ProductImprovementCategory {
/// or update data in specific language: https://github.com/openfoodfacts/openfoodfacts-dart/blob/master/DOCUMENTATION.md#about-languages-mechanics
@JsonSerializable()
class Product extends JsonObject {
/// Barcode of the product. Will very very very often be not null.
@JsonKey(name: 'code')
String? barcode;

/// Product name, either set directly or taken from one of the localizations.
///
/// Rather use [productNameInLanguages] instead.
@JsonKey(name: 'product_name', includeIfNull: false)
String? productName;

/// Localized product name.
@JsonKey(
name: 'product_name_in_languages',
fromJson: LanguageHelper.fromJsonStringMap,
Expand Down Expand Up @@ -193,8 +199,13 @@ class Product extends JsonObject {
toJson: JsonHelper.ingredientsToJson)
List<Ingredient>? ingredients;

/// Ingredients, either set directly or taken from one of the localizations.
///
/// Rather use [ingredientsTextInLanguages] instead.
@JsonKey(name: 'ingredients_text', includeIfNull: false)
String? ingredientsText;

/// Localized ingredients.
@JsonKey(
name: 'ingredients_text_in_languages',
fromJson: LanguageHelper.fromJsonStringMap,
Expand Down
Loading

0 comments on commit 60f7d1e

Please sign in to comment.