I'm taking a response from an API and using below model, but I'm getting an error ObjectMapper fail to serialize response, what is wrong with the model ?
import ObjectMapper
// MARK: - RealTimeSummary
class RealTimeSummary: Mappable {
var realTimeSummaryReturn: ReturnRealTime = ReturnRealTime()
var success: Bool = false
required convenience init?(map: Map) {
self.init()
self.mapping(map: map)
}
func mapping(map: Map) {
realTimeSummaryReturn <- map["Return"]
success <- map["Success"]
}
}
// MARK: - Return
class ReturnRealTime: Mappable {
var summary: Summary = Summary()
var accounts: [AccountRealTime] = []
init(){}
required convenience init?(map: Map) {
self.init()
self.mapping(map: map)
}
func mapping(map: Map) {
summary <- map["Summary"]
accounts <- map["Accounts"]
}
}
// MARK: - Account
class AccountRealTime: Mappable {
var accountType: String = ""
var accountNumber: String = ""
var accountDescription: String = ""
var accountProductCode: String = ""
var availableBalance: Double = 0.0
var currentBalance: Int = 0
var holdAmount: Int = 0
init(){}
required convenience init?(map: Map) {
self.init()
self.mapping(map: map)
}
func mapping(map: Map) {
accountType <- map["AccountType"]
accountNumber <- map["AccountNumber"]
accountDescription <- map["AccountDescription"]
accountProductCode <- map["AccountProductCode"]
availableBalance <- map["AvailableBalance"]
currentBalance <- map["CurrentBalance"]
holdAmount <- map["HoldAmount"]
}
}
// MARK: - Summary
class Summary: Mappable {
var availableBalanceTotal: Double = 0.0
var currentBalanceTotal: Int = 0
init(){}
required convenience init?(map: Map) {
self.init()
self.mapping(map: map)
}
func mapping(map: Map) {
availableBalanceTotal <- map["AvailableBalanceTotal"]
currentBalanceTotal <- map["CurrentBalanceTotal"]
}
}