This commit is contained in:
Suresh, Kamlesh 2019-12-18 12:09:22 -05:00
parent 12e06894de
commit 5f395f8cc3
13 changed files with 237 additions and 39 deletions

View File

@ -22,6 +22,14 @@
/* Begin PBXBuildFile section */
01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */; };
01F2A03623A80A7300D954D8 /* ActionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03523A80A7300D954D8 /* ActionProtocol.swift */; };
01F2A03923A812DD00D954D8 /* ActionOpenUrl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03823A812DD00D954D8 /* ActionOpenUrl.swift */; };
01F2A03B23A8159900D954D8 /* ActionOpenApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03A23A8159900D954D8 /* ActionOpenApp.swift */; };
01F2A04C23A82B1B00D954D8 /* ActionCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04B23A82B1B00D954D8 /* ActionCall.swift */; };
01F2A04E23A82CF500D954D8 /* ActionPopup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04D23A82CF500D954D8 /* ActionPopup.swift */; };
01F2A05023A82D0800D954D8 /* ActionTopAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04F23A82D0800D954D8 /* ActionTopAlert.swift */; };
01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; };
01F2A05423A83E9200D954D8 /* KeyedDecodingContainer+CodingKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05323A83E9200D954D8 /* KeyedDecodingContainer+CodingKey.swift */; };
30349BF11FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
30349BF21FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */; };
881D26931FCC9D180079C521 /* MVMCoreErrorObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 881D268F1FCC9D180079C521 /* MVMCoreErrorObject.m */; };
@ -45,7 +53,7 @@
946EE1B0237B5EF70036751F /* JSONHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1AF237B5EF70036751F /* JSONHelper.swift */; };
946EE1B2237B5F260036751F /* JSONValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B1237B5F260036751F /* JSONValue.swift */; };
946EE1B4237B619D0036751F /* Encoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B3237B619D0036751F /* Encoder.swift */; };
946EE1BC237B691A0036751F /* ActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1BB237B691A0036751F /* ActionModel.swift */; };
946EE1BC237B691A0036751F /* ActionOpenPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1BB237B691A0036751F /* ActionOpenPage.swift */; };
A332F33F20C7231700DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h in Headers */ = {isa = PBXBuildFile; fileRef = A332F33E20C7231600DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF1201832108C9B400E2F592 /* MVMCoreViewManagerViewControllerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AF1201812108C9B400E2F592 /* MVMCoreViewManagerViewControllerProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AF26DDAE1FCE6A37004E8F65 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = AF26DDB01FCE6A37004E8F65 /* Localizable.strings */; };
@ -154,6 +162,14 @@
/* Begin PBXFileReference section */
01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dictionary+MFConvenience.swift"; sourceTree = "<group>"; };
01F2A03523A80A7300D954D8 /* ActionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionProtocol.swift; sourceTree = "<group>"; };
01F2A03823A812DD00D954D8 /* ActionOpenUrl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrl.swift; sourceTree = "<group>"; };
01F2A03A23A8159900D954D8 /* ActionOpenApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenApp.swift; sourceTree = "<group>"; };
01F2A04B23A82B1B00D954D8 /* ActionCall.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCall.swift; sourceTree = "<group>"; };
01F2A04D23A82CF500D954D8 /* ActionPopup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionPopup.swift; sourceTree = "<group>"; };
01F2A04F23A82D0800D954D8 /* ActionTopAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopAlert.swift; sourceTree = "<group>"; };
01F2A05123A8325100D954D8 /* ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMapping.swift; sourceTree = "<group>"; };
01F2A05323A83E9200D954D8 /* KeyedDecodingContainer+CodingKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KeyedDecodingContainer+CodingKey.swift"; sourceTree = "<group>"; };
0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionTimeHandler.h; sourceTree = "<group>"; };
@ -181,7 +197,7 @@
946EE1AF237B5EF70036751F /* JSONHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONHelper.swift; sourceTree = "<group>"; };
946EE1B1237B5F260036751F /* JSONValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONValue.swift; sourceTree = "<group>"; };
946EE1B3237B619D0036751F /* Encoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Encoder.swift; sourceTree = "<group>"; };
946EE1BB237B691A0036751F /* ActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModel.swift; sourceTree = "<group>"; };
946EE1BB237B691A0036751F /* ActionOpenPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenPage.swift; sourceTree = "<group>"; };
A332F33E20C7231600DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerAnimatedTransitioning.h; sourceTree = "<group>"; };
AF1201812108C9B400E2F592 /* MVMCoreViewManagerViewControllerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewManagerViewControllerProtocol.h; sourceTree = "<group>"; };
AF26DDAF1FCE6A37004E8F65 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -381,6 +397,7 @@
946EE19B237B4DB80036751F /* Models */ = {
isa = PBXGroup;
children = (
01F2A05123A8325100D954D8 /* ModelMapping.swift */,
946EE1B6237B66630036751F /* ActionType */,
946EE1A9237B5C720036751F /* Extensions */,
946EE1A8237B5C650036751F /* Model */,
@ -403,6 +420,7 @@
children = (
946EE1AA237B5C940036751F /* Decoder.swift */,
946EE1B3237B619D0036751F /* Encoder.swift */,
01F2A05323A83E9200D954D8 /* KeyedDecodingContainer+CodingKey.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -419,7 +437,13 @@
946EE1B6237B66630036751F /* ActionType */ = {
isa = PBXGroup;
children = (
946EE1BB237B691A0036751F /* ActionModel.swift */,
01F2A03523A80A7300D954D8 /* ActionProtocol.swift */,
946EE1BB237B691A0036751F /* ActionOpenPage.swift */,
01F2A03823A812DD00D954D8 /* ActionOpenUrl.swift */,
01F2A03A23A8159900D954D8 /* ActionOpenApp.swift */,
01F2A04B23A82B1B00D954D8 /* ActionCall.swift */,
01F2A04D23A82CF500D954D8 /* ActionPopup.swift */,
01F2A04F23A82D0800D954D8 /* ActionTopAlert.swift */,
);
path = ActionType;
sourceTree = "<group>";
@ -833,9 +857,11 @@
AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */,
AFBB968E1FBA3A9A0008D868 /* MVMCoreNavigationHandler.m in Sources */,
D2E1FAD92260C3E400AEFD8C /* DelegateObject.swift in Sources */,
01F2A03623A80A7300D954D8 /* ActionProtocol.swift in Sources */,
AFBB96991FBA3A9A0008D868 /* MVMCoreAlertController.m in Sources */,
881D26941FCC9D180079C521 /* MVMCoreOperation.m in Sources */,
AFED77A41FCCA29400BAE689 /* MVMCoreViewControllerMappingObject.m in Sources */,
01F2A04C23A82B1B00D954D8 /* ActionCall.swift in Sources */,
8876D5ED1FB50AB000EB2E3D /* NSDictionary+MFConvenience.m in Sources */,
AFBB968C1FBA3A9A0008D868 /* MVMCoreDismissViewControllerOperation.m in Sources */,
AFBB96BA1FBA3CEC0008D868 /* MVMCoreActionHandler.m in Sources */,
@ -845,7 +871,7 @@
AFBB965F1FBA3A570008D868 /* MFFreebeeOperation.m in Sources */,
AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */,
946EE1AB237B5C940036751F /* Decoder.swift in Sources */,
946EE1BC237B691A0036751F /* ActionModel.swift in Sources */,
946EE1BC237B691A0036751F /* ActionOpenPage.swift in Sources */,
AFBB96A61FBA3A9A0008D868 /* MVMCoreTopAlertOperation.m in Sources */,
881D26931FCC9D180079C521 /* MVMCoreErrorObject.m in Sources */,
946EE1B0237B5EF70036751F /* JSONHelper.swift in Sources */,
@ -854,11 +880,13 @@
946EE1B2237B5F260036751F /* JSONValue.swift in Sources */,
AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */,
AFBB96581FBA3A570008D868 /* FreeBeeAuthObject.m in Sources */,
01F2A04E23A82CF500D954D8 /* ActionPopup.swift in Sources */,
AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */,
AFBB96691FBA3A570008D868 /* MVMCoreRequestParameters.m in Sources */,
AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m in Sources */,
8876D5EB1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.m in Sources */,
AFBB96A41FBA3A9A0008D868 /* MVMCoreTopAlertObject.m in Sources */,
01F2A03923A812DD00D954D8 /* ActionOpenUrl.swift in Sources */,
AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */,
AFBB969C1FBA3A9A0008D868 /* MVMCoreAlertHandler.m in Sources */,
AF43A5881FBB67D6008E9347 /* MVMCoreActionUtility.m in Sources */,
@ -866,17 +894,21 @@
AF43A57C1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.m in Sources */,
AFBB965D1FBA3A570008D868 /* MFFreebeeHandler.m in Sources */,
AFEEE81F1FCDF3CA00B5EDD0 /* MVMCoreLoggingHandler.m in Sources */,
01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */,
AFBB969E1FBA3A9A0008D868 /* MVMCoreAlertObject.m in Sources */,
8876D5F51FB50AB000EB2E3D /* UILabel+MFCustom.m in Sources */,
01F2A05423A83E9200D954D8 /* KeyedDecodingContainer+CodingKey.swift in Sources */,
AFBB96B31FBA3B590008D868 /* MVMCoreGetterUtility.m in Sources */,
AF43A7071FC4D7A2008E9347 /* MVMCoreObject.m in Sources */,
01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */,
AFBB96B11FBA3B590008D868 /* MVMCoreDispatchUtility.m in Sources */,
946EE1A3237B59C30036751F /* Model.swift in Sources */,
01F2A05023A82D0800D954D8 /* ActionTopAlert.swift in Sources */,
AFBB965B1FBA3A570008D868 /* FreeBeeUrlObject.m in Sources */,
AFEA17A9209B6A1C00BC6740 /* MVMCoreBlockOperation.m in Sources */,
AF43A70A1FC4F415008E9347 /* MVMCoreCache.m in Sources */,
AF43A6FF1FBE3252008E9347 /* Reachability.m in Sources */,
01F2A03B23A8159900D954D8 /* ActionOpenApp.swift in Sources */,
AFBB96921FBA3A9A0008D868 /* MVMCoreNavigationOperation.m in Sources */,
AFBB96611FBA3A570008D868 /* MVMCoreLoadObject.m in Sources */,
946EE1B4237B619D0036751F /* Encoder.swift in Sources */,

View File

@ -0,0 +1,17 @@
//
// ActionCall.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
@objcMembers public class ActionCall: ActionProtocol {
public static var identifier: String = "call"
public var callNumber: String
public init(callNumber: String) {
self.callNumber = callNumber
}
}

View File

@ -1,17 +0,0 @@
//
// ActionModel.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 10/3/19.
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
//
import Foundation
@objcMembers public class ActionModel: Codable {
public var actionType: String?
public init(actionType: String?) {
self.actionType = actionType
}
}

View File

@ -0,0 +1,17 @@
//
// ActionOpenApp.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
@objcMembers public class ActionOpenApp: ActionProtocol {
public static var identifier: String = "openApp"
public var appUrl: String
public init(appUrl: String) {
self.appUrl = appUrl
}
}

View File

@ -0,0 +1,17 @@
//
// ActionModel.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 10/3/19.
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
//
import Foundation
@objcMembers public class ActionOpenPage: ActionProtocol {
public static var identifier: String = "openPage"
public var pageType: String
public init(pageType: String) {
self.pageType = pageType
}
}

View File

@ -0,0 +1,17 @@
//
// ActionOpenUrl.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
@objcMembers public class ActionOpenUrl: ActionProtocol {
public static var identifier: String = "openUrl"
public var browserUrl: String
public init(browserUrl: String) {
self.browserUrl = browserUrl
}
}

View File

@ -0,0 +1,17 @@
//
// ActionPopup.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
@objcMembers public class ActionPopup: ActionProtocol {
public static var identifier: String = "popup"
public var pageType: String
public init(pageType: String) {
self.pageType = pageType
}
}

View File

@ -0,0 +1,23 @@
//
// ActionProtocol.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
public enum ActionCodingKey: String, CodingKey {
case type
}
public protocol ActionProtocol: Model {
var type: String? { get }
}
extension ActionProtocol {
public var type: String? {
get { return Self.identifier }
}
}

View File

@ -0,0 +1,17 @@
//
// ActionTopAlert.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
@objcMembers public class ActionTopAlert: ActionProtocol {
public static var identifier: String = "topAlert"
public var pageType: String
public init(pageType: String) {
self.pageType = pageType
}
}

View File

@ -0,0 +1,34 @@
//
// KeyedDecodingContainer+Action.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
extension KeyedDecodingContainer where Key : CodingKey {
// private enum TypeCodingKey: String, CodingKey {
// case type
// }
// public func decode(codingKey: KeyedDecodingContainer<K>.Key) throws -> ActionProtocol {
// return try decode(codingKey: codingKey, typeCodingKey: TypeCodingKey.type)
// }
//
// public func decodeActionIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> ActionProtocol? {
// return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.type)
// }
//
// public func decodeActionArray(codingKey: KeyedDecodingContainer<K>.Key) throws -> [ActionProtocol] {
// guard let models = try decodeArray(codingKey: codingKey, typeCodingKey: TypeCodingKey.type) as? [ActionProtocol] else {
// throw ModelRegistry.Error.decoderError
// }
// return models
// }
//
// public func decodeActionArrayIfPresent(codingKey: KeyedDecodingContainer<K>.Key) throws -> [ActionProtocol]? {
// return try decodeArrayIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.type) as? [ActionProtocol]
// }
}

View File

@ -45,27 +45,29 @@ extension KeyedDecodingContainer where Key: CodingKey {
//MARK: - DecodeIfPresent
public func decodeIfPresent<T, C:CodingKey>(codingKey: KeyedDecodingContainer<K>.Key, typeCodingKey: C) throws -> T? {
do {
let meta = try self.nestedContainer(keyedBy: C.self, forKey: codingKey)
guard let type = try meta.decodeIfPresent(String.self, forKey: typeCodingKey) else {
return nil
}
//get the type string
let meta = try self.nestedContainer(keyedBy: C.self, forKey: codingKey)
guard let type = try meta.decodeIfPresent(String.self, forKey: typeCodingKey) else {
//get the type
guard let found = ModelRegistry.types[type] else {
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Model not mapped: \(type)")
throw ModelRegistry.Error.decoderErrorModelNotMapped
}
//decode the type using the decoder
let model = try found.mvmdecode(keyedContainer: self, codingKey: codingKey)
guard let m = model as? T else {
throw ModelRegistry.Error.decoderError
}
return m
} catch {
return nil
}
//get the type
guard let found = ModelRegistry.types[type] else {
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Model not mapped: \(type)")
throw ModelRegistry.Error.decoderErrorModelNotMapped
}
//decode the type using the decoder
let model = try found.mvmdecode(keyedContainer: self, codingKey: codingKey)
guard let m = model as? T else {
throw ModelRegistry.Error.decoderError
}
return m
}

View File

@ -0,0 +1,20 @@
//
// ModelMapping.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
@objcMembers public class ModelMapping: NSObject {
public static func registerObjects() {
ModelRegistry.register(ActionOpenPage.self)
ModelRegistry.register(ActionOpenUrl.self)
ModelRegistry.register(ActionOpenApp.self)
ModelRegistry.register(ActionCall.self)
ModelRegistry.register(ActionPopup.self)
ModelRegistry.register(ActionTopAlert.self)
}
}

View File

@ -9,6 +9,7 @@
#import "MVMCoreSessionObject.h"
#import "MVMCoreObject.h"
#import "MVMCoreActionUtility.h"
#import <MVMCore/MVMCore-Swift.h>
@implementation MVMCoreSessionObject
@ -20,6 +21,7 @@
}
+ (nullable instancetype)sharedGlobal {
[ModelMapping registerObjects];
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].session classToVerify:self];
}