Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // userInRaiting.swift
- // RussianWodify
- //
- // Created by Elibay Nuptebek on 21.10.17.
- // Copyright © 2017 Codebusters. All rights reserved.
- //
- import Foundation
- import Alamofire
- import ObjectMapper
- struct Raiting {
- static func getRaiting (completion: @escaping ([UsersInRaiting]?, [UsersInRaiting]?, String?) -> Void) {
- let url = UIViewController.mainUrl + "/main/get_global_results/"
- let header: HTTPHeaders = ["Auth-Token": Storage.user!.token]
- print (Storage.user!.token)
- Alamofire.request(url, method: .get, headers: header).responseJSON { response in
- switch response.result {
- case .success(let value):
- let json = value as! [String: Any]
- let code = json["code"] as! Int
- switch code {
- case 0:
- let result = json["results"] as! [[String:Any]]
- let a = result[0] as [String:Any]
- print (a)
- let b = a["male_resutls"] as? [String: Any]
- let c = a["female_resutls"] as? [String: Any]
- print (c)
- print (b)
- // completion (b.map { UsersInRaiting (JSON: $0)! },
- // c.map { UsersInRaiting (JSON: $0)! },
- // a["name"])
- completion (nil, nil, "Error")
- default:
- completion (nil, nil, "Error")
- }
- case .failure(let error):
- completion (nil, nil, "Error")
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement