コード例 #1
0
        public void EmbeddedConsoleTest()
        {
            try
            {
                // create draft envelope structure
                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                envDef.EmailSubject = "EmbeddedConsoleTest";

                // call login to authenticate and get default accountId
                AuthenticationApiTests loginTests = new AuthenticationApiTests();
                loginTests.LoginTest();

                // create the Draft envelope on the DocuSign Service
                EnvelopesApi envelopesApi = new EnvelopesApi();
                EnvelopeSummary envSummary = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(envSummary);
                Assert.IsNotNull(envSummary.EnvelopeId);

                // Start the embedded sending session
                ReturnUrlRequest urlRequest = new ReturnUrlRequest();
                urlRequest.ReturnUrl = TestConfig.DefaultReturnUrl;

                // Adding the envelopeId start sthe console with the envelope open
                ConsoleViewRequest consoleViewRequest = new ConsoleViewRequest();
                consoleViewRequest.EnvelopeId = envSummary.EnvelopeId;
                ViewUrl viewUrl = envelopesApi.CreateConsoleView(TestConfig.AccountId, consoleViewRequest);

                // Start the embedded signing session.
                System.Diagnostics.Process.Start(viewUrl.Url);
            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
コード例 #2
0
        public void RequestSignatureViaTemplateTest()
        {
            try
            {
                // upload template if one doesn't exist
                // FAILED - CANT UPLOAD A TEMPLATE - API-3002 submitted
                // use predefined template
                AuthenticationApiTests authTests = new AuthenticationApiTests();
                authTests.LoginTest();

                // get pre-existing template with Signer1 role
                // since I can't upload a template right now
                TemplatesApi templatesApi = new TemplatesApi();
                EnvelopeTemplateResults templateResults = templatesApi.ListTemplates(TestConfig.AccountId);
                Assert.IsNotNull(templateResults);
                Assert.IsNotNull(templateResults.EnvelopeTemplates);
                string templateId = null;
                foreach (EnvelopeTemplateResult et in templateResults.EnvelopeTemplates)
                {
                    if (et.Name == "Test Template")
                    {
                        templateId = et.TemplateId;
                        break;
                    }
                }
                Assert.IsNotNull(templateId);

                EnvelopeDefinition envDef = new EnvelopeDefinition();
                envDef.TemplateId = templateId;

                envDef.TemplateRoles = new List<TemplateRole>();
                TemplateRole templateRole = new TemplateRole();
                templateRole.Email = TestConfig.DefaultEmail;
                templateRole.Name = TestConfig.DefaultName;
                templateRole.RoleName = "Signer1";
                envDef.TemplateRoles.Add(templateRole);
                envDef.Status = "sent"; // trigger the envelope to be sent (vs. Draft/Created)

                // send envelope using template roles
                EnvelopesApi envelopesApi = new EnvelopesApi();
                EnvelopeSummary es = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(es);
                Assert.IsNotNull(es.EnvelopeId);
                Trace.WriteLine("Envelope: " + es.ToJson());

            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
コード例 #3
0
        public void RequestSignatureOnADocumentTest()
        {
            try
            {

                // get the logininformation and accountId
                AuthenticationApiTests loginTests = new AuthenticationApiTests();
                loginTests.LoginTest();

                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                // send the envelope (otherwise it will be "created" in the Draft folder
                envDef.EmailSubject = "RequestSignatureOnADocumentTest";
                envDef.Status = "sent";

                EnvelopesApi envelopesApi = new EnvelopesApi();
                //   EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(envelopeSummary);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(envelopeSummary.EnvelopeId));

                // store for use in other tests.
                TestConfig.EnvelopeId = envelopeSummary.EnvelopeId;

            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
コード例 #4
0
        public void GetEnvelopeInformationTest()
        {
            try
            {
                // get the logininformation and accountId
                AuthenticationApiTests loginTests = new AuthenticationApiTests();
                loginTests.LoginTest();

                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                // send the envelope (otherwise it will be "created" in the Draft folder
                envDef.EmailSubject = "GetEnvelopeInformationTest";
                envDef.Status = "sent";

                EnvelopesApi envelopesApi = new EnvelopesApi();
                EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(envelopeSummary);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(envelopeSummary.EnvelopeId));

                // Get the status of the envelope
                Envelope envelope = envelopesApi.GetEnvelope(TestConfig.AccountId, envelopeSummary.EnvelopeId, null);
                Assert.IsNotNull(envelope);
                Assert.IsNotNull(envelope.Status);
                Assert.IsNotNull(envelope.EnvelopeId);
                Trace.WriteLine("Envelope: " + envelope.ToJson());

            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
コード例 #5
0
        public static void Execute()
        {
            // Enter your DocuSign credentials
            var credentials = new DocusignQuickStart.DocusignCredentials
            {
                Username = "******",
                Password = "******",
                IntegratorKey = "81f3bae3-f472-4a51-8d5f-e966f74cb0ab"
            };

            // specify the document (file) we want signed
            string SignTest1File = @"C:\Users\callu_000\Documents\UD Group\Docusign\CNG\CNG Contract.pdf";

            // Enter recipient (signer) name and email address
            string recipientName = "Callum Rigby";
            string recipientEmail = "*****@*****.**";

            string recipientName2 = "John Smith";
            string recipientEmail2 = "*****@*****.**";

            // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi)
            string basePath = "https://demo.docusign.net/restapi";

            // instantiate a new api client
            var apiClient = new ApiClient(basePath);

            // set client in global config so we don't need to pass it to each API object
            Configuration.Default.ApiClient = apiClient;

            string authHeader = JsonConvert.SerializeObject(credentials);
            //DocusignCredentials cred = JsonConvert.DeserializeObject<DocusignCredentials>(authHeader);
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // we will retrieve this from the login() results
            string accountId = null;

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            var authApi = new AuthenticationApi();
            LoginInformation loginInfo = authApi.Login();

            // user might be a member of multiple accounts
            accountId = loginInfo.LoginAccounts[0].AccountId;

            Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson());

            // Read a file from disk to use as a document
            byte[] fileBytes = File.ReadAllBytes(SignTest1File);

            var envDef = new EnvelopeDefinition();
            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // Add a document to the envelope
            var doc = new Document();
            doc.DocumentBase64 = Convert.ToBase64String(fileBytes);
            doc.Name = "TestFile.pdf";
            doc.DocumentId = "1";

            envDef.Documents = new List<Document>();
            envDef.Documents.Add(doc);

            // Add a recipient to sign the documeent
            var signer = new Signer();
            signer.Name = recipientName;
            signer.Email = recipientEmail;
            signer.RecipientId = "1";
            signer.RoutingOrder = "1";

            var signer2 = new Signer();
            signer2.Name = recipientName2;
            signer2.Email = recipientEmail2;
            signer2.RecipientId = "2";
            signer.RoutingOrder = "2";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List<SignHere>();
            var signHere = new SignHere();
            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.RecipientId = "1";
            signHere.XPosition = "100";
            signHere.YPosition = "150";
            signer.Tabs.SignHereTabs.Add(signHere);

            signer2.Tabs = new Tabs();
            signer2.Tabs.SignHereTabs = new List<SignHere>();
            var signHere2 = new SignHere();
            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.RecipientId = "2";
            signHere.XPosition = "100";
            signHere.YPosition = "200";
            signer2.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients = new Recipients();
            envDef.Recipients.Signers = new List<Signer>();
            envDef.Recipients.Signers.Add(signer);
            envDef.Recipients.Signers.Add(signer2);

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

            // Use the EnvelopesApi to send the signature request!
            var envelopesApi = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            // print the JSON response
            Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
            Console.Read();
        }
コード例 #6
0
        static void Main(string[] args)
        {
            // Enter your DocuSign credentials
            string Username = "******";
            string Password = "******";
            string IntegratorKey = "[INTEGRATOR_KEY]";

            // specify the document (file) we want signed
            string SignTest1File = @"[PATH/TO/DOCUMENT/TEST.PDF]";

            // Enter recipient (signer) name and email address
            string recipientName = "[SIGNER_NAME]";
            string recipientEmail = "[SIGNER_EMAIL]";

            // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi)
            string basePath = "https://demo.docusign.net/restapi";

            // instantiate a new api client
            ApiClient apiClient = new ApiClient(basePath);

            // set client in global config so we don't need to pass it to each API object
            Configuration.Default.ApiClient = apiClient;

            string authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegratorKey + "\"}";
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // we will retrieve this from the login() results
            string accountId = null;

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi = new AuthenticationApi();
            LoginInformation loginInfo = authApi.Login();

			// user might be a member of multiple accounts
            accountId = loginInfo.LoginAccounts[0].AccountId;

            Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson());

            // Read a file from disk to use as a document
            byte[] fileBytes = File.ReadAllBytes(SignTest1File);

            EnvelopeDefinition envDef = new EnvelopeDefinition();
            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // Add a document to the envelope
            Document doc = new Document();
            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name = "TestFile.pdf";
            doc.DocumentId = "1";

            envDef.Documents = new List<Document>();
            envDef.Documents.Add(doc);

            // Add a recipient to sign the documeent
            Signer signer = new Signer();
            signer.Name = recipientName;
            signer.Email = recipientEmail;            
            signer.RecipientId = "1";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List<SignHere>();
            SignHere signHere = new SignHere();
            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.RecipientId = "1";
            signHere.XPosition = "100";
            signHere.YPosition = "150";
            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients = new Recipients();
            envDef.Recipients.Signers = new List<Signer>();
            envDef.Recipients.Signers.Add(signer);

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

            // Use the EnvelopesApi to send the signature request!
            EnvelopesApi envelopesApi = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            // print the JSON response
            Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
            Console.Read();
        }
コード例 #7
-1
        public void EmbeddedSigningTest()
        {
            try
            {
                AuthenticationApiTests loginTests = new AuthenticationApiTests();
                loginTests.LoginTest();
                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                envDef.Status = "sent";
                envDef.EmailSubject = "Please Sign my C# SDK Envelope";
                string clientUserId = "1234";
                envDef.Recipients.Signers[0].ClientUserId = clientUserId;

                EnvelopesApi envelopesApi = new EnvelopesApi();

                EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(envelopeSummary);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(envelopeSummary.EnvelopeId));

                // get a URL that can be placed in a browser or embedded in an IFrame
                string returnUrl = TestConfig.DefaultReturnUrl;
                RecipientViewRequest recipientView = new RecipientViewRequest()
                {
                    ReturnUrl = returnUrl,
                    ClientUserId = clientUserId,
                    AuthenticationMethod = "email",
                    UserName = envDef.Recipients.Signers[0].Name,
                    Email = envDef.Recipients.Signers[0].Email
                };

                ViewUrl viewUrl = envelopesApi.CreateRecipientView(TestConfig.AccountId, envelopeSummary.EnvelopeId, recipientView);
                Assert.IsNotNull(viewUrl);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(viewUrl.Url));
                Trace.WriteLine("ViewUrl is " + viewUrl);

                /// Start a browser to Sign
                System.Diagnostics.Process.Start(viewUrl.Url);
            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }