public DocuSignResponseModel GetDocument(DocuSignLog log, DocuSignAuthHeader authInformation, string serverPath, string host) { var docusignResponse = new DocuSignResponseModel(); var loginInfo = GetLoginInfo(authInformation); EnvelopesApi envelopesApi = new EnvelopesApi(); var document2 = envelopesApi.GetDocument(loginInfo.AccountId, log.EnvelopeID, log.DocumentID); var documentUrl = "/documents/signed/signedocument-" + Guid.NewGuid() + ".pdf"; var filePath = serverPath + documentUrl; using (Stream file = File.Create(filePath)) { FileHelpers.CopyStream(document2, file); } docusignResponse.DocumentUrl = host + "/" + documentUrl; docusignResponse.CaseID = log.CaseID.ToString(); docusignResponse.DocumentID = log.DocumentID; docusignResponse.EnvelopeID = log.EnvelopeID; return(docusignResponse); }
public ApiResponse <DocuSignResponseModel> GetDocument(int caseID, string serverPath, string host) { try { var docusignLog = repository.Query(r => r.CaseID == caseID).FirstOrDefault(); if (docusignLog != null) { var docusignManager = new DocuSignManager(); var authInformation = new DocuSignAuthHeader { Username = settings.Docusign.UserName, Password = settings.Docusign.Password, IntegratorKey = settings.Docusign.IntegratorKey }; var responseModel = docusignManager.GetDocument(docusignLog, authInformation, serverPath, host); return(new ApiResponse <DocuSignResponseModel>(responseModel)); } throw new ArgumentException("No document found"); } catch (Exception e) { return(HandleErrorAndReturnStatus <ApiResponse <DocuSignResponseModel> >(e)); } }
public async Task <ApiResponse <DocuSignResponseModel> > SendDocument(DocumentSignModel model, string serverPath) { var docusignManager = new DocuSignManager(); var confirmationUrl = appSettings.Get("docusign:ConfirmationUrl"); var authInformation = new DocuSignAuthHeader { Username = settings.Docusign.UserName, Password = settings.Docusign.Password, IntegratorKey = settings.Docusign.IntegratorKey }; var caseModel = caseRepository.Query(c => c.ID == model.CaseID).FirstOrDefault(); var responseModel = docusignManager.SendDocument(model, caseModel, authInformation, serverPath, confirmationUrl); var docusignLog = new DocuSignLog { CaseID = model.CaseID, DocumentID = responseModel.DocumentID, EnvelopeID = responseModel.EnvelopeID, CreatedDate = DateTime.Now }; repository.Add(docusignLog); await repository.SaveChanges(); return(new ApiResponse <DocuSignResponseModel>(responseModel)); }
private LoginAccount GetLoginInfo(DocuSignAuthHeader headerOptions) { var basePath = "https://demo.docusign.net/restapi"; var apiClient = new ApiClient(basePath); Configuration.Default.ApiClient = apiClient; var authHeader = JsonConvert.SerializeObject(headerOptions); if (!Configuration.Default.DefaultHeader.ContainsKey("X-DocuSign-Authentication")) { Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader); } var authApi = new AuthenticationApi(); var loginInfoResult = authApi.Login(); var loginInfo = loginInfoResult.LoginAccounts.First(); return(loginInfo); }
public DocuSignResponseModel SendDocument(DocumentSignModel model, Case caseModel, DocuSignAuthHeader authInformation, string serverPath) { var docusignResponse = new DocuSignResponseModel(); var loginInfo = GetLoginInfo(authInformation); var documentModel = SendDocumentAndGetUrl(model, caseModel, loginInfo, serverPath); docusignResponse.SignUrl = documentModel.SignUrl; docusignResponse.CaseID = model.CaseID.ToString(); docusignResponse.DocumentID = documentModel.DocumentID; docusignResponse.EnvelopeID = documentModel.EnvelopeID; return(docusignResponse); }