Manos Chorianopoulos

fix SharingCouponModel

......@@ -3492,13 +3492,6 @@ public class swiftApi {
public class SharingCouponModel: Codable {
// public let transactionMetadata: String?
// public let sharingType: String?
// public let discount: Float
// public let date: Date?
// public let couponsetUuid: String?
// public let name: String?
private var couponset_uuid: String?
private var date: String?
private var discount: String?
......@@ -3520,29 +3513,19 @@ public class swiftApi {
}
public init(dictionary: [String: Any]) {
// self.transactionMetadata = dictionary["transaction_metadata"] as? String? ?? ""
// self.sharingType = dictionary["sharing_type"] as? String? ?? ""
// self.discount = dictionary["discount"] as? Float ?? 0.0
// self.couponsetUuid = dictionary["couponsetUuid"] as? String? ?? ""
// self.name = dictionary["name"] as? String? ?? ""
// let dateString = dictionary["date"] as? String? ?? ""
// let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
// if let date = dateFormatter.date(from: dateString ?? "") {
// self.date = date
// } else {
// self.date = nil
// }
self.couponset_uuid = dictionary["couponset_uuid"] as? String? ?? ""
self.discount = dictionary["discount"] as? String? ?? ""
self.sharing_type = dictionary["sharing_type"] as? String? ?? ""
// self.transaction_metadata = dictionary["transaction_metadata"] as? String? ?? ""
self.name = dictionary["name"] as? String? ?? ""
self.name = ""
let couponsetsList = swiftApi().getCouponSetList()
for item in couponsetsList {
if (item.uuid == self.couponset_uuid) {
self.name = item.name ?? ""
break;
}
}
// Example "date": "Thu, Jun 23 2022 16:24:44",
let dateString = dictionary["date"] as? String? ?? ""
......@@ -3660,8 +3643,17 @@ public class swiftApi {
for item in responseDataResult {
if let itemDictionary = item {
let couponsetUuid = itemDictionary["couponset_uuid"] as? String? ?? ""
let couponsetsList = swiftApi().getCouponSetList()
for item in couponsetsList {
if (item.uuid == couponsetUuid) {
let tempHistoyItem = SharingCouponModel(dictionary: itemDictionary)
historyArray.append(tempHistoyItem)
break;
}
}
}
}
......