         return task
     }
 
-    func isUnauthorized(urlResponse: NSHTTPURLResponse?) -> Bool {
+    private func isUnauthorized(urlResponse: NSHTTPURLResponse?) -> Bool {
         if let actualResponse = urlResponse as NSHTTPURLResponse! {
             if (actualResponse.statusCode == 403 || actualResponse.statusCode == 401) {
                 return true

        return task
    }


    func urlSessionDownloadTask(method: httpMethod, encryptionModel: POSBaseEncryptedModel, acceptHeader: String, progress: NSProgress?, success: (url: NSURL) -> Void , failure: (error: APIError) -> ()) -> NSURLSessionTask {

        var completedURL : NSURL?
        let encryptedModelUri = encryptionModel.uri
        let urlRequest = fileTransferSessionManager.requestSerializer.requestWithMethod("GET", URLString: encryptionModel.uri, parameters: nil, error: nil)

        return task
    }

    private func jsonDataTask(urlrequest: NSURLRequest, success: (Dictionary <String, AnyObject>) -> Void , failure: (error: APIError) -> () ) -> NSURLSessionTask {
        let task = session.dataTaskWithRequest(urlrequest, completionHandler: { (data, response, error) -> Void in
            dispatch_async(dispatch_get_main_queue(), {
                let httpResponse = response as? NSHTTPURLResponse
                let string = NSString(data: data, encoding: NSASCIIStringEncoding)
                // if error happens in client, for example no internet, timeout ect.
                if let actualError = error as NSError! {
                    let error = APIError(error: actualError)
                    error.responseText = string as String?
                    failure(error: error)
                } else {
                    var jsonError : NSError?
                    let code : Int = {
                        if httpResponse == nil {
                            return Constants.Error.Code.UnknownError.rawValue
                        } else {
                            return httpResponse!.statusCode
                        }
                        }()
                    if self.isUnauthorized(httpResponse) {
                        let error = APIError(domain: Constants.Error.apiClientErrorDomain, code: Constants.Error.Code.oAuthUnathorized.rawValue, userInfo: nil)
                        failure(error:error)
                    } else {
                        if let actualData = data as NSData? {
                            if actualData.length == 0 {
                                failure(error:APIError(error: NSError(domain: Constants.Error.apiClientErrorDomain, code: code, userInfo: nil)))
                            } else if (response as! NSHTTPURLResponse).didFail()  {
                                let err = APIError(domain: Constants.Error.apiClientErrorDomain, code: httpResponse!.statusCode, userInfo: nil)
                                failure(error:err)
                            } else {
                                let serializer = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments, error: &jsonError) as! Dictionary<String, AnyObject>
                                success(serializer)
                            }
                        }
                    }
                }
            })
