This PR introduces a refactor in the FoodFacts data class and enhances the OpenFoodFactsRepository to also handle the imageUrl property when extracting JSON product details from OpenFoodFacts.
Changes
Refactor (FoodFacts Data Class)
Introduced a default image URL constant for imageUrl in FoodFacts, it is placed in a companion object
imageUrl will default to this blank placeholder image
Enhancement (extractFoodFactsFromJson function)
Updated the extractFoodFactsFromJson function inside OpenFoodFactsRepository function to extract the image Url or else use the default FoodFacts placeholder
Tests
(OpenFoodFactsRepositoryTest) Enhanced existing tests to validate that imageUrl is correctly sent back if it exists, and defaults to the placeholder when invalid
Next steps
The OpenFoodFacts API sends back multiple images of multiple sizes. In the future we should store these multiple images, to adapt our UI to the viewport, and to optimize when we use smaller images (e.g we do not need large images for food icons)
PR: Feat/Add
imageUrl
handling to FoodFactsSummary
This PR introduces a refactor in the
FoodFacts
data class and enhances theOpenFoodFactsRepository
to also handle theimageUrl
property when extracting JSON product details from OpenFoodFacts.Changes
Refactor (
FoodFacts
Data Class)imageUrl
inFoodFacts
, it is placed in a companion objectimageUrl
will default to this blank placeholder imageEnhancement (
extractFoodFactsFromJson
function)extractFoodFactsFromJson
function insideOpenFoodFactsRepository
function to extract the image Url or else use the default FoodFacts placeholderTests
OpenFoodFactsRepositoryTest
) Enhanced existing tests to validate thatimageUrl
is correctly sent back if it exists, and defaults to the placeholder when invalidNext steps