Manos Chorianopoulos

add native couponset flow at gfyVC, mfyVC

......@@ -84,58 +84,78 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
if (campaigns[indexPath.row]._campaign_type == "coupon") {
let couponsetUuid = campaigns[indexPath.row]._couponset
// TODO: DELETE
print("isCcmsOffer: " + (isCcmsOffer ? "true" : "false"))
if (isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
if (couponsetUuid != "") {
let couponsetsList = swiftApi().getCouponSetList()
for item in couponsetsList {
if (item.uuid == couponsetUuid) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
vc.couponset = item
self.navigationController?.pushViewController(vc, animated: true)
break;
}
}
}
} else {
if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
// TODO: DELETE
print("ccmsCampaigns count: " + String(ccmsCampaigns.count))
print("isCcmsOffer: " + (isCcmsOffer ? "true" : "false"))
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
// TODO: DELETE
print("loyaltyCampaignIdExists: " + (loyaltyCampaignIdExists ? "true" : "false"))
// TODO: DELETE
print("ccmsCampaigns count: " + String(ccmsCampaigns.count))
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
ccmsCampaignFound = item
}
}
url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
// TODO: DELETE
print("ccmsCampaignFound: " + ccmsCampaignFound._loyaltyCampaignId)
print("loyaltyCampaignIdExists: " + (loyaltyCampaignIdExists ? "true" : "false"))
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
ccmsCampaignFound = item
}
}
url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
// TODO: DELETE
print("ccmsCampaignFound: " + ccmsCampaignFound._loyaltyCampaignId)
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
// TODO: DELETE
print("loyaltyCampaignId DOESNT Exist")
}
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
// TODO: DELETE
print("loyaltyCampaignId DOESNT Exist")
}
print("CampaignUrl url onclick: " + url)
vc.campaignUrl = url
self.navigationController?.pushViewController(vc, animated: true)
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
seasonalEvent._title = campaigns[indexPath.row]._title ?? ""
seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? ""
seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? ""
SwiftEventBus.post("seasonal", sender: seasonalEvent)
}
print("CampaignUrl url onclick: " + url)
vc.campaignUrl = url
self.navigationController?.pushViewController(vc, animated: true)
} else {
let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
seasonalEvent._title = campaigns[indexPath.row]._title ?? ""
seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? ""
seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? ""
SwiftEventBus.post("seasonal", sender: seasonalEvent)
}
}
......
......@@ -73,13 +73,32 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
print("CampaignUrl url onclick: " + url)
vc.campaignUrl = url
self.navigationController?.pushViewController(vc, animated: true)
if (campaigns[indexPath.row]._campaign_type == "coupon") {
let couponsetUuid = campaigns[indexPath.row]._couponset
if (couponsetUuid != "") {
let couponsetsList = swiftApi().getCouponSetList()
for item in couponsetsList {
if (item.uuid == couponsetUuid) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
vc.couponset = item
self.navigationController?.pushViewController(vc, animated: true)
break;
}
}
}
} else {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
print("CampaignUrl url onclick: " + url)
vc.campaignUrl = url
self.navigationController?.pushViewController(vc, animated: true)
}
}
}
......