public void EnvelopeCreateNoAccount() { ConfigLoader.LoadConfig(); Envelope target = new Envelope(); bool expected = false; bool actual = false; try { actual = target.Create(string.Empty); } catch(ArgumentNullException) { } Assert.AreEqual(expected, actual); }
public void AddRemoveDocumentsFromEnvelopeTest() { var envelope = new Envelope { Login = _account }; // add a draft envelope to be found later Assert.IsTrue(envelope.Create()); Assert.IsNull(envelope.RestError); // no docs yet Assert.AreEqual(0, envelope.GetDocIds(envelope.EnvelopeId).Count); // add a doc byte[] doc1 = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 }; Assert.IsTrue(envelope.AddDocument(doc1, "test1.doc", 1)); Assert.IsNull(envelope.RestError); // we should have exactly 1 doc now Assert.AreEqual(1, envelope.GetDocIds(envelope.EnvelopeId).Count); Assert.AreEqual("test1.doc", envelope.GetDocNames(envelope.EnvelopeId).First()); var envelopeDocuments = envelope.GetEnvelopeDocumentInfo(envelope.EnvelopeId); Assert.AreEqual(envelopeDocuments.envelopeId, envelope.EnvelopeId); Assert.AreEqual(envelopeDocuments.envelopeDocuments[0].name, "test1.doc"); Assert.AreEqual(envelopeDocuments.envelopeDocuments[0].documentId, "1"); // remove the doc Assert.IsTrue(envelope.RemoveDocument(1)); Assert.IsNull(envelope.RestError); // back to having no docs Assert.AreEqual(0, envelope.GetDocIds(envelope.EnvelopeId).Count); }
public void ReteivingAllDraftEnvelopesTest() { var envelope = new Envelope { Login = _account }; // add a draft envelope to be found later Assert.IsTrue(envelope.Create()); Assert.IsNull(envelope.RestError); Thread.Sleep(1000); // need to allow the system to fully create the envelope var accountEnvelopes = envelope.GetDraftEnvelopes(DateTime.Now.AddSeconds(-5)); Assert.IsNull(envelope.RestError); Assert.AreEqual(1, accountEnvelopes.Envelopes.Length, "We expect only 1 draft envelope in the last 5 seconds that was created by this unit test"); }
public List <DocuSignTabDTO> ExtractEnvelopeData(DocuSign.Integrations.Client.Envelope envelope, Signer curSigner) { List <DocuSignTabDTO> curEnvelopeDataSet = new List <DocuSignTabDTO>(); Tabs curTabsSet = curSigner.tabs; if (curTabsSet != null) { if (curTabsSet.textTabs != null) { foreach (TextTab curTextTab in curTabsSet.textTabs) { DocuSignTabDTO curEnvelopeData = new DocuSignTabDTO { RecipientId = curSigner.recipientId, EnvelopeId = envelope.EnvelopeId, DocumentId = curTextTab.documentId, Name = curTextTab.tabLabel + "(" + curSigner.roleName + ")", TabId = curTextTab.tabId, Value = curTextTab.value }; curEnvelopeDataSet.Add(curEnvelopeData); } } //TODO continue to do, all -> curTabsSet. tabs to envelope data ? Like below; //foreach (Tab curCheckBoxTab in curTabsSet.checkboxTabs) //{ // EnvelopeData curEnvelopeData = new EnvelopeData // { // RecipientId = curSigner.recipientId, // EnvelopeId = envelope.EnvelopeId, // DocumentName = curDocumentName, // Name = curCheckBoxTab.name, // TabId = curCheckBoxTab.tabId, // Value = curCheckBoxTab.value // }; //TODO make for companyTabs, dateSignedTabs, emailTabs etc. // curEnvelopeDataSet.Add(curEnvelopeData); //} } return(curEnvelopeDataSet); }
public void TemplateEndToEndTest() { Assert.IsTrue(string.IsNullOrEmpty(RestSettings.Instance.EmailSubject) == false, "Set the email subject for the envelope"); var template = new Template { Login = _account }; byte[] doc1 = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 }; var names = new List<string>(); var docs = new List<byte[]>(); names.Add("test1.doc"); docs.Add(doc1); // add recipients var signers = new List<Signer>(); signers.Add(new Signer { email = "*****@*****.**", name = "test test", recipientId = "1", roleName = "signer1", routingOrder = "1" }); signers.Add(new Signer { recipientId = "2", roleName = "signer2", routingOrder = "1" }); var recipients = new Recipients { signers = signers.ToArray() }; template.Recipients = recipients; Assert.IsTrue(template.CreateTemplate(docs, names, "DocuSign.NET Client Unit Test Template")); Assert.IsNull(template.RestError); // Note that EnvelopeId for a template is the TemplateId... // start a new envelope var templateId = template.EnvelopeId; var envelope = new Envelope { Login = _account }; Assert.IsTrue(envelope.Create()); // add the template var templates = new List<string>(); templates.Add(template.EnvelopeId); Assert.IsTrue(envelope.AddTemplates(templates)); Assert.IsNull(template.RestError); // update recipients recipients.signers[1].name = "test test2"; recipients.signers[1].email = "*****@*****.**"; Assert.IsTrue(envelope.UpdateRecipients(recipients, false)); Assert.IsNull(template.RestError); // send envelope envelope.Status = "sent"; Assert.IsTrue(envelope.UpdateStatus()); Assert.IsNull(template.RestError); }
//========================================================================================== // *** Walkthrough #8 - Embedded Signing //========================================================================================== private void EmbeddedSigning() { //***************************************************************** // ENTER VALUES FOR FOLLOWING VARIABLES! //***************************************************************** string AccountEmail = "***"; string AccountPassword = "******"; string EnvelopeId = "***"; string RecipientEmail = "***"; string RecipientName = "***"; //***************************************************************** // user credentials Account account = new Account(); account.Email = AccountEmail; account.Password = AccountPassword; // make the login call (retrieves your baseUrl and accountId) bool result = account.Login(); if (!result) { Console.WriteLine("Login API call failed for user {0}.\nError Code: {1}\nMessage: {2}", account.Email, account.RestError.errorCode, account.RestError.message); return; } // create envelope object and assign login info Envelope envelope = new Envelope(); envelope.Login = account; // assign the envelope id that was passed in envelope.EnvelopeId = EnvelopeId; // add one signer (single recipient embedded signing currently supported in DocuSign .NET Client) envelope.Recipients = new Recipients() { signers = new Signer[] { new Signer() { email = RecipientEmail, name = RecipientName, recipientId = "1" } } }; // generate the recipient view token result = envelope.GetRecipientView("http://www.nuget.org/packages/DocuSign.Integration.Client.dll/"); if (!result) { if (envelope.RestError != null) { Console.WriteLine("Error code: {0}\nMessage: {1}", envelope.RestError.errorCode, envelope.RestError.message); return; } else { Console.WriteLine("Error encountered retrieving signing token, please review your envelope and recipient data."); return; } } else { // open the recipient view (SenderViewUrl field is re-used for the recipient URL) Process.Start(envelope.SenderViewUrl); } }
public void EmbeddedSigningViewTest() { // create a new envelope with 2 recipients var envelope = new Envelope { Login = _account }; byte[] doc1 = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 }; var signers = new List<Signer>(); // note we need to specify clientUserId signers.Add(new Signer { email = "*****@*****.**", name = "test1", recipientId = "1", routingOrder = "1", clientUserId = "1" }); signers.Add(new Signer { email = "*****@*****.**", name = "test2", recipientId = "2", routingOrder = "2", clientUserId = "2" }); envelope.Recipients = new Recipients { signers = signers.ToArray() }; Assert.IsTrue(envelope.Create(doc1, "test-self-signed.doc")); Assert.IsNull(envelope.RestError); // send it envelope.Status = "sent"; Assert.IsTrue(envelope.UpdateStatus()); Assert.IsNull(envelope.RestError); // get embedded signing views for 2 recipients string urlForfirstSigner = envelope.GetEmbeddedSignerView("www.docusign.com", signers.First()); Assert.IsNull(envelope.RestError); Assert.IsFalse(string.IsNullOrEmpty(urlForfirstSigner)); string urlForSecondSigner = envelope.GetEmbeddedSignerView("www.docusign.com", signers.Last()); // now, this one won't work until first one signed (which cannot happen in this test) // this is because second recpieint was set to sign only after the first one finished (routing order) Assert.IsTrue(string.IsNullOrEmpty(urlForSecondSigner)); }
public void GetSearchFolderCountTest() { // Note: in order for this test to pass- you must have envelopes in these states var envelope = new Envelope { Login = _account }; int completed = envelope.GetSearchFolderCount("completed", DateTime.Today.AddMonths(-1)); Assert.IsNull(envelope.RestError); Assert.AreNotEqual(completed, 0); int waitingMe = envelope.GetSearchFolderCount("awaiting_my_signature", DateTime.Today.AddMonths(-1)); Assert.IsNull(envelope.RestError); Assert.AreNotEqual(waitingMe, 0); int waitingOthers = envelope.GetSearchFolderCount("out_for_signature", DateTime.Today.AddMonths(-1)); Assert.IsNull(envelope.RestError); Assert.AreNotEqual(waitingOthers, 0); }
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 EnvelopeCustomFieldsTest() { var envelope = new Envelope { Login = _account }; byte[] doc1 = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 }; var signers = new List<Signer>(); signers.Add(new Signer { email = "*****@*****.**", name = "test2", recipientId = "1", routingOrder = "1" }); envelope.Recipients = new Recipients { signers = signers.ToArray() }; Assert.IsTrue(envelope.Create(doc1, "test-self-signed.doc")); Assert.IsNull(envelope.RestError); var fields = new Dictionary<string, object>(); fields.Add("time", DateTime.Now); fields.Add("isUnitTest", true); fields.Add("unitTestName", "EnvelopeCustomFieldsTest"); Assert.IsTrue(envelope.AddCustomFields(fields)); Assert.IsNull(envelope.RestError); Assert.IsTrue(envelope.GetCustomFields()); Assert.IsNull(envelope.RestError); Assert.AreEqual(3, envelope.CustomFields.textCustomFields.Length); Assert.AreEqual("True", envelope.CustomFields.textCustomFields[1].value); }
public void EnvelopeCreateWithSmsAuthenticationDocumentTest() { ConfigLoader.LoadConfig(); bool expected = true; bool actual = false; Account acct = new Account(); acct.AccountName = Util.MakeUnique("freakin me out {unique}"); acct.Email = Util.MakeUnique("freakin_{unique}@gmail.com"); acct.Password = "******"; AddressInformation ai = new AddressInformation(); acct.Address = ai; ai.address1 = "123 Main ST"; ai.address2 = string.Empty; ai.city = "Anytown"; ai.country = "USA"; ai.postalCode = "11111"; ai.state = "WA"; CreditCardInformation cc = new CreditCardInformation(); acct.CreditCard = cc; cc.cardNumber = "4111111111111111"; cc.cardType = "visa"; cc.expirationMonth = "12"; cc.expirationYear = "2015"; cc.nameOnCard = "Freak Me Out"; try { actual = acct.Create(); } catch (Exception) { } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(acct.BaseUrl)); if (expected == actual) { Envelope target = new Envelope(); target.Login = acct; // add signers to the envelope target.Recipients = new Recipients() { signers = new Signer[] { new Signer() { email = "freakin_{unique}@gmail.com", name = "freakin", routingOrder = "1", recipientId = "1", requireIdLookup = "true", idCheckConfigurationName = "SMS Auth $", smsAuthentication = new SmsAuthentication() { senderProvidedNumbers = new string[] { String.Format("+{0} {1}", "34", "000000000") } } } } }; // Email subject is a required parameter when requesting signatures target.EmailSubject = "Example subject"; // "sent" to send immediately, "created" to save envelope as draft target.Status = "sent"; FileInfo fi = new FileInfo("./Test Contract.pdf"); string path = fi.FullName; actual = false; try { actual = target.Create(path); } catch (ArgumentNullException) { } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(target.SenderViewUrl)); } }
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 Envelope CreateEnvelope(ApplicationUser user, TemplateInfo templateInfo, string parentUserId) { try { if (user == null) throw new ArgumentNullException("user"); if (templateInfo == null) throw new ArgumentNullException("templateInfo"); var envelope = new Envelope { Login = Account, EmailSubject = user.Company, Status = "sent", TemplateId = templateInfo.Id, TemplateRoles = new[] { new TemplateRole { email = user.Email, name = string.Concat(user.FirstName, " ", user.LastName), roleName = "Signer", clientUserId = user.Id } } }; envelope.Create(); if (envelope.EnvelopeId != null) { _context.Envelopes.Add(new Envelopes { EnvelopeId = envelope.EnvelopeId, EnvelopeName = templateInfo.Name, UserId = parentUserId }); _context.SaveChanges(); return envelope; } } catch (Exception ex) { throw ex; } return null; }
public void EnvelopeCreateAddMemberWithDocumentTest() { ConfigLoader.LoadConfig(); bool expected = true; bool actual = false; Account acct = new Account(); acct.AccountName = Util.MakeUnique("ds client unit test {unique}"); acct.Email = Util.MakeUnique("ds_client_unit_{unique}@gmail.com"); acct.Password = "******"; try { actual = acct.Create(); } catch (Exception) { } Assert.AreEqual(expected, actual); AddUsers add = new AddUsers(); List<NewUser> userList = new List<NewUser>(); NewUser nu = new NewUser(); nu.userName = Util.MakeUnique("ds client unit test member {unique}"); nu.email = Util.MakeUnique("ds_client_unit_member_{unique}@gmail.com"); nu.sendActivationOnInvalidLogin = false.ToString(); nu.enableConnectForUser = true.ToString(); Guid g = Guid.NewGuid(); nu.password = g.ToString(); List<UserSetting> userSettings = new List<UserSetting>(); userSettings.Add(new UserSetting("canSendAPIRequests", "true")); userSettings.Add(new UserSetting("canSendEnvelope", "true")); userSettings.Add(new UserSetting("AllowSendOnBehalfOf", "true")); nu.userSettings = userSettings.ToArray(); userList.Add(nu); add.newUsers = userList.ToArray(); CreatedUsers added = null; try { added = acct.AddUser(add); } catch (Exception) { } Account member = new Account(); member.ApiPassword = added.NewUsers[0].ApiPassword; member.AccountId = added.NewUsers[0].UserId; member.Email = added.NewUsers[0].Email; //member.BaseUrl = added.NewUsers[0].Uri; bool log = member.Login(); Assert.IsNotNull(added); Envelope target = new Envelope(); target.Login = member; FileInfo fi = new FileInfo("./Test Contract.pdf"); string path = fi.FullName; actual = false; try { actual = target.Create(path); } catch (ArgumentNullException) { } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(target.SenderViewUrl)); }
//========================================================================================== // *** Walkthrough #2 - Get Envelope Information //========================================================================================== private void GetEnvelopeInformation() { //***************************************************************** // ENTER VALUES FOR FOLLOWING VARIABLES! //***************************************************************** string AccountEmail = "***"; string AccountPassword = "******"; string EnvelopeId = "***"; //***************************************************************** // user credentials Account account = new Account(); account.Email = AccountEmail; account.Password = AccountPassword; // make the login call (retrieves your baseUrl and accountId) bool result = account.Login(); if (!result) { Console.WriteLine("Login API call failed for user {0}.\nError Code: {1}\nMessage: {2}", account.Email, account.RestError.errorCode, account.RestError.message); return; } // create envelope object and assign login info Envelope envelope = new Envelope(); envelope.Login = account; DateTime sentTime = envelope.GetStatus(EnvelopeId); if (envelope.RestError != null) { Console.WriteLine("Error code: {0}\nMessage: {1}", envelope.RestError.errorCode, envelope.RestError.message); return; } Console.WriteLine("Envelope originally sent {0} currently has status: {1}\nEnvelope Email Subject is: {2}", sentTime, envelope.Status, envelope.EmailSubject); }
//========================================================================================== // *** Walkthrough #7 - Embedded Sending //========================================================================================== private void EmbeddedSending() { //***************************************************************** // ENTER VALUES FOR FOLLOWING VARIABLES! //***************************************************************** string AccountEmail = "***"; string AccountPassword = "******"; string documentPath = "***"; //***************************************************************** // user credentials Account account = new Account(); account.Email = AccountEmail; account.Password = AccountPassword; // make the login call (retrieves your baseUrl and accountId) bool result = account.Login(); if (!result) { Console.WriteLine("Login API call failed for user {0}.\nError Code: {1}\nMessage: {2}", account.Email, account.RestError.errorCode, account.RestError.message); return; } // create envelope object and assign login info Envelope envelope = new Envelope(); envelope.Login = account; // create a new DocuSign envelope (i.e. server side) envelope.Create(documentPath); // generate sender view token result = envelope.GetSenderView("http://www.nuget.org/packages/DocuSign.Integration.Client.dll/"); if (!result) { if (envelope.RestError != null) { Console.WriteLine("Error code: {0}\nMessage: {1}", envelope.RestError.errorCode, envelope.RestError.message); return; } else { Console.WriteLine("Error encountered retrieving signing token, please review your envelope and recipient data."); return; } } else { // open the envelope's sending view Process.Start(envelope.SenderViewUrl); } }
//========================================================================================== // *** Walkthrough #6 - Get Documents List and Download Documents //========================================================================================== private void GetDocsListAndDownloadDocuments() { //***************************************************************** // ENTER VALUES FOR FOLLOWING VARIABLES! //***************************************************************** string AccountEmail = "***"; string AccountPassword = "******"; string EnvelopeId = "***"; //***************************************************************** // user credentials Account account = new Account(); account.Email = AccountEmail; account.Password = AccountPassword; // make the login call (retrieves your baseUrl and accountId) bool result = account.Login(); if (!result) { Console.WriteLine("Login API call failed for user {0}.\nError Code: {1}\nMessage: {2}", account.Email, account.RestError.errorCode, account.RestError.message); return; } // create envelope object and assign login info Envelope envelope = new Envelope(); envelope.Login = account; // assign the passed in envelope id to the newly created envelope object envelope.EnvelopeId = EnvelopeId; // get the envelope's documents List<EnvelopeDocument> envDocs = envelope.GetDocuments(); // loop through the documents and display some info about them foreach (var doc in envDocs) { Console.WriteLine("Document id {0} is named {1}.", doc.documentId, doc.name); } // now let's download the actual document bytes and store in a local file in the application's main directory string applicationPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); byte[] completedDocBytes = envelope.GetCompletedDocument(EnvelopeId, true); // set local document name here, currently using envelopeID.pdf as name string localFileName = applicationPath + "\\" + EnvelopeId + ".pdf"; // combine all envelope documents (including certificate) into local PDF file File.WriteAllBytes(localFileName, completedDocBytes); Console.WriteLine("Completed documents have been downloaded to {0}", localFileName); }
//========================================================================================== // *** Walkthrough #4 - Request Signature on Document //========================================================================================== private void SignatureRequestOnDocument() { //***************************************************************** // ENTER VALUES FOR FOLLOWING VARIABLES! //***************************************************************** string AccountEmail = "***"; string AccountPassword = "******"; string RecipientEmail = "***"; string RecipientName = "***"; string documentPath = "***"; //***************************************************************** // user credentials Account account = new Account(); account.Email = AccountEmail; account.Password = AccountPassword; // make the login call (retrieves your baseUrl and accountId) bool result = account.Login(); if (!result) { Console.WriteLine("Login API call failed for user {0}.\nError Code: {1}\nMessage: {2}", account.Email, account.RestError.errorCode, account.RestError.message); return; } // create envelope object and assign login info Envelope envelope = new Envelope(); envelope.Login = account; // add one signer to the envelope envelope.Recipients = new Recipients() { signers = new Signer[] { new Signer() { email = RecipientEmail, name = RecipientName, routingOrder = "1", recipientId = "1" } } }; // send the envelope immediately (otherwise set to "created" to save as draft envelope) envelope.Status = "sent"; // email subject is required envelope.EmailSubject = "DocuSign .NET Client - Signature Request on Document"; // create envelope and send the signature request (since status is set to "sent") result = envelope.Create(documentPath); if (!result) { if (envelope.RestError != null) { Console.WriteLine("Error code: {0}\nMessage: {1}", envelope.RestError.errorCode, envelope.RestError.message); return; } else { Console.WriteLine("Error encountered while requesting signature from template, please review your envelope and recipient data."); return; } } else { Console.WriteLine("Signature request has been sent to {0}, envelopeId is {1}.", envelope.Recipients.signers[0].email, envelope.EnvelopeId); } }
//========================================================================================== // *** Walkthrough #3 - Get Recipient Information //========================================================================================== private void GetEnvelopeRecipientInformation() { //***************************************************************** // ENTER VALUES FOR FOLLOWING VARIABLES! //***************************************************************** string AccountEmail = "***"; string AccountPassword = "******"; string EnvelopeId = "***"; //***************************************************************** // user credentials Account account = new Account(); account.Email = AccountEmail; account.Password = AccountPassword; // make the login call (retrieves your baseUrl and accountId) bool result = account.Login(); if (!result) { Console.WriteLine("Login API call failed for user {0}.\nError Code: {1}\nMessage: {2}", account.Email, account.RestError.errorCode, account.RestError.message); return; } // create envelope object and assign login info Envelope envelope = new Envelope(); envelope.Login = account; // set the envelopeId for which we will retrieve recipient info from envelope.EnvelopeId = EnvelopeId; // Retrieve envelope recipient names var recipNames = envelope.GetRecipientNames(); if (envelope.RestError != null) { Console.WriteLine("Error code: {0}\nMessage: {1}", envelope.RestError.errorCode, envelope.RestError.message); return; } Console.WriteLine("Envelope contains following recipients:\n"); foreach (var name in recipNames) { Console.WriteLine("\t{0}", name); } }
//========================================================================================== // *** Walkthrough #1 - Request Signature from Template //========================================================================================== private void SignatureRequestFromTemplate() { //***************************************************************** // ENTER VALUES FOR FOLLOWING VARIABLES! //***************************************************************** string AccountEmail = "***"; string AccountPassword = "******"; string RecipientEmail = "***"; string RecipientName = "***"; string TemplateId = "***"; string TemplateRoleName = "***"; //***************************************************************** // user credentials Account account = new Account(); account.Email = AccountEmail; account.Password = AccountPassword; // make the login call (retrieves your baseUrl and accountId) bool result = account.Login(); if (!result) { Console.WriteLine("Login API call failed for user {0}.\nError Code: {1}\nMessage: {2}", account.Email, account.RestError.errorCode, account.RestError.message); return; } // create envelope object and assign login info Envelope envelope = new Envelope(); envelope.Login = account; // use an existing server template envelope.TemplateId = TemplateId; // add one signer to a template role identified by roleName envelope.TemplateRoles = new TemplateRole[] { new TemplateRole() { email = RecipientEmail, name = RecipientName, roleName = TemplateRoleName } }; // Email subject is a required parameter when requesting signatures envelope.EmailSubject = "DocuSign .NET Client - Signature Request from Template"; // "sent" to send immediately, "created" to save envelope as draft envelope.Status = "sent"; // create and send the envelope (since status is set to "sent") result = envelope.Create(); if (!result) { if (envelope.RestError != null) { Console.WriteLine("Error code: {0}\nMessage: {1}", envelope.RestError.errorCode, envelope.RestError.message); return; } else { Console.WriteLine("Error encountered while requesting signature from template, please review your envelope and recipient data."); return; } } else { Console.WriteLine("Signature request has been sent to {0}, envelopeId is {1}", envelope.TemplateRoles[0].email, envelope.EnvelopeId); } }
public void GetAuditEvents() { const string envelopeId = "83acwc73-6267-4f62-b937-04b7203d467c"; bool expected = true; bool actual = true; //need to add account details in LoadConfig ConfigLoader.LoadConfig(); 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 = envelopeId; try { var result = target.GetEnvelopeAuditEvents(envelopeId); } catch (Exception ex) { Assert.Fail("Unexpected exception during test {0}: {1}", ex.GetType(), ex.Message); return; } }
public void EnvelopeCreateNotLoggedIn() { ConfigLoader.LoadConfig(); bool expected = false; bool actual = false; Envelope target = new Envelope(); Account acct = new Account(); acct.AccountName = Util.MakeUnique("freakin me out {unique}"); acct.Email = Util.MakeUnique("freakin_{unique}@gmail.com"); acct.Password = "******"; try { target.Login = acct; actual = target.Create(string.Empty); } catch(ArgumentNullException) { } Assert.AreEqual(expected, actual); }
public void CreateEnvelopeFromStreamTest() { var envelope = new Envelope { Login = _account }; byte[] byteArray = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 }; var doc1 = new MemoryStream(byteArray); envelope.Status = "sent"; var signers = new List<Signer>(); signers.Add(new Signer { email = _account.Email, name = _account.AccountName, recipientId = "1", routingOrder = "1" }); envelope.Recipients = new Recipients { signers = signers.ToArray() }; Assert.IsTrue(envelope.Create(doc1, "test-self-signed.doc")); Assert.IsNull(envelope.RestError); Assert.IsTrue(envelope.GetRecipientView()); Assert.IsNull(envelope.RestError); // note SenderViewUrl in this case is the Signer view (Recipient) Assert.IsNotNull(envelope.SenderViewUrl); }
public void EnvelopeCreateWithDocumentTest() { ConfigLoader.LoadConfig(); bool expected = true; bool actual = false; Account acct = new Account(); acct.AccountName = Util.MakeUnique("freakin me out {unique}"); acct.Email = Util.MakeUnique("freakin_{unique}@gmail.com"); acct.Password = "******"; AddressInformation ai = new AddressInformation(); acct.Address = ai; ai.address1 = "123 Main ST"; ai.address2 = string.Empty; ai.city = "Anytown"; ai.country = "USA"; ai.postalCode = "11111"; ai.state = "WA"; CreditCardInformation cc = new CreditCardInformation(); acct.CreditCard = cc; cc.cardNumber = "4111111111111111"; cc.cardType = "visa"; cc.expirationMonth = "12"; cc.expirationYear = "2015"; cc.nameOnCard = "Freak Me Out"; try { actual = acct.Create(); } catch (Exception) { } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(acct.BaseUrl)); Envelope target = new Envelope(); target.Login = acct; FileInfo fi = new FileInfo("./Test Contract.pdf"); string path = fi.FullName; actual = false; try { actual = target.Create(path); } catch (ArgumentNullException) { } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(target.SenderViewUrl)); }
public void RecipientsEndToEndTest() { var envelope = new Envelope { Login = _account }; byte[] doc1 = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 }; var signers = new List<Signer>(); var ccs = new List<Signer>(); signers.Add(new Signer { email = "*****@*****.**", name = "test2", recipientId = "1", routingOrder = "1" }); ccs.Add(new Signer { email = _account.Email, name = _account.AccountName, recipientId = "2", routingOrder = "2" }); envelope.Recipients = new Recipients { signers = signers.ToArray(), carbonCopies = ccs.ToArray() }; Assert.IsTrue(envelope.Create(doc1, "test-self-signed.doc")); Assert.IsNull(envelope.RestError); Assert.AreEqual(2, envelope.GetRecipientNames().Count()); // add more recipients signers.Clear(); ccs.Clear(); ccs.Add(new Signer { email = "*****@*****.**", name = "test2", recipientId = "3", routingOrder = "4" }); signers.Add(new Signer { email = _account.Email, name = _account.AccountName, recipientId = "4", routingOrder = "3" }); Assert.IsTrue(envelope.AddRecipients(new Recipients { signers = signers.ToArray(), carbonCopies = ccs.ToArray() })); Assert.IsNull(envelope.RestError); Assert.AreEqual(4, envelope.GetRecipientNames().Count()); Assert.AreEqual((string)(envelope.GetFirstRecipients().First()["email"]), "*****@*****.**"); }
public void EnvelopeCreateNoDocument() { ConfigLoader.LoadConfig(); bool expected = true; bool actual = true; Account acct = new Account(); acct.AccountName = Util.MakeUnique("freakin me out {unique}"); acct.Email = Util.MakeUnique("freakin_{unique}@gmail.com"); acct.Password = "******"; try { actual = acct.Create(); } catch (Exception) { } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(acct.BaseUrl)); Envelope target = new Envelope(); target.Login = acct; actual = false; try { actual = target.Create(string.Empty); } catch (ArgumentNullException) { } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(target.SenderViewUrl)); }
public void AddEmailSubjectAndBlurbToExisitingEnvelopeAndVeryifyStatusTest() { var envelope = new Envelope { Login = _account }; byte[] doc1 = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 }; var signers = new List<Signer>(); signers.Add(new Signer { email = "*****@*****.**", name = "test2", recipientId = "1", routingOrder = "1" }); envelope.Recipients = new Recipients { signers = signers.ToArray()}; Assert.IsTrue(envelope.Create(doc1, "test-self-signed.doc")); Assert.IsNull(envelope.RestError); Assert.IsTrue(envelope.AddEmailInformation("DocuSign Client Tests Message", "DocuSign Client Tests Message")); Assert.IsNull(envelope.RestError); var time = envelope.GetStatus(envelope.EnvelopeId); Assert.AreEqual("created", envelope.Status); // envelope was created very recently... Assert.IsTrue(DateTime.Now.Subtract(time).Ticks < 10000); // send envelope envelope.Status = "sent"; envelope.UpdateStatus(); }
public void EnvelopeCreateWithDocumentObjectsAndGetDocumentFieldsTest() { const bool expected = true; const string expectedDocumentAttributeName = "Document Attribute Name"; const string expectedDocumentAttributeValue = "Document Attribute Value"; var actual = false; Assert.IsFalse(string.IsNullOrEmpty(_account.BaseUrl)); var target = new Envelope { Login = _account }; var fi = new FileInfo("./Test Contract.pdf"); var documentCustomFields = new List<DocumentField> { new DocumentField {name = expectedDocumentAttributeName, value = expectedDocumentAttributeValue} }; var documents = new List<Document> { new Document { attachmentDescription = fi.Name.Replace(fi.Extension, string.Empty), documentId = "1", documentFields = documentCustomFields.ToArray(), fileExtension = fi.Extension, name = fi.Name } }; var fileBytes = new List<Byte[]> { File.ReadAllBytes(fi.FullName) }; try { actual = target.Create(fileBytes, documents); } catch (ArgumentNullException) { } Assert.AreEqual(expected, actual); Assert.IsFalse(string.IsNullOrEmpty(target.SenderViewUrl)); var actualDocuments = target.GetDocuments(); Assert.AreEqual(documents.Count, actualDocuments.Count); for (var i = 0; i < documents.Count; i++) { Assert.AreEqual(documents[i].documentId, actualDocuments[i].documentId); Assert.AreEqual(documents[i].name, actualDocuments[i].name); var fields = target.GetDocumentFields(documents[i].documentId); Assert.AreEqual(documents[i].documentFields.Count(), fields.documentFields.Count()); for (var j = 0; j < documents[i].documentFields.Count(); j++) { Assert.AreEqual(documents[i].documentFields[j].name, fields.documentFields[j].name); Assert.AreEqual(documents[i].documentFields[j].value, fields.documentFields[j].value); } } }
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; }