From 214cb75b985f757ac7fa6916da916f82abac3142 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 24 Jun 2020 15:36:43 -0400 Subject: [PATCH 1/4] attach coding key data to ModelRegistry errors. --- .../MVMCore/Models/Model/ModelRegistry.swift | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index f9ec58b..93407d1 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -16,8 +16,8 @@ public struct ModelRegistry { case encoderError case decoderError case decoderOther(message: String) - case decoderErrorObjectNotPresent - case decoderErrorModelNotMapped + case decoderErrorObjectNotPresent(codingKey: CodingKey, codingPath: [CodingKey]) + case decoderErrorModelNotMapped(identifer: String? = nil, codingKey: CodingKey? = nil, codingPath: [CodingKey]? = nil) case other(message: String) } @@ -75,8 +75,8 @@ extension KeyedDecodingContainer where Key: CodingKey { /// Decodes to a registered model based on the identifier public func decodeModel(codingKey: KeyedDecodingContainer.Key) throws -> T { guard let model: T = try decodeModelIfPresent(codingKey: codingKey) else { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey)") - throw ModelRegistry.Error.decoderErrorObjectNotPresent + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") + throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) } return model } @@ -84,8 +84,8 @@ extension KeyedDecodingContainer where Key: CodingKey { /// Decodes an array of registered model based on the identifiers. public func decodeModels(codingKey: KeyedDecodingContainer.Key) throws -> [T] { guard let model: [T] = try decodeModelsIfPresent(codingKey: codingKey) else { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey)") - throw ModelRegistry.Error.decoderErrorObjectNotPresent + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") + throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) } return model } @@ -93,8 +93,8 @@ extension KeyedDecodingContainer where Key: CodingKey { /// Decodes an array with arrays of models based on the identifiers. public func decodeModels2D(codingKey: KeyedDecodingContainer.Key) throws -> [[T]] { guard let models: [[T]] = try decodeModels2DIfPresent(codingKey: codingKey) else { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey)") - throw ModelRegistry.Error.decoderErrorObjectNotPresent + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") + throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) } return models } @@ -114,7 +114,7 @@ extension KeyedDecodingContainer where Key: CodingKey { //get the type from the identifier value in the Registry guard let type = ModelRegistry.getType(for: identifier, with: T.self) else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelProtocol not mapped: \(identifier)") - throw ModelRegistry.Error.decoderErrorModelNotMapped + throw ModelRegistry.Error.decoderErrorModelNotMapped(identifer: identifier, codingKey: typeCodingKey, codingPath: container.codingPath) } //decode the type using the decoder @@ -208,7 +208,7 @@ public extension UnkeyedDecodingContainer { 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 + throw ModelRegistry.Error.decoderErrorModelNotMapped(identifer: identifier, codingKey: typeCodingKey, codingPath: nestedContainer.codingPath) } // Now get the decoder to use for the type let decoder = try self.superDecoder() @@ -233,7 +233,7 @@ public extension UnkeyedDecodingContainer { var arraycontainerCopy = try containerCopy.nestedUnkeyedContainer() guard let models: [T] = try arraycontainerCopy.decodeModelsIfPresent() else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorModelNotMapped: \(typeCodingKey)") - throw ModelRegistry.Error.decoderErrorModelNotMapped + throw ModelRegistry.Error.decoderErrorModelNotMapped(identifer: typeCodingKey.stringValue, codingKey: typeCodingKey, codingPath: arraycontainerCopy.codingPath) } modelLists.append(models) } From 5065205c4a8cded48a57586d407b16b5f1ee3528 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Thu, 2 Jul 2020 20:54:49 +0530 Subject: [PATCH 2/4] adding appUrl inside ActionOpenUrlModel to support open app url launch. --- MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift index 527cc5a..df86873 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift @@ -15,6 +15,7 @@ import Foundation public var browserUrl: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? + public var appURL: String? //TODO: Should be removed in future releases. This should be MF specific. //Missing params From 620bfaae2bc5d452d787e690c25853a07f55500b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 2 Jul 2020 16:29:17 -0400 Subject: [PATCH 3/4] action fix for tab bar --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h | 3 +++ MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 9644557..26afbe2 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -93,6 +93,9 @@ extern NSString * _Nonnull const KeyActionTypeOpen; #pragma mark - Default Action Protocol Functions +// Currently no default log action but this will eventually be server driven. ++ (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; + // Sends the request to the load handler. + (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 8eff939..7867991 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -110,7 +110,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if ([delegateObject.actionDelegate respondsToSelector:@selector(logActionWithActionInformation:additionalData:)]) { [delegateObject.actionDelegate logActionWithActionInformation:actionInformation additionalData:additionalData]; } else { - [MVMCoreActionHandler defaultLogAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + [[self class] defaultLogAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; } } From c125915fe0f08f668049e2656b596fa0b3824ac2 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Tue, 7 Jul 2020 20:18:25 +0530 Subject: [PATCH 4/4] Removing ActionOpenAppModel after Kamlesh approval, because it's not being used anywhere. And we are using appURL property of ActionOpenUrlModel for opening app. --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 ---- .../ActionType/ActionOpenAppModel.swift | 24 ------------------- MVMCore/MVMCore/Models/ModelMapping.swift | 1 - 3 files changed, 29 deletions(-) delete mode 100644 MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 16cb154..f1a3230 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -26,7 +26,6 @@ 01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */; }; 01F2A03623A80A7300D954D8 /* ActionModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */; }; 01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */; }; - 01F2A03B23A8159900D954D8 /* ActionOpenAppModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03A23A8159900D954D8 /* ActionOpenAppModel.swift */; }; 01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */; }; 01F2A04E23A82CF500D954D8 /* ActionPopupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */; }; 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; }; @@ -175,7 +174,6 @@ 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dictionary+MFConvenience.swift"; sourceTree = ""; }; 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelProtocol.swift; sourceTree = ""; }; 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrlModel.swift; sourceTree = ""; }; - 01F2A03A23A8159900D954D8 /* ActionOpenAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenAppModel.swift; sourceTree = ""; }; 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCallModel.swift; sourceTree = ""; }; 01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionPopupModel.swift; sourceTree = ""; }; 01F2A05123A8325100D954D8 /* ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMapping.swift; sourceTree = ""; }; @@ -460,7 +458,6 @@ 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */, 946EE1BB237B691A0036751F /* ActionOpenPageModel.swift */, 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */, - 01F2A03A23A8159900D954D8 /* ActionOpenAppModel.swift */, 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */, 01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */, 01C851D023CF97FE0021F976 /* ActionBackModel.swift */, @@ -950,7 +947,6 @@ AF43A70A1FC4F415008E9347 /* MVMCoreCache.m in Sources */, AF43A6FF1FBE3252008E9347 /* Reachability.m in Sources */, 01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */, - 01F2A03B23A8159900D954D8 /* ActionOpenAppModel.swift in Sources */, AFBB96921FBA3A9A0008D868 /* MVMCoreNavigationOperation.m in Sources */, AFBB96611FBA3A570008D868 /* MVMCoreLoadObject.m in Sources */, 946EE1B4237B619D0036751F /* Encoder.swift in Sources */, diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift deleted file mode 100644 index 6dd46a6..0000000 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// ActionOpenAppModel.swift -// MVMCore -// -// Created by Suresh, Kamlesh on 12/16/19. -// Copyright © 2019 myverizon. All rights reserved. -// - -import Foundation - -@objcMembers public class ActionOpenAppModel: ActionModelProtocol { - public static var identifier: String = "openApp" - public var actionType: String = ActionOpenAppModel.identifier - // TODO: decode into url once action handler is re-written - public var appURL: String - public var extraParameters: JSONValueDictionary? - public var analyticsData: JSONValueDictionary? - - 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/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index b0e9bc4..87cf215 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -13,7 +13,6 @@ import Foundation public static func registerObjects() { try? ModelRegistry.register(ActionOpenPageModel.self) try? ModelRegistry.register(ActionOpenUrlModel.self) - try? ModelRegistry.register(ActionOpenAppModel.self) try? ModelRegistry.register(ActionCallModel.self) try? ModelRegistry.register(ActionPopupModel.self) try? ModelRegistry.register(ActionBackModel.self)