diff --git a/siena/DocuSign-Sample.siena b/siena/DocuSign-Sample.siena index 0d983c2..7bf39a1 100644 Binary files a/siena/DocuSign-Sample.siena and b/siena/DocuSign-Sample.siena differ diff --git a/src/DocuSign.FunctionalTests/Tests.cs b/src/DocuSign.FunctionalTests/Tests.cs index c587739..03056ba 100644 --- a/src/DocuSign.FunctionalTests/Tests.cs +++ b/src/DocuSign.FunctionalTests/Tests.cs @@ -66,6 +66,18 @@ namespace DocuSign.FunctionalTests Assert.IsNotNull(templates); } + [Test] + public async void GetEnvelopes() + { + var auth = new AuthenticationClient(_username, _password, _integratorKey); + await auth.LoginInformationAsync(); + + var client = new DocuSignClient(auth); + var envelopes = await client.GetEnvelopesAsync(DateTime.Now.AddDays(-100)); + + Assert.IsNotNull(envelopes); + } + [Test] public async void GetEnvelopeInformation() { diff --git a/src/DocuSign.Web/Controllers/EnvelopesController.cs b/src/DocuSign.Web/Controllers/EnvelopesController.cs new file mode 100644 index 0000000..300e090 --- /dev/null +++ b/src/DocuSign.Web/Controllers/EnvelopesController.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using System.Web.Http; +using DocuSign.Models; +using DocuSign.Web.Utils; + +namespace DocuSign.Web.Controllers +{ + public class EnvelopesController : DocuSignController + { + // GET api/envelope/ + public async Task Get([FromUri]DateTime fromDate) + { + await CheckAuthInfo(); + var client = new DocuSignClient(BaseUrl, DocuSignCredentials); + + var envelopes = await client.GetEnvelopesAsync(fromDate); + + return envelopes; + } + } +} diff --git a/src/DocuSign.Web/DocuSign.Web.csproj b/src/DocuSign.Web/DocuSign.Web.csproj index a7e052a..3928ae2 100644 --- a/src/DocuSign.Web/DocuSign.Web.csproj +++ b/src/DocuSign.Web/DocuSign.Web.csproj @@ -156,6 +156,7 @@ + diff --git a/src/DocuSign.Web/microservice.json b/src/DocuSign.Web/microservice.json index cecc7bd..56c350f 100644 --- a/src/DocuSign.Web/microservice.json +++ b/src/DocuSign.Web/microservice.json @@ -1,11 +1,12 @@ { "id": "DocuSign", - "version": "0.0.12", + "version": "0.0.13", "authors": "Wade Wegner", "description": "DocuSign services and website upload tool", "name": "DocuSign", "endpoints": { "apiDefinition": "/swagger/api-docs/Envelope", + "apiDefinition": "/swagger/api-docs/Envelopes", "apiDefinition": "/swagger/api-docs/Recipient", "apiDefinition": "/swagger/api-docs/SignatureDocument", "apiDefinition": "/swagger/api-docs/SignatureTemplate", diff --git a/src/DocuSign/DocuSign.csproj b/src/DocuSign/DocuSign.csproj index 443721a..8929a2b 100644 --- a/src/DocuSign/DocuSign.csproj +++ b/src/DocuSign/DocuSign.csproj @@ -53,6 +53,7 @@ + diff --git a/src/DocuSign/DocuSignClient.cs b/src/DocuSign/DocuSignClient.cs index 1e227de..925dfc6 100644 --- a/src/DocuSign/DocuSignClient.cs +++ b/src/DocuSign/DocuSignClient.cs @@ -42,6 +42,44 @@ namespace DocuSign _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } + public async Task GetEnvelopesAsync(DateTime fromDate) + { + var currMonth = fromDate.Month; + var currDay = fromDate.Day; + var currYear = fromDate.Year; + + if (currMonth != 1) + { + currMonth -= 1; + } + else + { + // special case for january + currMonth = 12; + currYear -= 1; + } + + var url = _baseUrl + "/envelopes?from_date=" + currMonth + "%2F" + currDay + "%2F" + currYear; + + var request = new HttpRequestMessage + { + Method = HttpMethod.Get, + RequestUri = new Uri(url) + }; + + var responseMessage = await _httpClient.SendAsync(request).ConfigureAwait(false); + var response = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); + + if (responseMessage.IsSuccessStatusCode) + { + var envelopes = JsonConvert.DeserializeObject(response); + return envelopes; + } + + // implement exception + return null; + } + public async Task GetTemplatesAsync() { var url = _baseUrl + "/templates"; @@ -57,7 +95,6 @@ namespace DocuSign if (responseMessage.IsSuccessStatusCode) { - var jObject = JObject.Parse(response); var envelope = JsonConvert.DeserializeObject(response); return envelope; } diff --git a/src/DocuSign/Models/Envelopes.cs b/src/DocuSign/Models/Envelopes.cs new file mode 100644 index 0000000..10511d0 --- /dev/null +++ b/src/DocuSign/Models/Envelopes.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocuSign.Models +{ + public class Envelopes + { + public string resultSetSize { get; set; } + public string totalSetSize { get; set; } + public string startPosition { get; set; } + public string endPosition { get; set; } + public string nextUri { get; set; } + public string previousUri { get; set; } + public List envelopes { get; set; } + } +} diff --git a/wadl/DocuSign.xml b/wadl/DocuSign.xml index 5f4abf0..e4cb505 100644 --- a/wadl/DocuSign.xml +++ b/wadl/DocuSign.xml @@ -80,10 +80,32 @@ + + + + + + + + + + + + + + + + + + + + + + + - @@ -101,8 +123,18 @@ - - + + + + + + + + + + + +