 
 import Foundation
 
-enum ServiceQueueError: Error, CustomDebugStringConvertible {
-    case invalidSession(message: String, request: URLRequest)
-
-    var debugDescription: String {
-        switch self {
-        case .invalidSession(message: let message, request: let request):
-            return "📡🔥 you tried to perform a \(request) on a session that is invalid\nmessage: \(message)"
-        }
-    }
-}
-
 open class ServiceQueue {
 
-    var taskQueue: Set<URLSessionDataTask>
+    var taskQueue: Set<URLSessionTask>
     var failedTasks: Set<URLSessionTask>?
 
     let session: FaroURLSession


    // MARK: - Private

    private func add(_ task: URLSessionDataTask?) {
        guard let createdTask = task else {
            return
        }
        taskQueue.insert(createdTask)
    }

    private func cleanupQueue(for task: URLSessionDataTask?, didFail: Bool = false) {
        if let task = task {
            let _ = taskQueue.remove(task)
            if(didFail) {


    // MARK: - Update model instead of create

    open func performUpdate<M>(on model: M, call: Call, autoStart: Bool = false, complete: @escaping(@escaping () throws -> ()) -> Void) -> URLSessionTask?  where M: Decodable & Updatable {
        let task = perform(M.self, call: call, autoStart: autoStart) { (resultFunction) in
            complete {
                let serviceModel = try resultFunction()
