diff --git a/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift index 62f325a..a858f6c 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift @@ -10,9 +10,31 @@ import Foundation @objcMembers public class ActionBackModel: ActionModelProtocol { public static var identifier: String = "back" - public var actionType: String? = ActionBackModel.identifier + public var actionType: String? public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? // Temporary fix till server changes public var title: String? + + public enum CodingKeys: String, CodingKey { + case actionType + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift index 92f2847..b00c486 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class ActionCallModel: ActionModelProtocol { public static var identifier: String = "call" - public var actionType: String? = ActionCallModel.identifier + public var actionType: String? public var callNumber: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -20,4 +20,29 @@ import Foundation public init(callNumber: String) { self.callNumber = callNumber } + + public enum CodingKeys: String, CodingKey { + case actionType + case callNumber + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + callNumber = try typeContainer.decode(String.self, forKey: .callNumber) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(callNumber, forKey: .callNumber) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift index 189dcb1..7d82385 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift @@ -18,4 +18,26 @@ import UIKit public var analyticsData: JSONValueDictionary? public var title: String? + + public enum CodingKeys: String, CodingKey { + case actionType + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift index 04e1794..a6b9724 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenAppModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class ActionOpenAppModel: ActionModelProtocol { public static var identifier: String = "openApp" - public var actionType: String? = ActionOpenAppModel.identifier + public var actionType: String? public var appURL: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -20,4 +20,29 @@ import Foundation public init(appURL: String) { self.appURL = appURL } + + public enum CodingKeys: String, CodingKey { + case actionType + case appURL + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + appURL = try typeContainer.decode(String.self, forKey: .appURL) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(appURL, forKey: .appURL) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift index 30ba794..862cc2c 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class ActionOpenPageModel: ActionModelProtocol { public static var identifier: String = "openPage" - public var actionType: String? = ActionOpenPageModel.identifier + public var actionType: String? public var pageType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -22,4 +22,32 @@ import Foundation public init(pageType: String) { self.pageType = pageType } + + public enum CodingKeys: String, CodingKey { + case actionType + case pageType + case title + case extraParameters + case analyticsData + case presentationStyle + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + pageType = try typeContainer.decode(String.self, forKey: .pageType) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + presentationStyle = try typeContainer.decodeIfPresent(String.self, forKey: .presentationStyle) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(pageType, forKey: .pageType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + try encoderContainer.encodeIfPresent(presentationStyle, forKey: .presentationStyle) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPanelModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPanelModel.swift index 02d31fc..765ddbe 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPanelModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPanelModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class ActionOpenPanelModel: ActionModelProtocol { public static var identifier: String = "openPanel" - public var actionType: String? = ActionOpenPanelModel.identifier + public var actionType: String? public var panel: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -20,4 +20,29 @@ import Foundation public init(panel: String) { self.panel = panel } + + public enum CodingKeys: String, CodingKey { + case actionType + case panel + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + panel = try typeContainer.decode(String.self, forKey: .panel) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(panel, forKey: .panel) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift index d0b4f30..20a2e73 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift @@ -10,7 +10,7 @@ import Foundation @objcMembers public class ActionOpenUrlModel: ActionModelProtocol { public static var identifier: String = "openURL" - public var actionType: String? = ActionOpenUrlModel.identifier + public var actionType: String? public var browserUrl: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -31,4 +31,54 @@ import Foundation public init(browserUrl: String) { self.browserUrl = browserUrl } + + public enum CodingKeys: String, CodingKey { + case actionType + case browserUrl + case title + case extraParameters + case analyticsData + + case openOauthWebView + case showNativeNavigation + case openInWebview + case customUserAgent + case postRequest + case dontShowProgress + case headerParameters + + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + browserUrl = try typeContainer.decode(String.self, forKey: .browserUrl) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + + openOauthWebView = try typeContainer.decodeIfPresent(Bool.self, forKey: .openOauthWebView) + showNativeNavigation = try typeContainer.decodeIfPresent(Bool.self, forKey: .showNativeNavigation) + openInWebview = try typeContainer.decodeIfPresent(Bool.self, forKey: .openInWebview) + customUserAgent = try typeContainer.decodeIfPresent(String.self, forKey: .customUserAgent) + postRequest = try typeContainer.decodeIfPresent(Bool.self, forKey: .postRequest) + dontShowProgress = try typeContainer.decodeIfPresent(Bool.self, forKey: .dontShowProgress) + headerParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .headerParameters) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(browserUrl, forKey: .browserUrl) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + + try encoderContainer.encodeIfPresent(openOauthWebView, forKey: .openOauthWebView) + try encoderContainer.encodeIfPresent(showNativeNavigation, forKey: .showNativeNavigation) + try encoderContainer.encodeIfPresent(openInWebview, forKey: .openInWebview) + try encoderContainer.encodeIfPresent(customUserAgent, forKey: .customUserAgent) + try encoderContainer.encodeIfPresent(postRequest, forKey: .postRequest) + try encoderContainer.encodeIfPresent(dontShowProgress, forKey: .dontShowProgress) + try encoderContainer.encodeIfPresent(headerParameters, forKey: .headerParameters) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift index 2aee75f..861dcde 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift @@ -11,7 +11,7 @@ import Foundation @objcMembers public class ActionPopupModel: ActionModelProtocol { public static var identifier: String = "popup" - public var actionType: String? = ActionPopupModel.identifier + public var actionType: String? public var title: String? public var pageType: String public var extraParameters: JSONValueDictionary? @@ -19,4 +19,29 @@ import Foundation public init(pageType: String) { self.pageType = pageType } + + public enum CodingKeys: String, CodingKey { + case actionType + case pageType + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + pageType = try typeContainer.decode(String.self, forKey: .pageType) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(pageType, forKey: .pageType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift index 54e423d..9f61beb 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift @@ -18,4 +18,26 @@ import UIKit public var analyticsData: JSONValueDictionary? public var title: String? + + public enum CodingKeys: String, CodingKey { + case actionType + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift index bba379f..429e4af 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift @@ -21,4 +21,29 @@ import UIKit ///Optional pageType, if pageType is nil, will start with pageType launchApp public var pageType: String? + + public enum CodingKeys: String, CodingKey { + case actionType + case pageType + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + pageType = try typeContainer.decodeIfPresent(String.self, forKey: .pageType) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encodeIfPresent(pageType, forKey: .pageType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift index 9adb382..e5e8a43 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift @@ -21,4 +21,29 @@ import UIKit ///String type for pageType, currently only support "location" and "push" public var pageType: String + + public enum CodingKeys: String, CodingKey { + case actionType + case pageType + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + pageType = try typeContainer.decode(String.self, forKey: .pageType) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(pageType, forKey: .pageType) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionShareModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionShareModel.swift index c40fbcd..c81b7e1 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionShareModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionShareModel.swift @@ -30,4 +30,32 @@ import UIKit self.sharedType = sharedType self.sharedText = sharedText } + + public enum CodingKeys: String, CodingKey { + case actionType + case sharedType + case sharedText + case title + case extraParameters + case analyticsData + } + + public required init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + sharedType = try typeContainer.decode(String.self, forKey: .sharedType) + sharedText = try typeContainer.decode(String.self, forKey: .sharedText) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var encoderContainer = encoder.container(keyedBy: CodingKeys.self) + try encoderContainer.encodeIfPresent(actionType, forKey: .actionType) + try encoderContainer.encode(sharedType, forKey: .sharedType) + try encoderContainer.encode(sharedText, forKey: .sharedText) + try encoderContainer.encodeIfPresent(title, forKey: .title) + try encoderContainer.encodeIfPresent(extraParameters, forKey: .extraParameters) + try encoderContainer.encodeIfPresent(analyticsData, forKey: .analyticsData) + } }