Showing
4 changed files
with
261 additions
and
74 deletions
... | @@ -14,6 +14,7 @@ import SwiftEventBus | ... | @@ -14,6 +14,7 @@ import SwiftEventBus |
14 | @IBOutlet weak var webview: WKWebView! | 14 | @IBOutlet weak var webview: WKWebView! |
15 | 15 | ||
16 | public var campaignUrl: String = "" | 16 | public var campaignUrl: String = "" |
17 | + public var params: String = "" | ||
17 | 18 | ||
18 | public override func viewDidLoad() { | 19 | public override func viewDidLoad() { |
19 | super.viewDidLoad() | 20 | super.viewDidLoad() |
... | @@ -34,6 +35,20 @@ import SwiftEventBus | ... | @@ -34,6 +35,20 @@ import SwiftEventBus |
34 | webview.configuration.userContentController.add(self, name: "Cosmote") | 35 | webview.configuration.userContentController.add(self, name: "Cosmote") |
35 | } | 36 | } |
36 | 37 | ||
38 | + // MARK: - WKNavigationDelegate | ||
39 | + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { | ||
40 | + | ||
41 | + let scriptSource = "passParams(\(params));" | ||
42 | + | ||
43 | + webView.evaluateJavaScript(scriptSource, completionHandler: { (object, error) in | ||
44 | + print("==== object ====") | ||
45 | + print(object) | ||
46 | + print("==== error ====") | ||
47 | + print(error) | ||
48 | + }) | ||
49 | + } | ||
50 | + | ||
51 | + // MARK: - WKScriptMessageHandler | ||
37 | public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { | 52 | public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { |
38 | 53 | ||
39 | if let event = message.body as? String { | 54 | if let event = message.body as? String { | ... | ... |
... | @@ -172,6 +172,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -172,6 +172,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
172 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 172 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
173 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 173 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
174 | var url = "" | 174 | var url = "" |
175 | + var params = "" | ||
175 | let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") | 176 | let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") |
176 | 177 | ||
177 | if (isCcmsOffer) { | 178 | if (isCcmsOffer) { |
... | @@ -187,9 +188,11 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -187,9 +188,11 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
187 | } | 188 | } |
188 | } | 189 | } |
189 | url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) | 190 | url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) |
191 | + params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound) | ||
190 | 192 | ||
191 | } else { | 193 | } else { |
192 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | 194 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) |
195 | + params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) | ||
193 | 196 | ||
194 | } | 197 | } |
195 | 198 | ||
... | @@ -201,6 +204,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -201,6 +204,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
201 | 204 | ||
202 | } else { | 205 | } else { |
203 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | 206 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) |
207 | + params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) | ||
204 | 208 | ||
205 | let encoder = JSONEncoder() | 209 | let encoder = JSONEncoder() |
206 | encoder.outputFormatting = .prettyPrinted | 210 | encoder.outputFormatting = .prettyPrinted |
... | @@ -210,6 +214,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -210,6 +214,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
210 | } | 214 | } |
211 | print("CampaignUrl url onclick: " + url) | 215 | print("CampaignUrl url onclick: " + url) |
212 | vc.campaignUrl = url | 216 | vc.campaignUrl = url |
217 | + vc.params = params | ||
213 | self.navigationController?.pushViewController(vc, animated: true) | 218 | self.navigationController?.pushViewController(vc, animated: true) |
214 | 219 | ||
215 | } else { | 220 | } else { | ... | ... |
... | @@ -125,6 +125,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -125,6 +125,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
125 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 125 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
126 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 126 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
127 | var url = "" | 127 | var url = "" |
128 | + var params = "" | ||
128 | let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") | 129 | let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") |
129 | 130 | ||
130 | if (isCcmsOffer) { | 131 | if (isCcmsOffer) { |
... | @@ -140,9 +141,11 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -140,9 +141,11 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
140 | } | 141 | } |
141 | } | 142 | } |
142 | url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) | 143 | url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) |
144 | + params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound) | ||
143 | 145 | ||
144 | } else { | 146 | } else { |
145 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | 147 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) |
148 | + params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) | ||
146 | 149 | ||
147 | } | 150 | } |
148 | 151 | ||
... | @@ -154,6 +157,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -154,6 +157,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
154 | 157 | ||
155 | } else { | 158 | } else { |
156 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | 159 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) |
160 | + params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) | ||
157 | 161 | ||
158 | let encoder = JSONEncoder() | 162 | let encoder = JSONEncoder() |
159 | encoder.outputFormatting = .prettyPrinted | 163 | encoder.outputFormatting = .prettyPrinted |
... | @@ -163,6 +167,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -163,6 +167,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
163 | } | 167 | } |
164 | print("CampaignUrl url onclick: " + url) | 168 | print("CampaignUrl url onclick: " + url) |
165 | vc.campaignUrl = url | 169 | vc.campaignUrl = url |
170 | + vc.params = params | ||
166 | self.navigationController?.pushViewController(vc, animated: true) | 171 | self.navigationController?.pushViewController(vc, animated: true) |
167 | } | 172 | } |
168 | } | 173 | } | ... | ... |
... | @@ -2012,22 +2012,20 @@ public class swiftApi { | ... | @@ -2012,22 +2012,20 @@ public class swiftApi { |
2012 | let instanceOfMyApi = MyApi() | 2012 | let instanceOfMyApi = MyApi() |
2013 | let campaignInfo = instanceOfMyApi.provideInfoForCampaign() | 2013 | let campaignInfo = instanceOfMyApi.provideInfoForCampaign() |
2014 | let finalUrl = (campaign.index_url ?? "") | 2014 | let finalUrl = (campaign.index_url ?? "") |
2015 | - + "?web_id=" + (campaignInfo?["web_id"] as! String) | 2015 | + // + "?web_id=" + (campaignInfo?["web_id"] as! String) |
2016 | - + "&app_uuid=" + (campaignInfo?["app_uuid"] as! String) | 2016 | + // + "&app_uuid=" + (campaignInfo?["app_uuid"] as! String) |
2017 | - + "&api_key=" + (campaignInfo?["api_key"] as! String) | 2017 | + // + "&api_key=" + (campaignInfo?["api_key"] as! String) |
2018 | - + "&session_uuid=" + (campaign.session_uuid ?? "") | 2018 | + // + "&session_uuid=" + (campaign.session_uuid ?? "") |
2019 | - + "&access_token=" + (campaignInfo?["access_token"] as! String) | 2019 | + // + "&access_token=" + (campaignInfo?["access_token"] as! String) |
2020 | - + "&refresh_token=" + (campaignInfo?["refresh_token"] as! String) | 2020 | + // + "&refresh_token=" + (campaignInfo?["refresh_token"] as! String) |
2021 | - + "&client_id=" + (campaignInfo?["client_id"] as! String) | 2021 | + // + "&client_id=" + (campaignInfo?["client_id"] as! String) |
2022 | - + "&client_secret=" + (campaignInfo?["client_secret"] as! String); | 2022 | + // + "&client_secret=" + (campaignInfo?["client_secret"] as! String); |
2023 | 2023 | ||
2024 | print("constructCampaignUrl url: " + finalUrl) | 2024 | print("constructCampaignUrl url: " + finalUrl) |
2025 | return finalUrl | 2025 | return finalUrl |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | public func constructCcmsUrl(_ campaign: LoyaltyContextualOfferModel) -> String { | 2028 | public func constructCcmsUrl(_ campaign: LoyaltyContextualOfferModel) -> String { |
2029 | - // TODO: DELETE | ||
2030 | - print("======== constructCcmsUrl 1 arg ========") | ||
2031 | for item in GlobalVariables.campaigns { | 2029 | for item in GlobalVariables.campaigns { |
2032 | if (item.session_uuid == campaign._loyaltyCampaignId) { | 2030 | if (item.session_uuid == campaign._loyaltyCampaignId) { |
2033 | print("CCMS_PRESSED" + " " + campaign._id + " " + campaign._offerName) | 2031 | print("CCMS_PRESSED" + " " + campaign._id + " " + campaign._offerName) |
... | @@ -2048,36 +2046,36 @@ public class swiftApi { | ... | @@ -2048,36 +2046,36 @@ public class swiftApi { |
2048 | let instanceOfMyApi = MyApi() | 2046 | let instanceOfMyApi = MyApi() |
2049 | let campaignInfo = instanceOfMyApi.provideInfoForCampaign() | 2047 | let campaignInfo = instanceOfMyApi.provideInfoForCampaign() |
2050 | let finalUrl = (item.index_url ?? "") | 2048 | let finalUrl = (item.index_url ?? "") |
2051 | - + "?web_id=" + (campaignInfo?["web_id"] as? String ?? "") | 2049 | + // + "?web_id=" + (campaignInfo?["web_id"] as? String ?? "") |
2052 | - + "&app_uuid=" + (campaignInfo?["app_uuid"] as? String ?? "") | 2050 | + // + "&app_uuid=" + (campaignInfo?["app_uuid"] as? String ?? "") |
2053 | - + "&api_key=" + (campaignInfo?["api_key"] as? String ?? "") | 2051 | + // + "&api_key=" + (campaignInfo?["api_key"] as? String ?? "") |
2054 | - + "&session_uuid=" + (item.session_uuid ?? "") | 2052 | + // + "&session_uuid=" + (item.session_uuid ?? "") |
2055 | - + "&access_token=" + (campaignInfo?["access_token"] as? String ?? "") | 2053 | + // + "&access_token=" + (campaignInfo?["access_token"] as? String ?? "") |
2056 | - + "&refresh_token=" + (campaignInfo?["refresh_token"] as? String ?? "") | 2054 | + // + "&refresh_token=" + (campaignInfo?["refresh_token"] as? String ?? "") |
2057 | - + "&client_id=" + (campaignInfo?["client_id"] as? String ?? "") | 2055 | + // + "&client_id=" + (campaignInfo?["client_id"] as? String ?? "") |
2058 | - + "&client_secret=" + (campaignInfo?["client_secret"] as? String ?? "") | 2056 | + // + "&client_secret=" + (campaignInfo?["client_secret"] as? String ?? "") |
2059 | - + "&Session_ID=" + (campaign._sessionId) | 2057 | + // + "&Session_ID=" + (campaign._sessionId) |
2060 | - + "&businessService=" + (campaign._businessService) | 2058 | + // + "&businessService=" + (campaign._businessService) |
2061 | - + "&offerName=" + (campaign._offerName) | 2059 | + // + "&offerName=" + (campaign._offerName) |
2062 | - + "&productType=" + (campaign._productType) | 2060 | + // + "&productType=" + (campaign._productType) |
2063 | - + "&provDuration=" + (campaign._provDuration) | 2061 | + // + "&provDuration=" + (campaign._provDuration) |
2064 | - + "&noOfRecurrance=" + (campaign._noOfRecurrance) | 2062 | + // + "&noOfRecurrance=" + (campaign._noOfRecurrance) |
2065 | - + "&price=" + (campaign._price) | 2063 | + // + "&price=" + (campaign._price) |
2066 | - + "&discount=" + (campaign._discount) | 2064 | + // + "&discount=" + (campaign._discount) |
2067 | - + "&voiceCategory=" + (campaign._voiceCategory) | 2065 | + // + "&voiceCategory=" + (campaign._voiceCategory) |
2068 | - + "&dataCategory=" + (campaign._dataCategory) | 2066 | + // + "&dataCategory=" + (campaign._dataCategory) |
2069 | - + "&minsValue=" + (campaign._minsValue) | 2067 | + // + "&minsValue=" + (campaign._minsValue) |
2070 | - + "&dataValue=" + (campaign._dataValue) | 2068 | + // + "&dataValue=" + (campaign._dataValue) |
2071 | - + "&provStepValueMins=" + (campaign._provStepValueMins) | 2069 | + // + "&provStepValueMins=" + (campaign._provStepValueMins) |
2072 | - + "&UACIOfferTrackingCode=" + (campaign._uaciOfferTrackingCode) | 2070 | + // + "&UACIOfferTrackingCode=" + (campaign._uaciOfferTrackingCode) |
2073 | - + "&OFFERCODE1=" + (campaign._offerCode1) | 2071 | + // + "&OFFERCODE1=" + (campaign._offerCode1) |
2074 | - + "&SCORE=" + (campaign._score) | 2072 | + // + "&SCORE=" + (campaign._score) |
2075 | - + "&WAVE=" + (campaign._wave) | 2073 | + // + "&WAVE=" + (campaign._wave) |
2076 | - + "&VALIDITY=" + (campaign._validity) | 2074 | + // + "&VALIDITY=" + (campaign._validity) |
2077 | - + "&TREATMENT_CODE=" + (campaign._treatmentCode) | 2075 | + // + "&TREATMENT_CODE=" + (campaign._treatmentCode) |
2078 | - + "&OfferAudienceLevel=" + (campaign._offerAudienceLevel) | 2076 | + // + "&OfferAudienceLevel=" + (campaign._offerAudienceLevel) |
2079 | - + "&ASSETS=" + (assetsString) | 2077 | + // + "&ASSETS=" + (assetsString) |
2080 | - + "&ZONE=" + (campaign._zone); | 2078 | + // + "&ZONE=" + (campaign._zone); |
2081 | 2079 | ||
2082 | // + "&OfferAudienceLevel=" + (campaign._eligibleAssets != nil && campaign._eligibleAssets.count > 0 ? "MSISDN" : "GUID") | 2080 | // + "&OfferAudienceLevel=" + (campaign._eligibleAssets != nil && campaign._eligibleAssets.count > 0 ? "MSISDN" : "GUID") |
2083 | 2081 | ||
... | @@ -2087,14 +2085,10 @@ public class swiftApi { | ... | @@ -2087,14 +2085,10 @@ public class swiftApi { |
2087 | } | 2085 | } |
2088 | } | 2086 | } |
2089 | print("constructCcmsUrl url: " + "") | 2087 | print("constructCcmsUrl url: " + "") |
2090 | - // TODO: DELETE | ||
2091 | - print("======== constructCcmsUrl 1 arg: ccms not matched ========") | ||
2092 | return "" | 2088 | return "" |
2093 | } | 2089 | } |
2094 | 2090 | ||
2095 | public func constructCcmsUrl(_ campaign: CampaignItemModel, _ ccmsCampaign: LoyaltyContextualOfferModel) -> String { | 2091 | public func constructCcmsUrl(_ campaign: CampaignItemModel, _ ccmsCampaign: LoyaltyContextualOfferModel) -> String { |
2096 | - // TODO: DELETE | ||
2097 | - print("======== constructCcmsUrl 2 args ========") | ||
2098 | print("CCMS_PRESSED" + " " + ccmsCampaign._id + " " + ccmsCampaign._offerName) | 2092 | print("CCMS_PRESSED" + " " + ccmsCampaign._id + " " + ccmsCampaign._offerName) |
2099 | 2093 | ||
2100 | var assetsString = "" | 2094 | var assetsString = "" |
... | @@ -2111,42 +2105,204 @@ public class swiftApi { | ... | @@ -2111,42 +2105,204 @@ public class swiftApi { |
2111 | let instanceOfMyApi = MyApi() | 2105 | let instanceOfMyApi = MyApi() |
2112 | let campaignInfo = instanceOfMyApi.provideInfoForCampaign() | 2106 | let campaignInfo = instanceOfMyApi.provideInfoForCampaign() |
2113 | let finalUrl = (campaign.index_url ?? "") | 2107 | let finalUrl = (campaign.index_url ?? "") |
2114 | - + "?web_id=" + (campaignInfo?["web_id"] as? String ?? "") | 2108 | + // + "?web_id=" + (campaignInfo?["web_id"] as? String ?? "") |
2115 | - + "&app_uuid=" + (campaignInfo?["app_uuid"] as? String ?? "") | 2109 | + // + "&app_uuid=" + (campaignInfo?["app_uuid"] as? String ?? "") |
2116 | - + "&api_key=" + (campaignInfo?["api_key"] as? String ?? "") | 2110 | + // + "&api_key=" + (campaignInfo?["api_key"] as? String ?? "") |
2117 | - + "&session_uuid=" + (campaign.session_uuid ?? "") | 2111 | + // + "&session_uuid=" + (campaign.session_uuid ?? "") |
2118 | - + "&access_token=" + (campaignInfo?["access_token"] as? String ?? "") | 2112 | + // + "&access_token=" + (campaignInfo?["access_token"] as? String ?? "") |
2119 | - + "&refresh_token=" + (campaignInfo?["refresh_token"] as? String ?? "") | 2113 | + // + "&refresh_token=" + (campaignInfo?["refresh_token"] as? String ?? "") |
2120 | - + "&client_id=" + (campaignInfo?["client_id"] as? String ?? "") | 2114 | + // + "&client_id=" + (campaignInfo?["client_id"] as? String ?? "") |
2121 | - + "&client_secret=" + (campaignInfo?["client_secret"] as? String ?? "") | 2115 | + // + "&client_secret=" + (campaignInfo?["client_secret"] as? String ?? "") |
2122 | - + "&Session_ID=" + (ccmsCampaign._sessionId) | 2116 | + // + "&Session_ID=" + (ccmsCampaign._sessionId) |
2123 | - + "&businessService=" + (ccmsCampaign._businessService) | 2117 | + // + "&businessService=" + (ccmsCampaign._businessService) |
2124 | - + "&offerName=" + (ccmsCampaign._offerName) | 2118 | + // + "&offerName=" + (ccmsCampaign._offerName) |
2125 | - + "&productType=" + (ccmsCampaign._productType) | 2119 | + // + "&productType=" + (ccmsCampaign._productType) |
2126 | - + "&provDuration=" + (ccmsCampaign._provDuration) | 2120 | + // + "&provDuration=" + (ccmsCampaign._provDuration) |
2127 | - + "&noOfRecurrance=" + (ccmsCampaign._noOfRecurrance) | 2121 | + // + "&noOfRecurrance=" + (ccmsCampaign._noOfRecurrance) |
2128 | - + "&price=" + (ccmsCampaign._price) | 2122 | + // + "&price=" + (ccmsCampaign._price) |
2129 | - + "&discount=" + (ccmsCampaign._discount) | 2123 | + // + "&discount=" + (ccmsCampaign._discount) |
2130 | - + "&voiceCategory=" + (ccmsCampaign._voiceCategory) | 2124 | + // + "&voiceCategory=" + (ccmsCampaign._voiceCategory) |
2131 | - + "&dataCategory=" + (ccmsCampaign._dataCategory) | 2125 | + // + "&dataCategory=" + (ccmsCampaign._dataCategory) |
2132 | - + "&minsValue=" + (ccmsCampaign._minsValue) | 2126 | + // + "&minsValue=" + (ccmsCampaign._minsValue) |
2133 | - + "&dataValue=" + (ccmsCampaign._dataValue) | 2127 | + // + "&dataValue=" + (ccmsCampaign._dataValue) |
2134 | - + "&provStepValueMins=" + (ccmsCampaign._provStepValueMins) | 2128 | + // + "&provStepValueMins=" + (ccmsCampaign._provStepValueMins) |
2135 | - + "&UACIOfferTrackingCode=" + (ccmsCampaign._uaciOfferTrackingCode) | 2129 | + // + "&UACIOfferTrackingCode=" + (ccmsCampaign._uaciOfferTrackingCode) |
2136 | - + "&OFFERCODE1=" + (ccmsCampaign._offerCode1) | 2130 | + // + "&OFFERCODE1=" + (ccmsCampaign._offerCode1) |
2137 | - + "&SCORE=" + (ccmsCampaign._score) | 2131 | + // + "&SCORE=" + (ccmsCampaign._score) |
2138 | - + "&WAVE=" + (ccmsCampaign._wave) | 2132 | + // + "&WAVE=" + (ccmsCampaign._wave) |
2139 | - + "&VALIDITY=" + (ccmsCampaign._validity) | 2133 | + // + "&VALIDITY=" + (ccmsCampaign._validity) |
2140 | - + "&TREATMENT_CODE=" + (ccmsCampaign._treatmentCode) | 2134 | + // + "&TREATMENT_CODE=" + (ccmsCampaign._treatmentCode) |
2141 | - + "&OfferAudienceLevel=" + (ccmsCampaign._offerAudienceLevel) | 2135 | + // + "&OfferAudienceLevel=" + (ccmsCampaign._offerAudienceLevel) |
2142 | - + "&ASSETS=" + (assetsString) | 2136 | + // + "&ASSETS=" + (assetsString) |
2143 | - + "&ZONE=" + (ccmsCampaign._zone); | 2137 | + // + "&ZONE=" + (ccmsCampaign._zone); |
2144 | 2138 | ||
2145 | // + "&OfferAudienceLevel=" + (ccmsCampaign._eligibleAssets != nil && ccmsCampaign._eligibleAssets.count > 0 ? "MSISDN" : "GUID") | 2139 | // + "&OfferAudienceLevel=" + (ccmsCampaign._eligibleAssets != nil && ccmsCampaign._eligibleAssets.count > 0 ? "MSISDN" : "GUID") |
2146 | print("constructCcmsUrl url: " + finalUrl) | 2140 | print("constructCcmsUrl url: " + finalUrl) |
2147 | return finalUrl | 2141 | return finalUrl |
2148 | } | 2142 | } |
2149 | 2143 | ||
2144 | + | ||
2145 | + public func constructCampaignParams(_ campaign: CampaignItemModel) -> String { | ||
2146 | + let instanceOfMyApi = MyApi() | ||
2147 | + let campaignInfo = instanceOfMyApi.provideInfoForCampaign() | ||
2148 | + | ||
2149 | + let jsonObject: [String: String] = [ | ||
2150 | + "web_id": (campaignInfo?["web_id"] as! String), | ||
2151 | + "app_uuid": (campaignInfo?["app_uuid"] as! String), | ||
2152 | + "api_key": (campaignInfo?["api_key"] as! String), | ||
2153 | + "session_uuid": (campaign.session_uuid ?? ""), | ||
2154 | + "access_token": (campaignInfo?["access_token"] as! String), | ||
2155 | + "refresh_token": (campaignInfo?["refresh_token"] as! String), | ||
2156 | + "client_id": (campaignInfo?["client_id"] as! String), | ||
2157 | + "client_secret": (campaignInfo?["client_secret"] as! String) | ||
2158 | + ] | ||
2159 | + | ||
2160 | + let encoder = JSONEncoder() | ||
2161 | + encoder.outputFormatting = .prettyPrinted | ||
2162 | + let data = try! encoder.encode(jsonObject) | ||
2163 | + let stringData = String(data: data, encoding: .utf8) ?? "" | ||
2164 | + | ||
2165 | + print("constructCampaignParams: " + stringData) | ||
2166 | + return stringData | ||
2167 | + | ||
2168 | + // do { | ||
2169 | + // let data = try JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted) | ||
2170 | + // let stringData = String(data: data, encoding: String.Encoding.utf8) ?? "" | ||
2171 | + // print("constructCampaignParams: " + stringData) | ||
2172 | + // return stringData | ||
2173 | + // } catch { | ||
2174 | + // print("constructCampaignParams: ") | ||
2175 | + // return "" | ||
2176 | + // } | ||
2177 | + | ||
2178 | + } | ||
2179 | + | ||
2180 | + public func constructCcmsParams(_ campaign: LoyaltyContextualOfferModel) -> String { | ||
2181 | + | ||
2182 | + for item in GlobalVariables.campaigns { | ||
2183 | + if (item.session_uuid == campaign._loyaltyCampaignId) { | ||
2184 | + | ||
2185 | + var assetsString = "" | ||
2186 | + if (campaign._eligibleAssets != nil && campaign._eligibleAssets.count > 0) { | ||
2187 | + for (index, item) in campaign._eligibleAssets.enumerated() { | ||
2188 | + if (index == (campaign._eligibleAssets.endIndex - 1)) { | ||
2189 | + assetsString += String(item) | ||
2190 | + } else { | ||
2191 | + assetsString += String(item) + "," | ||
2192 | + } | ||
2193 | + } | ||
2194 | + } | ||
2195 | + | ||
2196 | + let instanceOfMyApi = MyApi() | ||
2197 | + let campaignInfo = instanceOfMyApi.provideInfoForCampaign() | ||
2198 | + | ||
2199 | + let jsonObject: [String: String] = [ | ||
2200 | + "web_id": (campaignInfo?["web_id"] as? String ?? ""), | ||
2201 | + "app_uuid": (campaignInfo?["app_uuid"] as? String ?? ""), | ||
2202 | + "api_key": (campaignInfo?["api_key"] as? String ?? ""), | ||
2203 | + "session_uuid": (item.session_uuid ?? ""), | ||
2204 | + "access_token": (campaignInfo?["access_token"] as? String ?? ""), | ||
2205 | + "refresh_token": (campaignInfo?["refresh_token"] as? String ?? ""), | ||
2206 | + "client_id": (campaignInfo?["client_id"] as? String ?? ""), | ||
2207 | + "client_secret": (campaignInfo?["client_secret"] as? String ?? ""), | ||
2208 | + "Session_ID": (campaign._sessionId), | ||
2209 | + "businessService": (campaign._businessService), | ||
2210 | + "offerName": (campaign._offerName), | ||
2211 | + "productType": (campaign._productType), | ||
2212 | + "provDuration": (campaign._provDuration), | ||
2213 | + "noOfRecurrance": (campaign._noOfRecurrance), | ||
2214 | + "price": (campaign._price), | ||
2215 | + "discount": (campaign._discount), | ||
2216 | + "voiceCategory": (campaign._voiceCategory), | ||
2217 | + "dataCategory": (campaign._dataCategory), | ||
2218 | + "minsValue": (campaign._minsValue), | ||
2219 | + "dataValue": (campaign._dataValue), | ||
2220 | + "provStepValueMins": (campaign._provStepValueMins), | ||
2221 | + "UACIOfferTrackingCode": (campaign._uaciOfferTrackingCode), | ||
2222 | + "OFFERCODE1": (campaign._offerCode1), | ||
2223 | + "SCORE": (campaign._score), | ||
2224 | + "WAVE": (campaign._wave), | ||
2225 | + "VALIDITY": (campaign._validity), | ||
2226 | + "TREATMENT_CODE": (campaign._treatmentCode), | ||
2227 | + "OfferAudienceLevel": (campaign._offerAudienceLevel), | ||
2228 | + "ASSETS": (assetsString), | ||
2229 | + "ZONE": (campaign._zone) | ||
2230 | + ] | ||
2231 | + | ||
2232 | + let encoder = JSONEncoder() | ||
2233 | + encoder.outputFormatting = .prettyPrinted | ||
2234 | + let data = try! encoder.encode(jsonObject) | ||
2235 | + let stringData = String(data: data, encoding: .utf8) ?? "" | ||
2236 | + | ||
2237 | + print("constructCcmsParams: " + stringData) | ||
2238 | + return stringData | ||
2239 | + break; | ||
2240 | + } | ||
2241 | + } | ||
2242 | + print("constructCcmsParams: " + "") | ||
2243 | + return "" | ||
2244 | + } | ||
2245 | + | ||
2246 | + | ||
2247 | + public func constructCcmsParams(_ campaign: CampaignItemModel, _ ccmsCampaign: LoyaltyContextualOfferModel) -> String { | ||
2248 | + | ||
2249 | + var assetsString = "" | ||
2250 | + if (ccmsCampaign._eligibleAssets != nil && ccmsCampaign._eligibleAssets.count > 0) { | ||
2251 | + for (index, item) in ccmsCampaign._eligibleAssets.enumerated() { | ||
2252 | + if (index == (ccmsCampaign._eligibleAssets.endIndex - 1)) { | ||
2253 | + assetsString += String(item) | ||
2254 | + } else { | ||
2255 | + assetsString += String(item) + "," | ||
2256 | + } | ||
2257 | + } | ||
2258 | + } | ||
2259 | + | ||
2260 | + let instanceOfMyApi = MyApi() | ||
2261 | + let campaignInfo = instanceOfMyApi.provideInfoForCampaign() | ||
2262 | + | ||
2263 | + let jsonObject: [String: String] = [ | ||
2264 | + "web_id": (campaignInfo?["web_id"] as? String ?? ""), | ||
2265 | + "app_uuid": (campaignInfo?["app_uuid"] as? String ?? ""), | ||
2266 | + "api_key": (campaignInfo?["api_key"] as? String ?? ""), | ||
2267 | + "session_uuid": (campaign.session_uuid ?? ""), | ||
2268 | + "access_token": (campaignInfo?["access_token"] as? String ?? ""), | ||
2269 | + "refresh_token": (campaignInfo?["refresh_token"] as? String ?? ""), | ||
2270 | + "client_id": (campaignInfo?["client_id"] as? String ?? ""), | ||
2271 | + "client_secret": (campaignInfo?["client_secret"] as? String ?? ""), | ||
2272 | + "Session_ID": (ccmsCampaign._sessionId), | ||
2273 | + "businessService": (ccmsCampaign._businessService), | ||
2274 | + "offerName": (ccmsCampaign._offerName), | ||
2275 | + "productType": (ccmsCampaign._productType), | ||
2276 | + "provDuration": (ccmsCampaign._provDuration), | ||
2277 | + "noOfRecurrance": (ccmsCampaign._noOfRecurrance), | ||
2278 | + "price": (ccmsCampaign._price), | ||
2279 | + "discount": (ccmsCampaign._discount), | ||
2280 | + "voiceCategory": (ccmsCampaign._voiceCategory), | ||
2281 | + "dataCategory": (ccmsCampaign._dataCategory), | ||
2282 | + "minsValue": (ccmsCampaign._minsValue), | ||
2283 | + "dataValue": (ccmsCampaign._dataValue), | ||
2284 | + "provStepValueMins": (ccmsCampaign._provStepValueMins), | ||
2285 | + "UACIOfferTrackingCode": (ccmsCampaign._uaciOfferTrackingCode), | ||
2286 | + "OFFERCODE1": (ccmsCampaign._offerCode1), | ||
2287 | + "SCORE": (ccmsCampaign._score), | ||
2288 | + "WAVE": (ccmsCampaign._wave), | ||
2289 | + "VALIDITY": (ccmsCampaign._validity), | ||
2290 | + "TREATMENT_CODE": (ccmsCampaign._treatmentCode), | ||
2291 | + "OfferAudienceLevel": (ccmsCampaign._offerAudienceLevel), | ||
2292 | + "ASSETS": (assetsString), | ||
2293 | + "ZONE": (ccmsCampaign._zone) | ||
2294 | + ] | ||
2295 | + | ||
2296 | + let encoder = JSONEncoder() | ||
2297 | + encoder.outputFormatting = .prettyPrinted | ||
2298 | + let data = try! encoder.encode(jsonObject) | ||
2299 | + let stringData = String(data: data, encoding: .utf8) ?? "" | ||
2300 | + | ||
2301 | + print("constructCcmsParams: " + stringData) | ||
2302 | + return stringData | ||
2303 | + } | ||
2304 | + | ||
2305 | + | ||
2150 | public func handleSharing(_ controller: UIViewController, _ sharingId: String) -> Void { | 2306 | public func handleSharing(_ controller: UIViewController, _ sharingId: String) -> Void { |
2151 | 2307 | ||
2152 | print("SHARING_ID: " + sharingId) | 2308 | print("SHARING_ID: " + sharingId) |
... | @@ -2514,7 +2670,9 @@ public class swiftApi { | ... | @@ -2514,7 +2670,9 @@ public class swiftApi { |
2514 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 2670 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
2515 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 2671 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
2516 | let url = swiftApi().constructCampaignUrl(item) | 2672 | let url = swiftApi().constructCampaignUrl(item) |
2673 | + let params = swiftApi().constructCampaignParams(item) | ||
2517 | vc.campaignUrl = url | 2674 | vc.campaignUrl = url |
2675 | + vc.params = params | ||
2518 | controller.navigationController?.pushViewController(vc, animated: true) | 2676 | controller.navigationController?.pushViewController(vc, animated: true) |
2519 | break; | 2677 | break; |
2520 | } | 2678 | } |
... | @@ -2528,8 +2686,10 @@ public class swiftApi { | ... | @@ -2528,8 +2686,10 @@ public class swiftApi { |
2528 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 2686 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
2529 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 2687 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
2530 | let url = swiftApi().constructCampaignUrl(item) | 2688 | let url = swiftApi().constructCampaignUrl(item) |
2689 | + let params = swiftApi().constructCampaignParams(item) | ||
2531 | print("openPacing url: " + url) | 2690 | print("openPacing url: " + url) |
2532 | vc.campaignUrl = url | 2691 | vc.campaignUrl = url |
2692 | + vc.params = params | ||
2533 | controller.navigationController?.pushViewController(vc, animated: true) | 2693 | controller.navigationController?.pushViewController(vc, animated: true) |
2534 | break; | 2694 | break; |
2535 | } | 2695 | } |
... | @@ -3704,6 +3864,7 @@ public class swiftApi { | ... | @@ -3704,6 +3864,7 @@ public class swiftApi { |
3704 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 3864 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
3705 | 3865 | ||
3706 | vc.campaignUrl = swiftApi().constructCampaignUrl(campaign) | 3866 | vc.campaignUrl = swiftApi().constructCampaignUrl(campaign) |
3867 | + vc.params = swiftApi().constructCampaignParams(campaign) | ||
3707 | controller.navigationController?.pushViewController(vc, animated: true) | 3868 | controller.navigationController?.pushViewController(vc, animated: true) |
3708 | } | 3869 | } |
3709 | } | 3870 | } |
... | @@ -3722,6 +3883,7 @@ public class swiftApi { | ... | @@ -3722,6 +3883,7 @@ public class swiftApi { |
3722 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 3883 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
3723 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 3884 | let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
3724 | vc.campaignUrl = swiftApi().constructCcmsUrl(loyaltyCampaign, ccms) | 3885 | vc.campaignUrl = swiftApi().constructCcmsUrl(loyaltyCampaign, ccms) |
3886 | + vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms) | ||
3725 | controller.navigationController?.pushViewController(vc, animated: true) | 3887 | controller.navigationController?.pushViewController(vc, animated: true) |
3726 | break; | 3888 | break; |
3727 | 3889 | ... | ... |
-
Please register or login to post a comment