Manos Chorianopoulos

merge campaigns at setCCMSLoyaltyCampaigns

......@@ -68,6 +68,16 @@ public class swiftApi {
public func setCCMSLoyaltyCampaigns(campaigns: Array<LoyaltyContextualOfferModel>) {
let ccmsCampaign: Array<LoyaltyContextualOfferModel> = campaigns
let mergedGFYCampaigns = GlobalVariables.campaigns.filter {
let tempCampaign = $0
let isGFY = tempCampaign.offer_category == "gifts_for_you"
let hasExtraFields = tempCampaign.hasExtraFields ?? false
let loyaltyCampaignIdExists = ccmsCampaign.contains { $0._loyaltyCampaignId == tempCampaign.loyaltyCampaignId }
return isGFY && (!hasExtraFields || loyaltyCampaignIdExists)
}
GlobalVariables.campaigns = GlobalVariables.campaigns.filter { $0.offer_category != "gifts_for_you" } + mergedGFYCampaigns
}
public func getActiveDFYCoupons() -> Array<ActiveDFYCouponModel> {
......