Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions core/data/src/main/java/com/mifos/core/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.mifos.core.data.repository.ClientIdentifierDialogRepository
import com.mifos.core.data.repository.ClientIdentifiersRepository
import com.mifos.core.data.repository.CreateNewCenterRepository
import com.mifos.core.data.repository.DataTableDataRepository
import com.mifos.core.data.repository.DataTableRowDialogRepository
import com.mifos.core.data.repository.DocumentListRepository
import com.mifos.core.data.repository.GroupDetailsRepository
import com.mifos.core.data.repository.GroupListRepository
Expand Down Expand Up @@ -39,6 +40,7 @@ import com.mifos.core.data.repository_imp.ClientIdentifierDialogRepositoryImp
import com.mifos.core.data.repository_imp.ClientIdentifiersRepositoryImp
import com.mifos.core.data.repository_imp.CreateNewCenterRepositoryImp
import com.mifos.core.data.repository_imp.DataTableDataRepositoryImp
import com.mifos.core.data.repository_imp.DataTableRowDialogRepositoryImp
import com.mifos.core.data.repository_imp.DocumentListRepositoryImp
import com.mifos.core.data.repository_imp.GroupDetailsRepositoryImp
import com.mifos.core.data.repository_imp.GroupListRepositoryImp
Expand Down Expand Up @@ -136,10 +138,13 @@ abstract class DataModule {
internal abstract fun bindChargeDialogRepository(impl: ChargeDialogRepositoryImp): ChargeDialogRepository

@Binds
internal abstract fun bindClientIdentifiersDialogRepository(impl: ClientIdentifierDialogRepositoryImp): ClientIdentifierDialogRepository
internal abstract fun bindDataTableDataRepository(impl: DataTableDataRepositoryImp): DataTableDataRepository

@Binds
internal abstract fun bindDataTableDataRepository(impl: DataTableDataRepositoryImp): DataTableDataRepository
internal abstract fun bindDataTableRowDialogRepository(impl: DataTableRowDialogRepositoryImp): DataTableRowDialogRepository

@Binds
internal abstract fun bindClientIdentifiersDialogRepository(impl: ClientIdentifierDialogRepositoryImp): ClientIdentifierDialogRepository

@Binds
internal abstract fun bindSignatureRepository(impl: SignatureRepositoryImp): SignatureRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mifos.core.data.repository

import com.mifos.core.network.GenericResponse

/**
* Created by Aditya Gupta on 13/08/23.
*/
interface DataTableRowDialogRepository {

suspend fun addDataTableEntry(
table: String, entityId: Int, payload: Map<String, String>
): GenericResponse

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mifos.mifosxdroid.dialogfragments.datatablerowdialog
package com.mifos.core.data.repository_imp

import com.mifos.core.data.repository.DataTableRowDialogRepository
import com.mifos.core.network.GenericResponse
import com.mifos.core.network.datamanager.DataManagerDataTable
import rx.Observable
import javax.inject.Inject

/**
Expand All @@ -11,13 +11,11 @@ import javax.inject.Inject
class DataTableRowDialogRepositoryImp @Inject constructor(private val dataManagerDataTable: DataManagerDataTable) :
DataTableRowDialogRepository {

override fun addDataTableEntry(
table: String?,
override suspend fun addDataTableEntry(
table: String,
entityId: Int,
payload: Map<String, String>
): Observable<GenericResponse> {
): GenericResponse {
return dataManagerDataTable.addDataTableEntry(table, entityId, payload)
}


}
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.DataTableRowDialogRepository
import com.mifos.core.network.GenericResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class AddDataTableEntryUseCase @Inject constructor(private val repository: DataTableRowDialogRepository) {

suspend operator fun invoke(
table: String,
entityId: Int,
payload: Map<String, String>
): Flow<Resource<GenericResponse>> = flow {
try {
emit(Resource.Loading())
val response = repository.addDataTableEntry(table, entityId, payload)
emit(Resource.Success(response))

} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class DataManagerDataTable @Inject constructor(
return mBaseApiManager.dataTableApi.getDataOfDataTable(table, entityId)
}

fun addDataTableEntry(
table: String?, entityId: Int, payload: Map<String, String>
): Observable<GenericResponse> {
suspend fun addDataTableEntry(
table: String, entityId: Int, payload: Map<String, String>
): GenericResponse {
return mBaseApiManager.dataTableApi
.createEntryInDataTable(table, entityId, payload)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ interface DataTableService {

//TODO Improve Body Implementation with Payload
@POST(APIEndPoint.DATATABLES + "/{dataTableName}/{entityId}/")
fun createEntryInDataTable(
@Path("dataTableName") dataTableName: String?,
suspend fun createEntryInDataTable(
@Path("dataTableName") dataTableName: String,
@Path("entityId") entityId: Int,
@Body requestPayload: Map<String, String>
): Observable<GenericResponse>
): GenericResponse

@DELETE(APIEndPoint.DATATABLES + "/{dataTableName}/{entityId}/{dataTableRowId}")
fun deleteEntryOfDataTableManyToMany(
Expand Down
Loading