public DocumentForSign GetEmbeddedDocument(Envelope envelope, TemplateInfo templateInfo, string returnUrl) { try { if (envelope == null) throw new ArgumentNullException("envelope"); if (templateInfo == null) throw new ArgumentNullException("templateInfo"); envelope.GetRecipients(); var signer = envelope.Recipients.signers[0]; if (signer != null) { var documents = envelope.GetDocuments(); var envelopeDocument = documents.FirstOrDefault(x => x.name.Contains(templateInfo.Name)); if (envelopeDocument != null) { var tabs = new CustomTabs(int.Parse(envelopeDocument.documentId), signer.recipientId, signer.name); envelope.AddTabs(new TabCollection { companyTabs = tabs.CompanyTabs, dateSignedTabs = tabs.dateSignedTabs, signHereTabs = tabs.SignHereTabs, textTabs = tabs.TextTabs }); var doc = new DocumentForSign { Document = Template.GetTemplatePreview(templateInfo.Id), DocumentName = templateInfo.Name, EmbeddedUrl = envelope.GetEmbeddedSignerView(returnUrl, signer) }; if (!string.IsNullOrEmpty(doc.EmbeddedUrl)) { _context.Documents.Add(new DocuSignDocument() { EnvelopeId = envelope.EnvelopeId, EmbeddedUrl = doc.EmbeddedUrl, Status = "sent", UserId = signer.clientUserId }); _context.SaveChanges(); } return doc; } } } catch (Exception ex) { throw ex; } return null; }
public void EnvelopeGetRecipients() { ConfigLoader.LoadConfig(); bool expected = true; bool actual = true; Account acct = ConfigLoader.RetrieveTestAccount(); try { actual = acct.Login(); } catch (Exception ex) { Assert.Fail("Unexpected exception during account creation part of test {0}: {1}", ex.GetType(), ex.Message); return; } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(acct.BaseUrl)); Envelope target = new Envelope(); target.Login = acct; // $TODO: add known Envelope ID target.EnvelopeId = " 10211DCED6744C13A2B82AACC0AF4BEC"; actual = false; try { actual = target.GetRecipients(); } catch (Exception ex) { Assert.Fail("Unexpected exception during test {0}: {1}", ex.GetType(), ex.Message); return; } Assert.AreEqual(expected, actual); // $TODO: add Asserts for known Recipient Properties on the envelope Assert.IsNotNull(target.Recipients); Assert.AreEqual(target.Recipients.recipientCount, "3"); Assert.AreEqual(target.Recipients.signers[0].email, "*****@*****.**"); Assert.AreEqual(target.Recipients.signers[0].name, "Test One"); Assert.AreEqual(target.Recipients.signers[0].status, "sent"); Assert.AreEqual(target.Recipients.signers[1].email, "*****@*****.**"); Assert.AreEqual(target.Recipients.signers[1].name, "Test Two"); Assert.AreEqual(target.Recipients.signers[1].status, "created"); Assert.AreEqual(target.Recipients.signers[2].email, "*****@*****.**"); Assert.AreEqual(target.Recipients.signers[2].name, "Test Three"); Assert.AreEqual(target.Recipients.signers[2].status, "created"); }
public Tabs GetDataFromCompletedEnvelope(string envelopeId) { try { var envelope = new Envelope { Login = Account, EnvelopeId = envelopeId }; envelope.GetRecipients(true, true); if (envelope.RestError == null && envelope.Recipients != null && envelope.Recipients.signers[0] != null && envelope.Recipients.signers[0].tabs != null) { return envelope.Recipients.signers[0].tabs; } if (envelope.RestError != null) { throw new Exception(envelope.RestError.message); } } catch (Exception ex) { throw ex; } return null; }