-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 617 - new "save packagings V3" feature #640
Conversation
New files: * `api_saveProductV3_test.dart`: Integration tests around the "save packagings V3" feature. * `ProductPackaging.dart`: Packaging component for a product, e.g. recyclable bottle made of glass. * `ProductPackaging.g.dart`: generated Impacted files: * `AbstractQueryConfiguration.dart`: populated parameter `tags_lc` * `api_getProduct_test.dart`: removed references to now deprecated field `packaging`; added a test about the new packagings field * `api_saveProduct_test.dart`: skipped one 504 test; removed references to deprecated field `packaging` * `HttpHelper.dart`: new method `doPatchRequest`; minor refactoring * `openfoodfacts.dart`: new method `temporarySaveProductV3` * `Product.dart`: deprecated field `packaging`; added field `packagings` * `Product.g.dart`: generated * `ProductFields.dart`: deprecated `PACKAGING`; added `PACKAGINGS` and `RAW` * `ProductSearchQueryConfiguration.dart`: added api version parameter * `UriHelper.dart`: new method `getPatchUri`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @monsieurtanuki just some minor comments
// TODO: deprecated from 2022-12-16; remove when old enough | ||
@Deprecated('User packagingS instead') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: deprecated from 2022-12-16; remove when old enough | |
@Deprecated('User packagingS instead') | |
// TODO: deprecated from 2022-12-16; remove when old enough | |
@Deprecated('Use [packagings] instead') |
@@ -468,7 +475,8 @@ class Product extends JsonObject { | |||
this.labels, | |||
this.labelsTags, | |||
this.labelsTagsInLanguages, | |||
this.packaging, | |||
// TODO: deprecated from 2022-12-16; remove when old enough | |||
@Deprecated('Use packagingS field instead') this.packaging, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Deprecated('Use packagingS field instead') this.packaging, | |
@Deprecated('Use [packagings] field instead') this.packaging, |
Feel free to leave it with the capital S
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The square bracket syntax is unfortunately not detected in strings, only in ///
comments.
/// | ||
/// For the moment that's the only field supported in WRITE by API V3. | ||
/// Long term target is of course more something like [saveProduct]. | ||
static Future<ProductResultV3> temporarySaveProductV3( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static Future<ProductResultV3> temporarySaveProductV3( | |
static Future<ProductResultV3> temporarySaveProductPackagingsV3( |
Just a suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could make sense but in the long run I expect more fields to match V3 (e.g. one by month) : I'm not going to create a different method for each.
static Map<String, dynamic>? addUserAgentParameters( | ||
Map<String, dynamic>? map, | ||
) { | ||
map ??= <String, String>{}; | ||
map ??= <String, dynamic>{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why dynamic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new method doPatchRequest
the input can be Map<String, dynamic>
, and not Map<String, String>
.
More specifically in that case:
parameterMap['product']['packagings'] = packagings;
Thank you @M123-dev for your fast review! |
New files:
api_saveProductV3_test.dart
: Integration tests around the "save packagings V3" feature.ProductPackaging.dart
: Packaging component for a product, e.g. recyclable bottle made of glass.ProductPackaging.g.dart
: generatedImpacted files:
AbstractQueryConfiguration.dart
: populated parametertags_lc
api_getProduct_test.dart
: removed references to now deprecated fieldpackaging
; added a test about the new packagings fieldapi_saveProduct_test.dart
: skipped one 504 test; removed references to deprecated fieldpackaging
HttpHelper.dart
: new methoddoPatchRequest
; minor refactoringopenfoodfacts.dart
: new methodtemporarySaveProductV3
Product.dart
: deprecated fieldpackaging
; added fieldpackagings
Product.g.dart
: generatedProductFields.dart
: deprecatedPACKAGING
; addedPACKAGINGS
andRAW
ProductSearchQueryConfiguration.dart
: added api version parameterUriHelper.dart
: new methodgetPatchUri
What
packagings
product field provides detailed information about the packaging, cf. new classProductPackaging
packagings
is supported with save/V3. That means that packagings should be saved with a different call from the other fields.Fixes bug(s)