add codable method to avoid set actionType value
This commit is contained in:
parent
68b805a417
commit
92584d935f
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user