public void Can_verify_invalid_SendSignatureRequestData_FileUrls()
 {
     var data = new HSSendSignatureRequestData
     {
         FileUrls = new List<string> {"http://example.com/pdf"},
     };
     Assert.False(data.IsValid);
 }
 public void Can_verify_invalid_SendSignatureRequestData_empty_FileUrls()
 {
     var data = new HSSendSignatureRequestData
     {
         FileUrls = new List<string>()
     };
     Assert.False(data.IsValid);
 }
 public void Can_verify_invalid_SendSignatureRequestData_Files()
 {
     var data = new HSSendSignatureRequestData
     {
         Files = new List<FileInfo> { new FileInfo("dummyfile.pdf") },
     };
     Assert.False(data.IsValid);
 }
 public void Can_verify_invalid_SendSignatureRequestData_FileUrls_and_Files()
 {
     var data = new HSSendSignatureRequestData
     {
         Signers = new List<HSSigner> {new HSSigner {Name = "John", EmailAddress = "*****@*****.**"}},
         Files = new List<FileInfo> { new FileInfo("dummyfile.pdf") },
         FileUrls = new List<string> {"http://example.com/pdf"},
     };
     Assert.Equal(false, data.IsValid);
 }
        public void Send_SignatureRequest_FileUrls_Response_Test()
        {
            var requestData = new HSSendSignatureRequestData
            {
                Title = "NDA for Project X",
                Subject = "NDA We Talk about",
                Message = "Bla Bla Bla",
                Signers = new List<HSSigner> { new HSSigner { Name = "John", EmailAddress = "*****@*****.**", Order = "1", Pin = "1234" } },
                FileUrls = new List<string> { "http://www.hollywood-arts.org/wp-content/uploads/2014/05/pdf-sample.pdf" },
            };

            using (var httpClient = FakeClientWithJsonResponse("TestData\\SignatureRequest.json"))
            {
                var apiClient = new HelloSignClient(httpClient);
                var t = apiClient.SendSignatureRequest(requestData);

                Assert.Equal("a9f4825edef25f47e7b", t.Result.SignatureRequest.SignatureRequestId);
            }
        }
        public void Send_SignatureRequest_Files_Response_Test()
        {
            var requestData = new HSSendSignatureRequestData
            {
                Title = "NDA for Project X",
                Subject = "NDA We Talk about",
                Message = "Bla Bla Bla",
                Signers = new List<HSSigner> {new HSSigner {Name = "John", EmailAddress = "*****@*****.**"}},
                Files = new List<FileInfo> {new FileInfo("TestData\\pdf-sample.pdf")}
            };

            using (var httpClient = FakeClientWithJsonResponse("TestData\\SignatureRequest.json"))
            {
                var apiClient = new HelloSignClient(httpClient);
                var t = apiClient.SendSignatureRequest(requestData);
                t.Wait();
                Assert.Equal("a9f4825edef25f47e7b", t.Result.SignatureRequest.SignatureRequestId);
            }
        }
        public void Send_Invalid_SignatureRequest_Get_Exception()
        {
            var requestData = new HSSendSignatureRequestData
            {
                Title = "NDA for Project X",
                Subject = "NDA We Talk about",
                Message = "Bla Bla Bla",
                Files = new List<FileInfo> {new FileInfo("TestData\\pdf-sample.pdf")}
            };

            using (var httpClient = FakeClientWithJsonResponse("TestData\\SignatureRequest.json"))
            {
                var apiClient = new HelloSignClient(httpClient);

                Assert.Throws<ArgumentException>(() => {
                    apiClient.SendSignatureRequest(requestData);
                });
            }
        }
 public void Can_verify_invalid_SendSignatureRequestData_Signer_info_email()
 {
     var data = new HSSendSignatureRequestData
     {
         Signers = new List<HSSigner> {new HSSigner {EmailAddress = "*****@*****.**" }},
         FileUrls = new List<string> {"http://example.com/pdf"},
     };
     Assert.Equal(false, data.IsValid);
 }
 public void Can_verify_invalid_SendSignatureRequestData_non_empty_Files_and_FileUrls()
 {
     var data = new HSSendSignatureRequestData
     {
         Files = new List<FileInfo> { new FileInfo("dummyfile.pdf") },
         FileUrls = new List<string> {"http://example.com/pdf"},
     };
     Assert.Equal(false, data.IsValid);
 }
