Manos Chorianopoulos

Added handleSMDealsCampaign

......@@ -3410,6 +3410,44 @@ public class swiftApi {
}
public func constructSMCampaignParams(_ campaign: CampaignItemModel, _ from_widget: Bool, _ dlParam: String) -> 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"),
"dl_param": dlParam
]
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(jsonObject)
let stringData = String(data: data, encoding: .utf8) ?? ""
print("constructSMCampaignParams: " + 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 {
for item in GlobalVariables.campaigns {
......@@ -4112,6 +4150,30 @@ public class swiftApi {
}
public func handleSMDealsCampaign(_ controller: UIViewController, _ dlParam: String) -> Void {
let status = swiftApi().getNetworkStatus()
if (status == -1 || status == 0) {
swiftApi().showDialog(controller, "Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.")
} else {
for item in GlobalVariables.campaigns {
if (item.session_uuid == "39e70f0548884020809dda5f78d06c85" || item.session_uuid == "8314046c83a44576a03ccc3cd9e825db") {
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().constructSMCampaignParams(item, true, dlParam)
print("handleSMDealsCampaign url: " + url)
vc.campaignUrl = url
vc.params = params
vc.showHeader = false
controller.navigationController?.pushViewController(vc, animated: true)
break;
}
}
}
}
public func openPacing(_ controller: UIViewController) -> Void {
let status = swiftApi().getNetworkStatus()
if (status == -1 || status == 0) {
......