forked from openfoodfacts/openfoodfacts-dart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 1003 - new price type field (openfoodfacts#1016)
* feat: 1003 - new price type field New files: * `price_type.dart`: Type of a Price. Impacted files: * `api_prices_test.dart`: additional test on price type * `openfoodfacts.dart`: exported the new file * `price.dart`: added the price type field * `price.g.dart`: generated * Updated LICENSE copyright year * Unit tests minor fixes * Unit tests minor fixes
- Loading branch information
1 parent
c583648
commit 5f7b911
Showing
7 changed files
with
49 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import '../model/off_tagged.dart'; | ||
|
||
/// Type of a Price. | ||
enum PriceType implements OffTagged { | ||
@JsonValue('PRODUCT') | ||
product(offTag: 'PRODUCT'), | ||
|
||
@JsonValue('CATEGORY') | ||
category(offTag: 'CATEGORY'); | ||
|
||
const PriceType({ | ||
required this.offTag, | ||
}); | ||
|
||
@override | ||
final String offTag; | ||
|
||
/// Returns the first [PriceType] that matches the [offTag]. | ||
static PriceType? fromOffTag(final String? offTag) => | ||
OffTagged.fromOffTag(offTag, PriceType.values) as PriceType?; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters