Manos Chorianopoulos

update CampaignItemModel

No preview for this file type
......@@ -481,6 +481,9 @@ public class swiftApi {
public let ccms_offer: String?
public var loyaltyPackageId: String?
public var badge: String?
public var campaign_type: String?
// public var campaign_type_settings: [String: Any]?
public var couponset: String?
public init() {
self.index_url = ""
......@@ -497,6 +500,9 @@ public class swiftApi {
self.ccms_offer = "false"
self.loyaltyPackageId = ""
self.badge = ""
self.campaign_type = ""
// self.campaign_type_settings = [String: Any]()
self.couponset = ""
}
public init(dictionary: [String: Any]) {
......@@ -509,6 +515,7 @@ public class swiftApi {
self.is_new = dictionary["is_new"] as? Bool? ?? false
self.message = dictionary["message"] as? String? ?? ""
self.loyaltyPackageId = ""
self.campaign_type = dictionary["campaign_type"] as? String? ?? ""
// let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""]
let extra_fields = dictionary["extra_fields"] as AnyObject
......@@ -540,6 +547,38 @@ public class swiftApi {
self.badge = ""
print(error)
}
// campaign_type_settings
if let campaign_type_settings_obj = dictionary["campaign_type_settings"] as? AnyObject {
if ((!(campaign_type_settings_obj is NSNull)) && (campaign_type_settings_obj != nil)) {
var campaign_type_settings_parsed:[String: Any]
let campaign_type_settings_json = campaign_type_settings_obj.data(using: String.Encoding.utf8.rawValue)
do {
if let jsonArray = try JSONSerialization.jsonObject(with: campaign_type_settings_json!, options: .allowFragments) as? [String:AnyObject]
{
campaign_type_settings_parsed = jsonArray;
// self.campaign_type_settings = campaign_type_settings_parsed as? [String: Any]? ?? [String: Any]()
self.couponset = campaign_type_settings_parsed["couponset"] as? String? ?? ""
} else {
// self.campaign_type_settings = [String: Any]()
self.couponset = ""
print("bad json")
}
} catch let error as NSError {
// self.campaign_type_settings = [String: Any]()
self.couponset = ""
print(error)
}
} else {
self.couponset = ""
}
} else {
self.couponset = ""
}
}
public var _logo_url: String? {
......@@ -577,6 +616,33 @@ public class swiftApi {
self.badge = newValue
}
}
public var _campaign_type: String? {
get { // getter
return self.campaign_type
}
set(newValue) { //setter
self.campaign_type = newValue
}
}
// public var _campaign_type_settings: [String: Any]? {
// get { // getter
// return self.campaign_type_settings
// }
// set(newValue) { //setter
// self.campaign_type_settings = newValue
// }
// }
public var _couponset: String? {
get { // getter
return self.couponset
}
set(newValue) { //setter
self.couponset = newValue
}
}
}
public class CampaignDataModel {
......