import Foundation struct BmlSession: Codable { let accessToken: String let deviceId: String let refreshToken: String let expiresAt: Int64 // Unix millis; 0 = unknown var isExpired: Bool { expiresAt > 0 && Int64(Date().timeIntervalSince1970 * 1000) >= expiresAt } } struct BmlProfile: Codable, Identifiable { let profileId: String let name: String let type: String // "Profile" or "Business" let profileType: String // "default" or "business" let autoActivated: Bool var id: String { profileId } } struct BmlOtpChannel: Codable { let channel: String let description: String let masked: String } enum BmlActivationResult { case success(BmlSession, [BankAccount]) case needsBusinessOtp([BmlOtpChannel]) } struct BmlUserInfo { let fullName: String let email: String let mobile: String let customerId: String let idCard: String let birthdate: String } struct BmlLoanDetail { let loanAmount: Double let outstandingAmt: Double let repayAmount: Double let intRate: Double let loanStatus: String let startDate: String let endDate: String let noOfRepayOverdue: Int let overdueAmount: Double } struct BmlWalletToken { let token: String let expiry: String let appCode: String let serviceCode: String let data: String let validUntil: String } struct BmlForeignLimit: Codable { let type: String let used: Double let totalLimit: Double let generalCap: Double let generalRemaining: Double let medicalRemaining: Double let isAtmEnabled: Bool let isPosEnabled: Bool let atmRemaining: Double let atmLimit: Double let ecomRemaining: Double let ecomLimit: Double let posRemaining: Double let posLimit: Double } enum BmlError: LocalizedError { case networkError(String) case loginFailed(String) case otpFailed(String) case serverError(String) case sessionExpired case profileActivationFailed(String) case oauthFailed(String) case invalidResponse case endpointNotFound var errorDescription: String? { switch self { case .networkError(let msg): return "Network error: \(msg)" case .loginFailed(let msg): return "Login failed: \(msg)" case .otpFailed(let msg): return "OTP failed: \(msg)" case .serverError(let msg): return msg case .sessionExpired: return "Session expired." case .profileActivationFailed(let msg): return "Profile activation failed: \(msg)" case .oauthFailed(let msg): return "OAuth failed: \(msg)" case .invalidResponse: return "Unexpected server response." case .endpointNotFound: return "Endpoint not found." } } }