<commit_before>//
//  ServerApi.swift
//  RXS
//
//  Created by 刘向宏 on 2017/4/24.
//  Copyright © 2017年 刘向宏. All rights reserved.
//

import UIKit
import Alamofire
import YYKit

class ServerApi: NSObject {
    
    static var userId: String?
    static var token:String?
    
    class func getCaptcha(mobile: String, complet: @escaping ((ServerResult) -> ())) {
        let param = ["version": "1.0.0"
            , "email": mobile
            , "userSource": "2"]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/user/getCaptcha", parameters: param) { (result) in
            let model = ServerResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func login(loginName: String, password: String, complet: @escaping ((ServerLoginResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "loginName": loginName
            , "password": <PASSWORD>()
            , "platform": 2
            , "userSource": 2]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/user/login", parameters: param) { (result) in
            let model = ServerLoginResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func regist(loginName: String, password: String, captcha: String, complet: @escaping ((ServerLoginResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "loginName": loginName
            , "password": <PASSWORD>()
            , "platform": 2
            , "userSource": 2
            , "captcha": captcha
            , "appPackageName": "com.smart.light"
            , "operateType": 1]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/user/regist", parameters: param) { (result) in
            let model = ServerLoginResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func forget(loginName: String, password: String, captcha: String, complet: @escaping ((ServerLoginResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "loginName": loginName
            , "password": <PASSWORD>()
            , "platform": 2
            , "userSource": 2
            , "captcha": captcha
            , "appPackageName": "com.smart.light"
            , "operateType": 2]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/user/regist", parameters: param) { (result) in
            let model = ServerLoginResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func getHomeDeviceList(complet: @escaping ((ServerHomeDeviceResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "userId": ServerApi.userId!
            , "token": ServerApi.token!
            , "homeId": "0"
            , "pageNo": 1
            , "pageSize": 10000]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/smartHome/getHomeDeviceList", parameters: param) { (result) in
            //print(result)
            //let rr = "{\"retCode\":\"0\",\"retMsg\":\"成功\",\"homeDeviceList\":[{\"deviceId\":\"1\"},{\"deviceId\":\"2\"}]}"
            let model = ServerHomeDeviceResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func addSmartLamp(devices: [(String, String)], complet: @escaping ((ServerResult) -> ())) {
    
        var list = [[String: String]]()
        for device in devices {
            list.append(["deviceName": device.0, "hardwareId": device.1])
        }
        let param: [String : Any] = ["version": "1.0.0"
            , "userId": ServerApi.userId!
            , "token": ServerApi.token!
            , "homeId": "0"
            , "deviceList": list]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/smartHome/addSmartLamp", parameters: param) { (result) in
            //print(result)
            let model = ServerResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func request(url: String, parameters: [String: Any]? = nil, complet: @escaping ((String?) -> ())) {
        let url = URL(string: url)
        Alamofire.request(url!, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseString { (respon) in
            complet(respon.value)
        }
    }
}
<commit_msg>no message<commit_after>//
//  ServerApi.swift
//  RXS
//
//  Created by 刘向宏 on 2017/4/24.
//  Copyright © 2017年 刘向宏. All rights reserved.
//

import UIKit
import Alamofire
import YYKit

class ServerApi: NSObject {
    
    static var userId: String?
    static var token:String?
    
    class func getCaptcha(mobile: String, complet: @escaping ((ServerResult) -> ())) {
        let param = ["version": "1.0.0"
            , "email": mobile
            , "userSource": "2"]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/user/getCaptcha", parameters: param) { (result) in
            let model = ServerResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func login(loginName: String, password: String, complet: @escaping ((ServerLoginResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "loginName": loginName
            , "password": <PASSWORD>()
            , "platform": 2
            , "userSource": 2]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/user/login", parameters: param) { (result) in
            let model = ServerLoginResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func regist(loginName: String, password: String, captcha: String, complet: @escaping ((ServerLoginResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "loginName": loginName
            , "password": <PASSWORD>()
            , "platform": 2
            , "userSource": 2
            , "captcha": captcha
            , "appPackageName": "com.smart.light"
            , "operateType": 1]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/user/regist", parameters: param) { (result) in
            let model = ServerLoginResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func forget(loginName: String, password: String, captcha: String, complet: @escaping ((ServerLoginResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "loginName": loginName
            , "password": <PASSWORD>()
            , "platform": 2
            , "userSource": 2
            , "captcha": captcha
            , "appPackageName": "com.smart.light"
            , "operateType": 2]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/user/regist", parameters: param) { (result) in
            let model = ServerLoginResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func getHomeDeviceList(complet: @escaping ((ServerHomeDeviceResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "userId": ServerApi.userId!
            , "token": ServerApi.token!
            , "homeId": "0"
            , "pageNo": 1
            , "pageSize": 10000]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/smartHome/getHomeDeviceList", parameters: param) { (result) in
            //print(result)
            //let rr = "{\"retCode\":\"0\",\"retMsg\":\"成功\",\"homeDeviceList\":[{\"deviceId\":\"1\"},{\"deviceId\":\"2\"}]}"
            let model = ServerHomeDeviceResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func addSmartLamp(devices: [(String, String)], complet: @escaping ((ServerResult) -> ())) {
    
        var list = [[String: String]]()
        for device in devices {
            list.append(["deviceName": device.0, "hardwareId": device.1])
        }
        let param: [String : Any] = ["version": "1.0.0"
            , "userId": ServerApi.userId!
            , "token": ServerApi.token!
            , "homeId": "0"
            , "deviceList": list]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/smartHome/addSmartLamp", parameters: param) { (result) in
            //print(result)
            let model = ServerResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func updateDevicePassword(deviceId: String, old: String, new: String, complet: @escaping ((ServerResult) -> ())) {
        let param: [String : Any] = ["version": "1.0.0"
            , "userId": ServerApi.userId!
            , "token": ServerApi.token!
            , "deviceId": "0"
            , "oldPassword": <PASSWORD>
            , "newPassword": <PASSWORD>]
        ServerApi.request(url: "http://gaoyi.gooorun.com:8282/uis/smartHome/updateDevicePassword", parameters: param) { (result) in
            let model = ServerResult()
            model.modelSet(withJSON: result ?? "")
            complet(model)
        }
    }
    
    class func request(url: String, parameters: [String: Any]? = nil, complet: @escaping ((String?) -> ())) {
        let url = URL(string: url)
        Alamofire.request(url!, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseString { (respon) in
            complet(respon.value)
        }
    }
}

{'fraction_non_alphanumeric': 0.1580863234529381, 'fraction_numerical': 0.016432657306292252, 'mean_word_length': 2.066326530612245, 'pattern_counts': {'":': 90, '<': 11, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4220845', 'n_tokens_mistral': 2991, 'n_tokens_neox': 2908, 'n_words': 616}