// // ExchangeModel.swift // GMERemittance // // Created by gme_2 on 21/08/2018. // Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved. // import Foundation import ObjectMapper class ExchangeRateModel: Mappable { var country: String? var countryCode: String? var currency: String? var countryId: String? var availableServices: [PaymentServiceType]? init() {} required init?(map: Map) { } func mapping(map: Map) { country <- map["country"] countryCode <- map["countryCode"] currency <- map["currency"] countryId <- map["countryId"] availableServices <- map["serviceAvailable"] } } extension ExchangeRateModel: TablePresenterProtocol { var cellTitle: String? { return "\(country ?? "") (\(currency ?? ""))" } var cellImage: UIImage? { return CountryEnum(rawValue: countryCode?.lowercased() ?? "")?.flag } } class PaymentServiceType: Mappable { var id: String? var type: String? var currency: [String]? var subtitle: String? init() {} required init?(map: Map) { } func mapping(map: Map) { id <- map["id"] type <- map["text"] currency <- map["currency"] subtitle <- map["description"] } func toPaymentMethodModel() -> PaymentMethodModel { return PaymentMethodModel(id: id, name: type, localizedName: subtitle) } } extension PaymentServiceType: Equatable { static func == (lhs: PaymentServiceType, rhs: PaymentServiceType) -> Bool { return lhs.id == rhs.id && lhs.type == rhs.type && lhs.currency == rhs.currency && lhs.subtitle == rhs.subtitle } } extension PaymentServiceType: TablePresenterProtocol { var cellTitle: String? { return "\(subtitle ?? "")" } var cellImage: UIImage? { switch id ?? "1" { case "1": return #imageLiteral(resourceName: "ic_cash") case "2": return #imageLiteral(resourceName: "ic_bank") case "12": return #imageLiteral(resourceName: "ic_homeDelivery") case "13": return #imageLiteral(resourceName: "wallet-transfer") case "14": return #imageLiteral(resourceName: "ic_card_payment") default: return nil } } } class ExchangeRateContainer: Mappable { var errorCode: String? var message: String? var id: String? var data: [ExchangeRateModel]? required init?(map: Map) { } func mapping(map: Map) { errorCode <- map["ErrorCode"] id <- map["Id"] message <- map["Msg"] data <- map["Data"] } }