Esempio n. 10
0
        public void Can_verify_Valid_SendSignatureRequestData_FileUrls()
        {
            var data = new HSSendSignatureRequestData
            {
                Signers = new List<HSSigner> {new HSSigner {Name = "John", EmailAddress = "*****@*****.**"}},
                FileUrls = new List<string> {"http://example.com/pdf"}
            };

            Assert.True(data.IsValid);
        }
Esempio n. 11
0
 public void Can_verify_Valid_SendSignatureRequestData_Files()
 {
     var data = new HSSendSignatureRequestData
     {
         Signers = new List<HSSigner> {new HSSigner {Name = "John", EmailAddress = "*****@*****.**"}},
         Files = new List<FileInfo> { new FileInfo("dummyfile.pdf") },
     };
     Assert.True(data.IsValid);
 }
Esempio n. 12
0
 public void Can_verify_invalid_SendSignatureRequestData_with_empty_Files()
 {
     var data = new HSSendSignatureRequestData
     {
         Signers = new List<HSSigner> {new HSSigner {Name = "John", EmailAddress = "*****@*****.**"}},
         Files = new List<FileInfo>() {new FileInfo("TestFile.xml")}
     };
     Assert.Equal(true, data.IsValid);
 }
Esempio n. 13
0
        private MultipartFormDataContent CreateFormData(HSSendSignatureRequestData request)
        {
            var formData = new MultipartFormDataContent();

            if (!string.IsNullOrEmpty(request.Title))
                formData.AddStringContent("title", request.Title);
            if (!string.IsNullOrEmpty(request.Subject))
                formData.AddStringContent("subject", request.Subject);
            if (!string.IsNullOrEmpty(request.Message))
                formData.AddStringContent("message", request.Message);
            if (!string.IsNullOrEmpty(request.SigningRedirectUrl))
                formData.AddStringContent("signing_redirect_url", request.SigningRedirectUrl);

            for (var i = 0; i < request.Signers.Count; i++)
            {
                formData.AddStringContent(string.Format("signers[{0}][name]", i), request.Signers[i].Name);
                formData.AddStringContent(string.Format("signers[{0}][email_address]", i),
                    request.Signers[i].EmailAddress);
                if (!string.IsNullOrEmpty(request.Signers[i].Order))
                    formData.AddStringContent(string.Format("signers[{0}][order]", i), request.Signers[i].Order);
                if (!string.IsNullOrEmpty(request.Signers[i].Pin))
                    formData.AddStringContent(string.Format("signers[{0}][pin]", i), request.Signers[i].Pin);
            }

            for (var i = 0; request.CcEmailAddresses != null && i < request.CcEmailAddresses.Count; i++)
            {
                formData.AddStringContent(string.Format("cc_email_addresses[{0}]", i), request.CcEmailAddresses[i]);
            }

            for (var i = 0; request.Files != null && i < request.Files.Count; i++)
            {
                formData.AddFileStreamContent(i, request.Files[i].FullName, request.Files[i].Name);
            }

            for (var i = 0; request.FileUrls != null && i < request.FileUrls.Count; i++)
            {
                formData.AddStringContent(string.Format("file_url[{0}]", i), request.FileUrls[i]);
            }

            if (request.UseTextTags == 1)
                formData.AddStringContent("use_text_tags", "1");

            if (request.HideTextTags == 1)
                formData.AddStringContent("hide_text_tags", "1");

            formData.AddStringContent("test_mode", "1");

            return formData;
        }
Esempio n. 14
0
        public Task<HSSignatureRequestResponse> SendSignatureRequest(HSSendSignatureRequestData request)
        {
            if (!request.IsValid)
                throw new ArgumentException("Invalid Signature Request Data");

            var formData = CreateFormData(request);

            return _httpClient.PostAsync(Config.SendSignatureRequestUri, formData).ContinueWith(t =>
            {
                using (var sr = new StreamReader(t.Result.Content.ReadAsStreamAsync().Result))
                using (var jtr = new JsonTextReader(sr))
                {
                    var response = Serializer.Deserialize<HSSignatureRequestResponse>(jtr);
                    return response;
                }
            });
        }