Manos Chorianopoulos

fix SharingCouponModel

...@@ -3492,13 +3492,6 @@ public class swiftApi { ...@@ -3492,13 +3492,6 @@ public class swiftApi {
3492 3492
3493 3493
3494 public class SharingCouponModel: Codable { 3494 public class SharingCouponModel: Codable {
3495 - // public let transactionMetadata: String?
3496 - // public let sharingType: String?
3497 - // public let discount: Float
3498 - // public let date: Date?
3499 - // public let couponsetUuid: String?
3500 - // public let name: String?
3501 -
3502 private var couponset_uuid: String? 3495 private var couponset_uuid: String?
3503 private var date: String? 3496 private var date: String?
3504 private var discount: String? 3497 private var discount: String?
...@@ -3520,29 +3513,19 @@ public class swiftApi { ...@@ -3520,29 +3513,19 @@ public class swiftApi {
3520 } 3513 }
3521 3514
3522 public init(dictionary: [String: Any]) { 3515 public init(dictionary: [String: Any]) {
3523 - // self.transactionMetadata = dictionary["transaction_metadata"] as? String? ?? ""
3524 - // self.sharingType = dictionary["sharing_type"] as? String? ?? ""
3525 - // self.discount = dictionary["discount"] as? Float ?? 0.0
3526 - // self.couponsetUuid = dictionary["couponsetUuid"] as? String? ?? ""
3527 - // self.name = dictionary["name"] as? String? ?? ""
3528 -
3529 - // let dateString = dictionary["date"] as? String? ?? ""
3530 -
3531 - // let dateFormatter = DateFormatter()
3532 - // dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
3533 - // if let date = dateFormatter.date(from: dateString ?? "") {
3534 - // self.date = date
3535 - // } else {
3536 - // self.date = nil
3537 - // }
3538 -
3539 -
3540 self.couponset_uuid = dictionary["couponset_uuid"] as? String? ?? "" 3516 self.couponset_uuid = dictionary["couponset_uuid"] as? String? ?? ""
3541 self.discount = dictionary["discount"] as? String? ?? "" 3517 self.discount = dictionary["discount"] as? String? ?? ""
3542 self.sharing_type = dictionary["sharing_type"] as? String? ?? "" 3518 self.sharing_type = dictionary["sharing_type"] as? String? ?? ""
3543 // self.transaction_metadata = dictionary["transaction_metadata"] as? String? ?? "" 3519 // self.transaction_metadata = dictionary["transaction_metadata"] as? String? ?? ""
3544 - self.name = dictionary["name"] as? String? ?? ""
3545 3520
3521 + self.name = ""
3522 + let couponsetsList = swiftApi().getCouponSetList()
3523 + for item in couponsetsList {
3524 + if (item.uuid == self.couponset_uuid) {
3525 + self.name = item.name ?? ""
3526 + break;
3527 + }
3528 + }
3546 3529
3547 // Example "date": "Thu, Jun 23 2022 16:24:44", 3530 // Example "date": "Thu, Jun 23 2022 16:24:44",
3548 let dateString = dictionary["date"] as? String? ?? "" 3531 let dateString = dictionary["date"] as? String? ?? ""
...@@ -3660,8 +3643,17 @@ public class swiftApi { ...@@ -3660,8 +3643,17 @@ public class swiftApi {
3660 3643
3661 for item in responseDataResult { 3644 for item in responseDataResult {
3662 if let itemDictionary = item { 3645 if let itemDictionary = item {
3646 +
3647 + let couponsetUuid = itemDictionary["couponset_uuid"] as? String? ?? ""
3648 + let couponsetsList = swiftApi().getCouponSetList()
3649 + for item in couponsetsList {
3650 + if (item.uuid == couponsetUuid) {
3663 let tempHistoyItem = SharingCouponModel(dictionary: itemDictionary) 3651 let tempHistoyItem = SharingCouponModel(dictionary: itemDictionary)
3664 historyArray.append(tempHistoyItem) 3652 historyArray.append(tempHistoyItem)
3653 + break;
3654 + }
3655 + }
3656 +
3665 } 3657 }
3666 } 3658 }
3667 3659
......