Manos Chorianopoulos

Added handleSMDealsCampaign

...@@ -3408,6 +3408,44 @@ public class swiftApi { ...@@ -3408,6 +3408,44 @@ public class swiftApi {
3408 // } 3408 // }
3409 3409
3410 } 3410 }
3411 +
3412 +
3413 + public func constructSMCampaignParams(_ campaign: CampaignItemModel, _ from_widget: Bool, _ dlParam: String) -> String {
3414 + let instanceOfMyApi = MyApi()
3415 + let campaignInfo = instanceOfMyApi.provideInfoForCampaign()
3416 +
3417 + let jsonObject: [String: String] = [
3418 + "web_id": (campaignInfo?["web_id"] as! String),
3419 + "app_uuid": (campaignInfo?["app_uuid"] as! String),
3420 + "api_key": (campaignInfo?["api_key"] as! String),
3421 + "session_uuid": (campaign.session_uuid ?? ""),
3422 + "access_token": (campaignInfo?["access_token"] as! String),
3423 + "refresh_token": (campaignInfo?["refresh_token"] as! String),
3424 + "client_id": (campaignInfo?["client_id"] as! String),
3425 + "client_secret": (campaignInfo?["client_secret"] as! String),
3426 + "from_widget": (from_widget ? "true" : "false"),
3427 + "dl_param": dlParam
3428 + ]
3429 +
3430 + let encoder = JSONEncoder()
3431 + encoder.outputFormatting = .prettyPrinted
3432 + let data = try! encoder.encode(jsonObject)
3433 + let stringData = String(data: data, encoding: .utf8) ?? ""
3434 +
3435 + print("constructSMCampaignParams: " + stringData)
3436 + return stringData
3437 +
3438 + // do {
3439 + // let data = try JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted)
3440 + // let stringData = String(data: data, encoding: String.Encoding.utf8) ?? ""
3441 + // print("constructCampaignParams: " + stringData)
3442 + // return stringData
3443 + // } catch {
3444 + // print("constructCampaignParams: ")
3445 + // return ""
3446 + // }
3447 +
3448 + }
3411 3449
3412 3450
3413 public func constructCcmsParams(_ campaign: LoyaltyContextualOfferModel) -> String { 3451 public func constructCcmsParams(_ campaign: LoyaltyContextualOfferModel) -> String {
...@@ -4112,6 +4150,30 @@ public class swiftApi { ...@@ -4112,6 +4150,30 @@ public class swiftApi {
4112 } 4150 }
4113 4151
4114 4152
4153 + public func handleSMDealsCampaign(_ controller: UIViewController, _ dlParam: String) -> Void {
4154 + let status = swiftApi().getNetworkStatus()
4155 + if (status == -1 || status == 0) {
4156 + swiftApi().showDialog(controller, "Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.")
4157 +
4158 + } else {
4159 + for item in GlobalVariables.campaigns {
4160 + if (item.session_uuid == "39e70f0548884020809dda5f78d06c85" || item.session_uuid == "8314046c83a44576a03ccc3cd9e825db") {
4161 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
4162 + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
4163 + let url = swiftApi().constructCampaignUrl(item)
4164 + let params = swiftApi().constructSMCampaignParams(item, true, dlParam)
4165 + print("handleSMDealsCampaign url: " + url)
4166 + vc.campaignUrl = url
4167 + vc.params = params
4168 + vc.showHeader = false
4169 + controller.navigationController?.pushViewController(vc, animated: true)
4170 + break;
4171 + }
4172 + }
4173 + }
4174 + }
4175 +
4176 +
4115 public func openPacing(_ controller: UIViewController) -> Void { 4177 public func openPacing(_ controller: UIViewController) -> Void {
4116 let status = swiftApi().getNetworkStatus() 4178 let status = swiftApi().getNetworkStatus()
4117 if (status == -1 || status == 0) { 4179 if (status == -1 || status == 0) {
......