Showing
2 changed files
with
39 additions
and
40 deletions
No preview for this file type
| ... | @@ -53,55 +53,23 @@ import SwiftEventBus | ... | @@ -53,55 +53,23 @@ import SwiftEventBus |
| 53 | 53 | ||
| 54 | SwiftEventBus.onMainThread(self, name: "ccms_retrieved") { result in | 54 | SwiftEventBus.onMainThread(self, name: "ccms_retrieved") { result in |
| 55 | print("===== SwiftEventBus ccms_retrieved =====") | 55 | print("===== SwiftEventBus ccms_retrieved =====") |
| 56 | - self.campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) | 56 | + |
| 57 | - | 57 | + self.refreshData() |
| 58 | - self.seasonalList = swiftApi().getSeasonalList() | 58 | + |
| 59 | - | ||
| 60 | - if (self.seasonalList.count > 0) { | ||
| 61 | - for seasonalItem in self.seasonalList { | ||
| 62 | - let newCampaign = swiftApi.CampaignItemModel() | ||
| 63 | - newCampaign._title = seasonalItem._title | ||
| 64 | - newCampaign._logo_url = seasonalItem._imageUrl | ||
| 65 | - newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId | ||
| 66 | - self.campaigns.append(newCampaign) | ||
| 67 | - } | ||
| 68 | - } | ||
| 69 | - self.tableView.reloadData() | ||
| 70 | } | 59 | } |
| 71 | 60 | ||
| 72 | SwiftEventBus.onMainThread(self, name: "campaigns_retrieved") { result in | 61 | SwiftEventBus.onMainThread(self, name: "campaigns_retrieved") { result in |
| 73 | print("===== SwiftEventBus campaigns_retrieved =====") | 62 | print("===== SwiftEventBus campaigns_retrieved =====") |
| 74 | - self.campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) | 63 | + |
| 75 | - | 64 | + self.refreshData() |
| 76 | - self.seasonalList = swiftApi().getSeasonalList() | 65 | + |
| 77 | - | ||
| 78 | - if (self.seasonalList.count > 0) { | ||
| 79 | - for seasonalItem in self.seasonalList { | ||
| 80 | - let newCampaign = swiftApi.CampaignItemModel() | ||
| 81 | - newCampaign._title = seasonalItem._title | ||
| 82 | - newCampaign._logo_url = seasonalItem._imageUrl | ||
| 83 | - newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId | ||
| 84 | - self.campaigns.append(newCampaign) | ||
| 85 | - } | ||
| 86 | - } | ||
| 87 | - self.tableView.reloadData() | ||
| 88 | } | 66 | } |
| 89 | 67 | ||
| 90 | SwiftEventBus.onMainThread(self, name: "seasonals_retrieved") { result in | 68 | SwiftEventBus.onMainThread(self, name: "seasonals_retrieved") { result in |
| 91 | print("===== SwiftEventBus seasonals_retrieved =====") | 69 | print("===== SwiftEventBus seasonals_retrieved =====") |
| 70 | + | ||
| 71 | + self.refreshData() | ||
| 92 | 72 | ||
| 93 | - self.seasonalList = swiftApi().getSeasonalList() | ||
| 94 | - | ||
| 95 | - if (self.seasonalList.count > 0) { | ||
| 96 | - for seasonalItem in self.seasonalList { | ||
| 97 | - let newCampaign = swiftApi.CampaignItemModel() | ||
| 98 | - newCampaign._title = seasonalItem._title | ||
| 99 | - newCampaign._logo_url = seasonalItem._imageUrl | ||
| 100 | - newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId | ||
| 101 | - self.campaigns.append(newCampaign) | ||
| 102 | - } | ||
| 103 | - } | ||
| 104 | - self.tableView.reloadData() | ||
| 105 | } | 73 | } |
| 106 | 74 | ||
| 107 | tableView.clipsToBounds = true | 75 | tableView.clipsToBounds = true |
| ... | @@ -117,6 +85,37 @@ import SwiftEventBus | ... | @@ -117,6 +85,37 @@ import SwiftEventBus |
| 117 | 85 | ||
| 118 | } | 86 | } |
| 119 | 87 | ||
| 88 | + // MARK: - Functions | ||
| 89 | + func refreshData() -> Void { | ||
| 90 | + self.campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns()) | ||
| 91 | + self.seasonalList = swiftApi().getSeasonalList() | ||
| 92 | + self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns() | ||
| 93 | + | ||
| 94 | + if (self.seasonalList.count > 0) { | ||
| 95 | + for seasonalItem in self.seasonalList { | ||
| 96 | + let newCampaign = swiftApi.CampaignItemModel() | ||
| 97 | + newCampaign._title = seasonalItem._title | ||
| 98 | + newCampaign._logo_url = seasonalItem._imageUrl | ||
| 99 | + newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId | ||
| 100 | + self.campaigns.append(newCampaign) | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + if (self.ccmsList.count > 0) { | ||
| 105 | + for ccmsItem in self.ccmsList { | ||
| 106 | + if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_GIFTS4U")) { | ||
| 107 | + let newCampaign = swiftApi.CampaignItemModel() | ||
| 108 | + newCampaign._title = ccmsItem._title | ||
| 109 | + newCampaign._logo_url = ccmsItem._imageUrl | ||
| 110 | + newCampaign._ccms = ccmsItem | ||
| 111 | + self.campaigns.append(newCampaign) | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + self.tableView.reloadData() | ||
| 117 | + } | ||
| 118 | + | ||
| 120 | } | 119 | } |
| 121 | 120 | ||
| 122 | // MARK: - TableView | 121 | // MARK: - TableView | ... | ... |
-
Please register or login to post a comment