public DownloadDocumentResponse DownloadDocument(DownloadDocumentRequest request)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            DownloadDocumentResponse response = null;
            var httpResponse = SendGetRequest(request, "DownloadDocument");

            //The DownloadDocument endpoint will return either the file as an attachment, or a JSON object if there was an error.

            //DispositionType will be attachment if file was successfully returned.
            if (httpResponse.Content.Headers.ContentDisposition != null && httpResponse.Content.Headers.ContentDisposition.DispositionType == "attachment")
            {
                response = new DownloadDocumentResponse
                {
                    FileStream = httpResponse.Content.ReadAsStreamAsync().Result,
                    FileName = httpResponse.Content.Headers.ContentDisposition.FileName
                };
            }
            else
            {
                //File was not successfully returned, check for JSON response instead
                response = LoadResponse<DownloadDocumentResponse>(httpResponse);
            }

            response.DocumentID = request.DocumentID;
            return response;
        }
        public DownloadDocumentResponse DownloadDocument(string documentID, string merchantSessionID)
        {
            if (documentID == null)
                throw new ArgumentNullException("documentID");

            var request = new DownloadDocumentRequest
            {
                DocumentID = documentID,
                MerchantSessionID = merchantSessionID
            };

            return DownloadDocument(request);
        }