<commit_before>//
//  ApiManager.swift
//
//  Created by <NAME> on 7/14/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

let networkLogger = Logger.defaultLogger(["network"])

import Alamofire

public class ApiManager {
    public static var sharedManager: ApiManager = ApiManager()

    public var userCredentials: UserCredentials = {
        return UserCredentials(email: "", password: "")
    }()

    public var didCreateNewTask: ((newTask: ApiTask) -> ())? = nil
    public private(set) var isOffline: Bool = false

    public var baseUrl: String!

    public init() {
        Manager.sharedInstance.startRequestsImmediately = false
    }

    // MARK: tasks
    public func task(
        urlRequest: URLRequestConvertible,
        completionHandler: (data: [String : AnyObject]) -> ()
    ) -> ApiTask {
        let task = ApiTask(
            urlRequest: urlRequest,
            completionHandler: completionHandler
        )

        self.didCreateNewTask?(newTask: task)

        return task
    }

    public func groupTask(tasks: [ApiTask]) -> ApiGroupTask {
        let task = ApiGroupTask()
        task.tasks = tasks
        return task<commit_msg>create ApiObjectTasks<commit_after>//
//  ApiManager.swift
//
//  Created by <NAME> on 7/14/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

let networkLogger = Logger.defaultLogger(["network"])

import Alamofire

public class ApiManager {
    public static var sharedManager: ApiManager = ApiManager()

    public var userCredentials: UserCredentials = {
        return UserCredentials(email: "", password: "")
    }()

    public var didCreateNewTask: ((newTask: ApiTask) -> ())? = nil
    public private(set) var isOffline: Bool = false

    public var baseUrl: String!

    public init() {
        Manager.sharedInstance.startRequestsImmediately = false
    }

    // MARK: tasks
    public func task(
        urlRequest: URLRequestConvertible,
        completionHandler: (data: [String : AnyObject]) -> ()
    ) -> ApiTask {
        let task = ApiTask (
            urlRequest: urlRequest,
            completionHandler: completionHandler
        )

        self.didCreateNewTask?(newTask: task)

        return task
    }
    
    public func task<T>() -> ApiObjectTask<T> {
        let task = ApiObjectTask<T> ()
        
        self.didCreateNewTask?(newTask: task)
        
        return task
    
    }
    
    public func groupTask(tasks: [ApiTask]) -> ApiGroupTask {
        let task = ApiGroupTask()
        task.tasks = tasks
        return task
{'fraction_non_alphanumeric': 0.10683424980361352, 'fraction_numerical': 0.007069913589945012, 'mean_word_length': 2.418791946308725, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 19, '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': '901189', 'n_tokens_mistral': 734, 'n_tokens_neox': 724, 'n_words': 191}