diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/UseCase.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/UseCase.kt index fb2ec2ae..5a54e976 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/UseCase.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/UseCase.kt @@ -1,9 +1,9 @@ package com.hieuwu.groceriesstore.domain.usecases interface SuspendUseCase { - suspend fun execute(input: Input): Output + suspend operator fun invoke(input: Input): Output } interface UseCase { - fun execute(input: Input): Output + operator fun invoke(input: Input): Output } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/AddMealToPlanUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/AddMealToPlanUseCaseImpl.kt index 889f96c3..e9ad7a36 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/AddMealToPlanUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/AddMealToPlanUseCaseImpl.kt @@ -7,7 +7,7 @@ import javax.inject.Inject class AddMealToPlanUseCaseImpl @Inject constructor( private val mealPlanRepository: MealPlanRepository ) : AddMealToPlanUseCase { - override suspend fun execute(input: AddMealToPlanUseCase.Input): AddMealToPlanUseCase.Output { + override suspend fun invoke(input: AddMealToPlanUseCase.Input): AddMealToPlanUseCase.Output { mealPlanRepository.addMealToPlan( weekDay = input.weekDay, name = input.name, diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/AddToCartUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/AddToCartUseCaseImpl.kt index ba4f282c..0452b988 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/AddToCartUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/AddToCartUseCaseImpl.kt @@ -12,7 +12,7 @@ class AddToCartUseCaseImpl @Inject constructor( @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : AddToCartUseCase { - override suspend fun execute(input: AddToCartUseCase.Input): AddToCartUseCase.Output { + override suspend fun invoke(input: AddToCartUseCase.Input): AddToCartUseCase.Output { withContext(ioDispatcher) { orderRepository.addLineItem(input.lineItem) } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/CreateNewOrderUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/CreateNewOrderUseCaseImpl.kt index 8737abae..de24d369 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/CreateNewOrderUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/CreateNewOrderUseCaseImpl.kt @@ -12,7 +12,7 @@ class CreateNewOrderUseCaseImpl @Inject constructor( @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : CreateNewOrderUseCase { - override suspend fun execute(input: CreateNewOrderUseCase.Input): CreateNewOrderUseCase.Output { + override suspend fun invoke(input: CreateNewOrderUseCase.Input): CreateNewOrderUseCase.Output { return withContext(ioDispatcher) { val result = orderRepository.createOrUpdate(input.order) CreateNewOrderUseCase.Output(result) diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCategoriesListUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCategoriesListUseCaseImpl.kt index 63d5cbee..cc8c8b64 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCategoriesListUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCategoriesListUseCaseImpl.kt @@ -7,7 +7,7 @@ import javax.inject.Inject class GetCategoriesListUseCaseImpl @Inject constructor( private val categoryRepository: CategoryRepository ) : GetCategoriesListUseCase { - override suspend fun execute(input: GetCategoriesListUseCase.Input): GetCategoriesListUseCase.Output { + override suspend fun invoke(input: GetCategoriesListUseCase.Input): GetCategoriesListUseCase.Output { val result = categoryRepository.getFromLocal() return GetCategoriesListUseCase.Output(result) } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCurrentCartUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCurrentCartUseCaseImpl.kt index 82e47dfc..f6e0b188 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCurrentCartUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCurrentCartUseCaseImpl.kt @@ -9,7 +9,7 @@ class GetCurrentCartUseCaseImpl @Inject constructor( private val orderRepository: OrderRepository, ) : GetCurrentCartUseCase { - override suspend fun execute(input: GetCurrentCartUseCase.Input): GetCurrentCartUseCase.Output { + override suspend fun invoke(input: GetCurrentCartUseCase.Input): GetCurrentCartUseCase.Output { val res = orderRepository.getOneOrderByStatus(OrderStatus.IN_CART) return GetCurrentCartUseCase.Output(res) diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetOrderListUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetOrderListUseCaseImpl.kt index 39d3b361..90090ba0 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetOrderListUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetOrderListUseCaseImpl.kt @@ -11,7 +11,7 @@ class GetOrderListUseCaseImpl @Inject constructor( private val orderRepository: OrderRepository, @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : GetOrderListUseCase { - override suspend fun execute(input: GetOrderListUseCase.Input): GetOrderListUseCase.Output { + override suspend fun invoke(input: GetOrderListUseCase.Input): GetOrderListUseCase.Output { return withContext(ioDispatcher) { val result = orderRepository.getOrders() GetOrderListUseCase.Output.Success(data = result) diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsByCategoryUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsByCategoryUseCaseImpl.kt index 5d9c214a..9a32d5e7 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsByCategoryUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsByCategoryUseCaseImpl.kt @@ -8,7 +8,7 @@ import javax.inject.Inject class GetProductsByCategoryUseCaseImpl @Inject constructor(private val productRepository: ProductRepository) : GetProductsByCategoryUseCase { - override fun execute(input: GetProductsByCategoryUseCase.Input): GetProductsByCategoryUseCase.Output { + override fun invoke(input: GetProductsByCategoryUseCase.Input): GetProductsByCategoryUseCase.Output { val result = productRepository.getAllProductsByCategory(input.categoryId) return GetProductsByCategoryUseCase.Output(result) } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsListUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsListUseCaseImpl.kt index 381e69ba..557daf00 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsListUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsListUseCaseImpl.kt @@ -8,7 +8,7 @@ import javax.inject.Inject class GetProductsListUseCaseImpl @Inject constructor(private val productRepository: ProductRepository) : GetProductsListUseCase { - override fun execute(input: GetProductsListUseCase.Input): GetProductsListUseCase.Output { + override fun invoke(input: GetProductsListUseCase.Input): GetProductsListUseCase.Output { val result = productRepository.products return GetProductsListUseCase.Output(result) } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProfileUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProfileUseCaseImpl.kt index d56648e7..1525c94d 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProfileUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProfileUseCaseImpl.kt @@ -8,7 +8,7 @@ class GetProfileUseCaseImpl @Inject constructor( private val userRepository: UserRepository, ) : GetProfileUseCase { - override suspend fun execute(input: GetProfileUseCase.Input): GetProfileUseCase.Output { + override suspend fun invoke(input: GetProfileUseCase.Input): GetProfileUseCase.Output { val user = userRepository.getCurrentUser() return GetProfileUseCase.Output(user) } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RefreshAppDataUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RefreshAppDataUseCaseImpl.kt index 435729d4..d5ce8456 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RefreshAppDataUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RefreshAppDataUseCaseImpl.kt @@ -15,7 +15,7 @@ class RefreshAppDataUseCaseImpl @Inject constructor( private val recipeRepository: RecipeRepository, @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : RefreshAppDataUseCase { - override suspend fun execute(input: Unit) { + override suspend fun invoke(input: Unit) { withContext(ioDispatcher) { categoryRepository.refreshDatabase() productRepository.refreshDatabase() diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RemoveMealFromPlanUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RemoveMealFromPlanUseCaseImpl.kt index fae7433f..934eb692 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RemoveMealFromPlanUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RemoveMealFromPlanUseCaseImpl.kt @@ -11,7 +11,7 @@ class RemoveMealFromPlanUseCaseImpl @Inject constructor( private val mealPlanRepository: MealPlanRepository, @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : RemoveMealFromPlanUseCase { - override suspend fun execute(input: RemoveMealFromPlanUseCase.Input): RemoveMealFromPlanUseCase.Output { + override suspend fun invoke(input: RemoveMealFromPlanUseCase.Input): RemoveMealFromPlanUseCase.Output { return withContext(ioDispatcher) { try { mealPlanRepository.removeMealFromPlan(input.id) diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RetrieveMealByTypeUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RetrieveMealByTypeUseCaseImpl.kt index d234d98b..c7711351 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RetrieveMealByTypeUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/RetrieveMealByTypeUseCaseImpl.kt @@ -16,7 +16,7 @@ class RetrieveMealByTypeUseCaseImpl @Inject constructor( private val mealPlanRepository: MealPlanRepository, @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : RetrieveMealByTypeUseCase { - override suspend fun execute(input: RetrieveMealByTypeUseCase.Input): RetrieveMealByTypeUseCase.Output { + override suspend fun invoke(input: RetrieveMealByTypeUseCase.Input): RetrieveMealByTypeUseCase.Output { return withContext(ioDispatcher) { try { val result = mealPlanRepository.retrieveMealByType( diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SearchProductUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SearchProductUseCaseImpl.kt index ebe8687c..5dd03c01 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SearchProductUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SearchProductUseCaseImpl.kt @@ -12,7 +12,7 @@ class SearchProductUseCaseImpl @Inject constructor( @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : SearchProductUseCase { - override suspend fun execute(input: SearchProductUseCase.Input): SearchProductUseCase.Output { + override suspend fun invoke(input: SearchProductUseCase.Input): SearchProductUseCase.Output { return withContext(ioDispatcher) { val result = productRepository.searchProductsListByName(input.name) SearchProductUseCase.Output(result) diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignInUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignInUseCaseImpl.kt index 0a18de6b..a5803d13 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignInUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignInUseCaseImpl.kt @@ -14,7 +14,7 @@ class SignInUseCaseImpl @Inject constructor( @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : SignInUseCase { - override suspend fun execute(input: SignInUseCase.Input): SignInUseCase.Output { + override suspend fun invoke(input: SignInUseCase.Input): SignInUseCase.Output { return withContext(ioDispatcher) { try { val res = userRepository.authenticate(input.email, input.password) diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignOutUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignOutUseCaseImpl.kt index 507662f0..372e21ab 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignOutUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignOutUseCaseImpl.kt @@ -12,7 +12,7 @@ class SignOutUseCaseImpl @Inject constructor( @IoDispatcher private val ioDispatcher: CoroutineDispatcher ) : SignOutUseCase { - override suspend fun execute(input: SignOutUseCase.Input): SignOutUseCase.Output { + override suspend fun invoke(input: SignOutUseCase.Input): SignOutUseCase.Output { return withContext(ioDispatcher) { userRepository.clearUser() SignOutUseCase.Output() diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SubmitOrderUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SubmitOrderUseCaseImpl.kt index 42a1a9c8..d1b8433b 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SubmitOrderUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/SubmitOrderUseCaseImpl.kt @@ -11,7 +11,7 @@ class SubmitOrderUseCaseImpl @Inject constructor( private val orderRepository: OrderRepository, @IoDispatcher private val ioDispatcher: CoroutineDispatcher, ) : SubmitOrderUseCase { - override suspend fun execute(input: SubmitOrderUseCase.Input): SubmitOrderUseCase.Output { + override suspend fun invoke(input: SubmitOrderUseCase.Input): SubmitOrderUseCase.Output { return withContext(ioDispatcher) { val result = orderRepository.sendOrderToServer(input.order) SubmitOrderUseCase.Output(result) diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImpl.kt index 8f987eb3..9e21fc19 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImpl.kt @@ -10,7 +10,7 @@ class UpdateProfileUseCaseImpl @Inject constructor( private val userRepository: UserRepository, ) : UpdateProfileUseCase { - override suspend fun execute(input: UpdateProfileUseCase.Input): UpdateProfileUseCase.Output { + override suspend fun invoke(input: UpdateProfileUseCase.Input): UpdateProfileUseCase.Output { userRepository.updateUserProfile( input.userId, input.name, input.email, input.phone, input.address ) diff --git a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/UserSettingsUseCaseImpl.kt b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/UserSettingsUseCaseImpl.kt index df787383..0468c3f5 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/UserSettingsUseCaseImpl.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/UserSettingsUseCaseImpl.kt @@ -13,7 +13,7 @@ class UserSettingsUseCaseImpl @Inject constructor( ) : UserSettingsUseCase { - override suspend fun execute(input: UserSettingsUseCase.Input): UserSettingsUseCase.Output { + override suspend fun invoke(input: UserSettingsUseCase.Input): UserSettingsUseCase.Output { withContext(ioDispatcher) { userRepository.updateUserSettings( input.id, diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/account/AccountViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/account/AccountViewModel.kt index 9f60f1d4..14df78b1 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/account/AccountViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/account/AccountViewModel.kt @@ -26,7 +26,7 @@ class AccountViewModel @Inject constructor( private fun getCurrentUser() { viewModelScope.launch { - getProfileUseCase.execute(GetProfileUseCase.Input()).result.collect { + getProfileUseCase(GetProfileUseCase.Input()).result.collect { _user.value = it } } @@ -34,7 +34,7 @@ class AccountViewModel @Inject constructor( fun signOut() { viewModelScope.launch { - signOutUseCase.execute(SignOutUseCase.Input()) + signOutUseCase(SignOutUseCase.Input()) } } } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/authentication/signin/SignInViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/authentication/signin/SignInViewModel.kt index 5e7751e3..418ff7fd 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/authentication/signin/SignInViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/authentication/signin/SignInViewModel.kt @@ -42,7 +42,7 @@ class SignInViewModel @Inject constructor( fun signIn() { viewModelScope.launch { - when (signInUseCase.execute( + when (signInUseCase( SignInUseCase.Input( email = _email.value, password = _password.value diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/checkout/CheckOutViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/checkout/CheckOutViewModel.kt index 5a0aae5e..27d2544f 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/checkout/CheckOutViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/checkout/CheckOutViewModel.kt @@ -57,7 +57,7 @@ class CheckOutViewModel @Inject constructor( private fun getCurrentCard(): Flow? { var res: Flow? = null viewModelScope.launch { - res = getCurrentCartUseCase.execute(GetCurrentCartUseCase.Input()).result + res = getCurrentCartUseCase(GetCurrentCartUseCase.Input()).result } return res } @@ -65,7 +65,7 @@ class CheckOutViewModel @Inject constructor( private fun getCurrentUser(): Flow? { var res: Flow? = null viewModelScope.launch { - res = getProfileUseCase.execute(GetProfileUseCase.Input()).result + res = getProfileUseCase(GetProfileUseCase.Input()).result } return res } @@ -75,7 +75,7 @@ class CheckOutViewModel @Inject constructor( setOrderAddress() viewModelScope.launch { _isOrderSentSuccessful.value = - submitOrderUseCase.execute(SubmitOrderUseCase.Input(order.value!!)).result + submitOrderUseCase(SubmitOrderUseCase.Input(order.value!!)).result } } } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/explore/ExploreViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/explore/ExploreViewModel.kt index a5d2db54..3ce0bb8b 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/explore/ExploreViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/explore/ExploreViewModel.kt @@ -67,7 +67,7 @@ class ExploreViewModel @Inject constructor( if (name.isNotBlank()) { viewModelScope.launch { val res = - searchProductUseCase.execute(SearchProductUseCase.Input(name = name.trim())) + searchProductUseCase(SearchProductUseCase.Input(name = name.trim())) res.result.collect { _productList.value = it } @@ -78,7 +78,7 @@ class ExploreViewModel @Inject constructor( private fun getCurrentCard(): Flow? { var res: Flow? = null viewModelScope.launch { - res = getCurrentCartUseCase.execute(GetCurrentCartUseCase.Input()).result + res = getCurrentCartUseCase(GetCurrentCartUseCase.Input()).result } return res } @@ -86,7 +86,7 @@ class ExploreViewModel @Inject constructor( private fun getCategoriesList(): Flow>? { var res: Flow>? = null viewModelScope.launch { - res = getCategoriesListUseCase.execute(GetCategoriesListUseCase.Input()).result + res = getCategoriesListUseCase(GetCategoriesListUseCase.Input()).result } return res } @@ -102,20 +102,20 @@ class ExploreViewModel @Inject constructor( quantity = 1, subtotal = product.price!! ) - addToCartUseCase.execute(AddToCartUseCase.Input(lineItem = lineItem)) + addToCartUseCase(AddToCartUseCase.Input(lineItem = lineItem)) } } else { val id = UUID.randomUUID().toString() val newOrder = Order(id, OrderStatus.IN_CART.value, "") viewModelScope.launch { - createNewOrderUseCase.execute(CreateNewOrderUseCase.Input(order = newOrder)) + createNewOrderUseCase(CreateNewOrderUseCase.Input(order = newOrder)) val lineItem = LineItem( productId = product.id, orderId = id, quantity = 1, subtotal = product.price!! ) - addToCartUseCase.execute(AddToCartUseCase.Input(lineItem = lineItem)) + addToCartUseCase(AddToCartUseCase.Input(lineItem = lineItem)) } } } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/mealplanning/overview/OverviewViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/mealplanning/overview/OverviewViewModel.kt index 8a36afec..844fcf73 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/mealplanning/overview/OverviewViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/mealplanning/overview/OverviewViewModel.kt @@ -76,7 +76,7 @@ class OverviewViewModel @Inject constructor( weekDayValue: WeekDayValue, mealType: MealType, ) { - val result = retrieveMealByTypeUseCase.execute( + val result = retrieveMealByTypeUseCase( RetrieveMealByTypeUseCase.Input( dayValue = weekDayValue, mealType = mealType @@ -126,7 +126,7 @@ class OverviewViewModel @Inject constructor( fun onRemoveMeal(id: String) { viewModelScope.launch { - removeMealFromPlanUseCase.execute( + removeMealFromPlanUseCase( RemoveMealFromPlanUseCase.Input( id = id ) @@ -149,7 +149,7 @@ class OverviewViewModel @Inject constructor( private fun onAddBreakfast(name: String, ingredients: List, mealImageUri: ByteArray) { viewModelScope.launch { - addMealToPlanUseCase.execute( + addMealToPlanUseCase( AddMealToPlanUseCase.Input( name = name, weekDay = _days.value[selectedDayIndex].name, @@ -167,7 +167,7 @@ class OverviewViewModel @Inject constructor( private fun onAddLunch(name: String, ingredients: List, mealImageUri: ByteArray) { viewModelScope.launch { - addMealToPlanUseCase.execute( + addMealToPlanUseCase( AddMealToPlanUseCase.Input( name = name, weekDay = _days.value[selectedDayIndex].name, @@ -185,7 +185,7 @@ class OverviewViewModel @Inject constructor( private fun onAddDinner(name: String, ingredients: List, mealImageUri: ByteArray) { viewModelScope.launch { - addMealToPlanUseCase.execute( + addMealToPlanUseCase( AddMealToPlanUseCase.Input( name = name, weekDay = _days.value[selectedDayIndex].name, diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/notificationsettings/NotificationSettingsViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/notificationsettings/NotificationSettingsViewModel.kt index 74886508..cd760936 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/notificationsettings/NotificationSettingsViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/notificationsettings/NotificationSettingsViewModel.kt @@ -48,7 +48,7 @@ class NotificationSettingsViewModel @Inject constructor( private fun getCurrentUser() { viewModelScope.launch { - getProfileUseCase.execute(GetProfileUseCase.Input()).result.collect { + getProfileUseCase(GetProfileUseCase.Input()).result.collect { _user.value = it } } @@ -65,7 +65,7 @@ class NotificationSettingsViewModel @Inject constructor( fun updateNotificationSettings() { Timber.d("promo: $isPromotionNotiEnabled, ord: $isOrderCreatedNotiEnabled, db: $isDatabaseRefreshedNotiEnabled") viewModelScope.launch { - userSettingsUseCase.execute( + userSettingsUseCase( UserSettingsUseCase.Input( user.value?.id!!, isOrderCreatedNotiEnabled.value!!, diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/onboarding/OnboardingViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/onboarding/OnboardingViewModel.kt index 6695817e..66cc5d12 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/onboarding/OnboardingViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/onboarding/OnboardingViewModel.kt @@ -28,7 +28,7 @@ class OnboardingViewModel @Inject constructor( } else { try { viewModelScope.launch { - refreshAppDataUseCase.execute(Unit) + refreshAppDataUseCase(Unit) with(sharedPreferences.edit()) { putBoolean("PRODUCT_SYNC_SUCCESS", true) apply() diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/orderhistory/OrderListViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/orderhistory/OrderListViewModel.kt index c5f24dfc..005c382e 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/orderhistory/OrderListViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/orderhistory/OrderListViewModel.kt @@ -24,7 +24,7 @@ class OrderListViewModel @Inject constructor( private fun getOrderList() { viewModelScope.launch { - when (val result = getOrderListUseCase.execute(GetOrderListUseCase.Input())) { + when (val result = getOrderListUseCase(GetOrderListUseCase.Input())) { is GetOrderListUseCase.Output.Success -> { _orderList.emit(result.data) } diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/productlist/ProductListViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/productlist/ProductListViewModel.kt index 5f04f64d..42b08ee1 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/productlist/ProductListViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/productlist/ProductListViewModel.kt @@ -63,24 +63,24 @@ class ProductListViewModel @Inject constructor( private fun getCurrentCart(): Flow? { var res: Flow? = null viewModelScope.launch { - res = getCurrentCartUseCase.execute(GetCurrentCartUseCase.Input()).result + res = getCurrentCartUseCase(GetCurrentCartUseCase.Input()).result } return res } private fun getProductLists(): Flow> { - return getProductsListUseCase.execute(GetProductsListUseCase.Input()).result + return getProductsListUseCase(GetProductsListUseCase.Input()).result } private fun getProductLists(categoryId: String): Flow> { - return getProductsByCategoryUseCase.execute(GetProductsByCategoryUseCase.Input(categoryId)).result + return getProductsByCategoryUseCase(GetProductsByCategoryUseCase.Input(categoryId)).result } fun addToCart(product: ProductModel) { viewModelScope.launch { if (currentCart.value != null) { // Add to cart - addToCartUseCase.execute( + addToCartUseCase( AddToCartUseCase.Input( LineItem( productId = product.id, @@ -94,8 +94,8 @@ class ProductListViewModel @Inject constructor( // TODO: Move order creation to repository layer, at this point only pass domain object val id = UUID.randomUUID().toString() val newOrder = Order(id, OrderStatus.IN_CART.value, "") - createNewOrderUseCase.execute(CreateNewOrderUseCase.Input(newOrder)) - addToCartUseCase.execute( + createNewOrderUseCase(CreateNewOrderUseCase.Input(newOrder)) + addToCartUseCase( AddToCartUseCase.Input( LineItem( productId = product.id, diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/shop/ShopViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/shop/ShopViewModel.kt index 5507dedf..540c1b26 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/shop/ShopViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/shop/ShopViewModel.kt @@ -62,7 +62,7 @@ class ShopViewModel @Inject constructor( private fun getProductLists(): Flow>? { var res: Flow>? = null viewModelScope.launch { - res = getProductsListUseCase.execute(GetProductsListUseCase.Input()).result + res = getProductsListUseCase(GetProductsListUseCase.Input()).result } return res } @@ -70,7 +70,7 @@ class ShopViewModel @Inject constructor( private fun getCurrentCart(): Flow? { var res: Flow? = null viewModelScope.launch { - res = getCurrentCartUseCase.execute(GetCurrentCartUseCase.Input()).result + res = getCurrentCartUseCase(GetCurrentCartUseCase.Input()).result } return res } @@ -80,7 +80,7 @@ class ShopViewModel @Inject constructor( // Add to cart val cartId = currentCart.value!!.id viewModelScope.launch { - addToCartUseCase.execute( + addToCartUseCase( AddToCartUseCase.Input( LineItem( productId = product.id, @@ -94,7 +94,7 @@ class ShopViewModel @Inject constructor( } else { val id = UUID.randomUUID().toString() viewModelScope.launch { - createNewOrderUseCase.execute( + createNewOrderUseCase( CreateNewOrderUseCase.Input( Order( id = id, @@ -103,7 +103,7 @@ class ShopViewModel @Inject constructor( ) ) ) - addToCartUseCase.execute( + addToCartUseCase( AddToCartUseCase.Input( LineItem( productId = product.id, diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/updateprofile/UpdateProfileViewModel.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/updateprofile/UpdateProfileViewModel.kt index b69497a9..5cae7435 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/updateprofile/UpdateProfileViewModel.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/updateprofile/UpdateProfileViewModel.kt @@ -39,7 +39,7 @@ class UpdateProfileViewModel @Inject constructor( private fun getCurrentUser() { viewModelScope.launch { - getProfileUseCase.execute(GetProfileUseCase.Input()).result.collect { + getProfileUseCase(GetProfileUseCase.Input()).result.collect { setUserProperties(it) _user.value = it } @@ -57,7 +57,7 @@ class UpdateProfileViewModel @Inject constructor( val id = _user.value!!.id try { viewModelScope.launch { - updateProfileUseCase.execute( + updateProfileUseCase( UpdateProfileUseCase.Input( userId = id, name = name!!, diff --git a/app/src/main/java/com/hieuwu/groceriesstore/works/RefreshDatabaseWork.kt b/app/src/main/java/com/hieuwu/groceriesstore/works/RefreshDatabaseWork.kt index 08a97c4e..87942d26 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/works/RefreshDatabaseWork.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/works/RefreshDatabaseWork.kt @@ -15,7 +15,7 @@ class RefreshDatabaseWork(appContext: Context, params: WorkerParameters) : override suspend fun doWork(): Result { return try { Timber.d("Refreshing database") - refreshAppDataUseCase.execute(Unit) + refreshAppDataUseCase(Unit) Result.success() } catch (e: Exception) { Result.retry() diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCategoriesListUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCategoriesListUseCaseImplTest.kt index 7e844fdf..811e1fd8 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCategoriesListUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCategoriesListUseCaseImplTest.kt @@ -41,7 +41,7 @@ class GetCategoriesListUseCaseImplTest { emit(mockCategories) }) runBlocking { - val result = testee.execute(GetCategoriesListUseCase.Input()) + val result = testee(GetCategoriesListUseCase.Input()) result.result.collect { categories -> assertEquals(mockCategories[0], categories[0]) @@ -59,7 +59,7 @@ class GetCategoriesListUseCaseImplTest { emit(listOf()) }) runBlocking { - val result = testee.execute(GetCategoriesListUseCase.Input()) + val result = testee(GetCategoriesListUseCase.Input()) result.result.collect { assertEquals(it.isEmpty(), true) } diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCurrentCartUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCurrentCartUseCaseImplTest.kt index 2eda357e..be0d52ad 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCurrentCartUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetCurrentCartUseCaseImplTest.kt @@ -44,7 +44,7 @@ class GetCurrentCartUseCaseImplTest { emit(mockOrder) }) runBlocking { - val result = testee.execute(GetCurrentCartUseCase.Input()) + val result = testee(GetCurrentCartUseCase.Input()) result.result.collect { order -> assertEquals(order?.id, "") @@ -62,7 +62,7 @@ class GetCurrentCartUseCaseImplTest { null }) runBlocking { - val result = testee.execute(GetCurrentCartUseCase.Input()) + val result = testee(GetCurrentCartUseCase.Input()) result.result.collect { assertNull(it) } diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsByCategoryUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsByCategoryUseCaseImplTest.kt index dad923db..44929489 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsByCategoryUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsByCategoryUseCaseImplTest.kt @@ -36,7 +36,7 @@ class GetProductsByCategoryUseCaseImplTest { }) runBlocking { - val result = testee.execute(input) + val result = testee(input) result.result.collect { TestCase.assertTrue(it.isNotEmpty()) TestCase.assertEquals(mockedProducts[0], it[0]) @@ -55,7 +55,7 @@ class GetProductsByCategoryUseCaseImplTest { }) runBlocking { - val result = testee.execute(input) + val result = testee(input) result.result.collect { TestCase.assertTrue(it.isEmpty()) } diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsListUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsListUseCaseImplTest.kt index 307f70d0..e4816763 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsListUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProductsListUseCaseImplTest.kt @@ -40,7 +40,7 @@ class GetProductsListUseCaseImplTest { emit(mockedProducts) }) runBlocking { - val result = testee.execute(GetProductsListUseCase.Input()) + val result = testee(GetProductsListUseCase.Input()) result.result.collect { products -> assertEquals(mockedProducts[0], products[0]) @@ -58,7 +58,7 @@ class GetProductsListUseCaseImplTest { }) runBlocking { - val result = testee.execute(GetProductsListUseCase.Input()) + val result = testee(GetProductsListUseCase.Input()) result.result.collect { assertEquals(it.isEmpty(), true) } diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProfileUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProfileUseCaseImplTest.kt index e9f8cb97..7fc3c0f5 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProfileUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetProfileUseCaseImplTest.kt @@ -47,7 +47,7 @@ class GetProfileUseCaseImplTest { ) }) runBlocking { - val result = testee.execute(GetProfileUseCase.Input()) + val result = testee(GetProfileUseCase.Input()) result.result.collect { assertEquals("", it?.id) @@ -66,7 +66,7 @@ class GetProfileUseCaseImplTest { }) runBlocking { - val result = testee.execute(GetProfileUseCase.Input()) + val result = testee(GetProfileUseCase.Input()) result.result.collect { assertNull(it) } diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/RefreshAppDataUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/RefreshAppDataUseCaseImplTest.kt index 436e7cad..c5b667ef 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/RefreshAppDataUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/RefreshAppDataUseCaseImplTest.kt @@ -40,7 +40,7 @@ class RefreshAppDataUseCaseImplTest { @Test fun whenExecute_thenCallRepositories() { runBlocking { - testee.execute(Unit) + testee(Unit) verify(mockedProductRepository).refreshDatabase() verify(mockedCategoryRepository).refreshDatabase() diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SearchProductUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SearchProductUseCaseImplTest.kt index 1f0a2fe8..117acd1b 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SearchProductUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SearchProductUseCaseImplTest.kt @@ -40,7 +40,7 @@ class SearchProductUseCaseImplTest { }) runBlocking { - val result = testee.execute(input) + val result = testee(input) result.result.collect { TestCase.assertTrue(it.isNotEmpty()) TestCase.assertEquals(mockProducts[0], it[0]) @@ -59,7 +59,7 @@ class SearchProductUseCaseImplTest { }) runBlocking { - val result = testee.execute(input) + val result = testee(input) result.result.collect { TestCase.assertTrue(it.isEmpty()) } diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignInUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignInUseCaseImplTest.kt index b3b4327c..8b59fcc6 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignInUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignInUseCaseImplTest.kt @@ -41,7 +41,7 @@ class SignInUseCaseImplTest { whenever(mockedUserRepository.authenticate(input.email, input.password)) .thenReturn(authenticationResult) - val output = testee.execute(input) + val output = testee(input) assertEquals(authenticationResult, output.result) } } @@ -57,7 +57,7 @@ class SignInUseCaseImplTest { whenever(mockedUserRepository.authenticate(input.email, input.password)) .thenThrow(RuntimeException()) - val output = testee.execute(input) + val output = testee(input) assertEquals(SignInUseCase.Output.AccountNotExistedError, output) } } diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignOutUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignOutUseCaseImplTest.kt index d2beeeda..0f2df783 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignOutUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SignOutUseCaseImplTest.kt @@ -31,7 +31,7 @@ class SignOutUseCaseImplTest { val input = SignOutUseCase.Input() runBlocking { - testee.execute(input) + testee(input) verify(mockedUserRepository).clearUser() } diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SubmitOrderUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SubmitOrderUseCaseImplTest.kt index c60f93ad..636ae50c 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SubmitOrderUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/SubmitOrderUseCaseImplTest.kt @@ -33,7 +33,7 @@ class SubmitOrderUseCaseImplTest { fun whenExecute_thenSubmitOrderSuccessfully() { runBlocking { whenever(mockedOrderRepository.sendOrderToServer(any())).thenReturn(true) - testee.execute( + testee( SubmitOrderUseCase.Input( order = OrderModel( lineItemList = mutableListOf() diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImplTest.kt index 46a45af8..f183b477 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UpdateProfileUseCaseImplTest.kt @@ -35,7 +35,7 @@ class UpdateProfileUseCaseImplTest { ) runBlocking { - testee.execute(input) + testee(input) verify(mockedUserRepository) .updateUserProfile( diff --git a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UserSettingsUseCaseImplTest.kt b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UserSettingsUseCaseImplTest.kt index 84f7083a..fe567a16 100644 --- a/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UserSettingsUseCaseImplTest.kt +++ b/app/src/test/java/com/hieuwu/groceriesstore/domain/usecases/impl/UserSettingsUseCaseImplTest.kt @@ -39,7 +39,7 @@ class UserSettingsUseCaseImplTest { ) runBlocking { - testee.execute(input) + testee(input) verify(mockedUserRepository) .updateUserSettings(