Showing
5 changed files
with
129 additions
and
133 deletions
| ... | @@ -127,14 +127,19 @@ extension AnalysisItemViewCell { | ... | @@ -127,14 +127,19 @@ extension AnalysisItemViewCell { | 
| 127 | 127 | ||
| 128 | titleLabel.text = "" | 128 | titleLabel.text = "" | 
| 129 | 129 | ||
| 130 | - for merchant in merchantList { | 130 | + // for merchant in merchantList { | 
| 131 | - if (merchant._uuid == couponSetData?.merchant_uuid) { | 131 | + // // if (merchant._uuid == couponSetData?.merchant_uuid) { | 
| 132 | - // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | 132 | + // if (merchant._uuid == item.merchant_uuid) { | 
| 133 | - self.postImageURL = merchant._img_preview | 133 | + // // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | 
| 134 | - titleLabel.text = merchant._admin_name | 134 | + // self.postImageURL = merchant._img_preview | 
| 135 | - break; | 135 | + // titleLabel.text = merchant._admin_name | 
| 136 | - } | 136 | + // break; | 
| 137 | - } | 137 | + // } | 
| 138 | + // } | ||
| 139 | + | ||
| 140 | + let merchantDetails: swiftApi.MerchantModel? = item.merchant_details | ||
| 141 | + self.postImageURL = merchantDetails?._img_preview | ||
| 142 | + titleLabel.text = merchantDetails?._admin_name | ||
| 138 | 143 | ||
| 139 | dateLabel.text = item.redeemed ?? "" // expiration | 144 | dateLabel.text = item.redeemed ?? "" // expiration | 
| 140 | // itemImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache()) | 145 | // itemImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache()) | 
| ... | @@ -164,14 +169,18 @@ extension AnalysisItemViewCell { | ... | @@ -164,14 +169,18 @@ extension AnalysisItemViewCell { | 
| 164 | 169 | ||
| 165 | titleLabel.text = "" | 170 | titleLabel.text = "" | 
| 166 | 171 | ||
| 167 | - for merchant in merchantList { | 172 | + // for merchant in merchantList { | 
| 168 | - if (merchant._uuid == item.merchant_uuid) { | 173 | + // if (merchant._uuid == item.merchant_uuid) { | 
| 169 | - // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | 174 | + // // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | 
| 170 | - self.postImageURL = merchant._img_preview | 175 | + // self.postImageURL = merchant._img_preview | 
| 171 | - titleLabel.text = merchant._admin_name | 176 | + // titleLabel.text = merchant._admin_name | 
| 172 | - break; | 177 | + // break; | 
| 173 | - } | 178 | + // } | 
| 174 | - } | 179 | + // } | 
| 180 | + | ||
| 181 | + let merchantDetails: swiftApi.MerchantModel? = item.merchant_details | ||
| 182 | + self.postImageURL = merchantDetails?._img_preview | ||
| 183 | + titleLabel.text = merchantDetails?._admin_name | ||
| 175 | 184 | ||
| 176 | // titleLabel.text = item.name | 185 | // titleLabel.text = item.name | 
| 177 | // self.postImageURL = item.image | 186 | // self.postImageURL = item.image | ... | ... | 
| ... | @@ -144,16 +144,19 @@ import AVFoundation | ... | @@ -144,16 +144,19 @@ import AVFoundation | 
| 144 | 144 | ||
| 145 | let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() | 145 | let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() | 
| 146 | var merchantUuid: String = "" | 146 | var merchantUuid: String = "" | 
| 147 | - if (isMarket == true) { | 147 | + // if (isMarket == true) { | 
| 148 | merchantUuid = coupon?.merchant_uuid ?? "" | 148 | merchantUuid = coupon?.merchant_uuid ?? "" | 
| 149 | - } else { | 149 | + // } else { | 
| 150 | - merchantUuid = couponSetData?.merchant_uuid ?? "" | 150 | + // merchantUuid = couponSetData?.merchant_uuid ?? "" | 
| 151 | - } | 151 | + // } | 
| 152 | 152 | ||
| 153 | - for merchant in merchantList { | 153 | + // for merchant in merchantList { | 
| 154 | - if (merchant._uuid == merchantUuid) { | 154 | + // if (merchant._uuid == merchantUuid) { | 
| 155 | - let htmlMerchDescrText = merchant._body | 155 | + // let htmlMerchDescrText = merchant._body | 
| 156 | 156 | ||
| 157 | + let merchantDetails: swiftApi.MerchantModel? = coupon?.merchant_details | ||
| 158 | + let htmlMerchDescrText = merchantDetails?._body ?? "" | ||
| 159 | + | ||
| 157 | if (isMarket != true && htmlMerchDescrText != "") { | 160 | if (isMarket != true && htmlMerchDescrText != "") { | 
| 158 | merchantDescrTextView.attributedText = htmlMerchDescrText.htmlToAttributedString | 161 | merchantDescrTextView.attributedText = htmlMerchDescrText.htmlToAttributedString | 
| 159 | merchantDescrTextView.font = UIFont(name: "PeridotPE-Regular", size: 16) | 162 | merchantDescrTextView.font = UIFont(name: "PeridotPE-Regular", size: 16) | 
| ... | @@ -173,9 +176,9 @@ import AVFoundation | ... | @@ -173,9 +176,9 @@ import AVFoundation | 
| 173 | couponCodeLabelTopSpace.constant = CGFloat(0) | 176 | couponCodeLabelTopSpace.constant = CGFloat(0) | 
| 174 | } | 177 | } | 
| 175 | 178 | ||
| 176 | - break; | 179 | + // break; | 
| 177 | - } | 180 | + // } | 
| 178 | - } | 181 | + // } | 
| 179 | 182 | ||
| 180 | couponView.layer.cornerRadius = 16 | 183 | couponView.layer.cornerRadius = 16 | 
| 181 | couponNumberLabel.text = coupon?.coupon ?? "" | 184 | couponNumberLabel.text = coupon?.coupon ?? "" | 
| ... | @@ -364,7 +367,7 @@ import AVFoundation | ... | @@ -364,7 +367,7 @@ import AVFoundation | 
| 364 | termsTextView.dataDetectorTypes = [.link] | 367 | termsTextView.dataDetectorTypes = [.link] | 
| 365 | 368 | ||
| 366 | // Uncomment if Barcode Section is active again | 369 | // Uncomment if Barcode Section is active again | 
| 367 | - toggleTerms() | 370 | + toggleTerms() | 
| 368 | if (isMarket == false) { | 371 | if (isMarket == false) { | 
| 369 | toggleBarcode() | 372 | toggleBarcode() | 
| 370 | } | 373 | } | 
| ... | @@ -518,7 +521,7 @@ import AVFoundation | ... | @@ -518,7 +521,7 @@ import AVFoundation | 
| 518 | if (isMarket == true) { | 521 | if (isMarket == true) { | 
| 519 | vc.isMarket = true | 522 | vc.isMarket = true | 
| 520 | } else { | 523 | } else { | 
| 521 | - vc.couponSet = coupon?.couponset_data | 524 | + vc.coupon = coupon | 
| 522 | } | 525 | } | 
| 523 | 526 | ||
| 524 | self.navigationController?.pushViewController(vc, animated: true) | 527 | self.navigationController?.pushViewController(vc, animated: true) | ... | ... | 
| ... | @@ -23,6 +23,9 @@ import UIKit | ... | @@ -23,6 +23,9 @@ import UIKit | 
| 23 | var postImageURL: String? { | 23 | var postImageURL: String? { | 
| 24 | didSet { | 24 | didSet { | 
| 25 | if let url = postImageURL { | 25 | if let url = postImageURL { | 
| 26 | + // TODO: DELETE LOGS | ||
| 27 | + print("=== postImageURL: ",url) | ||
| 28 | + | ||
| 26 | self.couponImage.image = UIImage() // UIImage(named: "loading") | 29 | self.couponImage.image = UIImage() // UIImage(named: "loading") | 
| 27 | 30 | ||
| 28 | UIImage.loadImageUsingCacheWithUrlString(url) { image in | 31 | UIImage.loadImageUsingCacheWithUrlString(url) { image in | 
| ... | @@ -79,14 +82,19 @@ import UIKit | ... | @@ -79,14 +82,19 @@ import UIKit | 
| 79 | 82 | ||
| 80 | nameLabel.text = "" | 83 | nameLabel.text = "" | 
| 81 | 84 | ||
| 82 | - for merchant in merchantList { | 85 | + // for merchant in merchantList { | 
| 83 | - if (merchant._uuid == couponSetData?.merchant_uuid) { | 86 | + // // if (merchant._uuid == couponSetData?.merchant_uuid) { | 
| 84 | - // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | 87 | + // if (merchant._uuid == coupon.merchant_uuid) { | 
| 85 | - self.postImageURL = merchant._img_preview | 88 | + // // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | 
| 86 | - nameLabel.text = merchant._admin_name | 89 | + // self.postImageURL = merchant._img_preview | 
| 87 | - break; | 90 | + // nameLabel.text = merchant._admin_name | 
| 88 | - } | 91 | + // break; | 
| 89 | - } | 92 | + // } | 
| 93 | + // } | ||
| 94 | + | ||
| 95 | + let merchantDetails: swiftApi.MerchantModel? = coupon.merchant_details | ||
| 96 | + self.postImageURL = merchantDetails?._img_preview | ||
| 97 | + nameLabel.text = merchantDetails?._admin_name | ||
| 90 | 98 | ||
| 91 | // couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache()) | 99 | // couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache()) | 
| 92 | // nameLabel.text = couponSetData?.name ?? "" | 100 | // nameLabel.text = couponSetData?.name ?? "" | ... | ... | 
| ... | @@ -28,7 +28,7 @@ import MapKit | ... | @@ -28,7 +28,7 @@ import MapKit | 
| 28 | @IBOutlet weak var addressImageView: UIImageView! | 28 | @IBOutlet weak var addressImageView: UIImageView! | 
| 29 | 29 | ||
| 30 | // public | 30 | // public | 
| 31 | - public var couponSet: swiftApi.CouponSetItemModel? | 31 | + public var coupon: swiftApi.CouponItemModel? | 
| 32 | public var isMarket: Bool? = false | 32 | public var isMarket: Bool? = false | 
| 33 | var merchantsArray:Array<swiftApi.MerchantModel> = [] | 33 | var merchantsArray:Array<swiftApi.MerchantModel> = [] | 
| 34 | var selectedMerchant: swiftApi.MerchantModel? | 34 | var selectedMerchant: swiftApi.MerchantModel? | 
| ... | @@ -132,8 +132,8 @@ import MapKit | ... | @@ -132,8 +132,8 @@ import MapKit | 
| 132 | } | 132 | } | 
| 133 | showLoading() | 133 | showLoading() | 
| 134 | 134 | ||
| 135 | - if (couponSet != nil) { | 135 | + if (coupon != nil) { | 
| 136 | - if let merchantUuid: String = couponSet?.merchant_uuid { | 136 | + if let merchantUuid: String = coupon?.merchant_uuid { | 
| 137 | swiftApi().getMultilingualMerchantsAsync([], false, 0.0, [], "", 0, [merchantUuid], getMerchantsCallback) | 137 | swiftApi().getMultilingualMerchantsAsync([], false, 0.0, [], "", 0, [merchantUuid], getMerchantsCallback) | 
| 138 | showContent() | 138 | showContent() | 
| 139 | } | 139 | } | 
| ... | @@ -209,30 +209,49 @@ import MapKit | ... | @@ -209,30 +209,49 @@ import MapKit | 
| 209 | alert.addAction(UIAlertAction(title: "Δες το eshop", style: .default, handler: { action in | 209 | alert.addAction(UIAlertAction(title: "Δες το eshop", style: .default, handler: { action in | 
| 210 | switch action.style{ | 210 | switch action.style{ | 
| 211 | case .default: | 211 | case .default: | 
| 212 | - if (self.couponSet != nil) { | 212 | + if (self.coupon != nil) { | 
| 213 | - if let merchantUuid: String = self.couponSet?.merchant_uuid { | 213 | + // if let merchantUuid: String = self.coupon?.merchant_uuid { | 
| 214 | - for item in swiftApi().getMerchantList() { | 214 | + // for item in swiftApi().getMerchantList() { | 
| 215 | - if (item._uuid == merchantUuid) { | 215 | + // if (item._uuid == merchantUuid) { | 
| 216 | 216 | ||
| 217 | - let eshopWebsite = item._website | 217 | + // let eshopWebsite = item._website | 
| 218 | - | 218 | + | 
| 219 | - if (eshopWebsite != "") { | 219 | + // if (eshopWebsite != "") { | 
| 220 | - guard let websiteUrl = URL(string: eshopWebsite) else { | 220 | + // guard let websiteUrl = URL(string: eshopWebsite) else { | 
| 221 | - print("Error creating URL") | 221 | + // print("Error creating URL") | 
| 222 | - return | 222 | + // return | 
| 223 | - } | 223 | + // } | 
| 224 | - | 224 | + | 
| 225 | - // check if link can be opened. | 225 | + // // check if link can be opened. | 
| 226 | - guard UIApplication.shared.canOpenURL(websiteUrl) else { | 226 | + // guard UIApplication.shared.canOpenURL(websiteUrl) else { | 
| 227 | - return | 227 | + // return | 
| 228 | - } | 228 | + // } | 
| 229 | - | 229 | + | 
| 230 | - swiftApi().logTrackersEvent("click", "SeeShopWebsite") | 230 | + // swiftApi().logTrackersEvent("click", "SeeShopWebsite") | 
| 231 | - UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil) | 231 | + // UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil) | 
| 232 | - break; | 232 | + // break; | 
| 233 | - } | 233 | + // } | 
| 234 | - } | 234 | + // } | 
| 235 | + // } | ||
| 236 | + // } | ||
| 237 | + | ||
| 238 | + let merchantDetails: swiftApi.MerchantModel? = self.coupon?.merchant_details | ||
| 239 | + let eshopWebsite = merchantDetails?._website ?? "" | ||
| 240 | + | ||
| 241 | + if (eshopWebsite != "") { | ||
| 242 | + guard let websiteUrl = URL(string: eshopWebsite) else { | ||
| 243 | + print("Error creating URL") | ||
| 244 | + return | ||
| 235 | } | 245 | } | 
| 246 | + | ||
| 247 | + // check if link can be opened. | ||
| 248 | + guard UIApplication.shared.canOpenURL(websiteUrl) else { | ||
| 249 | + return | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + swiftApi().logTrackersEvent("click", "SeeShopWebsite") | ||
| 253 | + UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil) | ||
| 254 | + break; | ||
| 236 | } | 255 | } | 
| 237 | } | 256 | } | 
| 238 | // if (self.merchantsArray.count > 0) { | 257 | // if (self.merchantsArray.count > 0) { | ... | ... | 
| ... | @@ -512,6 +512,9 @@ public class swiftApi { | ... | @@ -512,6 +512,9 @@ public class swiftApi { | 
| 512 | public let merchant_uuid: String? | 512 | public let merchant_uuid: String? | 
| 513 | public let discount_type: String? // "value" / "percentage" / "plus_one" | 513 | public let discount_type: String? // "value" / "percentage" / "plus_one" | 
| 514 | public let final_price: Float? | 514 | public let final_price: Float? | 
| 515 | + | ||
| 516 | + // Universal Coupons | ||
| 517 | + public let couponset_type: String? | ||
| 515 | 518 | ||
| 516 | public init(dictionary: [String: Any]) { | 519 | public init(dictionary: [String: Any]) { | 
| 517 | self.uuid = dictionary["uuid"] as? String? ?? "" | 520 | self.uuid = dictionary["uuid"] as? String? ?? "" | 
| ... | @@ -530,6 +533,9 @@ public class swiftApi { | ... | @@ -530,6 +533,9 @@ public class swiftApi { | 
| 530 | self.merchant_uuid = dictionary["merchant_uuid"] as? String? ?? "" | 533 | self.merchant_uuid = dictionary["merchant_uuid"] as? String? ?? "" | 
| 531 | self.discount_type = dictionary["discount_type"] as? String? ?? "" | 534 | self.discount_type = dictionary["discount_type"] as? String? ?? "" | 
| 532 | // self.final_price = dictionary["final_price"] as? Float? ?? 0.0 | 535 | // self.final_price = dictionary["final_price"] as? Float? ?? 0.0 | 
| 536 | + | ||
| 537 | + // Universal Coupons | ||
| 538 | + self.couponset_type = dictionary["couponset_type"] as? String? ?? "" | ||
| 533 | 539 | ||
| 534 | if let double_final_price = dictionary["final_price"] as? Double { | 540 | if let double_final_price = dictionary["final_price"] as? Double { | 
| 535 | self.final_price = Float(double_final_price) | 541 | self.final_price = Float(double_final_price) | 
| ... | @@ -738,6 +744,9 @@ public class swiftApi { | ... | @@ -738,6 +744,9 @@ public class swiftApi { | 
| 738 | public let short_description: String? | 744 | public let short_description: String? | 
| 739 | public let terms: String? | 745 | public let terms: String? | 
| 740 | 746 | ||
| 747 | + // Universal Coupons | ||
| 748 | + public let merchant_details: MerchantModel? | ||
| 749 | + | ||
| 741 | 750 | ||
| 742 | public init(dictionary: [String: Any]) { | 751 | public init(dictionary: [String: Any]) { | 
| 743 | self.couponset_uuid = dictionary["couponset_uuid"] as? String? ?? "" | 752 | self.couponset_uuid = dictionary["couponset_uuid"] as? String? ?? "" | 
| ... | @@ -775,33 +784,30 @@ public class swiftApi { | ... | @@ -775,33 +784,30 @@ public class swiftApi { | 
| 775 | self.short_description = dictionary["short_description"] as? String? ?? "" | 784 | self.short_description = dictionary["short_description"] as? String? ?? "" | 
| 776 | self.terms = dictionary["terms"] as? String? ?? "" | 785 | self.terms = dictionary["terms"] as? String? ?? "" | 
| 777 | 786 | ||
| 778 | - // TODO: DELETE | ||
| 779 | -// if let couponSetData = dictionary["couponset_data"] as? [String: Any]? ?? ["":""] { | ||
| 780 | -// | ||
| 781 | -// let tempCouponset = CouponSetItemModel(dictionary: couponSetData) | ||
| 782 | -// | ||
| 783 | -// self.couponset_data = tempCouponset | ||
| 784 | -// } else { | ||
| 785 | -// self.couponset_data = nil | ||
| 786 | -// } | ||
| 787 | - | ||
| 788 | if let couponSetData = dictionary["couponset_data"] as? [String: Any] { | 787 | if let couponSetData = dictionary["couponset_data"] as? [String: Any] { | 
| 789 | 788 | ||
| 790 | let tempCouponset = CouponSetItemModel(dictionary: couponSetData) | 789 | let tempCouponset = CouponSetItemModel(dictionary: couponSetData) | 
| 791 | 790 | ||
| 792 | self.couponset_data = tempCouponset | 791 | self.couponset_data = tempCouponset | 
| 792 | + | ||
| 793 | + // Universal Coupons ==> | ||
| 794 | + } else if let couponSetDetails = dictionary["couponset_details"] as? [String: Any] { | ||
| 795 | + let tempCouponset = CouponSetItemModel(dictionary: couponSetDetails) | ||
| 796 | + | ||
| 797 | + self.couponset_data = tempCouponset | ||
| 793 | } else { | 798 | } else { | 
| 794 | self.couponset_data = nil | 799 | self.couponset_data = nil | 
| 795 | } | 800 | } | 
| 796 | - | 801 | + | 
| 797 | - if let couponSetDetails = dictionary["couponset_details"] as? [String: Any] { | 802 | + if let merchantDetails = dictionary["merchant_details"] as? [String: Any] { | 
| 798 | 803 | ||
| 799 | - let tempCouponset = CouponSetItemModel(dictionary: couponSetDetails) | 804 | + let tempMerchantDetails = MerchantModel(dictionary: merchantDetails) | 
| 800 | 805 | ||
| 801 | - self.couponset_data = tempCouponset | 806 | + self.merchant_details = tempMerchantDetails | 
| 802 | } else { | 807 | } else { | 
| 803 | - self.couponset_data = nil | 808 | + self.merchant_details = nil | 
| 804 | } | 809 | } | 
| 810 | + // <== | ||
| 805 | 811 | ||
| 806 | 812 | ||
| 807 | let expirationString = dictionary["expiration"] as? String? ?? "" | 813 | let expirationString = dictionary["expiration"] as? String? ?? "" | 
| ... | @@ -1040,7 +1046,7 @@ public class swiftApi { | ... | @@ -1040,7 +1046,7 @@ public class swiftApi { | 
| 1040 | // var temp = NSMutableDictionary(dictionary: s); | 1046 | // var temp = NSMutableDictionary(dictionary: s); | 
| 1041 | if c["couponset_uuid"] as! String == s["uuid"] as! String { | 1047 | if c["couponset_uuid"] as! String == s["uuid"] as! String { | 
| 1042 | let temp = NSMutableDictionary(dictionary: c); | 1048 | let temp = NSMutableDictionary(dictionary: c); | 
| 1043 | - | 1049 | + | 
| 1044 | temp.setValue(s as! [AnyHashable : Any],forKey: "couponset_data") | 1050 | temp.setValue(s as! [AnyHashable : Any],forKey: "couponset_data") | 
| 1045 | 1051 | ||
| 1046 | let tempCoupon = CouponItemModel(dictionary: temp as! [String : Any]) | 1052 | let tempCoupon = CouponItemModel(dictionary: temp as! [String : Any]) | 
| ... | @@ -1087,6 +1093,7 @@ public class swiftApi { | ... | @@ -1087,6 +1093,7 @@ public class swiftApi { | 
| 1087 | }) | 1093 | }) | 
| 1088 | } | 1094 | } | 
| 1089 | 1095 | ||
| 1096 | + // Old implementation | ||
| 1090 | // public func getCouponsAsync(_ getCouponsCallback: @escaping (_ couponsData: Array<CouponItemModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void { | 1097 | // public func getCouponsAsync(_ getCouponsCallback: @escaping (_ couponsData: Array<CouponItemModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void { | 
| 1091 | // CouponsDataModel().getCouponsData(getCouponsCallback, failureCallback: failureCallback) | 1098 | // CouponsDataModel().getCouponsData(getCouponsCallback, failureCallback: failureCallback) | 
| 1092 | // } | 1099 | // } | 
| ... | @@ -1107,46 +1114,6 @@ public class swiftApi { | ... | @@ -1107,46 +1114,6 @@ public class swiftApi { | 
| 1107 | 1114 | ||
| 1108 | swiftApi().getCouponsUniversalAsync(language: "el", getCouponsCallback, failureCallback: failureCallback) | 1115 | swiftApi().getCouponsUniversalAsync(language: "el", getCouponsCallback, failureCallback: failureCallback) | 
| 1109 | 1116 | ||
| 1110 | - // swiftApi().getCouponsUniversalAsync(language: "el", getCouponsUniversalCallback) { errorCode in | ||
| 1111 | - // // TODO: DELETE LOGS | ||
| 1112 | - // print("========= getCouponsUniversalRequest ERROR CODE =========", errorCode) | ||
| 1113 | - | ||
| 1114 | - // failureCallback(errorCode) | ||
| 1115 | - // } | ||
| 1116 | - | ||
| 1117 | - // func getCouponsUniversalCallback (_ responseData: Array<swiftApi.CouponItemModel>?) -> Void { | ||
| 1118 | - // if (responseData != nil) { | ||
| 1119 | - // DispatchQueue.main.async { | ||
| 1120 | - // // TODO: DELETE LOGS | ||
| 1121 | - // print("========= getCouponsUniversalRequest responseData =========") | ||
| 1122 | - // print(responseData) | ||
| 1123 | - | ||
| 1124 | - // var activeCoupons = responseData.filter({ return $0.status == 1 }) | ||
| 1125 | - // // sort activeCoupons by expiration date | ||
| 1126 | - // let dateFormatter = DateFormatter() | ||
| 1127 | - // dateFormatter.dateFormat = "dd/MM/yyyy" | ||
| 1128 | - | ||
| 1129 | - // activeCoupons.sort(by: { | ||
| 1130 | - // let date1 = dateFormatter.date(from: $0.expiration ?? "") | ||
| 1131 | - // let date2 = dateFormatter.date(from: $1.expiration ?? "") | ||
| 1132 | - | ||
| 1133 | - // if ((date1 != nil) && (date2 != nil)) { | ||
| 1134 | - // return date1!.compare(date2!) == .orderedAscending | ||
| 1135 | - // } else { | ||
| 1136 | - // return false | ||
| 1137 | - // } | ||
| 1138 | - | ||
| 1139 | - // }) | ||
| 1140 | - // getCouponsCallback(activeCoupons) | ||
| 1141 | - // } | ||
| 1142 | - // } else { | ||
| 1143 | - // // TODO: DELETE LOGS | ||
| 1144 | - // print("========= getCouponsUniversalRequest ERROR =========") | ||
| 1145 | - | ||
| 1146 | - // getCouponsCallback(nil) | ||
| 1147 | - // } | ||
| 1148 | - // } | ||
| 1149 | - | ||
| 1150 | instanceOfMyApi.getCouponsetsAsync(true, andVisible: true, andUuids: nil, couponSetsCallback, failureBlock: couponSetsFailureCallback) | 1117 | instanceOfMyApi.getCouponsetsAsync(true, andVisible: true, andUuids: nil, couponSetsCallback, failureBlock: couponSetsFailureCallback) | 
| 1151 | 1118 | ||
| 1152 | func couponSetsCallback(_ couponSetsData: [AnyHashable : Any]?) -> Void { | 1119 | func couponSetsCallback(_ couponSetsData: [AnyHashable : Any]?) -> Void { | 
| ... | @@ -8391,15 +8358,6 @@ public class swiftApi { | ... | @@ -8391,15 +8358,6 @@ public class swiftApi { | 
| 8391 | 8358 | ||
| 8392 | if let responseDataDictionary = responseData as? [String: AnyObject] { | 8359 | if let responseDataDictionary = responseData as? [String: AnyObject] { | 
| 8393 | 8360 | ||
| 8394 | - // TODO: DELETE LOGS | ||
| 8395 | - print("=== responseDataDictionary ===") | ||
| 8396 | - print(responseDataDictionary) | ||
| 8397 | - print("=== responseDataDictionary result ===") | ||
| 8398 | - print(responseDataDictionary["result"]) | ||
| 8399 | - print("=== responseDataDictionary status ===") | ||
| 8400 | - print(responseDataDictionary["status"]) | ||
| 8401 | - | ||
| 8402 | - | ||
| 8403 | if (responseDataDictionary["status"] as? Int == 1) { | 8361 | if (responseDataDictionary["status"] as? Int == 1) { | 
| 8404 | let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | 8362 | let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | 
| 8405 | dynatraceEvent._eventName = "custom_success_user_coupons_loyalty" | 8363 | dynatraceEvent._eventName = "custom_success_user_coupons_loyalty" | 
| ... | @@ -8414,17 +8372,16 @@ public class swiftApi { | ... | @@ -8414,17 +8372,16 @@ public class swiftApi { | 
| 8414 | } | 8372 | } | 
| 8415 | } | 8373 | } | 
| 8416 | 8374 | ||
| 8417 | - // TODO: DELETE LOGS | ||
| 8418 | - print("=== AllCoupons NEW ===") | ||
| 8419 | - print(couponsArray.count) | ||
| 8420 | - | ||
| 8421 | // setAllOldCouponList uncluding Supermarkets ==> | 8375 | // setAllOldCouponList uncluding Supermarkets ==> | 
| 8422 | swiftApi().setAllOldCouponList(couponsArray) | 8376 | swiftApi().setAllOldCouponList(couponsArray) | 
| 8423 | // <== | 8377 | // <== | 
| 8424 | - swiftApi().setCouponList(couponsArray) | ||
| 8425 | - swiftApi().setOldCouponList(couponsArray) | ||
| 8426 | 8378 | ||
| 8427 | - var activeCoupons = couponsArray.filter({ return $0.status == 1 }) | 8379 | + let noSMCoupons = couponsArray.filter({ return $0.couponset_data?.couponset_type != "supermarket" }) | 
| 8380 | + | ||
| 8381 | + swiftApi().setCouponList(noSMCoupons) | ||
| 8382 | + swiftApi().setOldCouponList(noSMCoupons) | ||
| 8383 | + | ||
| 8384 | + var activeCoupons = noSMCoupons.filter({ return $0.status == 1 }) | ||
| 8428 | // sort activeCoupons by expiration date | 8385 | // sort activeCoupons by expiration date | 
| 8429 | let dateFormatter = DateFormatter() | 8386 | let dateFormatter = DateFormatter() | 
| 8430 | dateFormatter.dateFormat = "dd/MM/yyyy" | 8387 | dateFormatter.dateFormat = "dd/MM/yyyy" | ... | ... | 
- 
Please register or login to post a comment