diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h index 9596929..dba1c92 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h @@ -20,6 +20,8 @@ @optional +@property (nullable, strong, nonatomic) MVMCoreLoadObject *loadObject; + // Allows override of the delegate to use. - (nullable DelegateObject *)delegateObject; diff --git a/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift index 72b84f7..cb8b643 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift @@ -10,9 +10,12 @@ import Foundation @objcMembers public class ActionBackModel: ActionModelProtocol { public static var identifier: String = "back" - public var actionType: String + public var actionType: String = ActionBackModel.identifier public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - // Temporary fix till server changes - public var title: String? + + public init(_ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift index 3f13e6a..75ce450 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift @@ -15,10 +15,10 @@ import Foundation public var callNumber: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - // Temporary fix till server changes - public var title: String? - public init(callNumber: String) { + public init(callNumber: String, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { self.callNumber = callNumber + self.extraParameters = extraParameters + self.analyticsData = analyticsData } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift index 08bf63c..0b1b675 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift @@ -10,8 +10,12 @@ import UIKit @objcMembers public class ActionCancelModel: ActionModelProtocol { public static var identifier: String = "cancel" - public var actionType: String + public var actionType: String = ActionCancelModel.identifier public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - public var title: String? + + public init(_ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionModelProtocol.swift b/MVMCore/MVMCore/Models/ActionType/ActionModelProtocol.swift index dc36409..70c3150 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionModelProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionModelProtocol.swift @@ -13,9 +13,6 @@ public protocol ActionModelProtocol: ModelProtocol { var actionType: String { get } var extraParameters: JSONValueDictionary? { get set } var analyticsData: JSONValueDictionary? { get set } - - // Temporary fix till server changes - var title: String? { get set } } public extension ActionModelProtocol { diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift index 9614bc8..6dd46a6 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift @@ -15,10 +15,10 @@ import Foundation public var appURL: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - // Temporary fix till server changes - public var title: String? - public init(appURL: String) { + public init(appURL: String, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { self.appURL = appURL + self.extraParameters = extraParameters + self.analyticsData = analyticsData } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift index 413adf8..ac4d537 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift @@ -16,10 +16,10 @@ import Foundation public var analyticsData: JSONValueDictionary? public var presentationStyle: String? - // Temporary fix till server changes - public var title: String? - - public init(pageType: String) { + public init(pageType: String, _ presentationStyle: String? = nil, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { self.pageType = pageType + self.presentationStyle = presentationStyle + self.extraParameters = extraParameters + self.analyticsData = analyticsData } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift index fc8c11f..527cc5a 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift @@ -15,9 +15,6 @@ import Foundation public var browserUrl: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - // Temporary fix till server changes - public var title: String? - //TODO: Should be removed in future releases. This should be MF specific. //Missing params diff --git a/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift index eaff84c..9c5ee17 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift @@ -11,11 +11,13 @@ import Foundation @objcMembers public class ActionPopupModel: ActionModelProtocol { public static var identifier: String = "popup" public var actionType: String = ActionPopupModel.identifier - public var title: String? public var pageType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - public init(pageType: String) { + + public init(pageType: String, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { self.pageType = pageType + self.extraParameters = extraParameters + self.analyticsData = analyticsData } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift index f6d5ad7..f64b5ba 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift @@ -10,8 +10,12 @@ import UIKit @objcMembers public class ActionPreviousSubmitModel: ActionModelProtocol { public static var identifier: String = "previousSubmit" - public var actionType: String + public var actionType: String = ActionPreviousSubmitModel.identifier public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - public var title: String? + + public init(_ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift index 0cdbae3..fe9c09d 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift @@ -10,11 +10,16 @@ import UIKit @objcMembers public class ActionRestartModel: ActionModelProtocol { public static var identifier: String = "restart" - public var actionType: String + public var actionType: String = ActionRestartModel.identifier public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - public var title: String? ///Optional pageType, if pageType is nil, will start with pageType launchApp public var pageType: String? + + public init(_ pageType: String? = nil, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.pageType = pageType + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift index 212b526..5986e47 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift @@ -10,8 +10,12 @@ import UIKit @objcMembers public class ActionSettingModel: ActionModelProtocol { public static var identifier: String = "openSettings" - public var actionType: String + public var actionType: String = ActionSettingModel.identifier public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - public var title: String? + + public init(_ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionShareModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionShareModel.swift index 16da245..7dc327f 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionShareModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionShareModel.swift @@ -16,7 +16,6 @@ import UIKit public static var identifier: String = "share" public var actionType: String = ActionShareModel.identifier - public var title: String? public var sharedType: String public var sharedText: String public var extraParameters: JSONValueDictionary? @@ -26,8 +25,10 @@ import UIKit // MARK: - Initializer //-------------------------------------------------- - public init(sharedText: String,sharedType: String) { + public init(sharedText: String, sharedType: String, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { self.sharedType = sharedType self.sharedText = sharedText + self.extraParameters = extraParameters + self.analyticsData = analyticsData } } diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index b002175..f9ec58b 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -205,19 +205,18 @@ public extension UnkeyedDecodingContainer { // Iterate and decode each. while !containerCopy.isAtEnd { let nestedContainer = try containerCopy.nestedContainer(keyedBy: AnyCodingKey.self) - if let identifier = try nestedContainer.decodeIfPresent(String.self, forKey: typeCodingKey) { - guard let type = ModelRegistry.getType(for: identifier, with: T.self) else { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorModelNotMapped: \(identifier)") - throw ModelRegistry.Error.decoderErrorModelNotMapped - } - // Now get the decoder to use for the type - let decoder = try self.superDecoder() - if let model = try type.init(from: decoder) as? T { - models.append(model) - } else { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderError: \(typeCodingKey)") - throw ModelRegistry.Error.decoderError - } + let identifier = try nestedContainer.decode(String.self, forKey: typeCodingKey) + guard let type = ModelRegistry.getType(for: identifier, with: T.self) else { + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorModelNotMapped: \(identifier)") + throw ModelRegistry.Error.decoderErrorModelNotMapped + } + // Now get the decoder to use for the type + let decoder = try self.superDecoder() + if let model = try type.init(from: decoder) as? T { + models.append(model) + } else { + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderError: \(typeCodingKey)") + throw ModelRegistry.Error.decoderError } } return models