Skip to content

Commit

Permalink
Merge branch 'development' into homeOldPresenter-mvvm
Browse files Browse the repository at this point in the history
  • Loading branch information
PratyushSingh07 authored Aug 2, 2023
2 parents 6bd0af2 + bae4926 commit 35dd265
Show file tree
Hide file tree
Showing 107 changed files with 4,825 additions and 445 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ dependencies {

// Hilt
implementation("com.google.dagger:hilt-android:2.44")
kapt("com.google.dagger:hilt-android-compiler:2.44")
kapt("com.google.dagger:hilt-android-compiler:2.47")

}
apply plugin: 'com.google.gms.google-services'
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.api.local.PreferencesHelper
import org.mifos.mobile.repositories.*

@Module
Expand All @@ -25,4 +26,37 @@ class RepositoryModule {
fun providesUserDetailRepository(dataManager: DataManager): UserDetailRepository {
return UserDetailRepositoryImp(dataManager)
}

@Provides
fun providesLoanRepository(dataManager: DataManager): LoanRepository {
return LoanRepositoryImp(dataManager)
}

@Provides
fun providesNotificationRepository(dataManager: DataManager): NotificationRepository {
return NotificationRepositoryImp(dataManager)
}

@Provides
fun providesClientRepository(
dataManager: DataManager, preferencesHelper: PreferencesHelper
): ClientRepository {
return ClientRepositoryImp(dataManager, preferencesHelper)
}

@Provides
fun providesRecentTransactionRepository(dataManager: DataManager): RecentTransactionRepository {
return RecentTransactionRepositoryImp(dataManager)
}

@Provides
fun providesGuarantorRepository(dataManager: DataManager): GuarantorRepository {
return GuarantorRepositoryImp(dataManager)
}

@Provides
fun providesBeneficiaryRepository(dataManager: DataManager): BeneficiaryRepository {
return BeneficiaryRepositoryImp(dataManager)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import okhttp3.ResponseBody
import org.mifos.mobile.models.beneficiary.Beneficiary
import org.mifos.mobile.models.beneficiary.BeneficiaryPayload
import org.mifos.mobile.models.beneficiary.BeneficiaryUpdatePayload
import org.mifos.mobile.models.templates.beneficiary.BeneficiaryTemplate

interface BeneficiaryRepository {

fun beneficiaryTemplate(): Observable<BeneficiaryTemplate?>?

fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): Observable<ResponseBody?>?

fun updateBeneficiary(
beneficiaryId: Long?,
payload: BeneficiaryUpdatePayload?,
): Observable<ResponseBody?>?

fun deleteBeneficiary(beneficiaryId: Long?): Observable<ResponseBody?>?

fun beneficiaryList(): Observable<List<Beneficiary?>?>?

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import okhttp3.ResponseBody
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.models.beneficiary.Beneficiary
import org.mifos.mobile.models.beneficiary.BeneficiaryPayload
import org.mifos.mobile.models.beneficiary.BeneficiaryUpdatePayload
import org.mifos.mobile.models.templates.beneficiary.BeneficiaryTemplate
import javax.inject.Inject

class BeneficiaryRepositoryImp @Inject constructor(private val dataManager: DataManager) :
BeneficiaryRepository {

override fun beneficiaryTemplate(): Observable<BeneficiaryTemplate?>? {
return dataManager.beneficiaryTemplate
}

override fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): Observable<ResponseBody?>? {
return dataManager.createBeneficiary(beneficiaryPayload)
}

override fun updateBeneficiary(
beneficiaryId: Long?,
payload: BeneficiaryUpdatePayload?
): Observable<ResponseBody?>? {
return dataManager.updateBeneficiary(beneficiaryId, payload)
}

override fun deleteBeneficiary(beneficiaryId: Long?): Observable<ResponseBody?>? {
return dataManager.deleteBeneficiary(beneficiaryId)
}

override fun beneficiaryList(): Observable<List<Beneficiary?>?>? {
return dataManager.beneficiaryList
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import org.mifos.mobile.models.Page
import org.mifos.mobile.models.User
import org.mifos.mobile.models.client.Client

interface ClientRepository {

fun loadClient() : Observable<Page<Client?>?>?

fun saveAuthenticationTokenForSession(user: User)

fun reInitializeService()

fun setClientId(clientId: Long?)

fun clearPrefHelper()

fun updateAuthenticationToken(password: String)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import okhttp3.Credentials
import org.mifos.mobile.api.BaseApiManager
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.api.local.PreferencesHelper
import org.mifos.mobile.models.Page
import org.mifos.mobile.models.User
import org.mifos.mobile.models.client.Client
import org.mifos.mobile.utils.Constants
import javax.inject.Inject

class ClientRepositoryImp @Inject constructor(
private val dataManager: DataManager, private val preferencesHelper: PreferencesHelper
) : ClientRepository {

override fun loadClient(): Observable<Page<Client?>?>? {
return dataManager.clients
}

/**
* Save the authentication token from the server and the user ID.
* The authentication token would be used for accessing the authenticated
* APIs.
*
* @param user - The user that is to be saved.
*/
override fun saveAuthenticationTokenForSession(user: User) {
val authToken = Constants.BASIC + user.base64EncodedAuthenticationKey
preferencesHelper.userName = user.username
preferencesHelper.userId = user.userId
preferencesHelper.saveToken(authToken)
reInitializeService()
}

override fun reInitializeService() {
BaseApiManager.createService(
preferencesHelper.baseUrl,
preferencesHelper.tenant,
preferencesHelper.token,
)
}

override fun setClientId(clientId: Long?) {
preferencesHelper.clientId = clientId
dataManager.clientId = clientId
}

override fun clearPrefHelper() {
preferencesHelper.clear()
}

override fun updateAuthenticationToken(password: String) {
val authenticationToken = Credentials.basic(preferencesHelper.userName!!, password)
preferencesHelper.saveToken(authenticationToken)
BaseApiManager.createService(
preferencesHelper.baseUrl,
preferencesHelper.tenant,
preferencesHelper.token,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import okhttp3.ResponseBody
import org.mifos.mobile.models.guarantor.GuarantorApplicationPayload
import org.mifos.mobile.models.guarantor.GuarantorPayload
import org.mifos.mobile.models.guarantor.GuarantorTemplatePayload

interface GuarantorRepository {

fun getGuarantorTemplate(loanId: Long?): Observable<GuarantorTemplatePayload?>?

fun createGuarantor(
loanId: Long?,
payload: GuarantorApplicationPayload?,
): Observable<ResponseBody?>?

fun updateGuarantor(
payload: GuarantorApplicationPayload?,
loanId: Long?,
guarantorId: Long?,
): Observable<ResponseBody?>?

fun deleteGuarantor(loanId: Long?, guarantorId: Long?): Observable<ResponseBody?>?

fun getGuarantorList(loanId: Long): Observable<List<GuarantorPayload?>?>?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import okhttp3.ResponseBody
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.models.guarantor.GuarantorApplicationPayload
import org.mifos.mobile.models.guarantor.GuarantorPayload
import org.mifos.mobile.models.guarantor.GuarantorTemplatePayload
import javax.inject.Inject

class GuarantorRepositoryImp @Inject constructor(private val dataManager: DataManager) :
GuarantorRepository {

override fun getGuarantorTemplate(loanId: Long?): Observable<GuarantorTemplatePayload?>? {
return dataManager.getGuarantorTemplate(loanId)
}

override fun createGuarantor(
loanId: Long?,
payload: GuarantorApplicationPayload?
): Observable<ResponseBody?>? {
return dataManager.createGuarantor(loanId, payload)
}

override fun updateGuarantor(
payload: GuarantorApplicationPayload?,
loanId: Long?,
guarantorId: Long?
): Observable<ResponseBody?>? {
return dataManager.updateGuarantor(payload, loanId, guarantorId)
}

override fun deleteGuarantor(loanId: Long?, guarantorId: Long?): Observable<ResponseBody?>? {
return dataManager.deleteGuarantor(loanId, guarantorId)
}

override fun getGuarantorList(loanId: Long): Observable<List<GuarantorPayload?>?>? {
return dataManager.getGuarantorList(loanId)
}
}
26 changes: 26 additions & 0 deletions app/src/main/java/org/mifos/mobile/repositories/LoanRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import okhttp3.ResponseBody
import org.mifos.mobile.models.accounts.loan.LoanWithAssociations
import org.mifos.mobile.models.accounts.loan.LoanWithdraw
import org.mifos.mobile.models.templates.loans.LoanTemplate

interface LoanRepository {

fun getLoanWithAssociations(
associationType: String?,
loanId: Long?
): Observable<LoanWithAssociations?>?

fun withdrawLoanAccount(
loanId: Long?,
loanWithdraw: LoanWithdraw?,
): Observable<ResponseBody?>?

fun template(): Observable<LoanTemplate?>?

fun getLoanTemplateByProduct(
productId: Int?
): Observable<LoanTemplate?>?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import okhttp3.ResponseBody
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.models.accounts.loan.LoanWithAssociations
import org.mifos.mobile.models.accounts.loan.LoanWithdraw
import org.mifos.mobile.models.templates.loans.LoanTemplate
import javax.inject.Inject

class LoanRepositoryImp @Inject constructor(private val dataManager: DataManager) : LoanRepository {

override fun getLoanWithAssociations(
associationType: String?,
loanId: Long?
): Observable<LoanWithAssociations?>? {
return dataManager.getLoanWithAssociations(associationType, loanId)
}

override fun withdrawLoanAccount(
loanId: Long?,
loanWithdraw: LoanWithdraw?
): Observable<ResponseBody?>? {
return dataManager.withdrawLoanAccount(loanId, loanWithdraw)
}

override fun template(): Observable<LoanTemplate?>? {
return dataManager.loanTemplate
}

override fun getLoanTemplateByProduct(productId: Int?): Observable<LoanTemplate?>? {
return dataManager.getLoanTemplateByProduct(productId)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import org.mifos.mobile.models.notification.MifosNotification

interface NotificationRepository {

fun loadNotifications(): Observable<List<MifosNotification?>?>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.mifos.mobile.repositories

import io.reactivex.Observable
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.models.notification.MifosNotification
import javax.inject.Inject

class NotificationRepositoryImp @Inject constructor(private val dataManager: DataManager) : NotificationRepository {

override fun loadNotifications(): Observable<List<MifosNotification?>?> {
return dataManager.notifications
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.mifos.mobile.repositories


import io.reactivex.Observable
import org.mifos.mobile.models.Page
import org.mifos.mobile.models.Transaction

interface RecentTransactionRepository {

fun recentTransactions(
offset: Int?,
limit: Int?
): Observable<Page<Transaction?>?>?
}
Loading

0 comments on commit 35dd265

Please sign in to comment.