Loan Information
Relevant source files
The following files were used as context for generating this wiki page:
The Loan Information module in the MBBank SDK provides developers with the capability to retrieve and manage loan-related data from Military Commercial Joint Stock Bank (MBBank) personal accounts. This feature is integrated into both the synchronous and asynchronous core clients, allowing for the retrieval of loan lists, balances, and branch-specific account information associated with credit facilities.
Within the broader architecture, Loan Information serves as a sub-module of the Account Management system, complementing features such as Balance Information and Saving Information. It relies on the project's centralized authentication mechanism and Pydantic-based response modeling to ensure data integrity and type safety when communicating with MBBank's REST API.
Sources: mbbank/init.py:66, mbbank/aio/mbbank.py:417-431, mbbank/sync/mbbank.py:388-402
API Architecture and Integration
The SDK implements loan data retrieval through a dedicated endpoint managed by both MBBank (synchronous) and MBBankAsync (asynchronous) classes. The process involves sending a POST request to the MBBank retail online loan management system.
Request Flow
The following diagram illustrates the sequence of operations required to fetch loan information, including the internal authentication check:
Endpoint Specification
| Detail | Value |
|---|---|
| URL | https://online.mbbank.com.vn/api/retail-onlineloanms/loan/getList |
| Method | POST |
| Authentication | Required (Session ID + Device ID) |
| Encryption | Standard Request (No Wasm Encryption applied to this specific endpoint) |
Sources: mbbank/aio/mbbank.py:429, mbbank/sync/mbbank.py:400
Data Modeling
The SDK utilizes Pydantic models to structure the loan data returned by the API. The primary model is the LoanListResponseModal, which encapsulates loan totals, online loan lists, and branch account details.
LoanListResponseModal Structure
The LoanListResponseModal inherits from BaseResponseModal and contains several fields related to credit balances and loan aggregates.
| Field | Type | Description |
|---|---|---|
totalLoan | str | Total value of all loans. |
onlineLoansList | List[Any] | A list containing individual online loan objects. |
olaTotalBalance | str | Total balance for Online Loan Accounts (OLA). |
branchAccountList | List[Any] | List of accounts associated with physical bank branches. |
lbaTotalBalance | str | Total balance for Loan Branch Accounts (LBA). |
currencyEquivalent | str | The currency designation for the loan amounts (e.g., VND). |
Sources: mbbank/modals/loan_list.py:5-18
User Profile Association
Loan status is also tracked at the user profile level. The CustModel within UserInfoResponseModal contains a flag indicating if the customer has active loans.
class CustModel(BaseModel):
# ... other fields
isLoan: Optional[str] # Indicates loan status
# ...
Sources: mbbank/modals/userinfo.py:186
Implementation Details
Synchronous Implementation
The synchronous MBBank.getLoanList() method performs a blocking network call using the requests library.
def getLoanList(self) -> LoanListResponseModal:
data_out = self._req(
"https://online.mbbank.com.vn/api/retail-onlineloanms/loan/getList"
)
return LoanListResponseModal.model_validate(data_out, strict=True)
Sources: mbbank/sync/mbbank.py:388-402
Asynchronous Implementation
The asynchronous MBBankAsync.getLoanList() method utilizes aiohttp for non-blocking I/O, suitable for high-concurrency environments.
async def getLoanList(self) -> LoanListResponseModal:
data_out = await self._req(
"https://online.mbbank.com.vn/api/retail-onlineloanms/loan/getList"
)
return LoanListResponseModal.model_validate(data_out, strict=True)
Sources: mbbank/aio/mbbank.py:417-431
Conclusion
The Loan Information system provides a streamlined interface for accessing a user's credit portfolio. By abstracting the complexities of the MBBank API and providing structured models like LoanListResponseModal, the SDK enables developers to monitor loan balances and list active credit facilities with minimal boilerplate code. Accessing this data requires a valid session, which is handled automatically by the client's internal authentication logic.