Manos Chorianopoulos

update ProfileModel

...@@ -1006,6 +1006,9 @@ public class swiftApi { ...@@ -1006,6 +1006,9 @@ public class swiftApi {
1006 public let optin_segmentation: Bool? 1006 public let optin_segmentation: Bool?
1007 public let optin_sms_segmentation: Bool? 1007 public let optin_sms_segmentation: Bool?
1008 1008
1009 + // profile_metadata
1010 + public let badge: String?
1011 +
1009 1012
1010 public init() { 1013 public init() {
1011 self.ack_optin = false 1014 self.ack_optin = false
...@@ -1043,6 +1046,8 @@ public class swiftApi { ...@@ -1043,6 +1046,8 @@ public class swiftApi {
1043 self.optin_segmentation = false 1046 self.optin_segmentation = false
1044 self.optin_sms_segmentation = false 1047 self.optin_sms_segmentation = false
1045 1048
1049 + // profile_metadata
1050 + self.badge = ""
1046 } 1051 }
1047 1052
1048 public init(dictionary: [String: Any]) { 1053 public init(dictionary: [String: Any]) {
...@@ -1064,7 +1069,6 @@ public class swiftApi { ...@@ -1064,7 +1069,6 @@ public class swiftApi {
1064 self.nameday = dictionary["nameday"] as? String? ?? "" 1069 self.nameday = dictionary["nameday"] as? String? ?? ""
1065 self.nickname = dictionary["nickname"] as? String? ?? "" 1070 self.nickname = dictionary["nickname"] as? String? ?? ""
1066 self.password_set = dictionary["password_set"] as? Bool? ?? false 1071 self.password_set = dictionary["password_set"] as? Bool? ?? false
1067 - self.profile_metadata = dictionary["profile_metadata"] as? [String: Any]? ?? ["":""]
1068 self.redeemed_points = dictionary["redeemed_points"] as? Double? ?? 0.0 1072 self.redeemed_points = dictionary["redeemed_points"] as? Double? ?? 0.0
1069 self.retrieved_points = dictionary["retrieved_points"] as? Double? ?? 0.0 1073 self.retrieved_points = dictionary["retrieved_points"] as? Double? ?? 0.0
1070 self.salutation = dictionary["salutation"] as? String? ?? "" 1074 self.salutation = dictionary["salutation"] as? String? ?? ""
...@@ -1082,6 +1086,28 @@ public class swiftApi { ...@@ -1082,6 +1086,28 @@ public class swiftApi {
1082 self.optin_segmentation = optin?["segmentation"] as? Bool? ?? false 1086 self.optin_segmentation = optin?["segmentation"] as? Bool? ?? false
1083 self.optin_sms_segmentation = optin?["sms_segmentation"] as? Bool? ?? false 1087 self.optin_sms_segmentation = optin?["sms_segmentation"] as? Bool? ?? false
1084 1088
1089 + // profile_metadata
1090 + let profile_metadata_json = dictionary["profile_metadata"] as AnyObject
1091 + var profile_metadata_parsed:[String: Any]
1092 +
1093 + let json = profile_metadata_json.data(using: String.Encoding.utf8.rawValue)
1094 + do {
1095 + if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject]
1096 + {
1097 + profile_metadata_parsed = jsonArray;
1098 + self.profile_metadata = profile_metadata_parsed as? [String: Any]? ?? [String: Any]()
1099 + self.badge = profile_metadata_parsed["badge"] as? String? ?? ""
1100 + } else {
1101 + self.profile_metadata = [String: Any]()
1102 + self.badge = ""
1103 + print("bad json")
1104 + }
1105 + } catch let error as NSError {
1106 + self.profile_metadata = [String: Any]()
1107 + self.badge = ""
1108 + print(error)
1109 + }
1110 +
1085 } 1111 }
1086 } 1112 }
1087 1113
......