<commit_before>//
//  OctoApi.swift
//  OctoPhone
//
//  Created by <NAME> on 10/11/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation
import Alamofire


enum Router: URLRequestConvertible {
    enum FileLocation: String {
        case sd
        case local
    }

    enum FileCommand: String {
        case select
        case slice
    }

    //MARK: - API Informations
    case apiVersion

    //MARK: - Files
    case readAllFiles
    case readFiles(at: FileLocation)
    case createFile(at: FileLocation, parameters: Parameters)
    case readFile(name: String, at: FileLocation)
    case issueFile(name: String, at: FileLocation, parameters: Parameters)
    case deleteFile(name: String, at: FileLocation)

    //MARK: - Connection
    case getAllConnections
    case issuePrinterCommand(parameters: Parameters)

    //MARK: - Printer operations
    case readPrinterState(parameters: Parameters)
    case issuePrinterHeadCommand(parameters: Parameters)
    case issueToolCommand(parameters: Parameters)
    case readToolState
    case issueBedCommand(paramters: Parameters)
    case readBedState
    case issueSDCommand(parameters: Parameters)
    case readSDState
    case issueArbitraryPrinterCommand(parameters: Parameters)

    //MARK: - Networking data
    var requestData: (method: HTTPMethod, path: String, parameters: Parameters?) {
        switch self {
        case .apiVersion: return(.get, "version", nil)

        case .readAllFiles(): return (.get, "files", nil)
        case .readFiles(let location): return (.get, "files/\(location.rawValue)", nil)
        case .createFile(let location, let parameters): return (.post, "files/\(location.rawValue)", parameters)
        case .readFile(let name, let location): return (.get, "files/\(location.rawValue)/\(name)", nil)
        case .issueFile(let name, let location, let parameters): return (.post, "files/\(location.rawValue)/\(name)", parameters) // slice, select nebo connect, disconnect, fake_ack
        case .deleteFile(let name, let location): return (.delete, "files/\(location)/\(name)", nil)

        case .getAllConnections: return (.get, "connection", nil)
        case .issuePrinterCommand(let parameters): return (.post, "connection", parameters)

        case .readPrinterState(let parameters): return (.get, "printer", parameters)
        case .issuePrinterHeadCommand(let parameters): return (.post, "printer/printhead", parameters) // jog, home, feedrate
        case .issueToolCommand(let parameters): return (.post, "printer/tool", parameters) // target, offset, select, extrude, flowrate
        case .readToolState: return (.get, "printer/tool", nil)
        case .issueBedCommand(let paramters): return (.post, "printer/bed", paramters) // target, offset
        case .readBedState: return (.get, "printer/bed", nil)
        case .issueSDCommand(let parameters): return (.post, "printer/sd", parameters) // init, refresh, release
        case .readSDState: return (.get, "printer/sd", nil)
        case .issueArbitraryPrinterCommand(parameters: let parameters): return (.post, "printer/command", parameters)
        }
    }

    static let baseURLString = "https://example.com"

    // MARK: URLRequestConvertible
    func asURLRequest() throws -> URLRequest {
        let url = try Router.baseURLString.asURL()
        let requestData = self.requestData

        var urlRequest = URLRequest(url: url.appendingPathComponent(requestData.path))
        urlRequest.httpMethod = requestData.method.rawValue

        urlRequest = try URLEncoding.default.encode(urlRequest, with: requestData.parameters)
        
        return urlRequest
    }<commit_msg>FIX: Fix endpoint name<commit_after>//
//  OctoApi.swift
//  OctoPhone
//
//  Created by <NAME> on 10/11/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation
import Alamofire


enum Router: URLRequestConvertible {
    enum FileLocation: String {
        case sd
        case local
    }

    enum FileCommand: String {
        case select
        case slice
    }

    //MARK: - API Informations
    case apiVersion

    //MARK: - Files
    case readAllFiles
    case readFiles(at: FileLocation)
    case createFile(at: FileLocation, parameters: Parameters)
    case readFile(name: String, at: FileLocation)
    case issueFileCommand(name: String, at: FileLocation, parameters: Parameters)
    case deleteFile(name: String, at: FileLocation)

    //MARK: - Connection
    case getAllConnections
    case issueConnectionCommand(parameters: Parameters)

    //MARK: - Printer operations
    case readPrinterState(parameters: Parameters)
    case issuePrinterHeadCommand(parameters: Parameters)
    case issueToolCommand(parameters: Parameters)
    case readToolState
    case issueBedCommand(paramters: Parameters)
    case readBedState
    case issueSDCommand(parameters: Parameters)
    case readSDState
    case issueArbitraryPrinterCommand(parameters: Parameters)

    //MARK: - Networking data
    var requestData: (method: HTTPMethod, path: String, parameters: Parameters?) {
        switch self {
        case .apiVersion: return(.get, "version", nil)

        case .readAllFiles(): return (.get, "files", nil)
        case .readFiles(let location): return (.get, "files/\(location.rawValue)", nil)
        case .createFile(let location, let parameters): return (.post, "files/\(location.rawValue)", parameters)
        case .readFile(let name, let location): return (.get, "files/\(location.rawValue)/\(name)", nil)
        case .issueFileCommand(let name, let location, let parameters): return (.post, "files/\(location.rawValue)/\(name)", parameters) // slice, select
        case .deleteFile(let name, let location): return (.delete, "files/\(location)/\(name)", nil)

        case .getAllConnections: return (.get, "connection", nil)
        case .issueConnectionCommand(let parameters): return (.post, "connection", parameters) // connect, disconnect, fake_ack

        case .readPrinterState(let parameters): return (.get, "printer", parameters)
        case .issuePrinterHeadCommand(let parameters): return (.post, "printer/printhead", parameters) // jog, home, feedrate
        case .issueToolCommand(let parameters): return (.post, "printer/tool", parameters) // target, offset, select, extrude, flowrate
        case .readToolState: return (.get, "printer/tool", nil)
        case .issueBedCommand(let paramters): return (.post, "printer/bed", paramters) // target, offset
        case .readBedState: return (.get, "printer/bed", nil)
        case .issueSDCommand(let parameters): return (.post, "printer/sd", parameters) // init, refresh, release
        case .readSDState: return (.get, "printer/sd", nil)
        case .issueArbitraryPrinterCommand(parameters: let parameters): return (.post, "printer/command", parameters)
        }
    }

    static let baseURLString = "https://example.com"

    // MARK: URLRequestConvertible
    func asURLRequest() throws -> URLRequest {
        let url = try Router.baseURLString.asURL()
        let requestData = self.requestData

        var urlRequest = URLRequest(url: url.appendingPathComponent(requestData.path))
        urlRequest.httpMethod = requestData.method.rawValue

        urlRequest = try URLEncoding.default.encode(urlRequest, with: requestData.parameters)
        
        return urlRequest
    }
{'fraction_non_alphanumeric': 0.1139481189732446, 'fraction_numerical': 0.002716284123319299, 'mean_word_length': 3.281395348837209, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '3714473', 'n_tokens_mistral': 2081, 'n_tokens_neox': 1976, 'n_words': 594}