From bd729b514a8250ae4da1d8f24a9ef8a143cd6314 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Tue, 21 Dec 2021 13:08:39 +0530 Subject: [PATCH] added analytics data for AlertModel --- MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift | 5 ++++- MVMCoreUI/Atomic/Actions/AlertModel.swift | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift b/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift index 9594c576..c2c5d50f 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift @@ -36,11 +36,14 @@ public extension MVMCoreAlertObject { actions: actionsForAlert, isGreedy: false) - alertObject?.pageJson = actionJson?.optionalDictionaryForKey(KeyPage) if let alertStyle = alertJson.optionalStringForKey("style") { alertObject?.alertStyle = UIAlertController.Style(rawValue: alertStyle) } + if let analyticsData = alertJson.optionalDictionaryForKey("analyticsData") { + alertObject?.pageJson = ["analyticsData": analyticsData] + } + return alertObject } } diff --git a/MVMCoreUI/Atomic/Actions/AlertModel.swift b/MVMCoreUI/Atomic/Actions/AlertModel.swift index 866bfb31..76bfb273 100644 --- a/MVMCoreUI/Atomic/Actions/AlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/AlertModel.swift @@ -7,6 +7,7 @@ // import UIKit +import MVMCore public class AlertButtonModel: Codable { @@ -69,6 +70,7 @@ public class AlertModel: Codable { public var message: String public var style: UIAlertController.Style = .alert public var alertActions: [AlertButtonModel] + public var analyticsData: JSONValueDictionary? //-------------------------------------------------- // MARK: - Properties @@ -89,6 +91,7 @@ public class AlertModel: Codable { case message case alertActions case style + case analyticsData } //-------------------------------------------------- @@ -100,7 +103,8 @@ public class AlertModel: Codable { title = try typeContainer.decode(String.self, forKey: .title) message = try typeContainer.decode(String.self, forKey: .message) alertActions = try typeContainer.decode([AlertButtonModel].self, forKey: .alertActions) - + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) { self.style = UIAlertController.Style(rawValue: style) } @@ -112,5 +116,6 @@ public class AlertModel: Codable { try container.encode(message, forKey: .message) try container.encode(alertActions, forKey: .alertActions) try container.encode(style.rawValueString, forKey: .style) + try container.encodeIfPresent(analyticsData, forKey: .analyticsData) } }