From 7089ebcb3cbf3dbd43bc2a235e1327883205a889 Mon Sep 17 00:00:00 2001 From: Pratyush Singh <90026952+PratyushSingh07@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:44:31 +0530 Subject: [PATCH] getSavingsWithAssociations in SavingsAccountService migrated to ktor (#1757) --- .../account/FetchAccountTransactions.kt | 50 +++++++++---------- .../fineract/repository/FineractRepository.kt | 4 +- .../com/mifospay/core/model/domain/Account.kt | 9 ++-- .../mifospay/core/model/domain/Currency.kt | 7 ++- .../mifospay/core/model/domain/Transaction.kt | 15 +++--- .../core/model/domain/client/Client.kt | 5 +- .../mifospay/core/model/entity/Timeline.kt | 7 ++- .../model/entity/accounts/savings/Currency.kt | 7 ++- .../accounts/savings/PaymentDetailData.kt | 7 ++- .../entity/accounts/savings/PaymentType.kt | 7 ++- .../entity/accounts/savings/SavingAccount.kt | 7 ++- .../savings/SavingsWithAssociations.kt | 7 ++- .../model/entity/accounts/savings/Status.kt | 7 ++- .../model/entity/accounts/savings/Summary.kt | 7 ++- .../model/entity/accounts/savings/TimeLine.kt | 7 ++- .../accounts/savings/TransactionType.kt | 5 +- .../entity/accounts/savings/Transactions.kt | 7 ++- .../model/entity/accounts/savings/Transfer.kt | 7 ++- .../entity/accounts/savings/TransferDetail.kt | 8 ++- .../core/model/entity/client/Client.kt | 5 +- .../model/entity/client/ClientAccounts.kt | 7 ++- .../core/model/entity/client/DepositType.kt | 7 ++- .../core/model/entity/client/Status.kt | 7 ++- .../StandingInstruction.kt | 7 ++- .../core/network/SelfServiceApiManager.kt | 5 ++ .../mifospay/core/network/di/NetworkModule.kt | 11 ++++ ...ervice.kt => KtorAuthenticationService.kt} | 0 .../services/KtorSavingsAccountService.kt | 24 +++++++++ .../services/SavingsAccountsService.kt | 5 -- 29 files changed, 138 insertions(+), 120 deletions(-) rename core/network/src/main/kotlin/org/mifospay/core/network/services/{KtorAuthService.kt => KtorAuthenticationService.kt} (100%) create mode 100644 core/network/src/main/kotlin/org/mifospay/core/network/services/KtorSavingsAccountService.kt diff --git a/core/data/src/main/java/org/mifospay/core/data/domain/usecase/account/FetchAccountTransactions.kt b/core/data/src/main/java/org/mifospay/core/data/domain/usecase/account/FetchAccountTransactions.kt index 5a2a5c318..26d1db1c9 100644 --- a/core/data/src/main/java/org/mifospay/core/data/domain/usecase/account/FetchAccountTransactions.kt +++ b/core/data/src/main/java/org/mifospay/core/data/domain/usecase/account/FetchAccountTransactions.kt @@ -9,15 +9,16 @@ */ package org.mifospay.core.data.domain.usecase.account +import android.util.Log import com.mifospay.core.model.domain.Transaction -import com.mifospay.core.model.entity.accounts.savings.SavingsWithAssociations +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import org.mifospay.core.data.base.UseCase import org.mifospay.core.data.fineract.entity.mapper.TransactionMapper import org.mifospay.core.data.fineract.repository.FineractRepository import org.mifospay.core.data.util.Constants -import rx.Subscriber -import rx.android.schedulers.AndroidSchedulers -import rx.schedulers.Schedulers import javax.inject.Inject class FetchAccountTransactions @Inject constructor( @@ -26,27 +27,26 @@ class FetchAccountTransactions @Inject constructor( ) : UseCase() { override fun executeUseCase(requestValues: RequestValues) { - fineractRepository.getSelfAccountTransactions(requestValues.accountId) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe( - object : Subscriber() { - override fun onCompleted() {} - override fun onError(e: Throwable) { - useCaseCallback.onError( - Constants.ERROR_FETCHING_REMOTE_ACCOUNT_TRANSACTIONS, - ) - } - - override fun onNext(transactions: SavingsWithAssociations) { - useCaseCallback.onSuccess( - ResponseValue( - transactionMapper.transformTransactionList(transactions), - ), - ) - } - }, - ) + CoroutineScope(Dispatchers.IO).launch { + try { + val api = fineractRepository.getSelfAccountTransactions(requestValues.accountId) + withContext(Dispatchers.Main) { + Log.d("FetchTransactions@@@@","$api") + useCaseCallback.onSuccess( + ResponseValue( + transactionMapper.transformTransactionList(api), + ), + ) + } + } catch (e: Exception) { + withContext(Dispatchers.Main) { + Log.d("FetchTransactions@@@@","${e.message}") + useCaseCallback.onError( + Constants.ERROR_FETCHING_REMOTE_ACCOUNT_TRANSACTIONS, + ) + } + } + } } data class RequestValues(var accountId: Long) : UseCase.RequestValues diff --git a/core/data/src/main/java/org/mifospay/core/data/fineract/repository/FineractRepository.kt b/core/data/src/main/java/org/mifospay/core/data/fineract/repository/FineractRepository.kt index eb006980f..9c3db3c00 100644 --- a/core/data/src/main/java/org/mifospay/core/data/fineract/repository/FineractRepository.kt +++ b/core/data/src/main/java/org/mifospay/core/data/fineract/repository/FineractRepository.kt @@ -286,8 +286,8 @@ class FineractRepository @Inject constructor( val selfClientDetails: Observable> get() = selfApiManager.clientsApi.clients - fun getSelfAccountTransactions(accountId: Long): Observable { - return selfApiManager.savingAccountsListApi.getSavingsWithAssociations( + suspend fun getSelfAccountTransactions(accountId: Long): SavingsWithAssociations { + return selfApiManager.ktorSavingsAccountApi.getSavingsWithAssociations( accountId, Constants.TRANSACTIONS, ) diff --git a/core/model/src/main/java/com/mifospay/core/model/domain/Account.kt b/core/model/src/main/java/com/mifospay/core/model/domain/Account.kt index 3753343b5..111a68214 100644 --- a/core/model/src/main/java/com/mifospay/core/model/domain/Account.kt +++ b/core/model/src/main/java/com/mifospay/core/model/domain/Account.kt @@ -9,10 +9,9 @@ */ package com.mifospay.core.model.domain -import android.os.Parcelable -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Account( var image: String = "", var name: String, @@ -20,5 +19,5 @@ data class Account( var balance: Double = 0.0, var id: Long = 0L, var productId: Long = 0L, - var currency: com.mifospay.core.model.domain.Currency, -) : Parcelable + var currency: Currency, +) diff --git a/core/model/src/main/java/com/mifospay/core/model/domain/Currency.kt b/core/model/src/main/java/com/mifospay/core/model/domain/Currency.kt index e5d6a693b..b17050b84 100644 --- a/core/model/src/main/java/com/mifospay/core/model/domain/Currency.kt +++ b/core/model/src/main/java/com/mifospay/core/model/domain/Currency.kt @@ -9,14 +9,13 @@ */ package com.mifospay.core.model.domain -import android.os.Parcelable -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Currency( var code: String, var displaySymbol: String, var displayLabel: String, -) : Parcelable { +) { constructor() : this("", "", "") } diff --git a/core/model/src/main/java/com/mifospay/core/model/domain/Transaction.kt b/core/model/src/main/java/com/mifospay/core/model/domain/Transaction.kt index ed13dfd16..48a73f7f5 100644 --- a/core/model/src/main/java/com/mifospay/core/model/domain/Transaction.kt +++ b/core/model/src/main/java/com/mifospay/core/model/domain/Transaction.kt @@ -9,32 +9,31 @@ */ package com.mifospay.core.model.domain -import android.os.Parcelable import com.mifospay.core.model.entity.accounts.savings.TransferDetail -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable @Suppress("MaxLineLength") -@Parcelize +@Serializable data class Transaction( var transactionId: String? = null, var clientId: Long = 0, var accountId: Long = 0, var amount: Double = 0.0, var date: String? = null, - var currency: com.mifospay.core.model.domain.Currency = com.mifospay.core.model.domain.Currency(), - var transactionType: com.mifospay.core.model.domain.TransactionType = com.mifospay.core.model.domain.TransactionType.OTHER, + var currency: Currency = Currency(), + var transactionType: TransactionType = TransactionType.OTHER, var transferId: Long = 0, var transferDetail: TransferDetail = TransferDetail(), var receiptId: String? = null, -) : Parcelable { +) { constructor() : this( "", 0, 0, 0.0, "", - com.mifospay.core.model.domain.Currency(), - com.mifospay.core.model.domain.TransactionType.OTHER, + Currency(), + TransactionType.OTHER, 0, TransferDetail(), "", diff --git a/core/model/src/main/java/com/mifospay/core/model/domain/client/Client.kt b/core/model/src/main/java/com/mifospay/core/model/domain/client/Client.kt index 578d0f3fe..0ec05be34 100644 --- a/core/model/src/main/java/com/mifospay/core/model/domain/client/Client.kt +++ b/core/model/src/main/java/com/mifospay/core/model/domain/client/Client.kt @@ -11,8 +11,9 @@ package com.mifospay.core.model.domain.client import android.os.Parcelable import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Client( var name: String? = null, var image: String, @@ -20,6 +21,6 @@ data class Client( var clientId: Long = 0L, var displayName: String, var mobileNo: String, -) : Parcelable { +) { constructor() : this("", "", "", 0L, "", "") } diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/Timeline.kt b/core/model/src/main/java/com/mifospay/core/model/entity/Timeline.kt index 8ee44f42a..cbc1e3418 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/Timeline.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/Timeline.kt @@ -9,10 +9,9 @@ */ package com.mifospay.core.model.entity -import android.os.Parcelable -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Timeline( var submittedOnDate: List = ArrayList(), var submittedByUsername: String? = null, @@ -26,6 +25,6 @@ data class Timeline( var closedByUsername: String? = null, var closedByFirstname: String? = null, var closedByLastname: String? = null, -) : Parcelable { +) { constructor() : this(ArrayList(), "", "", "", ArrayList(), "", "", "", ArrayList(), "", "", "") } diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Currency.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Currency.kt index 962fd9e7b..a6156f0d3 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Currency.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Currency.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Currency( @SerializedName("code") @@ -37,6 +36,6 @@ data class Currency( @SerializedName("displayLabel") var displayLabel: String = " ", -) : Parcelable { +) { constructor() : this("", "", 0, 0, "", "", "") } diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/PaymentDetailData.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/PaymentDetailData.kt index 718942f83..3cca8dfa6 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/PaymentDetailData.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/PaymentDetailData.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class PaymentDetailData( @SerializedName("id") var id: Int? = null, @@ -35,6 +34,6 @@ data class PaymentDetailData( @SerializedName("bankNumber") var bankNumber: String? = null, -) : Parcelable { +) { constructor() : this(null, null, null, null, null, null, null) } diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/PaymentType.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/PaymentType.kt index 034d39aa5..57e449a09 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/PaymentType.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/PaymentType.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class PaymentType( @SerializedName("id") var id: Int? = null, @@ -21,4 +20,4 @@ data class PaymentType( @SerializedName("name") var name: String? = null, -) : Parcelable +) diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/SavingAccount.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/SavingAccount.kt index 8d6ce73b2..5d3336b15 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/SavingAccount.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/SavingAccount.kt @@ -9,12 +9,11 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName import com.mifospay.core.model.entity.client.DepositType -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class SavingAccount( @SerializedName("id") @@ -62,7 +61,7 @@ data class SavingAccount( @SerializedName("depositType") var depositType: DepositType? = null, -) : Parcelable { +) { fun isRecurring(): Boolean { return this.depositType != null && this.depositType!!.isRecurring } diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/SavingsWithAssociations.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/SavingsWithAssociations.kt index 50a202acf..5e5304f22 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/SavingsWithAssociations.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/SavingsWithAssociations.kt @@ -9,12 +9,11 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName import com.mifospay.core.model.entity.client.DepositType -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class SavingsWithAssociations( @SerializedName("id") @@ -86,7 +85,7 @@ data class SavingsWithAssociations( @SerializedName("transactions") var transactions: List = ArrayList(), -) : Parcelable { +) { constructor() : this( 0L, null, diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Status.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Status.kt index 205279d60..580034a32 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Status.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Status.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Status( @SerializedName("id") @@ -54,7 +53,7 @@ data class Status( @SerializedName("matured") var matured: Boolean? = null, -) : Parcelable { +) { constructor() : this( null, null, diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Summary.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Summary.kt index 55b0c9074..4107908ab 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Summary.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Summary.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Summary( @SerializedName("currency") var currency: Currency? = null, @@ -41,4 +40,4 @@ data class Summary( @SerializedName("lastInterestCalculationDate") var lastInterestCalculationDate: List? = null, -) : Parcelable +) diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TimeLine.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TimeLine.kt index aa0210783..033935f16 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TimeLine.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TimeLine.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class TimeLine( @SerializedName("submittedOnDate") var submittedOnDate: List = ArrayList(), @@ -50,7 +49,7 @@ data class TimeLine( @SerializedName("activatedByLastname") var activatedByLastname: String? = null, -) : Parcelable { +) { constructor() : this( ArrayList(), null, diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TransactionType.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TransactionType.kt index 2c72300f9..c51e65c9a 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TransactionType.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TransactionType.kt @@ -12,8 +12,9 @@ package com.mifospay.core.model.entity.accounts.savings import android.os.Parcelable import com.google.gson.annotations.SerializedName import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class TransactionType( @SerializedName("id") var id: Int? = null, @@ -67,4 +68,4 @@ data class TransactionType( @SerializedName("escheat") var escheat: Boolean? = null, -) : Parcelable +) diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Transactions.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Transactions.kt index 58c3a9afa..b5d7dab26 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Transactions.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Transactions.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Transactions( @SerializedName("id") @@ -54,7 +53,7 @@ data class Transactions( @SerializedName("interestedPostedAsOn") var interestedPostedAsOn: Boolean? = null, -) : Parcelable { +) { constructor() : this( 0, TransactionType(), diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Transfer.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Transfer.kt index 5162dc4b0..5dce2a848 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Transfer.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/Transfer.kt @@ -9,14 +9,13 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Transfer( @SerializedName("id") var id: Long = 0L, -) : Parcelable { +) { constructor() : this(0L) } diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TransferDetail.kt b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TransferDetail.kt index a7d02d0ef..57c156b6a 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TransferDetail.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/accounts/savings/TransferDetail.kt @@ -9,12 +9,10 @@ */ package com.mifospay.core.model.entity.accounts.savings -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import com.mifospay.core.model.domain.client.Client -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class TransferDetail( @SerializedName("id") var id: Long = 0L, @@ -30,7 +28,7 @@ data class TransferDetail( @SerializedName("toAccount") var toAccount: SavingAccount = SavingAccount(), -) : Parcelable { +) { constructor() : this( 0L, com.mifospay.core.model.domain.client.Client(), diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/client/Client.kt b/core/model/src/main/java/com/mifospay/core/model/entity/client/Client.kt index e1cd187ae..62fef0e1a 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/client/Client.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/client/Client.kt @@ -13,8 +13,9 @@ import android.os.Parcelable import com.google.gson.annotations.SerializedName import com.mifospay.core.model.entity.Timeline import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Client( @SerializedName("id") @@ -76,7 +77,7 @@ data class Client( @SerializedName("mobileNo") var mobileNo: String = "", -) : Parcelable { +) { constructor() : this( 0, "", diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/client/ClientAccounts.kt b/core/model/src/main/java/com/mifospay/core/model/entity/client/ClientAccounts.kt index b534e6f90..79c8787b1 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/client/ClientAccounts.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/client/ClientAccounts.kt @@ -9,14 +9,13 @@ */ package com.mifospay.core.model.entity.client -import android.os.Parcelable import com.mifospay.core.model.entity.accounts.savings.SavingAccount -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class ClientAccounts( var savingsAccounts: List = ArrayList(), -) : Parcelable { +) { fun withSavingsAccounts(savingsAccounts: List): ClientAccounts { this.savingsAccounts = savingsAccounts diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/client/DepositType.kt b/core/model/src/main/java/com/mifospay/core/model/entity/client/DepositType.kt index 7a76a1a60..b82c3886a 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/client/DepositType.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/client/DepositType.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.client -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class DepositType( @SerializedName("id") var id: Int? = null, @@ -24,7 +23,7 @@ data class DepositType( @SerializedName("value") var value: String? = null, -) : Parcelable { +) { val isRecurring: Boolean get() = ServerTypes.RECURRING.id == id val endpoint: String diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/client/Status.kt b/core/model/src/main/java/com/mifospay/core/model/entity/client/Status.kt index 87913df15..a8d079182 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/client/Status.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/client/Status.kt @@ -9,11 +9,10 @@ */ package com.mifospay.core.model.entity.client -import android.os.Parcelable import com.google.gson.annotations.SerializedName -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class Status( @SerializedName("id") var id: Int? = null, @@ -23,6 +22,6 @@ data class Status( @SerializedName("value") var value: String? = null, -) : Parcelable { +) { constructor() : this(null, null, null) } diff --git a/core/model/src/main/java/com/mifospay/core/model/entity/standinginstruction/StandingInstruction.kt b/core/model/src/main/java/com/mifospay/core/model/entity/standinginstruction/StandingInstruction.kt index 11aacf0ba..84242a7f4 100644 --- a/core/model/src/main/java/com/mifospay/core/model/entity/standinginstruction/StandingInstruction.kt +++ b/core/model/src/main/java/com/mifospay/core/model/entity/standinginstruction/StandingInstruction.kt @@ -9,14 +9,13 @@ */ package com.mifospay.core.model.entity.standinginstruction -import android.os.Parcelable import com.google.gson.annotations.SerializedName import com.mifospay.core.model.entity.accounts.savings.SavingAccount import com.mifospay.core.model.entity.client.Client import com.mifospay.core.model.entity.client.Status -import kotlinx.parcelize.Parcelize +import kotlinx.serialization.Serializable -@Parcelize +@Serializable data class StandingInstruction( val id: Long, @@ -53,4 +52,4 @@ data class StandingInstruction( @SerializedName("recurrenceOnMonthDay") val recurrenceOnMonthDay: List, -) : Parcelable +) diff --git a/core/network/src/main/kotlin/org/mifospay/core/network/SelfServiceApiManager.kt b/core/network/src/main/kotlin/org/mifospay/core/network/SelfServiceApiManager.kt index 834b790bb..7dd8163c7 100644 --- a/core/network/src/main/kotlin/org/mifospay/core/network/SelfServiceApiManager.kt +++ b/core/network/src/main/kotlin/org/mifospay/core/network/SelfServiceApiManager.kt @@ -12,6 +12,8 @@ package org.mifospay.core.network import org.mifospay.core.network.services.AuthenticationService import org.mifospay.core.network.services.BeneficiaryService import org.mifospay.core.network.services.ClientService +import org.mifospay.core.network.services.KtorAuthenticationService +import org.mifospay.core.network.services.KtorSavingsAccountService import org.mifospay.core.network.services.RegistrationService import org.mifospay.core.network.services.SavingsAccountsService import org.mifospay.core.network.services.ThirdPartyTransferService @@ -24,6 +26,7 @@ class SelfServiceApiManager @Inject constructor( private val registrationService: RegistrationService, private val beneficiaryService: BeneficiaryService, private val thirdPartyTransferService: ThirdPartyTransferService, + private val ktorSavingsAccountService: KtorSavingsAccountService ) { val authenticationApi: AuthenticationService get() = authenticationService @@ -37,4 +40,6 @@ class SelfServiceApiManager @Inject constructor( get() = beneficiaryService val thirdPartyTransferApi: ThirdPartyTransferService get() = thirdPartyTransferService + val ktorSavingsAccountApi: KtorSavingsAccountService + get() = ktorSavingsAccountService } diff --git a/core/network/src/main/kotlin/org/mifospay/core/network/di/NetworkModule.kt b/core/network/src/main/kotlin/org/mifospay/core/network/di/NetworkModule.kt index 8f095f4d5..3af4cd732 100644 --- a/core/network/src/main/kotlin/org/mifospay/core/network/di/NetworkModule.kt +++ b/core/network/src/main/kotlin/org/mifospay/core/network/di/NetworkModule.kt @@ -39,6 +39,7 @@ import org.mifospay.core.network.services.DocumentService import org.mifospay.core.network.services.InvoiceService import org.mifospay.core.network.services.KYCLevel1Service import org.mifospay.core.network.services.KtorAuthenticationService +import org.mifospay.core.network.services.KtorSavingsAccountService import org.mifospay.core.network.services.NotificationService import org.mifospay.core.network.services.RegistrationService import org.mifospay.core.network.services.RunReportService @@ -142,6 +143,7 @@ class NetworkModule { @Named("SelfServiceAuthenticationService") authenticationService: AuthenticationService, @Named("SelfServiceClientService") clientService: ClientService, @Named("SelfServiceSavingsAccountsService") savingsAccountsService: SavingsAccountsService, + ktorSavingsAccountService: KtorSavingsAccountService, @Named("SelfServiceRegistrationService") registrationService: RegistrationService, beneficiaryService: BeneficiaryService, @Named("SelfServiceThirdPartyTransferService") thirdPartyTransferService: ThirdPartyTransferService, @@ -153,6 +155,7 @@ class NetworkModule { registrationService, beneficiaryService, thirdPartyTransferService, + ktorSavingsAccountService ) } @@ -187,6 +190,14 @@ class NetworkModule { return KtorAuthenticationService(client) } + @Provides + @Singleton + fun providesKtorSavingsAccountService( + client: HttpClient + ): KtorSavingsAccountService { + return KtorSavingsAccountService(client) + } + // -----Fineract API Service---------// @Provides diff --git a/core/network/src/main/kotlin/org/mifospay/core/network/services/KtorAuthService.kt b/core/network/src/main/kotlin/org/mifospay/core/network/services/KtorAuthenticationService.kt similarity index 100% rename from core/network/src/main/kotlin/org/mifospay/core/network/services/KtorAuthService.kt rename to core/network/src/main/kotlin/org/mifospay/core/network/services/KtorAuthenticationService.kt diff --git a/core/network/src/main/kotlin/org/mifospay/core/network/services/KtorSavingsAccountService.kt b/core/network/src/main/kotlin/org/mifospay/core/network/services/KtorSavingsAccountService.kt new file mode 100644 index 000000000..2f68f73b2 --- /dev/null +++ b/core/network/src/main/kotlin/org/mifospay/core/network/services/KtorSavingsAccountService.kt @@ -0,0 +1,24 @@ +package org.mifospay.core.network.services + +import com.mifospay.core.model.entity.accounts.savings.SavingsWithAssociations +import io.ktor.client.HttpClient +import io.ktor.client.call.body +import io.ktor.client.request.get +import jakarta.inject.Inject +import org.mifospay.core.network.ApiEndPoints +import org.mifospay.core.network.BaseURL + +class KtorSavingsAccountService @Inject constructor( + private val client: HttpClient +) { + suspend fun getSavingsWithAssociations( + accountId: Long, + associationType: String + ): SavingsWithAssociations { + return client.get("${BaseURL().selfServiceUrl}${ApiEndPoints.SAVINGS_ACCOUNTS}/$accountId") { + url { + parameters.append("associations", associationType) + } + }.body() + } +} \ No newline at end of file diff --git a/core/network/src/main/kotlin/org/mifospay/core/network/services/SavingsAccountsService.kt b/core/network/src/main/kotlin/org/mifospay/core/network/services/SavingsAccountsService.kt index 816029c4c..dbaa03ba8 100644 --- a/core/network/src/main/kotlin/org/mifospay/core/network/services/SavingsAccountsService.kt +++ b/core/network/src/main/kotlin/org/mifospay/core/network/services/SavingsAccountsService.kt @@ -23,11 +23,6 @@ import retrofit2.http.Query import rx.Observable interface SavingsAccountsService { - @GET(ApiEndPoints.SAVINGS_ACCOUNTS + "/{accountId}") - fun getSavingsWithAssociations( - @Path("accountId") accountId: Long, - @Query("associations") associationType: String, - ): Observable @GET(ApiEndPoints.SAVINGS_ACCOUNTS) fun getSavingsAccounts(