Showing
1 changed file
with
8 additions
and
7 deletions
... | @@ -76,9 +76,10 @@ public class swiftApi { | ... | @@ -76,9 +76,10 @@ public class swiftApi { |
76 | let mergedGFYCampaigns = GlobalVariables.campaigns.filter { | 76 | let mergedGFYCampaigns = GlobalVariables.campaigns.filter { |
77 | let tempCampaign = $0 | 77 | let tempCampaign = $0 |
78 | let isGFY = tempCampaign.offer_category == "gifts_for_you" | 78 | let isGFY = tempCampaign.offer_category == "gifts_for_you" |
79 | - let hasExtraFields = tempCampaign.hasExtraFields ?? false | 79 | + let hasExtraFields = (tempCampaign.hasExtraFields != nil) && (tempCampaign.hasExtraFields == true) |
80 | - let loyaltyCampaignIdExists = ccmsCampaign.contains { $0._loyaltyCampaignId == tempCampaign.loyaltyCampaignId } | 80 | + let isCcmsOffer = (tempCampaign.ccms_offer != nil) && (tempCampaign.ccms_offer != "") && (tempCampaign.ccms_offer == "true") |
81 | - return isGFY && (!hasExtraFields || loyaltyCampaignIdExists) | 81 | + let loyaltyCampaignIdExists = ccmsCampaign.contains { $0._loyaltyCampaignId == tempCampaign.session_uuid } |
82 | + return isGFY && (!isCcmsOffer || (isCcmsOffer && loyaltyCampaignIdExists)) | ||
82 | } | 83 | } |
83 | 84 | ||
84 | GlobalVariables.campaigns = GlobalVariables.campaigns.filter { $0.offer_category != "gifts_for_you" } + mergedGFYCampaigns | 85 | GlobalVariables.campaigns = GlobalVariables.campaigns.filter { $0.offer_category != "gifts_for_you" } + mergedGFYCampaigns |
... | @@ -415,7 +416,7 @@ public class swiftApi { | ... | @@ -415,7 +416,7 @@ public class swiftApi { |
415 | public let message: String? | 416 | public let message: String? |
416 | public let loyaltyCampaignId: String? | 417 | public let loyaltyCampaignId: String? |
417 | public let hasExtraFields: Bool? | 418 | public let hasExtraFields: Bool? |
418 | - public let ccms_offer: Bool? | 419 | + public let ccms_offer: String? |
419 | 420 | ||
420 | init(dictionary: [String: Any]) { | 421 | init(dictionary: [String: Any]) { |
421 | self.index_url = dictionary["index_url"] as? String? ?? "" | 422 | self.index_url = dictionary["index_url"] as? String? ?? "" |
... | @@ -439,19 +440,19 @@ public class swiftApi { | ... | @@ -439,19 +440,19 @@ public class swiftApi { |
439 | self.subcategory = extra_fields_parsed["subcategory"] as? String? ?? "" | 440 | self.subcategory = extra_fields_parsed["subcategory"] as? String? ?? "" |
440 | self.loyaltyCampaignId = extra_fields_parsed["loyaltyCampaignId"] as? String? ?? "" | 441 | self.loyaltyCampaignId = extra_fields_parsed["loyaltyCampaignId"] as? String? ?? "" |
441 | self.hasExtraFields = true | 442 | self.hasExtraFields = true |
442 | - self.ccms_offer = extra_fields_parsed["ccms_offer"] as? Bool? ?? false | 443 | + self.ccms_offer = extra_fields_parsed["ccms_offer"] as? String? ?? "false" |
443 | } else { | 444 | } else { |
444 | self.subcategory = "" | 445 | self.subcategory = "" |
445 | self.loyaltyCampaignId = "" | 446 | self.loyaltyCampaignId = "" |
446 | self.hasExtraFields = false | 447 | self.hasExtraFields = false |
447 | - self.ccms_offer = false | 448 | + self.ccms_offer = "false" |
448 | print("bad json") | 449 | print("bad json") |
449 | } | 450 | } |
450 | } catch let error as NSError { | 451 | } catch let error as NSError { |
451 | self.subcategory = "" | 452 | self.subcategory = "" |
452 | self.loyaltyCampaignId = "" | 453 | self.loyaltyCampaignId = "" |
453 | self.hasExtraFields = false | 454 | self.hasExtraFields = false |
454 | - self.ccms_offer = false | 455 | + self.ccms_offer = "false" |
455 | print(error) | 456 | print(error) |
456 | } | 457 | } |
457 | 458 | ... | ... |
-
Please register or login to post a comment