Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. struct Contact {
  2.  
  3. let user : User
  4. let address : Address
  5. let deliveryInstruction : String
  6. let deliveryMethod : String
  7.  
  8. init(dictionary: [String: Any]) {
  9.  
  10. self.deliveryInstruction = dictionary["delivery_instruction"] as? String ?? ""
  11.  
  12. self.deliveryMethod = dictionary["delivery_method"] as? String ?? ""
  13.  
  14. self.address = Address(dictionary: dictionary["address"] as? [String:Any] ?? [:])
  15.  
  16. self.user = User(dictionary: dictionary["address"] as? [String:Any] ?? [:])
  17. }
  18. }
  19.  
  20. struct User {
  21.  
  22. let name : String
  23. let email : String
  24. let phoneNo : String
  25.  
  26. init(dictionary : [String:Any] ) {
  27.  
  28. self.name = dictionary["name"] as? String ?? ""
  29. self.email = dictionary["email"] as? String ?? ""
  30. self.phoneNo = dictionary["phoneNo"] as? String ?? ""
  31. }
  32. }
  33.  
  34. struct Address {
  35.  
  36. let city : City
  37. let town : Town
  38.  
  39. let addressId : String
  40. let fullAddress : String
  41.  
  42. let house : String
  43. let street: String
  44.  
  45. init(dictionary : [String:Any] ) {
  46.  
  47. self.addressId = dictionary["address_id"] as? String ?? ""
  48. self.fullAddress = dictionary["full_address"] as? String ?? ""
  49.  
  50. self.house = dictionary["house"] as? String ?? ""
  51. self.street = dictionary["street"] as? String ?? ""
  52.  
  53.  
  54.  
  55. self.city = City(dictionary: dictionary["address"] as? [String:Any] ?? [:])
  56.  
  57. self.town = Town(dictionary: dictionary["address"] as? [String:Any] ?? [:])
  58.  
  59. }
  60.  
  61. }
  62.  
  63. struct City {
  64.  
  65. let cityId : String
  66. let cityName : String
  67.  
  68. init(dictionary : [String:Any] ) {
  69. self.cityId = dictionary["city_id"] as? String ?? ""
  70. self.cityName = dictionary["city_name"] as? String ?? ""
  71. }
  72. }
  73.  
  74. struct Town {
  75.  
  76. let townId : String
  77. let townName : String
  78.  
  79. init(dictionary : [String:Any]) {
  80.  
  81. self.townId = dictionary["town_id"] as? String ?? ""
  82. self.townName = dictionary["town_name"] as? String ?? ""
  83.  
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement