<commit_before>//
//  VoteUploader.swift
//  Voter
//
//  Created by <NAME> on 22/02/15.
//  Copyright (c) 2015 Lambda Academy. All rights reserved.
//

import Foundation

let updateURL = "http://xmpp.lambdadays.org:4000/talk_api/update"
let talksURL = "http://xmpp.lambdadays.org:4000/talk_api/index"

class VoteUploader: NSObject
{
    func submitVotes(votes: NSDictionary, succeded: (() -> Void)?, failed: ((error: NSError?) -> Void)? = nil )
    {
        println("Votes: \(votes)")
        var request = NSMutableURLRequest(URL: NSURL(string: updateURL)!)
        request.HTTPMethod = "POST"
        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
        println("Request: \(request)")
        
        var err: NSError?
        let bodyData = NSJSONSerialization.dataWithJSONObject(votes, options: NSJSONWritingOptions(0), error: &err)
        println("string: \(NSString(data: bodyData!, encoding: NSUTF8StringEncoding))")
        request.HTTPBody = bodyData<commit_msg>Remove port from api url<commit_after>//
//  VoteUploader.swift
//  Voter
//
//  Created by <NAME> on 22/02/15.
//  Copyright (c) 2015 Lambda Academy. All rights reserved.
//

import Foundation

let updateURL = "http://xmpp.lambdadays.org/talk_api/update"
let talksURL = "http://xmpp.lambdadays.org/talk_api/index"

class VoteUploader: NSObject
{
    func submitVotes(votes: NSDictionary, succeded: (() -> Void)?, failed: ((error: NSError?) -> Void)? = nil )
    {
        println("Votes: \(votes)")
        var request = NSMutableURLRequest(URL: NSURL(string: updateURL)!)
        request.HTTPMethod = "POST"
        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
        println("Request: \(request)")
        
        var err: NSError?
        let bodyData = NSJSONSerialization.dataWithJSONObject(votes, options: NSJSONWritingOptions(0), error: &err)
        println("string: \(NSString(data: bodyData!, encoding: NSUTF8StringEncoding))")
        request.HTTPBody = bodyData
{'fraction_non_alphanumeric': 0.1425012456402591, 'fraction_numerical': 0.015944195316392625, 'mean_word_length': 3.413186813186813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6697958', 'n_tokens_mistral': 687, 'n_tokens_neox': 638, 'n_words': 139}