Manos Chorianopoulos

fix getProfile crash

......@@ -1826,34 +1826,51 @@ public class swiftApi {
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? ?? ""
self.msisdnList = profile_metadata_parsed["msisdnList"] as? Array<String>? ?? []
self.answered = profile_metadata_parsed["answered"] as? Bool? ?? false
self.nonTelco = profile_metadata_parsed["nonTelco"] as? Bool? ?? false
if let profile_metadata_json = dictionary["profile_metadata"] as? AnyObject {
if ((!(profile_metadata_json is NSNull)) && (profile_metadata_json != nil)) {
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? ?? ""
self.msisdnList = profile_metadata_parsed["msisdnList"] as? Array<String>? ?? []
self.answered = profile_metadata_parsed["answered"] as? Bool? ?? false
self.nonTelco = profile_metadata_parsed["nonTelco"] as? Bool? ?? false
} else {
self.profile_metadata = [String: Any]()
self.badge = ""
self.msisdnList = []
self.answered = false
self.nonTelco = false
print("bad json")
}
} catch let error as NSError {
self.profile_metadata = [String: Any]()
self.badge = ""
self.msisdnList = []
self.answered = false
self.nonTelco = false
print(error)
}
} else {
self.profile_metadata = [String: Any]()
self.badge = ""
self.msisdnList = []
self.answered = false
self.nonTelco = false
print("bad json")
}
} catch let error as NSError {
} else {
self.profile_metadata = [String: Any]()
self.badge = ""
self.msisdnList = []
self.answered = false
self.nonTelco = false
print(error)
}
}
......@@ -4730,25 +4747,35 @@ public class swiftApi {
self.date = ""
}
let transaction_metadata_json = dictionary["transaction_metadata"] as AnyObject
var transaction_metadata_parsed:[String: Any]
let json = transaction_metadata_json.data(using: String.Encoding.utf8.rawValue)
do {
if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject]
{
transaction_metadata_parsed = jsonArray;
self.receiver_msisdn = transaction_metadata_parsed["receiver_msisdn"] as? String? ?? ""
self.sender_msisdn = transaction_metadata_parsed["sender_msisdn"] as? String? ?? ""
if let transaction_metadata_json = dictionary["transaction_metadata"] as? AnyObject {
if ((!(transaction_metadata_json is NSNull)) && (transaction_metadata_json != nil)) {
var transaction_metadata_parsed:[String: Any]
let json = transaction_metadata_json.data(using: String.Encoding.utf8.rawValue)
do {
if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject]
{
transaction_metadata_parsed = jsonArray;
self.receiver_msisdn = transaction_metadata_parsed["receiver_msisdn"] as? String? ?? ""
self.sender_msisdn = transaction_metadata_parsed["sender_msisdn"] as? String? ?? ""
} else {
self.receiver_msisdn = ""
self.sender_msisdn = ""
print("bad json")
}
} catch let error as NSError {
self.receiver_msisdn = ""
self.sender_msisdn = ""
print(error)
}
} else {
self.receiver_msisdn = ""
self.sender_msisdn = ""
print("bad json")
}
} catch let error as NSError {
} else {
self.receiver_msisdn = ""
self.sender_msisdn = ""
print(error)
}
}
......