<commit_before>import UIKit

class SignUpMaker {
    let url: NSURL
    
    init (url: NSURL) {
        self.url = url
    }
    
    func signUp(loginName: String, displayName: String, password: String) {
        println("loginName: \(loginName), displayName: \(displayName), password: \(password)")
    }
}<commit_msg>Simple JSON communication.<commit_after>import UIKit

typealias JSONObject = [String: String]

class SignUpMaker {
    let baseUrl: NSURL
    
    init (url: NSURL) {
        baseUrl = url
    }
    
    func signUp(loginName: String, displayName: String, password: String) {
        let jsonObject = mkSignUpRecord(loginName, displayName: displayName, password: password)
        let request = mkPostRequest(jsonObject, url: "user")
        let session = NSURLSession.sharedSession()
        let task = session.dataTaskWithRequest(request) {
            data, response, error in
            
            let resp = response as NSHTTPURLResponse
            println("Response code: \(resp.statusCode)")
            
            if error == nil {
                
                let jsonReply = NSString(data: data, encoding: NSUTF8StringEncoding)
                println("reply: \(jsonReply)")
            } else {
                println("Error: \(error)")
            }
        }
        task.resume()
    }
    
    private func mkSignUpRecord(loginName: String, displayName: String, password: String) -> JSONObject {
        var obj = Dictionary<String, String>()
        
        obj["loginName"] = loginName
        obj["displayName"] = displayName
        obj["password"] = password
        
        return obj
    }
    
    private func mkPostRequest(jsonObject: JSONObject, url: String) -> NSMutableURLRequest {
        let request = NSMutableURLRequest(URL: NSURL(string: url, relativeToURL: baseUrl)!)
        
        request.HTTPMethod = "POST"
        request.setValue("application/json", forHTTPHeaderField: "Accept")
        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
        request.HTTPBody = NSJSONSerialization.dataWithJSONObject(
            jsonObject, options: NSJSONWritingOptions.PrettyPrinted, error: nil)
        
        return request
    }
}
{'fraction_non_alphanumeric': 0.09847122302158273, 'fraction_numerical': 0.0004496402877697842, 'mean_word_length': 2.3208955223880596, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '6863699', 'n_tokens_mistral': 604, 'n_tokens_neox': 594, 'n_words': 147}