Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. //
  2. // userInRaiting.swift
  3. // RussianWodify
  4. //
  5. // Created by Elibay Nuptebek on 21.10.17.
  6. // Copyright © 2017 Codebusters. All rights reserved.
  7. //
  8.  
  9. import Foundation
  10. import Alamofire
  11. import ObjectMapper
  12.  
  13. struct Raiting {
  14.  
  15. static func getRaiting (completion: @escaping ([UsersInRaiting]?, [UsersInRaiting]?, String?) -> Void) {
  16. let url = UIViewController.mainUrl + "/main/get_global_results/"
  17. let header: HTTPHeaders = ["Auth-Token": Storage.user!.token]
  18. print (Storage.user!.token)
  19. Alamofire.request(url, method: .get, headers: header).responseJSON { response in
  20. switch response.result {
  21. case .success(let value):
  22. let json = value as! [String: Any]
  23. let code = json["code"] as! Int
  24. switch code {
  25. case 0:
  26. let result = json["results"] as! [[String:Any]]
  27. let a = result[0] as [String:Any]
  28. print (a)
  29. let b = a["male_resutls"] as? [String: Any]
  30. let c = a["female_resutls"] as? [String: Any]
  31. print (c)
  32. print (b)
  33. // completion (b.map { UsersInRaiting (JSON: $0)! },
  34. // c.map { UsersInRaiting (JSON: $0)! },
  35. // a["name"])
  36. completion (nil, nil, "Error")
  37. default:
  38. completion (nil, nil, "Error")
  39. }
  40. case .failure(let error):
  41. completion (nil, nil, "Error")
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement