refactor codebase to be more module for later adding new banks.. add support for single profile mib accounts.. add suport for disabling mib profiles in settings
Auto Tag on Version Change / check-version (push) Successful in 6s
Auto Tag on Version Change / check-version (push) Successful in 6s
This commit is contained in:
@@ -618,6 +618,7 @@ class BmlLoginFlow {
|
||||
if (accountType == "CASA") {
|
||||
val available = item.optDouble("availableBalance", 0.0)
|
||||
casaAccounts.add(MibAccount(
|
||||
bank = "BML",
|
||||
profileName = "Personal",
|
||||
profileType = "BML",
|
||||
accountNumber = accountNumber,
|
||||
@@ -641,6 +642,7 @@ class BmlLoginFlow {
|
||||
val available = cardBalance?.optDouble("AvailableLimit", 0.0) ?: 0.0
|
||||
val current = cardBalance?.optDouble("CurrentBalance", 0.0) ?: 0.0
|
||||
prepaidCards.add(MibAccount(
|
||||
bank = "BML",
|
||||
profileName = "Personal",
|
||||
profileType = if (isPrepaid) "BML_PREPAID" else "BML_CREDIT",
|
||||
accountNumber = accountNumber,
|
||||
|
||||
@@ -186,6 +186,7 @@ class FahipayLoginFlow {
|
||||
|
||||
fun buildAccount(profile: FahipayUserProfile, balance: Double, loginTag: String): MibAccount =
|
||||
MibAccount(
|
||||
bank = "FAHIPAY",
|
||||
profileName = profile.fullName.ifBlank { "Fahipay" },
|
||||
profileType = "FAHIPAY",
|
||||
accountNumber = profile.walletAccount,
|
||||
|
||||
@@ -136,10 +136,52 @@ class MibLoginFlow(private val credentialStore: CredentialStore) {
|
||||
}
|
||||
|
||||
val profiles = parseProfiles(loginResp)
|
||||
|
||||
lastSession = session2
|
||||
lastProfiles = profiles
|
||||
return fetchAllProfiles(session2, profiles, "mib_$username")
|
||||
lastProfiles = profiles // keep ALL profiles so settings can show them all
|
||||
|
||||
val hidden = credentialStore.getHiddenMibProfileIds()
|
||||
|
||||
// When the server already selected the profile and returned balances in A41
|
||||
// (single-profile case: profileSelected=true), use those accounts directly
|
||||
// without making an extra P47 call (which the server ignores or rejects).
|
||||
if (loginResp.optBoolean("profileSelected", false)) {
|
||||
val a41Balances = loginResp.optJSONArray("accountBalance")
|
||||
if (a41Balances != null && a41Balances.length() > 0) {
|
||||
val selectedId = loginResp.optString("selectedProfileId")
|
||||
val profile = profiles.firstOrNull { it.profileId == selectedId }
|
||||
?: profiles.firstOrNull()
|
||||
if (profile != null && (hidden.isEmpty() || profile.profileId !in hidden)) {
|
||||
val allAccounts = mutableListOf<MibAccount>()
|
||||
for (i in 0 until a41Balances.length()) {
|
||||
val a = a41Balances.getJSONObject(i)
|
||||
allAccounts.add(
|
||||
MibAccount(
|
||||
bank = "MIB",
|
||||
profileName = profile.name,
|
||||
profileType = profile.profileType,
|
||||
cifType = profile.cifType,
|
||||
accountNumber = a.optString("accountNumber"),
|
||||
accountBriefName = a.optString("accountBriefName"),
|
||||
currencyName = a.optString("currencyName"),
|
||||
accountTypeName = a.optString("accountTypeName"),
|
||||
availableBalance = a.optString("availableBalance"),
|
||||
currentBalance = a.optString("currentBalance"),
|
||||
blockedAmount = a.optString("blockedAmount"),
|
||||
mvrBalance = a.optString("mvrBalance"),
|
||||
statusDesc = a.optString("statusDesc"),
|
||||
profileImageHash = profile.customerImage,
|
||||
loginTag = "mib_$username",
|
||||
profileId = profile.profileId
|
||||
)
|
||||
)
|
||||
}
|
||||
return allAccounts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val visibleProfiles = if (hidden.isEmpty()) profiles else profiles.filter { it.profileId !in hidden }
|
||||
return fetchAllProfiles(session2, visibleProfiles, "mib_$username")
|
||||
}
|
||||
|
||||
// ─── Helpers ─────────────────────────────────────────────────────────────
|
||||
@@ -271,8 +313,10 @@ class MibLoginFlow(private val credentialStore: CredentialStore) {
|
||||
val a = accountBalances.getJSONObject(i)
|
||||
allAccounts.add(
|
||||
MibAccount(
|
||||
bank = "MIB",
|
||||
profileName = profile.name,
|
||||
profileType = profile.profileType,
|
||||
cifType = profile.cifType,
|
||||
accountNumber = a.optString("accountNumber"),
|
||||
accountBriefName = a.optString("accountBriefName"),
|
||||
currencyName = a.optString("currencyName"),
|
||||
|
||||
@@ -20,8 +20,10 @@ data class MibProfile(
|
||||
)
|
||||
|
||||
data class MibAccount(
|
||||
val bank: String, // "MIB", "BML", "FAHIPAY" — set by the login flow
|
||||
val profileName: String,
|
||||
val profileType: String,
|
||||
val cifType: String = "", // MIB: human-readable profile category (e.g. "Individual", "Sole Propr"); empty for other banks
|
||||
val accountNumber: String,
|
||||
val accountBriefName: String,
|
||||
val currencyName: String,
|
||||
|
||||
Reference in New Issue
Block a user