Manos Chorianopoulos

add native couponset flow at gfyVC, mfyVC

...@@ -84,58 +84,78 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -84,58 +84,78 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
84 } 84 }
85 85
86 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 86 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
87 - if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") { 87 + if (campaigns[indexPath.row]._campaign_type == "coupon") {
88 - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 88 + let couponsetUuid = campaigns[indexPath.row]._couponset
89 - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
90 - var url = ""
91 - let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
92 89
93 - // TODO: DELETE 90 + if (couponsetUuid != "") {
94 - print("isCcmsOffer: " + (isCcmsOffer ? "true" : "false")) 91 + let couponsetsList = swiftApi().getCouponSetList()
95 - 92 +
96 - if (isCcmsOffer) { 93 + for item in couponsetsList {
97 - let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 94 + if (item.uuid == couponsetUuid) {
95 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
96 + let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
97 + vc.couponset = item
98 + self.navigationController?.pushViewController(vc, animated: true)
98 99
100 + break;
101 + }
102 + }
103 + }
104 +
105 + } else {
106 + if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") {
107 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
108 + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
109 + var url = ""
110 + let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
111 +
99 // TODO: DELETE 112 // TODO: DELETE
100 - print("ccmsCampaigns count: " + String(ccmsCampaigns.count)) 113 + print("isCcmsOffer: " + (isCcmsOffer ? "true" : "false"))
101 114
102 - let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } 115 + if (isCcmsOffer) {
116 + let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
103 117
104 - // TODO: DELETE 118 + // TODO: DELETE
105 - print("loyaltyCampaignIdExists: " + (loyaltyCampaignIdExists ? "true" : "false")) 119 + print("ccmsCampaigns count: " + String(ccmsCampaigns.count))
106 120
107 - if (loyaltyCampaignIdExists == true) { 121 + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
108 - var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
109 - for item in ccmsCampaigns {
110 - if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
111 - ccmsCampaignFound = item
112 - }
113 - }
114 - url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
115 122
116 // TODO: DELETE 123 // TODO: DELETE
117 - print("ccmsCampaignFound: " + ccmsCampaignFound._loyaltyCampaignId) 124 + print("loyaltyCampaignIdExists: " + (loyaltyCampaignIdExists ? "true" : "false"))
125 +
126 + if (loyaltyCampaignIdExists == true) {
127 + var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
128 + for item in ccmsCampaigns {
129 + if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
130 + ccmsCampaignFound = item
131 + }
132 + }
133 + url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
134 +
135 + // TODO: DELETE
136 + print("ccmsCampaignFound: " + ccmsCampaignFound._loyaltyCampaignId)
137 +
138 + } else {
139 + url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
140 +
141 + // TODO: DELETE
142 + print("loyaltyCampaignId DOESNT Exist")
143 + }
118 144
119 } else { 145 } else {
120 url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) 146 url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
121 -
122 - // TODO: DELETE
123 - print("loyaltyCampaignId DOESNT Exist")
124 } 147 }
148 + print("CampaignUrl url onclick: " + url)
149 + vc.campaignUrl = url
150 + self.navigationController?.pushViewController(vc, animated: true)
125 151
126 } else { 152 } else {
127 - url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) 153 + let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
154 + seasonalEvent._title = campaigns[indexPath.row]._title ?? ""
155 + seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? ""
156 + seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? ""
157 + SwiftEventBus.post("seasonal", sender: seasonalEvent)
128 } 158 }
129 - print("CampaignUrl url onclick: " + url)
130 - vc.campaignUrl = url
131 - self.navigationController?.pushViewController(vc, animated: true)
132 -
133 - } else {
134 - let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
135 - seasonalEvent._title = campaigns[indexPath.row]._title ?? ""
136 - seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? ""
137 - seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? ""
138 - SwiftEventBus.post("seasonal", sender: seasonalEvent)
139 } 159 }
140 } 160 }
141 161
......
...@@ -73,13 +73,32 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -73,13 +73,32 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
73 } 73 }
74 74
75 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 75 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
76 - 76 + if (campaigns[indexPath.row]._campaign_type == "coupon") {
77 - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 77 + let couponsetUuid = campaigns[indexPath.row]._couponset
78 - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController 78 +
79 - let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) 79 + if (couponsetUuid != "") {
80 - print("CampaignUrl url onclick: " + url) 80 + let couponsetsList = swiftApi().getCouponSetList()
81 - vc.campaignUrl = url 81 +
82 - self.navigationController?.pushViewController(vc, animated: true) 82 + for item in couponsetsList {
83 + if (item.uuid == couponsetUuid) {
84 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
85 + let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
86 + vc.couponset = item
87 + self.navigationController?.pushViewController(vc, animated: true)
88 +
89 + break;
90 + }
91 + }
92 + }
93 +
94 + } else {
95 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
96 + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
97 + let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
98 + print("CampaignUrl url onclick: " + url)
99 + vc.campaignUrl = url
100 + self.navigationController?.pushViewController(vc, animated: true)
101 + }
83 } 102 }
84 103
85 } 104 }
......