Showing
6 changed files
with
58 additions
and
11 deletions
| ... | @@ -106,7 +106,7 @@ public class MyRewardsOfferCollectionViewCell: UICollectionViewCell { | ... | @@ -106,7 +106,7 @@ public class MyRewardsOfferCollectionViewCell: UICollectionViewCell { |
| 106 | 106 | ||
| 107 | func configureCell(data: CouponSetItemModel) { | 107 | func configureCell(data: CouponSetItemModel) { |
| 108 | // Use coupon set preview image | 108 | // Use coupon set preview image |
| 109 | - self.postImageURL = data._img_preview | 109 | + self.postImageURL = data._app_img_preview |
| 110 | 110 | ||
| 111 | // Default to not favorite for coupon sets | 111 | // Default to not favorite for coupon sets |
| 112 | favoriteImage.image = UIImage(named: "favorite_empty", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | 112 | favoriteImage.image = UIImage(named: "favorite_empty", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | ... | ... |
| ... | @@ -138,7 +138,7 @@ public class ProfileCouponTableViewCell: UITableViewCell { | ... | @@ -138,7 +138,7 @@ public class ProfileCouponTableViewCell: UITableViewCell { |
| 138 | logoImageView.backgroundColor = UIColor(rgb: 0xFFFFFF) | 138 | logoImageView.backgroundColor = UIColor(rgb: 0xFFFFFF) |
| 139 | logoImageView.layer.cornerRadius = 10.0 | 139 | logoImageView.layer.cornerRadius = 10.0 |
| 140 | 140 | ||
| 141 | - if let merchantImgPreview = data.merchant_details?._img_preview, !merchantImgPreview.isEmpty { | 141 | + if let merchantImgPreview = data.merchant_details?._app_img_preview, !merchantImgPreview.isEmpty { |
| 142 | self.logoImageURL = merchantImgPreview | 142 | self.logoImageURL = merchantImgPreview |
| 143 | } else { | 143 | } else { |
| 144 | logoImage.image = nil | 144 | logoImage.image = nil | ... | ... |
| ... | @@ -90,6 +90,9 @@ public class CouponSetItemModel { | ... | @@ -90,6 +90,9 @@ public class CouponSetItemModel { |
| 90 | private var regions: [String]? | 90 | private var regions: [String]? |
| 91 | private var show_as_banner: [String: Any]? | 91 | private var show_as_banner: [String: Any]? |
| 92 | private var tagging: [String: Any]? | 92 | private var tagging: [String: Any]? |
| 93 | + private var segment: String? | ||
| 94 | + private var hide_condition: String? | ||
| 95 | + private var extra_fields: [String: Any]? | ||
| 93 | 96 | ||
| 94 | // Bound merchant data for performance | 97 | // Bound merchant data for performance |
| 95 | private var merchant: MerchantModel? | 98 | private var merchant: MerchantModel? |
| ... | @@ -175,7 +178,17 @@ public class CouponSetItemModel { | ... | @@ -175,7 +178,17 @@ public class CouponSetItemModel { |
| 175 | self.offer_category = dictionary["offer_category"] as? String? ?? "" | 178 | self.offer_category = dictionary["offer_category"] as? String? ?? "" |
| 176 | 179 | ||
| 177 | // getCouponSetsNew fields | 180 | // getCouponSetsNew fields |
| 178 | - self.score = dictionary["score"] as? String | 181 | + if let scoreInt = dictionary["score"] as? Int { |
| 182 | + self.score = String(scoreInt) | ||
| 183 | + } else if let scoreDouble = dictionary["score"] as? Double { | ||
| 184 | + self.score = String(scoreDouble) | ||
| 185 | + } else { | ||
| 186 | + self.score = dictionary["score"] as? String | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + self.segment = dictionary["segment"] as? String | ||
| 190 | + self.hide_condition = dictionary["hide_condition"] as? String | ||
| 191 | + | ||
| 179 | if let lockedInt = dictionary["locked"] as? Int { | 192 | if let lockedInt = dictionary["locked"] as? Int { |
| 180 | self.locked = lockedInt == 1 | 193 | self.locked = lockedInt == 1 |
| 181 | } else { | 194 | } else { |
| ... | @@ -212,6 +225,11 @@ public class CouponSetItemModel { | ... | @@ -212,6 +225,11 @@ public class CouponSetItemModel { |
| 212 | self.expiration = "" | 225 | self.expiration = "" |
| 213 | } | 226 | } |
| 214 | 227 | ||
| 228 | + // Parse merchant_details if present | ||
| 229 | + if let merchantDetails = dictionary["merchant_details"] as? [String: Any] { | ||
| 230 | + self.merchant = MerchantModel(dictionary: merchantDetails) | ||
| 231 | + } | ||
| 232 | + | ||
| 215 | // img Example | 233 | // img Example |
| 216 | // img = "[\"https://warply.s3.amazonaws.com/applications/f83dfde1145e4c2da69793abb2f579af/couponset/00833266674d4a95b21dc4bf06995548/logo.png\"]"; | 234 | // img = "[\"https://warply.s3.amazonaws.com/applications/f83dfde1145e4c2da69793abb2f579af/couponset/00833266674d4a95b21dc4bf06995548/logo.png\"]"; |
| 217 | 235 | ||
| ... | @@ -240,6 +258,7 @@ public class CouponSetItemModel { | ... | @@ -240,6 +258,7 @@ public class CouponSetItemModel { |
| 240 | // {"shop_availability":"[{\"merchant_uuid\": \"9742752bcf904a269707c40b286e66de\", \"product_url\": \"https://www.ab.gr/el/eshop/Galaktokomika-Fytika-Rofimata-and-Eidi-Psygeioy/Gala-and-Fytika-Rofimata/Fytika-Rofimata/Fytiko-Rofima-Amygdalo-Choris-Prosthiki-Zacharis-1lt/p/7438640\"}]"} | 258 | // {"shop_availability":"[{\"merchant_uuid\": \"9742752bcf904a269707c40b286e66de\", \"product_url\": \"https://www.ab.gr/el/eshop/Galaktokomika-Fytika-Rofimata-and-Eidi-Psygeioy/Gala-and-Fytika-Rofimata/Fytika-Rofimata/Fytiko-Rofima-Amygdalo-Choris-Prosthiki-Zacharis-1lt/p/7438640\"}]"} |
| 241 | 259 | ||
| 242 | if let extra_fields = dictionary["extra_fields"] as? [String: Any] { | 260 | if let extra_fields = dictionary["extra_fields"] as? [String: Any] { |
| 261 | + self.extra_fields = extra_fields | ||
| 243 | if let shopAvailabilityString = extra_fields["shop_availability"] as? String { | 262 | if let shopAvailabilityString = extra_fields["shop_availability"] as? String { |
| 244 | // Convert the cleaned string to JSON data | 263 | // Convert the cleaned string to JSON data |
| 245 | if let shopData = shopAvailabilityString.data(using: .utf8) { | 264 | if let shopData = shopAvailabilityString.data(using: .utf8) { |
| ... | @@ -312,7 +331,7 @@ public class CouponSetItemModel { | ... | @@ -312,7 +331,7 @@ public class CouponSetItemModel { |
| 312 | public var _category: String { get { return self.category ?? "" } } | 331 | public var _category: String { get { return self.category ?? "" } } |
| 313 | public var _offer_category: String { get { return self.offer_category ?? "" } } | 332 | public var _offer_category: String { get { return self.offer_category ?? "" } } |
| 314 | 333 | ||
| 315 | - // getCouponSetsNew field accessors | 334 | + // getCouponSetsNew fields |
| 316 | public var _score: String? { get { return self.score } set { self.score = newValue } } | 335 | public var _score: String? { get { return self.score } set { self.score = newValue } } |
| 317 | public var _locked: Bool { get { return self.locked ?? false } } | 336 | public var _locked: Bool { get { return self.locked ?? false } } |
| 318 | public var _app_img_preview: String { get { return self.app_img_preview ?? "" } } | 337 | public var _app_img_preview: String { get { return self.app_img_preview ?? "" } } |
| ... | @@ -323,8 +342,11 @@ public class CouponSetItemModel { | ... | @@ -323,8 +342,11 @@ public class CouponSetItemModel { |
| 323 | public var _regions: [String]? { get { return self.regions } } | 342 | public var _regions: [String]? { get { return self.regions } } |
| 324 | public var _show_as_banner: [String: Any]? { get { return self.show_as_banner } } | 343 | public var _show_as_banner: [String: Any]? { get { return self.show_as_banner } } |
| 325 | public var _tagging: [String: Any]? { get { return self.tagging } } | 344 | public var _tagging: [String: Any]? { get { return self.tagging } } |
| 345 | + public var _segment: String { get { return self.segment ?? "" } } | ||
| 346 | + public var _hide_condition: String? { get { return self.hide_condition } } | ||
| 347 | + public var _extra_fields: [String: Any]? { get { return self.extra_fields } } | ||
| 326 | 348 | ||
| 327 | - // Bound merchant data accessor | 349 | + // Bound merchant data accessor |
| 328 | public var _merchant: MerchantModel? { | 350 | public var _merchant: MerchantModel? { |
| 329 | get { return self.merchant } | 351 | get { return self.merchant } |
| 330 | set(newValue) { self.merchant = newValue } | 352 | set(newValue) { self.merchant = newValue } | ... | ... |
| ... | @@ -37,6 +37,7 @@ public class MerchantModel { | ... | @@ -37,6 +37,7 @@ public class MerchantModel { |
| 37 | private var created: String? | 37 | private var created: String? |
| 38 | private var parent: String? | 38 | private var parent: String? |
| 39 | private var img_preview: String? | 39 | private var img_preview: String? |
| 40 | + private var preview_img: String? | ||
| 40 | private var admin_name: String? | 41 | private var admin_name: String? |
| 41 | private var sorting: Int? | 42 | private var sorting: Int? |
| 42 | private var body: String? | 43 | private var body: String? |
| ... | @@ -48,6 +49,8 @@ public class MerchantModel { | ... | @@ -48,6 +49,8 @@ public class MerchantModel { |
| 48 | private var hidden: Bool? | 49 | private var hidden: Bool? |
| 49 | private var show_map: Bool? | 50 | private var show_map: Bool? |
| 50 | private var eshop: Bool? | 51 | private var eshop: Bool? |
| 52 | + private var app_img_preview: String? | ||
| 53 | + private var app_imgs: [String]? | ||
| 51 | 54 | ||
| 52 | // NEW FIELDS - Missing from API response | 55 | // NEW FIELDS - Missing from API response |
| 53 | // Image array - multiple merchant images | 56 | // Image array - multiple merchant images |
| ... | @@ -103,6 +106,7 @@ public class MerchantModel { | ... | @@ -103,6 +106,7 @@ public class MerchantModel { |
| 103 | self.created = "" | 106 | self.created = "" |
| 104 | self.parent = "" | 107 | self.parent = "" |
| 105 | self.img_preview = "" | 108 | self.img_preview = "" |
| 109 | + self.preview_img = "" | ||
| 106 | self.admin_name = "" | 110 | self.admin_name = "" |
| 107 | self.sorting = 0 | 111 | self.sorting = 0 |
| 108 | self.body = "" | 112 | self.body = "" |
| ... | @@ -114,6 +118,8 @@ public class MerchantModel { | ... | @@ -114,6 +118,8 @@ public class MerchantModel { |
| 114 | self.hidden = false | 118 | self.hidden = false |
| 115 | self.show_map = false | 119 | self.show_map = false |
| 116 | self.eshop = false | 120 | self.eshop = false |
| 121 | + self.app_img_preview = "" | ||
| 122 | + self.app_imgs = [] | ||
| 117 | 123 | ||
| 118 | // New fields - initialize with appropriate defaults | 124 | // New fields - initialize with appropriate defaults |
| 119 | self.img = [] | 125 | self.img = [] |
| ... | @@ -185,6 +191,7 @@ public class MerchantModel { | ... | @@ -185,6 +191,7 @@ public class MerchantModel { |
| 185 | // parent_uuid key used by stores endpoint; fallback to parent for merchants | 191 | // parent_uuid key used by stores endpoint; fallback to parent for merchants |
| 186 | self.parent = dictionary["parent_uuid"] as? String ?? dictionary["parent"] as? String ?? "" | 192 | self.parent = dictionary["parent_uuid"] as? String ?? dictionary["parent"] as? String ?? "" |
| 187 | self.img_preview = dictionary["img_preview"] as? String? ?? "" | 193 | self.img_preview = dictionary["img_preview"] as? String? ?? "" |
| 194 | + self.preview_img = dictionary["preview_img"] as? String? ?? "" | ||
| 188 | self.admin_name = dictionary["admin_name"] as? String? ?? "" | 195 | self.admin_name = dictionary["admin_name"] as? String? ?? "" |
| 189 | self.sorting = dictionary["sorting"] as? Int? ?? 0 | 196 | self.sorting = dictionary["sorting"] as? Int? ?? 0 |
| 190 | self.body = dictionary["body"] as? String? ?? "" | 197 | self.body = dictionary["body"] as? String? ?? "" |
| ... | @@ -204,6 +211,9 @@ public class MerchantModel { | ... | @@ -204,6 +211,9 @@ public class MerchantModel { |
| 204 | self.eshop = false | 211 | self.eshop = false |
| 205 | } | 212 | } |
| 206 | 213 | ||
| 214 | + self.app_img_preview = dictionary["app_img_preview"] as? String ?? "" | ||
| 215 | + self.app_imgs = dictionary["app_imgs"] as? [String] ?? [] | ||
| 216 | + | ||
| 207 | // Parse NEW FIELDS - with safe type handling | 217 | // Parse NEW FIELDS - with safe type handling |
| 208 | 218 | ||
| 209 | // Parse img array safely | 219 | // Parse img array safely |
| ... | @@ -396,6 +406,11 @@ public class MerchantModel { | ... | @@ -396,6 +406,11 @@ public class MerchantModel { |
| 396 | set(newValue) { self.img_preview = newValue } | 406 | set(newValue) { self.img_preview = newValue } |
| 397 | } | 407 | } |
| 398 | 408 | ||
| 409 | + public var _preview_img: String { | ||
| 410 | + get { return self.preview_img ?? "" } | ||
| 411 | + set(newValue) { self.preview_img = newValue } | ||
| 412 | + } | ||
| 413 | + | ||
| 399 | public var _admin_name: String { | 414 | public var _admin_name: String { |
| 400 | get { return self.admin_name ?? "" } | 415 | get { return self.admin_name ?? "" } |
| 401 | set(newValue) { self.admin_name = newValue } | 416 | set(newValue) { self.admin_name = newValue } |
| ... | @@ -451,6 +466,16 @@ public class MerchantModel { | ... | @@ -451,6 +466,16 @@ public class MerchantModel { |
| 451 | set(newValue) { self.eshop = newValue } | 466 | set(newValue) { self.eshop = newValue } |
| 452 | } | 467 | } |
| 453 | 468 | ||
| 469 | + public var _app_img_preview: String { | ||
| 470 | + get { return self.app_img_preview ?? "" } | ||
| 471 | + set(newValue) { self.app_img_preview = newValue } | ||
| 472 | + } | ||
| 473 | + | ||
| 474 | + public var _app_imgs: [String] { | ||
| 475 | + get { return self.app_imgs ?? [] } | ||
| 476 | + set(newValue) { self.app_imgs = newValue } | ||
| 477 | + } | ||
| 478 | + | ||
| 454 | // MARK: - NEW FIELD ACCESSORS | 479 | // MARK: - NEW FIELD ACCESSORS |
| 455 | 480 | ||
| 456 | // Image array accessor | 481 | // Image array accessor | ... | ... |
| ... | @@ -78,7 +78,7 @@ import UIKit | ... | @@ -78,7 +78,7 @@ import UIKit |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | - couponImage.backgroundColor = UIColor(rgb: 0x00A3E033) | 81 | + couponImage.backgroundColor = UIColor(rgb: 0xCCE9FB) |
| 82 | 82 | ||
| 83 | infoView.backgroundColor = UIColor(rgb: 0xFFFFFF) | 83 | infoView.backgroundColor = UIColor(rgb: 0xFFFFFF) |
| 84 | infoView.layer.cornerRadius = 10.0 | 84 | infoView.layer.cornerRadius = 10.0 |
| ... | @@ -159,7 +159,7 @@ import UIKit | ... | @@ -159,7 +159,7 @@ import UIKit |
| 159 | websiteButton.layer.cornerRadius = websiteButton.bounds.height / 2 | 159 | websiteButton.layer.cornerRadius = websiteButton.bounds.height / 2 |
| 160 | 160 | ||
| 161 | couponImage.addDashedBorder( | 161 | couponImage.addDashedBorder( |
| 162 | - color: UIColor(rgb: 0x00A3E033), | 162 | + color: UIColor(rgb: 0xCCE9FB), |
| 163 | lineWidth: 1, | 163 | lineWidth: 1, |
| 164 | dash: 3, | 164 | dash: 3, |
| 165 | gap: 3 | 165 | gap: 3 |
| ... | @@ -202,7 +202,7 @@ import UIKit | ... | @@ -202,7 +202,7 @@ import UIKit |
| 202 | 202 | ||
| 203 | merchantNameLabel.font = UIFont(name: "PingLCG-Bold", size: 15) | 203 | merchantNameLabel.font = UIFont(name: "PingLCG-Bold", size: 15) |
| 204 | merchantNameLabel.textColor = UIColor(rgb: 0x9BA1A6) | 204 | merchantNameLabel.textColor = UIColor(rgb: 0x9BA1A6) |
| 205 | - merchantNameLabel.text = coupon.couponset_data?._merchant?._name | 205 | + merchantNameLabel.text = coupon.merchant_details?._name |
| 206 | 206 | ||
| 207 | // Title — from couponset_data name | 207 | // Title — from couponset_data name |
| 208 | titleLabel.font = UIFont(name: "PingLCG-Bold", size: 24) | 208 | titleLabel.font = UIFont(name: "PingLCG-Bold", size: 24) | ... | ... |
| ... | @@ -90,7 +90,7 @@ import UIKit | ... | @@ -90,7 +90,7 @@ import UIKit |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | 92 | ||
| 93 | - couponImage.backgroundColor = UIColor(rgb: 0x00A3E033) | 93 | + couponImage.backgroundColor = UIColor(rgb: 0xCCE9FB) |
| 94 | 94 | ||
| 95 | infoView.backgroundColor = UIColor(rgb: 0xFFFFFF) | 95 | infoView.backgroundColor = UIColor(rgb: 0xFFFFFF) |
| 96 | infoView.layer.cornerRadius = 10.0 | 96 | infoView.layer.cornerRadius = 10.0 |
| ... | @@ -139,7 +139,7 @@ import UIKit | ... | @@ -139,7 +139,7 @@ import UIKit |
| 139 | redeemButton.layer.cornerRadius = redeemButton.bounds.height / 2 | 139 | redeemButton.layer.cornerRadius = redeemButton.bounds.height / 2 |
| 140 | 140 | ||
| 141 | couponImage.addDashedBorder( | 141 | couponImage.addDashedBorder( |
| 142 | - color: UIColor(rgb: 0x00A3E033), | 142 | + color: UIColor(rgb: 0xCCE9FB), |
| 143 | lineWidth: 1, | 143 | lineWidth: 1, |
| 144 | dash: 3, | 144 | dash: 3, |
| 145 | gap: 3 | 145 | gap: 3 |
| ... | @@ -279,7 +279,7 @@ import UIKit | ... | @@ -279,7 +279,7 @@ import UIKit |
| 279 | 279 | ||
| 280 | merchantNameLabel.font = UIFont(name: "PingLCG-Bold", size: 15) | 280 | merchantNameLabel.font = UIFont(name: "PingLCG-Bold", size: 15) |
| 281 | merchantNameLabel.textColor = UIColor(rgb: 0x9BA1A6) | 281 | merchantNameLabel.textColor = UIColor(rgb: 0x9BA1A6) |
| 282 | - merchantNameLabel.text = couponset._merchant?._name | 282 | + merchantNameLabel.text = couponset._merchant_admin_name |
| 283 | 283 | ||
| 284 | titleLabel.font = UIFont(name: "PingLCG-Bold", size: 24) | 284 | titleLabel.font = UIFont(name: "PingLCG-Bold", size: 24) |
| 285 | titleLabel.textColor = UIColor(rgb: 0x000F1E) | 285 | titleLabel.textColor = UIColor(rgb: 0x000F1E) | ... | ... |
-
Please register or login to post a comment