public void GetPlansForDistributor()
        {
            ConfigLoader.LoadConfig();

            Plans actual = null;

            Account acct = new Account();
            //acct.Email = "*****@*****.**";
            //acct.Password = "******";

            //if (acct.Login() == false)
            //{
            //    return;
            //}

            try
            {
                actual = acct.BillingPlans();
            }
            catch (Exception)
            {
            }

            Assert.IsNotNull(actual);
        }
 public void InitializeAccount()
 {
     ConfigLoader.LoadConfig();
     //TODO - udpate these values with valid user/password for demo
     string email = "";
     string password = "";
     _account = new Account { Email = email, Password = password };
     Assert.IsTrue(_account.Login());
 }
        public void AccountCreate()
        {
            try
            {
                bool expected = true;
                bool actual = false;

                ConfigLoader.LoadConfig();

                Account acct = new Account();
                //acct.Email = "*****@*****.**";
                //acct.Password = "******";
                //acct.AccountName = "Fester Rester";
                acct.Password = Guid.NewGuid().ToString();

                acct.AccountName = Util.MakeUnique("freakin me out {unique}");
                acct.Email = Util.MakeUnique("freakin_{unique}@gmail.com");

                //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 = "4111 1111 1111 1111";
                //cc.cardType = "visa";
                //cc.expirationMonth = "12";
                //cc.expirationYear = "2015";
                //cc.nameOnCard = "Freak Me Out";

                try
                {
                    actual = acct.Create();
                }
                catch (Exception)
                {
                }

                Assert.AreEqual(expected, actual);
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }
        }
        public static void MyClassInitialize(TestContext testContext)
        {
            ConfigLoader.LoadConfig();
            _account = ConfigLoader.RetrieveTestAccount();

            try
            {
                if (!_account.Login())
                    Assert.Fail("Unexpected exception during account creation part of test {0}: {1}", _account.RestError.errorCode, _account.RestError.message);
            }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception during account creation part of test {0}: {1}", ex.GetType(), ex.Message);
            }
        }
        public void GetPlanDetails()
        {
            ConfigLoader.LoadConfig();

            Plan actual = null;

            Account acct = new Account();

            try
            {
                actual = acct.BillingPlan("8844269c-be6d-4b33-9d9f-f4895fdbbb16");
            }
            catch (Exception)
            {
            }

            Assert.IsNotNull(actual);
        }
        public DocuSignService(string signAddress, string serviceUrl, string integratorKey, string email, string password)
        {
            RestSettings.Instance.DocuSignAddress = signAddress;
            RestSettings.Instance.WebServiceUrl = serviceUrl;
            RestSettings.Instance.IntegratorKey = integratorKey;

            _account = new Account
            {
                Email = email,
                Password = password
            };

            if (!_account.Login())
            {
                throw new Exception("Login failed!");
            }

            _template = new Template {Login = _account};
        }
        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));
        }
Example #8
0
        //==========================================================================================
        // *** 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);
        }
        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);
        }
Example #10
0
        //==========================================================================================
        // *** 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);
            }

        }
        public void EnvelopeGetRecipients()
        {
            ConfigLoader.LoadConfig();

            bool expected = true;
            bool actual = true;

            Account acct = new Account();

            // $TODO: Add creds for known account
            acct.Email = "";
            acct.Password = "";
            acct.AccountName = "";

            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 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));
        }
Example #13
0
        //==========================================================================================
        // *** 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);
            }
        }
Example #14
0
        //==========================================================================================
        // *** 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);
            }
        }
        public void AccountCreateSocialNoUserName()
        {
            ConfigLoader.LoadConfig();

            bool expected = false;
            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 = "******";

            acct.Social = new SocialAccountInformation();
            acct.Social.email = acct.Email;
            acct.Social.provider = "FaceBook";
            acct.Social.socialId = string.Empty;
            acct.Social.userName = string.Empty;

            try
            {
                actual = acct.Create();
            }
            catch(Exception)
            {
                actual = false;
            }

            Assert.AreEqual(expected, actual);
        }
 public void InitializeAccount()
 {
     ConfigLoader.LoadConfig();
     _account = ConfigLoader.RetrieveTestAccount();
     Assert.IsTrue(_account.Login());
 }
        public void AccountCreateNoPassword()
        {
            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 = string.Empty;

            try
            {
                actual = acct.Create();
            }
            catch(Exception)
            {
                actual = false;
            }

            Assert.AreEqual(expected, actual);
        }
Example #18
0
        //==========================================================================================
        // *** 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);
            }
        }
Example #19
0
        //==========================================================================================
        // *** Walkthrough #9 - Embedded DocuSign Console
        //==========================================================================================
        private void EmbeddedDocuSignConsole()
        {
            //*****************************************************************
            // ENTER VALUES FOR FOLLOWING VARIABLES!
            //*****************************************************************
            string AccountEmail = "***";
            string AccountPassword = "******";
            //*****************************************************************

            // 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;
            }

            // generate user console URL 
            result = account.GetUserConsoleView();

            if (!result)
            {
                if (account.RestError != null)
                {
                    Console.WriteLine("Error code:  {0}\nMessage:  {1}", account.RestError.errorCode, account.RestError.message);
                    return;
                }
                else
                {
                    Console.WriteLine("Error encountered retrieving signing token, please review your envelope and recipient data.");
                    return;
                }
            }
            else
            {
                // open the DocuSign Console View
                Process.Start(account.ConsoleUrl);
            }
        }
Example #20
0
        //==========================================================================================
        // *** 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 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 AccountLoginNoPassword()
        {
            ConfigLoader.LoadConfig();

            bool expected = false;
            bool actual = true;

            // create a new account
            Account acct = new Account();
            acct.AccountName = Util.MakeUnique("freakin me out {unique}");
            acct.Email = Util.MakeUnique("freakin_{unique}@gmail.com");
            acct.Password = string.Empty;

            try
            {
                actual = acct.Login();
            }
            catch(Exception)
            {
                actual = false;
            }

            Assert.AreEqual(expected, actual);
            Assert.IsTrue(string.IsNullOrEmpty(acct.BaseUrl));
            Assert.IsTrue(string.IsNullOrEmpty(acct.ApiPassword));
        }
        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 AccountCreateAddUser()
        {
            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)
            {
            }

            Assert.IsNotNull(added);
        }
        public void AccountCreateSocial()
        {
            ConfigLoader.LoadConfig();

            bool expected = true;
            bool actual = false;

            Account acct = new Account();
            acct.AccountName = Util.MakeUnique("restclienttest {unique}");
            acct.Email = Util.MakeUnique("restclienttest_{unique}@gmail.com");
            //acct.AccountName = "Trinity UltraStar";
            //acct.Email = "*****@*****.**";
            acct.Password = Guid.NewGuid().ToString();

            acct.Social = new SocialAccountInformation();
            acct.Social.email = acct.Email;
            acct.Social.provider = "Google";
            acct.Social.socialId = Util.MakeUnique("{unique}");
            acct.Social.userName = acct.AccountName;

            try
            {
                actual = acct.Create();
                var trace = acct.RestTrace;

                Assert.AreEqual(expected, actual);

                if (actual == true)
                {
                    actual = false;
                    acct.Password = string.Empty;
                    acct.Email = acct.AccountIdGuid.ToString();
                    actual = acct.Login();
                    trace = acct.RestTrace;

                    Assert.AreEqual(expected, actual);
                }
            }
            catch (Exception)
            {
                actual = false;
            }

            Assert.AreEqual(expected, actual);
        }
Example #26
0
        //==========================================================================================
        // *** 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);
        }