         return components.map { "\($0)=\($1)" }.joined(separator: "&")
     }
 }
-
-extension NSNumber {
-    fileprivate var isBool: Bool { return CFBooleanGetTypeID() == CFGetTypeID(self) }
-}

        self.allowsCellularAccess = true
        self.httpMethod = method
        [
            "application/x-www-form-urlencoded; charset=utf-8": "Content-Type",
            //"multipart/form-data": "Content-Type",
            //"application/json": "Content-Type",
            //"text/xml": "Content-Type",
            //"charset=utf-8": "Content-Type",
            "*/*": "Accept"
            ].forEach { (key, value) in
                self.addValue(key, forHTTPHeaderField: value)
        }
        if let body = body {
            self.httpBody = body
        }
        self.httpShouldHandleCookies = true
        self.httpShouldUsePipelining = true
    }
}

// MARK: - copy from alamofire
extension URLRequest {
    private static func escape(_ string: String) -> String {
        let generalDelimitersToEncode = ":#[]@" // does not include "?" or "/" due to RFC 3986 - Section 3.4


extension URLRequest {
    public init?(method: HTTPMethod, url: String, parameters: [String: Any]?) {
        guard let parameters = parameters else {
            self.init(method: method.rawString, url: url, body: nil)
            return
        }
        switch method {
        case .get, .head, .delete:
            if parameters.isEmpty == false,
                let u = URL(string: url),
                var components = URLComponents(url: u, resolvingAgainstBaseURL: false) {
                let encodedQuery = (components.percentEncodedQuery.map { $0 + "&" } ?? "") + URLRequest.query(parameters)
                components.percentEncodedQuery = encodedQuery
                if let encodeUrl = components.url?.absoluteString {
                    self.init(method: method.rawString, url: encodeUrl, body: nil)
                    return
                }
            }
            self.init(method: method.rawString, url: url, body: nil)
        case .post:
            let body: Data?
            do {
                body = try JSONSerialization.data(withJSONObject: parameters, options: [])
            } catch let error {
                debugPrint(error.localizedDescription, parameters.debugDescription)
                body = URLRequest.query(parameters).data(using: .utf8, allowLossyConversion: false)
            }
            self.init(method: method.rawString, url: url, body: body)
        default:
            self.init(method: method.rawString, url: url, body: nil)
        }
    }
    public init?(method: String, url: String, body: Data?) {
        guard let url = URL(string: url) else { return nil }
