Manos Chorianopoulos

fix campaign url constructions at GFYVC

...@@ -86,7 +86,26 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -86,7 +86,26 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
86 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 86 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
87 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 87 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
88 let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController 88 let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
89 - let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) 89 + var url = ""
90 + let hasLoyaltyCampaignId = campaigns[indexPath.row].loyaltyCampaignId != ""
91 +
92 + if (hasLoyaltyCampaignId) {
93 + let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
94 + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].loyaltyCampaignId }
95 +
96 + if (loyaltyCampaignIdExists == true) {
97 + var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
98 + for item in ccmsCampaigns {
99 + if (item._loyaltyCampaignId == campaigns[indexPath.row].loyaltyCampaignId) {
100 + ccmsCampaignFound = item
101 + }
102 + }
103 + url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
104 + }
105 +
106 + } else {
107 + url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
108 + }
90 vc.campaignUrl = url 109 vc.campaignUrl = url
91 self.navigationController?.pushViewController(vc, animated: true) 110 self.navigationController?.pushViewController(vc, animated: true)
92 } 111 }
......