forked from openMF/android-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MIFOSAC-249 Moved createNewClient & SyncClientsDialog to client Module (
openMF#2185) moved create new client to module MIFOSAC-249 Moved createNewClient & SyncClientsDialog to client Module
- Loading branch information
Showing
21 changed files
with
326 additions
and
914 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...atenewclient/CreateNewClientRepository.kt → ...a/repository/CreateNewClientRepository.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
2 changes: 1 addition & 1 deletion
2
...entsdialog/SyncClientsDialogRepository.kt → ...repository/SyncClientsDialogRepository.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
3 changes: 2 additions & 1 deletion
3
...newclient/CreateNewClientRepositoryImp.kt → ...itory_imp/CreateNewClientRepositoryImp.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
3 changes: 2 additions & 1 deletion
3
...sdialog/SyncClientsDialogRepositoryImp.kt → ...ory_imp/SyncClientsDialogRepositoryImp.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
44 changes: 44 additions & 0 deletions
44
core/domain/src/main/java/com/mifos/core/domain/use_cases/ClientTemplateUseCase.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,44 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.CreateNewClientRepository | ||
import com.mifos.core.objects.templates.clients.ClientsTemplate | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Pronay Sarker on 10/08/2024 (8:27 PM) | ||
*/ | ||
class ClientTemplateUseCase @Inject constructor(private val repository: CreateNewClientRepository) { | ||
|
||
suspend operator fun invoke(): Flow<Resource<ClientsTemplate>> = | ||
callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
|
||
repository.clientTemplate() | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<ClientsTemplate>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
|
||
override fun onNext(clientsTemplate: ClientsTemplate) { | ||
trySend(Resource.Success(clientsTemplate)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} catch (e: Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...rc/main/java/com/mifos/core/domain/use_cases/GetStaffInOfficeForCreateNewClientUseCase.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,45 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.CreateNewClientRepository | ||
import com.mifos.core.objects.organisation.Staff | ||
import com.mifos.core.objects.templates.clients.ClientsTemplate | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import rx.Subscriber | ||
import rx.android.schedulers.AndroidSchedulers | ||
import rx.schedulers.Schedulers | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by Pronay Sarker on 10/08/2024 (8:43 PM) | ||
*/ | ||
class GetStaffInOfficeForCreateNewClientUseCase @Inject constructor(private val repository: CreateNewClientRepository) { | ||
|
||
suspend operator fun invoke(officeId: Int): Flow<Resource<List<Staff>>> = | ||
callbackFlow { | ||
try { | ||
trySend(Resource.Loading()) | ||
|
||
repository.getStaffInOffice(officeId) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribeOn(Schedulers.io()) | ||
.subscribe(object : Subscriber<List<Staff>>() { | ||
override fun onCompleted() {} | ||
|
||
override fun onError(e: Throwable) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
|
||
override fun onNext(staffList: List<Staff>) { | ||
trySend(Resource.Success(staffList)) | ||
} | ||
}) | ||
|
||
awaitClose { channel.close() } | ||
} catch (e: Exception) { | ||
trySend(Resource.Error(e.message.toString())) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.