Manos Chorianopoulos

dinning campaign fix

......@@ -329,6 +329,70 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
break;
}
}
} else if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") {
let status = swiftApi().getNetworkStatus()
if (status == -1 || status == 0) {
self.showDialog("Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.")
} else {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
var params = ""
let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
if (isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
ccmsCampaignFound = item
}
}
swiftApi().logTrackersEvent("click", ("Contextual:" + (ccmsCampaignFound._sessionId)))
url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound)
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
params = swiftApi().constructCampaignParams(campaigns[indexPath.row])
}
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaigns[indexPath.row])
print("CCMS_CLICK " + String(data: data, encoding: .utf8)!)
} else {
swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaigns[indexPath.row].session_uuid ?? "")))
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
params = swiftApi().constructCampaignParams(campaigns[indexPath.row])
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaigns[indexPath.row])
print("GFY_CLICK " + String(data: data, encoding: .utf8)!)
}
print("CampaignUrl url onclick: " + url)
vc.campaignUrl = url
vc.params = params
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
}
} else {
......
......@@ -325,7 +325,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
}
}
} else if (campaign._campaign_type == "coupon") {
} else if (campaign._campaign_type == "coupon" && campaign._couponset != "") {
let couponsetUuid = campaign._couponset
if (couponsetUuid != "") {
......
......@@ -6863,7 +6863,7 @@ public class swiftApi {
public func handleLoyaltyCampaigns(_ campaign: CampaignItemModel, _ controller: UIViewController) -> Void {
if (campaign._campaign_type == "coupon") {
if (campaign._campaign_type == "coupon" && campaign._couponset != "") {
let couponsetUuid = campaign._couponset
if (couponsetUuid != "") {
......