<commit_before>//
//  TODOAPIClient.swift
//  KataTODOAPIClient
//
//  Created by <NAME> on 12/02/16.
//  Copyright © 2016 Karumi. All rights reserved.
//

import Foundation
import BothamNetworking
import Result

public class TODOAPIClient {

    private let botham: BothamAPIClient
    private let parser: TaskDTOParser

    public init() {
        self.botham = BothamAPIClient(baseEndpoint: TODOAPIClientConfig.baseEndpoint)
        self.botham.requestInterceptors.append(DefaultHeadersInterceptor())
        self.parser = TaskDTOParser()
    }

    public func getAll(completion: (Result<[TaskDTO], TODOAPIClientError>) -> ()) {
        botham.GET(TODOAPIClientConfig.tasksEndpoint) { result in
            result.mapJSON { json in
                let tasks: [TaskDTO] = self.parser.fromJSON(json)
                completion(Result.Success(tasks))
            }.mapErrorToTODOAPIClientError()
        }
    }

    public func getByTaskId(id: String, completion: (Result<TaskDTO, TODOAPIClientError>) -> ()) {
        botham.GET("\(TODOAPIClientConfig.tasksEndpoint)/\(id)") { result in
            result.mapJSON { json in
                let task: TaskDTO = self.parser.fromJSON(json)
                completion(Result.Success(task))
            }.mapErrorToTODOAPIClientError()
        }
    }

    public func addTaskToUser(userId: String, title: String, completed: Bool,
            completion: (Result<TaskDTO, TODOAPIClientError>) -> ()) {
        botham.POST(TODOAPIClientConfig.tasksEndpoint,
            body: ["userId": userId,
                    "title": title,
                    "completed": completed]){ result in
            result.mapJSON { json in
                let task: TaskDTO = self.parser.fromJSON(json)
                completion(Result.Success(task))
            }.mapErrorToTODOAPIClientError()
        }
    }

}<commit_msg>Add a new method to the api client to be able to delete a task<commit_after>//
//  TODOAPIClient.swift
//  KataTODOAPIClient
//
//  Created by <NAME> on 12/02/16.
//  Copyright © 2016 Karumi. All rights reserved.
//

import Foundation
import BothamNetworking
import Result

public class TODOAPIClient {

    private let botham: BothamAPIClient
    private let parser: TaskDTOParser

    public init() {
        self.botham = BothamAPIClient(baseEndpoint: TODOAPIClientConfig.baseEndpoint)
        self.botham.requestInterceptors.append(DefaultHeadersInterceptor())
        self.parser = TaskDTOParser()
    }

    public func getAll(completion: (Result<[TaskDTO], TODOAPIClientError>) -> ()) {
        botham.GET(TODOAPIClientConfig.tasksEndpoint) { result in
            result.mapJSON { json in
                let tasks: [TaskDTO] = self.parser.fromJSON(json)
                completion(Result.Success(tasks))
            }.mapErrorToTODOAPIClientError()
        }
    }

    public func getByTaskId(id: String, completion: (Result<TaskDTO, TODOAPIClientError>) -> ()) {
        botham.GET("\(TODOAPIClientConfig.tasksEndpoint)/\(id)") { result in
            result.mapJSON { json in
                let task: TaskDTO = self.parser.fromJSON(json)
                completion(Result.Success(task))
            }.mapErrorToTODOAPIClientError()
        }
    }

    public func addTaskToUser(userId: String, title: String, completed: Bool,
            completion: (Result<TaskDTO, TODOAPIClientError>) -> ()) {
        botham.POST(TODOAPIClientConfig.tasksEndpoint,
            body: ["userId": userId,
                    "title": title,
                    "completed": completed]){ result in
            result.mapJSON { json in
                let task: TaskDTO = self.parser.fromJSON(json)
                completion(Result.Success(task))
            }.mapErrorToTODOAPIClientError()
        }
    }

    public func deleteTaskById(id: String, completion: (Result<Void, TODOAPIClientError>) -> ()) {
        botham.DELETE("\(TODOAPIClientConfig.tasksEndpoint)/\(id)") { result in
            result.mapJSON { json in
                completion(Result.Success())
                }.mapErrorToTODOAPIClientError()
        }
    }

}
{'fraction_non_alphanumeric': 0.10703812316715543, 'fraction_numerical': 0.004887585532746823, 'mean_word_length': 2.3742786479802143, 'pattern_counts': {'":': 6, '<': 12, '<?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': '508337', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1203, 'n_words': 241}