Manos Chorianopoulos

update GiftsViewController

...@@ -12,14 +12,12 @@ import UIKit ...@@ -12,14 +12,12 @@ import UIKit
12 @IBOutlet weak var mainView: UIView! 12 @IBOutlet weak var mainView: UIView!
13 @IBOutlet weak var tableView: UITableView! 13 @IBOutlet weak var tableView: UITableView!
14 14
15 - public var campaigns:Array<swiftApi.CampaignItemModel> = [] 15 + public var campaigns:Array<swiftApi.CampaignItemModel> = swiftApi().getCampaignList().filter { $0.offer_category == "gifts_for_you" }
16 16
17 17
18 public override func viewDidLoad() { 18 public override func viewDidLoad() {
19 super.viewDidLoad() 19 super.viewDidLoad()
20 20
21 - getCampaignsRequest()
22 -
23 setBackButton() 21 setBackButton()
24 setNavigationTitle("GIFTS for YOU") 22 setNavigationTitle("GIFTS for YOU")
25 23
...@@ -39,24 +37,6 @@ import UIKit ...@@ -39,24 +37,6 @@ import UIKit
39 37
40 } 38 }
41 39
42 -
43 - func getCampaignsRequest() {
44 - swiftApi().getCampaignsAsync(getCampaignsCallback)
45 - }
46 -
47 - func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
48 - if (campaignsData != nil) {
49 -
50 - self.campaigns = campaignsData?.filter { $0.offer_category == "gifts_for_you" } ?? []
51 -
52 - DispatchQueue.main.async {
53 - self.tableView.reloadData()
54 - swiftApi().setUniqueCampaignList(campaignsData ?? [])
55 - }
56 - } else {
57 - self.campaigns = []
58 - }
59 - }
60 } 40 }
61 41
62 // MARK: - TableView 42 // MARK: - TableView
...@@ -87,11 +67,11 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -87,11 +67,11 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
87 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 67 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
88 let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController 68 let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
89 var url = "" 69 var url = ""
90 - let hasLoyaltyCampaignId = campaigns[indexPath.row].loyaltyCampaignId != nil && campaigns[indexPath.row].loyaltyCampaignId != "" 70 + let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
91 71
92 - if (hasLoyaltyCampaignId) { 72 + if (isCcmsOffer) {
93 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 73 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
94 - let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].loyaltyCampaignId } 74 + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
95 75
96 if (loyaltyCampaignIdExists == true) { 76 if (loyaltyCampaignIdExists == true) {
97 var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel() 77 var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
......