<commit_before>//
//  AlamoNetworkRetrierAdapter.swift
//  Makespace Inc.
//
//  Created by <NAME> (@darkzlave) on 3/8/17.
//
//

import Foundation
import Alamofire

class AlamoAuthenticationAdapter: RequestAdapter {

    // MARK: - RequestAdapter
    func adapt(_ urlRequest: URLRequest) throws -> URLRequest {
        var urlRequest = urlRequest
        //attach authentication if any token has been stored
        if let token = APITokenManager.currentToken, (urlRequest.value(forHTTPHeaderField: "Authorization") == nil){
            urlRequest.setValue("Bearer " + token.accessToken, forHTTPHeaderField: "Authorization")
        }
        //specify our custom user agent
        urlRequest.setValue(AlamoAuthenticationAdapter.agent, forHTTPHeaderField: "User-Agent")
        
        return urlRequest
    }
    
    /// Custom makespace agent header
    private static var agent:String{
        let name = UIDevice.current.name
        let version = UIDevice.current.systemVersion
        let model = UIDevice.current.model
        let bundleExecutableName = Bundle.main.bundleExecutableName
        let agent = "UserAgent:(AppName:\(bundleExecutableName), DeviceName:\(name), Version:\(version), Model:\(model))"
        return agent
    }
}<commit_msg>Add specific content type<commit_after>//
//  AlamoNetworkRetrierAdapter.swift
//  Makespace Inc.
//
//  Created by <NAME> (@darkzlave) on 3/8/17.
//
//

import Foundation
import Alamofire

class AlamoAuthenticationAdapter: RequestAdapter {

    // MARK: - RequestAdapter
    func adapt(_ urlRequest: URLRequest) throws -> URLRequest {
        var urlRequest = urlRequest
        //attach authentication if any token has been stored
        if let token = APITokenManager.currentToken, (urlRequest.value(forHTTPHeaderField: "Authorization") == nil){
            urlRequest.setValue("Bearer " + token.authorization, forHTTPHeaderField: "Authorization")
        }
        //specify our custom user agent
        urlRequest.setValue(AlamoAuthenticationAdapter.agent, forHTTPHeaderField: "User-Agent")
        urlRequest.setValue("application/x-www-form-urlencoded;charset=UTF-8", forHTTPHeaderField: "Content-Type")
        
        return urlRequest
    }
    
    /// Custom makespace agent header
    private static var agent:String{
        let name = UIDevice.current.name
        let version = UIDevice.current.systemVersion
        let model = UIDevice.current.model
        let bundleExecutableName = Bundle.main.bundleExecutableName
        let agent = "UserAgent:(AppName:\(bundleExecutableName), DeviceName:\(name), Version:\(version), Model:\(model))"
        return agent
    }
}
{'fraction_non_alphanumeric': 0.10003775009437524, 'fraction_numerical': 0.0033975084937712344, 'mean_word_length': 3.015151515151515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '2771104', 'n_tokens_mistral': 733, 'n_tokens_neox': 721, 'n_words': 176}