<commit_before>//
//  APIClient.swift
//  SwiftStack
//
//  Created by NobodyNada on 12/2/16.
//
//

import Foundation
import Dispatch

extension String {
	var urlEncodedString: String {
		var allowed = CharacterSet.urlQueryAllowed
		allowed.remove(charactersIn: "&+")
		return self.addingPercentEncoding(withAllowedCharacters: allowed)!
	}
	
	init(urlParameters: [String:String]) {
		var result = [String]()
		
		for (key, value) in urlParameters {
			result.append("\(key.urlEncodedString)=\(value.urlEncodedString)")
		}
		
		self.init(result.joined(separator: "&"))
	}
}

//MARK: -


///An APIClient communicates to the Stack Exchange API over HTTP.
open class APIClient: NSObject, URLSessionDataDelegate {
	//MARK: Instance variables and types.
	
	///The URLSession for this client.
	open var session: URLSession!
	
	///The queue used for asynchronous operations.
    public let queue = DispatchQueue(label: "API queue", attributes: [.concurrent])<commit_msg>import FoundationNetworking on Linux<commit_after>//
//  APIClient.swift
//  SwiftStack
//
//  Created by NobodyNada on 12/2/16.
//
//

import Foundation
import Dispatch

#if os(Linux)
import FoundationNetworking
#endif

extension String {
	var urlEncodedString: String {
		var allowed = CharacterSet.urlQueryAllowed
		allowed.remove(charactersIn: "&+")
		return self.addingPercentEncoding(withAllowedCharacters: allowed)!
	}
	
	init(urlParameters: [String:String]) {
		var result = [String]()
		
		for (key, value) in urlParameters {
			result.append("\(key.urlEncodedString)=\(value.urlEncodedString)")
		}
		
		self.init(result.joined(separator: "&"))
	}
}

//MARK: -


///An APIClient communicates to the Stack Exchange API over HTTP.
open class APIClient: NSObject, URLSessionDataDelegate {
	//MARK: Instance variables and types.
	
	///The URLSession for this client.
	open var session: URLSession!
	
	///The queue used for asynchronous operations.
    public let queue = DispatchQueue(label: "API queue", attributes: [.concurrent])
{'fraction_non_alphanumeric': 0.12093953023488256, 'fraction_numerical': 0.004997501249375313, 'mean_word_length': 3.9800995024875623, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7371285', 'n_tokens_mistral': 659, 'n_tokens_neox': 611, 'n_words': 167}