-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor generate collection sheet to compose (#2174)
- Loading branch information
1 parent
dad94b7
commit 87a470e
Showing
24 changed files
with
1,574 additions
and
1,226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/domain/src/main/java/com/mifos/core/domain/use_cases/FetchCenterDetailsUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.GenerateCollectionSheetRepository | ||
import com.mifos.core.objects.collectionsheet.CenterDetail | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class FetchCenterDetailsUseCase @Inject constructor( | ||
private val repository: GenerateCollectionSheetRepository | ||
) { | ||
|
||
suspend operator fun invoke( | ||
format: String?, | ||
locale: String?, | ||
meetingDate: String?, | ||
officeId: Int, | ||
staffId: Int | ||
): Flow<Resource<List<CenterDetail>>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val response = | ||
repository.fetchCenterDetails(format, locale, meetingDate, officeId, staffId) | ||
emit(Resource.Success(response)) | ||
|
||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
core/domain/src/main/java/com/mifos/core/domain/use_cases/FetchCollectionSheetUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.GenerateCollectionSheetRepository | ||
import com.mifos.core.objects.collectionsheet.CollectionSheetRequestPayload | ||
import com.mifos.core.objects.collectionsheet.CollectionSheetResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class FetchCollectionSheetUseCase @Inject constructor(private val repository: GenerateCollectionSheetRepository) { | ||
|
||
suspend operator fun invoke( | ||
groupId: Int, | ||
payload: CollectionSheetRequestPayload? | ||
): Flow<Resource<CollectionSheetResponse>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val response = repository.fetchCollectionSheet(groupId, payload) | ||
emit(Resource.Success(response)) | ||
|
||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...n/src/main/java/com/mifos/core/domain/use_cases/FetchGroupsAssociatedWithCenterUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.GenerateCollectionSheetRepository | ||
import com.mifos.core.objects.group.CenterWithAssociations | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class FetchGroupsAssociatedWithCenterUseCase @Inject constructor( | ||
private val repository: GenerateCollectionSheetRepository | ||
) { | ||
|
||
suspend operator fun invoke(centerId: Int): Flow<Resource<CenterWithAssociations>> = flow { | ||
|
||
try { | ||
emit(Resource.Loading()) | ||
val response = repository.fetchGroupsAssociatedWithCenter(centerId) | ||
emit(Resource.Success(response)) | ||
|
||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...in/src/main/java/com/mifos/core/domain/use_cases/FetchProductiveCollectionSheetUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.GenerateCollectionSheetRepository | ||
import com.mifos.core.objects.collectionsheet.CollectionSheetRequestPayload | ||
import com.mifos.core.objects.collectionsheet.CollectionSheetResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class FetchProductiveCollectionSheetUseCase @Inject constructor( | ||
private val repository: GenerateCollectionSheetRepository | ||
) { | ||
|
||
suspend operator fun invoke( | ||
centerId: Int, | ||
payload: CollectionSheetRequestPayload? | ||
): Flow<Resource<CollectionSheetResponse>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val response = repository.fetchProductiveCollectionSheet(centerId, payload) | ||
emit(Resource.Success(response)) | ||
|
||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
core/domain/src/main/java/com/mifos/core/domain/use_cases/GetCentersInOfficeUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.GenerateCollectionSheetRepository | ||
import com.mifos.core.objects.group.Center | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class GetCentersInOfficeUseCase @Inject constructor( | ||
private val repository: GenerateCollectionSheetRepository | ||
) { | ||
|
||
suspend operator fun invoke( | ||
id: Int, | ||
params: Map<String, String> | ||
): Flow<Resource<List<Center>>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val centers = repository.getCentersInOffice(id, params) | ||
emit(Resource.Success(centers)) | ||
|
||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core/domain/src/main/java/com/mifos/core/domain/use_cases/GetGroupsByOfficeUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.GenerateCollectionSheetRepository | ||
import com.mifos.core.objects.group.Group | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class GetGroupsByOfficeUseCase @Inject constructor( | ||
private val repository: GenerateCollectionSheetRepository | ||
) { | ||
|
||
suspend operator fun invoke( | ||
officeId: Int, | ||
params: Map<String, String> | ||
): Flow<Resource<List<Group>>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val response = repository.getGroupsByOffice(officeId, params) | ||
emit(Resource.Success(response)) | ||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core/domain/src/main/java/com/mifos/core/domain/use_cases/SubmitCollectionSheetUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.GenerateCollectionSheetRepository | ||
import com.mifos.core.network.GenericResponse | ||
import com.mifos.core.objects.collectionsheet.CollectionSheetPayload | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class SubmitCollectionSheetUseCase @Inject constructor(private val repository: GenerateCollectionSheetRepository) { | ||
|
||
suspend operator fun invoke( | ||
groupId: Int, | ||
payload: CollectionSheetPayload? | ||
): Flow<Resource<GenericResponse>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
val response = repository.submitCollectionSheet(groupId, payload) | ||
emit(Resource.Success(response)) | ||
|
||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
Oops, something went wrong.