Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/mvvm_architecture' into savingFe…
Browse files Browse the repository at this point in the history
…atures-MVVM-Migration

# Conflicts:
#	app/src/main/java/org/mifos/mobile/injection/module/RepositoryModule.kt
  • Loading branch information
gururani-abhishek committed Jul 17, 2023
2 parents 34cc390 + 85f34a6 commit 36ac2b3
Show file tree
Hide file tree
Showing 13 changed files with 396 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import dagger.hilt.components.SingletonComponent
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.repositories.SavingsAccountRepository
import org.mifos.mobile.repositories.SavingsAccountRepositoryImp
import org.mifos.mobile.api.local.PreferencesHelper
import org.mifos.mobile.repositories.ClientRepository
import org.mifos.mobile.repositories.ClientRepositoryImp
import org.mifos.mobile.repositories.RecentTransactionRepository
import org.mifos.mobile.repositories.RecentTransactionRepositoryImp
import org.mifos.mobile.repositories.UserAuthRepository
Expand All @@ -26,6 +29,11 @@ class RepositoryModule {
return SavingsAccountRepositoryImp(dataManager)
}

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

@Provides
fun providesRecentTransactionRepository(dataManager: DataManager): RecentTransactionRepository {
return RecentTransactionRepositoryImp(dataManager)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.mifos.mobile.repositories

interface ClientRepository {

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

import okhttp3.Credentials
import org.mifos.mobile.api.BaseApiManager
import org.mifos.mobile.api.local.PreferencesHelper
import javax.inject.Inject

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

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
Expand Up @@ -15,4 +15,9 @@ interface UserAuthRepository {
password: String?,
username: String?
): Observable<ResponseBody?>?

fun updateAccountPassword(
newPassword: String, confirmPassword: String
): Observable<ResponseBody?>?

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package org.mifos.mobile.repositories
import io.reactivex.Observable
import okhttp3.ResponseBody
import org.mifos.mobile.api.DataManager
import org.mifos.mobile.models.UpdatePasswordPayload
import org.mifos.mobile.models.register.RegisterPayload
import javax.inject.Inject

class UserAuthRepositoryImp @Inject constructor(private val dataManager: DataManager) :
UserAuthRepository {
class UserAuthRepositoryImp @Inject constructor(private val dataManager: DataManager) : UserAuthRepository {

override fun registerUser(
accountNumber: String?,
Expand All @@ -31,4 +31,16 @@ class UserAuthRepositoryImp @Inject constructor(private val dataManager: DataMan
}
return dataManager.registerUser(registerPayload)
}

override fun updateAccountPassword(
newPassword: String, confirmPassword: String
): Observable<ResponseBody?>? {
val payload = UpdatePasswordPayload().apply {
this.password = newPassword
this.repeatPassword = confirmPassword
}

return dataManager.updateAccountPassword(payload)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ class RegistrationFragment : BaseFragment() {
when (state) {
RegistrationUiState.Loading -> showProgress()

RegistrationUiState.RegistrationSuccessful -> {
RegistrationUiState.Success -> {
hideProgress()
showRegisteredSuccessfully()
}

is RegistrationUiState.ErrorOnRegistration -> {
is RegistrationUiState.Error -> {
hideProgress()
showError(MFErrorParser.errorMessage(state.exception))
}
Expand Down
Loading

0 comments on commit 36ac2b3

Please sign in to comment.