                 request.setValue("application/json", forHTTPHeaderField: "Content-Type")
             }
         } catch {
-            completionHandler(nil, error)
+            completionHandler(nil, nil, error)
         }
-        
         let task = session.dataTask(with: request) { (data, response, error) in
             guard error == nil else {
-                DispatchQueue.main.async { completionHandler(nil, error) }
+                DispatchQueue.main.async { completionHandler(nil, nil, error) }
                 return
             }
             guard let response = response as? HTTPURLResponse else {
-                DispatchQueue.main.async { completionHandler(nil, BoxCastError.unknown) }
+                DispatchQueue.main.async { completionHandler(nil, nil, BoxCastError.unknown) }
                 return
             }
             guard response.statusCode >= 200 && response.statusCode < 300 else {
                 if let data = data, let error = BoxCastError(responseData: data) {
-                    DispatchQueue.main.async { completionHandler(nil, error) }
+                    DispatchQueue.main.async { completionHandler(response, nil, error) }
                 } else {
-                    DispatchQueue.main.async { completionHandler(nil, BoxCastError.unknown) }
+                    DispatchQueue.main.async { completionHandler(response, nil, BoxCastError.unknown) }
                 }
                 return
             }
-            guard let data = data else {
-                DispatchQueue.main.async { completionHandler(nil, BoxCastError.unknown) }
-                return
-            }
-            do {
-                let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
-                DispatchQueue.main.async { completionHandler(json, nil) }
-            } catch {
-                DispatchQueue.main.async { completionHandler(nil, error) }
-            }
-            
-        }
-        task.resume()
-    }
-    
-    public func post(url: String, parameters: [String : Any], completionHandler: @escaping (HTTPURLResponse?, Error?) -> Void) {
-        guard let url = URL(string: url) else {
-            return completionHandler(nil, BoxCastError.invalidURL)
-        }
-        
-        var request = URLRequest(url: url)
-        request.addValue("application/json", forHTTPHeaderField: "Accept")
-        
-        do {
-            let data = try JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)
-            request.httpMethod = "POST"
-            request.httpBody = data
-            request.setValue("application/json", forHTTPHeaderField: "Content-Type")
-        } catch {
-            completionHandler(nil, error)
-        }
-        
-        let task = session.dataTask(with: request) { (data, response, error) in
-            guard error == nil else {
-                DispatchQueue.main.async { completionHandler(nil, error) }
-                return
-            }
-            guard let response = response as? HTTPURLResponse else {
-                DispatchQueue.main.async { completionHandler(nil, BoxCastError.unknown) }
-                return
-            }
-            DispatchQueue.main.async { completionHandler(response, nil) }
+            DispatchQueue.main.async { completionHandler(response, data, nil) }
         }
         task.resume()
     }

    
    // MARK: - Request
    
    public func getJSON(for url: String, completionHandler: @escaping (Any?, Error?) -> Void ) {
        getJSON(for: url, parameters: nil, completionHandler: completionHandler)
    }
    
    public func getJSON(for url: String, parameters: [String : Any]?, completionHandler: @escaping (Any?, Error?) -> Void) {
        requestJSON(for: url, method: "GET", parameters: parameters,
                    completionHandler: completionHandler)
    }

                    completionHandler: completionHandler)
    }
    
    public func post(url: String, parameters: [String : Any], completionHandler: @escaping (HTTPURLResponse?, Data?, Error?) -> Void) {
        request(url: url, method: "POST", parameters: parameters,
                completionHandler: completionHandler)
    }
    
    public func get(url: String, parameters: [String : Any], completionHandler: @escaping (HTTPURLResponse?, Data?, Error?) -> Void) {
        request(url: url, method: "GET", parameters: parameters,
                completionHandler: completionHandler)
    }
    
    private func requestJSON(for url: String, method: String, parameters: [String : Any]?, completionHandler: @escaping (Any?, Error?) -> Void) {
        request(url: url, method: method, parameters: parameters) { (response, data, error) in
            if let error = error {
                completionHandler(nil, error)
                return
            }
            guard let data = data else {
                DispatchQueue.main.async { completionHandler(nil, BoxCastError.unknown) }
                return
            }
            do {
                let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
                DispatchQueue.main.async { completionHandler(json, nil) }
            } catch {
                DispatchQueue.main.async { completionHandler(nil, error) }
            }
        }
    }
    
    private func request(url: String, method: String, parameters: [String : Any]?, completionHandler: @escaping (HTTPURLResponse?, Data?, Error?) -> Void) {
        guard let url = URL(string: url) else {
            return completionHandler(nil, nil, BoxCastError.invalidURL)
        }
        
        var request = URLRequest(url: url)
