Manos Chorianopoulos

fix pacing campaign opened from widget

......@@ -2843,6 +2843,44 @@ public class swiftApi {
// }
}
public func constructCampaignParams(_ campaign: CampaignItemModel, _ from_widget: Bool) -> String {
let instanceOfMyApi = MyApi()
let campaignInfo = instanceOfMyApi.provideInfoForCampaign()
let jsonObject: [String: String] = [
"web_id": (campaignInfo?["web_id"] as! String),
"app_uuid": (campaignInfo?["app_uuid"] as! String),
"api_key": (campaignInfo?["api_key"] as! String),
"session_uuid": (campaign.session_uuid ?? ""),
"access_token": (campaignInfo?["access_token"] as! String),
"refresh_token": (campaignInfo?["refresh_token"] as! String),
"client_id": (campaignInfo?["client_id"] as! String),
"client_secret": (campaignInfo?["client_secret"] as! String),
"from_widget": (from_widget ? "true" : "false")
]
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(jsonObject)
let stringData = String(data: data, encoding: .utf8) ?? ""
print("constructCampaignParams: " + stringData)
return stringData
// do {
// let data = try JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted)
// let stringData = String(data: data, encoding: String.Encoding.utf8) ?? ""
// print("constructCampaignParams: " + stringData)
// return stringData
// } catch {
// print("constructCampaignParams: ")
// return ""
// }
}
public func constructCcmsParams(_ campaign: LoyaltyContextualOfferModel) -> String {
......@@ -3440,7 +3478,7 @@ public class swiftApi {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
let url = swiftApi().constructCampaignUrl(item)
let params = swiftApi().constructCampaignParams(item)
let params = swiftApi().constructCampaignParams(item, true)
print("openPacing url: " + url)
vc.campaignUrl = url
vc.params = params
......