Added support for get envelopes; updated WADL and Siena doc

This commit is contained in:
Wade Wegner 2015-01-30 13:09:54 -07:00
Родитель c6c87d8a9f
Коммит b3469921b3
9 изменённых файлов: 134 добавлений и 5 удалений

Двоичные данные
siena/DocuSign-Sample.siena

Двоичный файл не отображается.

Просмотреть файл

@ -66,6 +66,18 @@ namespace DocuSign.FunctionalTests
Assert.IsNotNull(templates); 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] [Test]
public async void GetEnvelopeInformation() public async void GetEnvelopeInformation()
{ {

Просмотреть файл

@ -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/<id>
public async Task<Envelopes> Get([FromUri]DateTime fromDate)
{
await CheckAuthInfo();
var client = new DocuSignClient(BaseUrl, DocuSignCredentials);
var envelopes = await client.GetEnvelopesAsync(fromDate);
return envelopes;
}
}
}

Просмотреть файл

@ -156,6 +156,7 @@
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" /> <Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" /> <Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
<Compile Include="Controllers\EnvelopeController.cs" /> <Compile Include="Controllers\EnvelopeController.cs" />
<Compile Include="Controllers\EnvelopesController.cs" />
<Compile Include="Controllers\RecipientController.cs" /> <Compile Include="Controllers\RecipientController.cs" />
<Compile Include="Controllers\SignatureDocumentController.cs" /> <Compile Include="Controllers\SignatureDocumentController.cs" />
<Compile Include="Controllers\SignatureTemplateController.cs" /> <Compile Include="Controllers\SignatureTemplateController.cs" />

Просмотреть файл

@ -1,11 +1,12 @@
{ {
"id": "DocuSign", "id": "DocuSign",
"version": "0.0.12", "version": "0.0.13",
"authors": "Wade Wegner", "authors": "Wade Wegner",
"description": "DocuSign services and website upload tool", "description": "DocuSign services and website upload tool",
"name": "DocuSign", "name": "DocuSign",
"endpoints": { "endpoints": {
"apiDefinition": "/swagger/api-docs/Envelope", "apiDefinition": "/swagger/api-docs/Envelope",
"apiDefinition": "/swagger/api-docs/Envelopes",
"apiDefinition": "/swagger/api-docs/Recipient", "apiDefinition": "/swagger/api-docs/Recipient",
"apiDefinition": "/swagger/api-docs/SignatureDocument", "apiDefinition": "/swagger/api-docs/SignatureDocument",
"apiDefinition": "/swagger/api-docs/SignatureTemplate", "apiDefinition": "/swagger/api-docs/SignatureTemplate",

Просмотреть файл

@ -53,6 +53,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="AuthenticationClient.cs" /> <Compile Include="AuthenticationClient.cs" />
<Compile Include="DocuSignClient.cs" /> <Compile Include="DocuSignClient.cs" />
<Compile Include="Models\Envelopes.cs" />
<Compile Include="Models\EnvelopeTemplate.cs" /> <Compile Include="Models\EnvelopeTemplate.cs" />
<Compile Include="Models\Envelope.cs" /> <Compile Include="Models\Envelope.cs" />
<Compile Include="Models\LoginAccount.cs" /> <Compile Include="Models\LoginAccount.cs" />

Просмотреть файл

@ -42,6 +42,44 @@ namespace DocuSign
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
} }
public async Task<Envelopes> 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<Envelopes>(response);
return envelopes;
}
// implement exception
return null;
}
public async Task<Templates> GetTemplatesAsync() public async Task<Templates> GetTemplatesAsync()
{ {
var url = _baseUrl + "/templates"; var url = _baseUrl + "/templates";
@ -57,7 +95,6 @@ namespace DocuSign
if (responseMessage.IsSuccessStatusCode) if (responseMessage.IsSuccessStatusCode)
{ {
var jObject = JObject.Parse(response);
var envelope = JsonConvert.DeserializeObject<Templates>(response); var envelope = JsonConvert.DeserializeObject<Templates>(response);
return envelope; return envelope;
} }

Просмотреть файл

@ -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<Envelope> envelopes { get; set; }
}
}

Просмотреть файл

@ -80,10 +80,32 @@
<siena:property name="email" type="string" /> <siena:property name="email" type="string" />
<siena:property name="userId" type="string" /> <siena:property name="userId" type="string" />
</siena:object> </siena:object>
<siena:object name="GetEnvelopes_Root">
<siena:property name="resultSetSize" type="string" />
<siena:property name="totalSetSize" type="string" />
<siena:property name="startPosition" type="string" />
<siena:property name="endPosition" type="string" />
<siena:property name="nextUri" type="string" />
<siena:property name="previousUri" type="string" />
<siena:property name="envelopes" typeRef="GetEnvelopes_envelopes_Array" />
</siena:object>
<siena:object name="GetEnvelopes_envelopes_Object">
<siena:property name="envelopeId" type="string" />
<siena:property name="status" type="string" />
<siena:property name="documentsUri" type="string" />
<siena:property name="recipientsUri" type="string" />
<siena:property name="envelopeUri" type="string" />
<siena:property name="customFieldsUri" type="string" />
<siena:property name="notificationUri" type="string" />
<siena:property name="statusChangedDateTime" type="string" />
<siena:property name="documentsCombinedUri" type="string" />
<siena:property name="certificateUri" type="string" />
<siena:property name="templatesUri" type="string" />
</siena:object>
<siena:array name="GetEnvelopes_envelopes_Array" typeRef="GetEnvelopes_envelopes_Object" />
<siena:array name="GetTemplates_envelopeTemplates_Array" typeRef="GetTemplates_envelopeTemplates_Object" /> <siena:array name="GetTemplates_envelopeTemplates_Array" typeRef="GetTemplates_envelopeTemplates_Object" />
<siena:array name="GetRecipient_signers_Array" typeRef="GetRecipient_signers_Object" /> <siena:array name="GetRecipient_signers_Array" typeRef="GetRecipient_signers_Object" />
<siena:array name="StringArray" type="string" /> <siena:array name="StringArray" type="string" />
</siena:jsonTypes> </siena:jsonTypes>
</grammars> </grammars>
<siena:authenticationProviders /> <siena:authenticationProviders />
@ -101,8 +123,18 @@
</response> </response>
</method> </method>
</resource> </resource>
</resources> <resource path="DocuSign/api/envelopes/">
<resources base="http://rgendpointsproxysite.azurewebsites.net"> <method name="Get" id="GetEnvelopes" siena:requiresAuthentication="false">
<request>
<param name="fromDate" style="Query" required="true" siena:sampleDefault="01/01/2015" />
</request>
<response siena:resultForm="single">
<representation mediaType="application/json">
<param name="GetEnvelopes_Name" type="sienatool:GetEnvelopes_Root" style="Plain" path="" />
</representation>
</response>
</method>
</resource>
<resource path="DocuSign/api/recipient/"> <resource path="DocuSign/api/recipient/">
<method name="Get" id="GetRecipient" siena:requiresAuthentication="false"> <method name="Get" id="GetRecipient" siena:requiresAuthentication="false">
<request> <request>