Manos Chorianopoulos

update ProfileModel

......@@ -1006,6 +1006,9 @@ public class swiftApi {
public let optin_segmentation: Bool?
public let optin_sms_segmentation: Bool?
// profile_metadata
public let badge: String?
public init() {
self.ack_optin = false
......@@ -1043,6 +1046,8 @@ public class swiftApi {
self.optin_segmentation = false
self.optin_sms_segmentation = false
// profile_metadata
self.badge = ""
}
public init(dictionary: [String: Any]) {
......@@ -1064,7 +1069,6 @@ public class swiftApi {
self.nameday = dictionary["nameday"] as? String? ?? ""
self.nickname = dictionary["nickname"] as? String? ?? ""
self.password_set = dictionary["password_set"] as? Bool? ?? false
self.profile_metadata = dictionary["profile_metadata"] as? [String: Any]? ?? ["":""]
self.redeemed_points = dictionary["redeemed_points"] as? Double? ?? 0.0
self.retrieved_points = dictionary["retrieved_points"] as? Double? ?? 0.0
self.salutation = dictionary["salutation"] as? String? ?? ""
......@@ -1082,6 +1086,28 @@ public class swiftApi {
self.optin_segmentation = optin?["segmentation"] as? Bool? ?? false
self.optin_sms_segmentation = optin?["sms_segmentation"] as? Bool? ?? false
// profile_metadata
let profile_metadata_json = dictionary["profile_metadata"] as AnyObject
var profile_metadata_parsed:[String: Any]
let json = profile_metadata_json.data(using: String.Encoding.utf8.rawValue)
do {
if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject]
{
profile_metadata_parsed = jsonArray;
self.profile_metadata = profile_metadata_parsed as? [String: Any]? ?? [String: Any]()
self.badge = profile_metadata_parsed["badge"] as? String? ?? ""
} else {
self.profile_metadata = [String: Any]()
self.badge = ""
print("bad json")
}
} catch let error as NSError {
self.profile_metadata = [String: Any]()
self.badge = ""
print(error)
}
}
}
......