Manos Chorianopoulos

update GiftsViewController

......@@ -12,14 +12,12 @@ import UIKit
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var tableView: UITableView!
public var campaigns:Array<swiftApi.CampaignItemModel> = []
public var campaigns:Array<swiftApi.CampaignItemModel> = swiftApi().getCampaignList().filter { $0.offer_category == "gifts_for_you" }
public override func viewDidLoad() {
super.viewDidLoad()
getCampaignsRequest()
setBackButton()
setNavigationTitle("GIFTS for YOU")
......@@ -39,24 +37,6 @@ import UIKit
}
func getCampaignsRequest() {
swiftApi().getCampaignsAsync(getCampaignsCallback)
}
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
self.campaigns = campaignsData?.filter { $0.offer_category == "gifts_for_you" } ?? []
DispatchQueue.main.async {
self.tableView.reloadData()
swiftApi().setUniqueCampaignList(campaignsData ?? [])
}
} else {
self.campaigns = []
}
}
}
// MARK: - TableView
......@@ -87,11 +67,11 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
let hasLoyaltyCampaignId = campaigns[indexPath.row].loyaltyCampaignId != nil && campaigns[indexPath.row].loyaltyCampaignId != ""
let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
if (hasLoyaltyCampaignId) {
if (isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].loyaltyCampaignId }
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
......