getOldProduct static method
Future<OldProductResult>
getOldProduct(
- ProductQueryConfiguration configuration, {
- User? user,
- UriProductHelper uriHelper = uriHelperFoodProd,
Returns the product for the given barcode, with an old syntax.
Temporarily needed for OBF, OPF and OPFF, that do not support api v3.
Implementation
// TODO(monsieurtanuki): get rid of it when OBF OPF OPFF support api v3
static Future<OldProductResult> getOldProduct(
final ProductQueryConfiguration configuration, {
final User? user,
final UriProductHelper uriHelper = uriHelperFoodProd,
}) async {
if (configuration.matchesV3()) {
Exception("The configuration must not match V3!");
}
final String productString = await getProductString(
configuration,
user: user,
uriHelper: uriHelper,
);
final String jsonStr = _replaceQuotes(productString);
final OldProductResult result =
OldProductResult.fromJson(jsonDecode(jsonStr));
if (result.product != null) {
ProductHelper.removeImages(result.product!, configuration.language);
ProductHelper.createImageUrls(result.product!, uriHelper: uriHelper);
}
return result;
}