jermainedilao
08/26/2019, 2:25 AMProduct item. Now, that Product must contain category and subcategory. Currently, the API only returns the guid of the category and subcategory.
Now the question is. Should the mapping of getting the category and subcategory from the API and putting them inside the Product class be inside the data module? OR I can put it inside my GetProductUseCase?
If I choose the latter. So my usecase would look something like this:
getProducts()
.zip(repo.getCategory(), repo.getSubCategory())
.flatMap {
product.category = category
product.subcategory = subcategory
}
What’s the best practice for this?wasyl
08/26/2019, 7:08 AMdata module. My reasoning is that this is a shortcoming of the API, and ideally API would return product, category and subcategory in one call. Once the API is fixed you shouldn’t have to modify your use case to adjust to the new data layer behavior.
Conversely if it was business requirement that category and subcategory must be fetched separately (e.g. because they change more often than the Product), or it was an application requirement (we need product very early and categories later on) only then I would move fetching them to some use case.jermainedilao
08/26/2019, 10:56 AM