Manos Chorianopoulos

handleLoyaltyCampaigns, handleContextualCampaigns

......@@ -3678,4 +3678,64 @@ public class swiftApi {
}
}
public func handleLoyaltyCampaigns(_ campaign: CampaignItemModel, _ controller: UIViewController) -> Void {
if (campaign._campaign_type == "coupon") {
let couponsetUuid = campaign._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
vc.campaign = campaign
controller.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
vc.campaignUrl = swiftApi().constructCampaignUrl(campaign)
controller.navigationController?.pushViewController(vc, animated: true)
}
}
public func handleContextualCampaigns(_ ccms: LoyaltyContextualOfferModel, _ controller: UIViewController) -> Void {
let allCampaigns = swiftApi().getAllCampaignList()
for loyaltyCampaign in allCampaigns {
let isCcmsOffer = (loyaltyCampaign.ccms_offer != nil) && (loyaltyCampaign.ccms_offer != "") && (loyaltyCampaign.ccms_offer == "true")
let isTelco = (loyaltyCampaign._type != nil && loyaltyCampaign._type == "telco")
if (isCcmsOffer && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
vc.campaignUrl = swiftApi().constructCcmsUrl(loyaltyCampaign, ccms)
controller.navigationController?.pushViewController(vc, animated: true)
break;
} else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController
vc.ccms = ccms
vc.campaign = loyaltyCampaign
controller.navigationController?.pushViewController(vc, animated: true)
break;
}
}
}
}
......