Manos Chorianopoulos

fix getProfile crash

...@@ -1826,7 +1826,8 @@ public class swiftApi { ...@@ -1826,7 +1826,8 @@ public class swiftApi {
1826 self.optin_sms_segmentation = optin?["sms_segmentation"] as? Bool? ?? false 1826 self.optin_sms_segmentation = optin?["sms_segmentation"] as? Bool? ?? false
1827 1827
1828 // profile_metadata 1828 // profile_metadata
1829 - let profile_metadata_json = dictionary["profile_metadata"] as AnyObject 1829 + if let profile_metadata_json = dictionary["profile_metadata"] as? AnyObject {
1830 + if ((!(profile_metadata_json is NSNull)) && (profile_metadata_json != nil)) {
1830 var profile_metadata_parsed:[String: Any] 1831 var profile_metadata_parsed:[String: Any]
1831 1832
1832 let json = profile_metadata_json.data(using: String.Encoding.utf8.rawValue) 1833 let json = profile_metadata_json.data(using: String.Encoding.utf8.rawValue)
...@@ -1856,6 +1857,22 @@ public class swiftApi { ...@@ -1856,6 +1857,22 @@ public class swiftApi {
1856 print(error) 1857 print(error)
1857 } 1858 }
1858 1859
1860 + } else {
1861 + self.profile_metadata = [String: Any]()
1862 + self.badge = ""
1863 + self.msisdnList = []
1864 + self.answered = false
1865 + self.nonTelco = false
1866 + }
1867 +
1868 + } else {
1869 + self.profile_metadata = [String: Any]()
1870 + self.badge = ""
1871 + self.msisdnList = []
1872 + self.answered = false
1873 + self.nonTelco = false
1874 + }
1875 +
1859 } 1876 }
1860 1877
1861 public var _ack_optin: Bool { 1878 public var _ack_optin: Bool {
...@@ -4730,7 +4747,9 @@ public class swiftApi { ...@@ -4730,7 +4747,9 @@ public class swiftApi {
4730 self.date = "" 4747 self.date = ""
4731 } 4748 }
4732 4749
4733 - let transaction_metadata_json = dictionary["transaction_metadata"] as AnyObject 4750 + if let transaction_metadata_json = dictionary["transaction_metadata"] as? AnyObject {
4751 + if ((!(transaction_metadata_json is NSNull)) && (transaction_metadata_json != nil)) {
4752 +
4734 var transaction_metadata_parsed:[String: Any] 4753 var transaction_metadata_parsed:[String: Any]
4735 4754
4736 let json = transaction_metadata_json.data(using: String.Encoding.utf8.rawValue) 4755 let json = transaction_metadata_json.data(using: String.Encoding.utf8.rawValue)
...@@ -4750,6 +4769,14 @@ public class swiftApi { ...@@ -4750,6 +4769,14 @@ public class swiftApi {
4750 self.sender_msisdn = "" 4769 self.sender_msisdn = ""
4751 print(error) 4770 print(error)
4752 } 4771 }
4772 + } else {
4773 + self.receiver_msisdn = ""
4774 + self.sender_msisdn = ""
4775 + }
4776 + } else {
4777 + self.receiver_msisdn = ""
4778 + self.sender_msisdn = ""
4779 + }
4753 } 4780 }
4754 4781
4755 public var _couponset_uuid: String { 4782 public var _couponset_uuid: String {
......