 import IPaNetworkState
 public typealias IPaURLResourceUIResultHandler = ((Result<(URLResponse?,Any?),Error>) ->())
 open class IPaURLResourceUI : NSObject {
+    public enum HttpMethod:String {
+        case get = "GET"
+        case post = "POST"
+        case put = "PUT"
+        case delete = "DELETE"
+    }
     
     @objc open var baseURL:String! = ""
     @objc open var removeNSNull:Bool = true

        }
        
    }
    func apiUpload(_ api:String,method:String,headerFields:[String:String]?,file:Any,complete:@escaping IPaURLResourceUIResultHandler) {
        let operation = self.apiUploadOperation(api, method: method, headerFields: headerFields,file:file, complete: complete)
        self.operationQueue.addOperation(operation)
    }
    func apiUploadOperation(_ api:String,method:String,headerFields:[String:String]?,file:Any,complete:@escaping IPaURLResourceUIResultHandler) -> IPaURLRequestUploadOperation {
        let apiURL = urlString(for: api)
        var request = URLRequest(url:URL(string: apiURL)!)
        request.httpMethod = method
        if let headerFields = headerFields {
            for (key,value) in headerFields {
                request.setValue(value, forHTTPHeaderField: key)

        
        return operation
    }
    open func apiUpload(_ api:String,method:HttpMethod,headerFields:[String:String]?,fileUrl:URL,complete:@escaping IPaURLResourceUIResultHandler) {
        let operation = apiUploadOperation(api, method: method,headerFields: headerFields,fileUrl: fileUrl,complete:complete)
        self.operationQueue.addOperation(operation)
    }
    open func apiUploadOperation(_ api:String,method:HttpMethod,headerFields:[String:String]?,fileUrl:URL,complete:@escaping IPaURLResourceUIResultHandler) -> IPaURLRequestUploadOperation {
        return self.apiUploadOperation(api, method: method, headerFields: headerFields, file:fileUrl ,complete: complete)
    }
    open func apiUpload(_ api:String,method:HttpMethod,headerFields:[String:String]?,data:Data,complete:@escaping IPaURLResourceUIResultHandler) {
        let operation = apiUploadOperation(api, method: method, headerFields: headerFields, data: data, complete: complete)
        self.operationQueue.addOperation(operation)
    }
    
    open func apiUploadOperation(_ api:String,method:HttpMethod,headerFields:[String:String]?,data:Data,complete:@escaping IPaURLResourceUIResultHandler) -> IPaURLRequestUploadOperation {
        return self.apiUploadOperation(api, method: method, headerFields: headerFields,file:data, complete: complete)
    }
    open func apiUpload(_ api:String,method:HttpMethod,headerFields:[String:String]?,params:[String:Any],file:IPaMultipartFile,complete:@escaping IPaURLResourceUIResultHandler) {
        let operation = self.apiUploadOperation(api, method: method, headerFields: headerFields, params:params, file:file, complete: complete)
        self.operationQueue.addOperation(operation)
    }
    open func apiUploadOperation(_ api:String,method:HttpMethod,headerFields:[String:String]?,params:[String:Any],file:IPaMultipartFile,complete:@escaping IPaURLResourceUIResultHandler) -> IPaURLRequestUploadOperation {
        return self.apiUploadOperation(api, method: method, headerFields: headerFields, params: params, files: [file], complete: complete)
    }
    open func apiUpload(_ api:String,method:HttpMethod,headerFields:[String:String]?,params:[String:Any],files:[IPaMultipartFile],complete:@escaping IPaURLResourceUIResultHandler) {
        let extractedExpr = apiUploadOperation(api, method: method,headerFields: headerFields, params:params, files: files, complete: complete)
        let operation = extractedExpr
        self.operationQueue.addOperation(operation)
    }
    open func apiUploadOperation(_ api:String,method:HttpMethod,headerFields:[String:String]?,params:[String:Any],files:[IPaMultipartFile],complete:@escaping IPaURLResourceUIResultHandler) -> IPaURLRequestUploadOperation {
        
        let tempFilePath = (NSTemporaryDirectory() as NSString).appendingPathComponent("IPaURLResponseUITemp\(UUID().uuidString)")
        let boundary:String = ProcessInfo.processInfo.globallyUniqueString
