added analytics data for AlertModel

This commit is contained in:
Krishna Kishore Bandaru 2021-12-21 13:08:39 +05:30
parent 3c8046587b
commit bd729b514a
2 changed files with 10 additions and 2 deletions

View File

@ -36,11 +36,14 @@ public extension MVMCoreAlertObject {
actions: actionsForAlert, actions: actionsForAlert,
isGreedy: false) isGreedy: false)
alertObject?.pageJson = actionJson?.optionalDictionaryForKey(KeyPage)
if let alertStyle = alertJson.optionalStringForKey("style") { if let alertStyle = alertJson.optionalStringForKey("style") {
alertObject?.alertStyle = UIAlertController.Style(rawValue: alertStyle) alertObject?.alertStyle = UIAlertController.Style(rawValue: alertStyle)
} }
if let analyticsData = alertJson.optionalDictionaryForKey("analyticsData") {
alertObject?.pageJson = ["analyticsData": analyticsData]
}
return alertObject return alertObject
} }
} }

View File

@ -7,6 +7,7 @@
// //
import UIKit import UIKit
import MVMCore
public class AlertButtonModel: Codable { public class AlertButtonModel: Codable {
@ -69,6 +70,7 @@ public class AlertModel: Codable {
public var message: String public var message: String
public var style: UIAlertController.Style = .alert public var style: UIAlertController.Style = .alert
public var alertActions: [AlertButtonModel] public var alertActions: [AlertButtonModel]
public var analyticsData: JSONValueDictionary?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
@ -89,6 +91,7 @@ public class AlertModel: Codable {
case message case message
case alertActions case alertActions
case style case style
case analyticsData
} }
//-------------------------------------------------- //--------------------------------------------------
@ -100,6 +103,7 @@ public class AlertModel: Codable {
title = try typeContainer.decode(String.self, forKey: .title) title = try typeContainer.decode(String.self, forKey: .title)
message = try typeContainer.decode(String.self, forKey: .message) message = try typeContainer.decode(String.self, forKey: .message)
alertActions = try typeContainer.decode([AlertButtonModel].self, forKey: .alertActions) 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) { if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) {
self.style = UIAlertController.Style(rawValue: style) self.style = UIAlertController.Style(rawValue: style)
@ -112,5 +116,6 @@ public class AlertModel: Codable {
try container.encode(message, forKey: .message) try container.encode(message, forKey: .message)
try container.encode(alertActions, forKey: .alertActions) try container.encode(alertActions, forKey: .alertActions)
try container.encode(style.rawValueString, forKey: .style) try container.encode(style.rawValueString, forKey: .style)
try container.encodeIfPresent(analyticsData, forKey: .analyticsData)
} }
} }