Manos Chorianopoulos

fix pacing campaign opened from widget

...@@ -2843,6 +2843,44 @@ public class swiftApi { ...@@ -2843,6 +2843,44 @@ public class swiftApi {
2843 // } 2843 // }
2844 2844
2845 } 2845 }
2846 +
2847 +
2848 + public func constructCampaignParams(_ campaign: CampaignItemModel, _ from_widget: Bool) -> String {
2849 + let instanceOfMyApi = MyApi()
2850 + let campaignInfo = instanceOfMyApi.provideInfoForCampaign()
2851 +
2852 + let jsonObject: [String: String] = [
2853 + "web_id": (campaignInfo?["web_id"] as! String),
2854 + "app_uuid": (campaignInfo?["app_uuid"] as! String),
2855 + "api_key": (campaignInfo?["api_key"] as! String),
2856 + "session_uuid": (campaign.session_uuid ?? ""),
2857 + "access_token": (campaignInfo?["access_token"] as! String),
2858 + "refresh_token": (campaignInfo?["refresh_token"] as! String),
2859 + "client_id": (campaignInfo?["client_id"] as! String),
2860 + "client_secret": (campaignInfo?["client_secret"] as! String),
2861 + "from_widget": (from_widget ? "true" : "false")
2862 + ]
2863 +
2864 + let encoder = JSONEncoder()
2865 + encoder.outputFormatting = .prettyPrinted
2866 + let data = try! encoder.encode(jsonObject)
2867 + let stringData = String(data: data, encoding: .utf8) ?? ""
2868 +
2869 + print("constructCampaignParams: " + stringData)
2870 + return stringData
2871 +
2872 + // do {
2873 + // let data = try JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted)
2874 + // let stringData = String(data: data, encoding: String.Encoding.utf8) ?? ""
2875 + // print("constructCampaignParams: " + stringData)
2876 + // return stringData
2877 + // } catch {
2878 + // print("constructCampaignParams: ")
2879 + // return ""
2880 + // }
2881 +
2882 + }
2883 +
2846 2884
2847 public func constructCcmsParams(_ campaign: LoyaltyContextualOfferModel) -> String { 2885 public func constructCcmsParams(_ campaign: LoyaltyContextualOfferModel) -> String {
2848 2886
...@@ -3440,7 +3478,7 @@ public class swiftApi { ...@@ -3440,7 +3478,7 @@ public class swiftApi {
3440 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) 3478 let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
3441 let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController 3479 let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
3442 let url = swiftApi().constructCampaignUrl(item) 3480 let url = swiftApi().constructCampaignUrl(item)
3443 - let params = swiftApi().constructCampaignParams(item) 3481 + let params = swiftApi().constructCampaignParams(item, true)
3444 print("openPacing url: " + url) 3482 print("openPacing url: " + url)
3445 vc.campaignUrl = url 3483 vc.campaignUrl = url
3446 vc.params = params 3484 vc.params = params
......