Files
Thijooree-iOS/Thijooree iOS/API/MIB/MibModels.swift
T

85 lines
2.1 KiB
Swift

import Foundation
struct MibSession: Codable {
let appId: String
let xxid: String
let nonceGenerator: String
let sessionKey: String
}
struct MibProfile: Codable, Identifiable {
let profileId: String
let customerProfileId: String
let annexId: String
let customerId: String
let name: String
let cifType: String
let profileType: String
let color: String
let customerImage: String?
var id: String { profileId }
}
struct MibCard: Codable, Identifiable {
let cardId: String
let maskedCardNumber: String
let cardStatus: String
let cardType: String
let cardTypeDesc: String
let customerId: String
let phoneNumber: String
let cardHolderName: String
let loginTag: String
var id: String { cardId }
}
struct MibFinanceDeal: Codable, Identifiable {
let dealNo: String
let productDesc: String
let dealStatus: String
let statusDesc: String
let dealAmount: Double
let paidAmount: Double
let outstandingAmount: Double
let dealDate: String
let overdueAmount: Double
let installmentAmount: Double
let noOfInstallments: Int
let lastPaidDate: String
let lastPayAmount: Double
let currency: String
var id: String { dealNo }
}
struct MibTransferResult {
let success: Bool
let trxId: String
let date: String
let errorMessage: String
}
enum MibError: LocalizedError {
case networkError(String)
case serverError(String)
case sessionExpired
case invalidCredentials
case decryptionFailed
case encryptionFailed
case invalidResponse
var errorDescription: String? {
switch self {
case .networkError(let msg): return "Network error: \(msg)"
case .serverError(let msg): return "Server error: \(msg)"
case .sessionExpired: return "Session expired. Please log in again."
case .invalidCredentials: return "Invalid credentials."
case .decryptionFailed: return "Failed to decrypt response."
case .encryptionFailed: return "Failed to encrypt request."
case .invalidResponse: return "Unexpected server response."
}
}
}