Skip to content

Commit b8724d1

Browse files
Merge pull request #7 from harshitav-docusign/Flow-366
Flow-366: c2 : list envelope documents
2 parents 44e642c + 1fd56b5 commit b8724d1

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

certified-connectors/DocuSignDemo/apiDefinition.swagger.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,59 @@
21932193
"x-ms-visibility": "important"
21942194
}
21952195
},
2196+
"/accounts/{accountId}/envelopes/{envelopeId}/envelopeDocuments": {
2197+
"get": {
2198+
"tags": [
2199+
"DocuSign"
2200+
],
2201+
"summary": "List envelope documents",
2202+
"description": "List documents in an envelope.",
2203+
"operationId": "ListEnvelopeDocuments",
2204+
"consumes": [],
2205+
"produces": [
2206+
"application/json",
2207+
"text/json",
2208+
"application/xml",
2209+
"text/xml"
2210+
],
2211+
"parameters": [
2212+
{
2213+
"name": "accountId",
2214+
"in": "path",
2215+
"description": "Account id",
2216+
"required": true,
2217+
"x-ms-summary": "Account",
2218+
"x-ms-test-value": "insert account id",
2219+
"x-ms-dynamic-values": {
2220+
"operationId": "GetLoginAccounts",
2221+
"value-collection": "loginAccounts",
2222+
"value-path": "accountIdGuid",
2223+
"value-title": "name"
2224+
},
2225+
"type": "string"
2226+
},
2227+
{
2228+
"name": "envelopeId",
2229+
"in": "path",
2230+
"description": "Envelope id",
2231+
"required": true,
2232+
"x-ms-summary": "Envelope",
2233+
"x-ms-test-value": "insert envelope id",
2234+
"type": "string"
2235+
}
2236+
],
2237+
"responses": {
2238+
"200": {
2239+
"description": "OK",
2240+
"schema": {
2241+
"$ref": "#/definitions/ListDocumentsResponse"
2242+
}
2243+
}
2244+
},
2245+
"deprecated": false,
2246+
"x-ms-visibility": "advanced"
2247+
}
2248+
},
21962249
"/signers/accounts/{accountId}/templates/{templateId}/recipients": {
21972250
"get": {
21982251
"tags": [

certified-connectors/DocuSignDemo/script.csx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,13 @@ public class Script : ScriptBase
15241524
this.Context.Request.RequestUri = uriBuilder.Uri;
15251525
}
15261526

1527+
if ("ListEnvelopeDocuments".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
1528+
{
1529+
var uriBuilder = new UriBuilder(this.Context.Request.RequestUri);
1530+
uriBuilder.Path = uriBuilder.Path.Replace("/envelopeDocuments", "/documents");
1531+
this.Context.Request.RequestUri = uriBuilder.Uri;
1532+
}
1533+
15271534
if ("OnEnvelopeStatusChanges".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
15281535
{
15291536
var uriBuilder = new UriBuilder(this.Context.Request.RequestUri);
@@ -1739,6 +1746,31 @@ public class Script : ScriptBase
17391746
response.Content = new StringContent(newBody.ToString(), Encoding.UTF8, "application/json");
17401747
}
17411748

1749+
if ("ListEnvelopeDocuments".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
1750+
{
1751+
var body = ParseContentAsJObject(await response.Content.ReadAsStringAsync().ConfigureAwait(false), false);
1752+
var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query);
1753+
JArray envelopeDocuments = new JArray();
1754+
JObject newBody = new JObject();
1755+
1756+
if (body["envelopeDocuments"] == null)
1757+
{
1758+
throw new ConnectorException(HttpStatusCode.BadRequest, "ValidationFailure: Envelope do not contain documents");
1759+
}
1760+
1761+
foreach(var document in body["envelopeDocuments"] as JArray ?? new JArray())
1762+
{
1763+
envelopeDocuments.Add(new JObject()
1764+
{
1765+
["documentId"] = document["documentId"],
1766+
["name"] = document["name"]
1767+
});
1768+
}
1769+
1770+
newBody["envelopeDocuments"] = envelopeDocuments;
1771+
response.Content = new StringContent(newBody.ToString(), Encoding.UTF8, "application/json");
1772+
}
1773+
17421774
if ("GetDynamicSigners".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
17431775
{
17441776
var body = ParseContentAsJObject(await response.Content.ReadAsStringAsync().ConfigureAwait(false), false);

0 commit comments

Comments
 (0)