Data Models
Relevant source files
The following files were used as context for generating this wiki page:
Data Models in the MBBank library provide a structured, type-safe representation of the data structures returned by the Military Commercial Joint Stock Bank (MBBank) API. Built using the pydantic library, these models ensure that complex JSON responses from the bank's internal services are validated and converted into Python objects with clear attributes and nested relationships.
The models are primarily located within the mbbank.modals package and cover a wide range of banking domains including user profile management, account balances, fund transfers, card management, and savings accounts.
Core Architecture and Base Models
The data model hierarchy is built upon a standard base class that handles common metadata found in MBBank API responses.
Base Response Structure
Most API responses from MBBank include a reference number (refNo) used for tracking and auditing requests. The BaseResponseModal serves as the parent class for nearly all response models in the library.
Key Base Components
| Component | Description |
|---|---|
BaseResponseModal | The foundation for all response objects, containing the mandatory refNo. |
Account | A generic model representing basic bank account details like account number, name, and balance. |
ServiceTokenResponseModal | Represents tokens used for accessing external services like ATM card ID generation. |
Sources: mbbank/modals/base.py:7-45
User and Profile Models
The user information model is the most complex structure in the library, encompassing customer identity, active sessions, and nested summaries of accounts and security devices.
Customer Data Hierarchy
The CustModel acts as the central hub for user-specific data, including nested dictionaries of accounts and lists of security tokens.
Sources: mbbank/modals/userinfo.py:141-225
User Model Specifications
| Class | Purpose | Key Fields |
|---|---|---|
CustModel | Primary user identity data. | nm (name), userId, hostCifId, acct_list, cardList. |
UserInfoAccountModel | Specialized account info within user profile. | acctNo, acctNm, currentBalance, productType. |
SoftTokenModel | Security device information. | deviceNo, deviceType, token, status. |
BiometricAuthDeviceModel | Biometric security registration. | bioId, bioLevel, deviceId, hashCifId. |
Sources: mbbank/modals/userinfo.py:10-225
Financial and Transaction Models
These models handle the representation of liquid assets, transfers, and the configuration of banks within the MBBank ecosystem.
Transfer Flow and Verification
Fund transfers involve multiple stages, including inquiry and authentication. The models capture the verified transaction details and the authentication methods required.
Sources: mbbank/modals/transfer.py:7-78
Bank and Beneficiary Models
The library provides models for managing destination banks and saved beneficiaries for both transfers and bill payments.
- Bank: Represents financial institutions in the MBBank network with identifiers like
bankId,smlCode, andcitadCode. - BeneficiaryTransfer: Data for saved transfer recipients, including IBPS codes and fast transfer flags.
- BeneficiaryPayment: Data for billers and service providers.
Sources: mbbank/modals/bank_list.py:6-21, mbbank/modals/beneficiary_list.py:7-70
Asset Management Models
Specialized models manage credit/debit cards and savings products, reflecting the diverse financial instruments supported by MBBank.
Card Management
The Card model tracks physical and virtual card statuses, limits, and usage settings.
| Field | Type | Description |
|---|---|---|
cardNo | str | The card number. |
cardTyp | str | Type of card (e.g., Credit, Debit). |
sts | str | General status code. |
stsInetUsage | str | Status of internet usage/e-commerce. |
creditLmt | int | Credit limit for the card. |
Sources: mbbank/modals/card_list.py:6-42
Savings Systems
Savings data is divided into SavingInfo (for list summaries) and SavingDetail (for specific account deep-dives).
Sources: mbbank/modals/saving_list.py:7-92
Summary of Data Models
The MBBank library's data models provide a comprehensive mapping of the bank's internal API to a developer-friendly Python interface. By utilizing pydantic's validation and type hinting, the system ensures that data remains consistent across various banking operations, from simple balance checks to multi-factor authenticated transfers.
Sources: mbbank/modals/__init__.py:1-93