Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions certified-connectors/DocuSignDemo/apiDefinition.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,59 @@
"x-ms-visibility": "important"
}
},
"/accounts/{accountId}/envelopes/{envelopeId}/envelopeDocuments": {
"get": {
"tags": [
"DocuSign"
],
"summary": "List envelope documents",
"description": "List documents in an envelope.",
"operationId": "ListEnvelopeDocuments",
"consumes": [],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"description": "Account id",
"required": true,
"x-ms-summary": "Account",
"x-ms-test-value": "insert account id",
"x-ms-dynamic-values": {
"operationId": "GetLoginAccounts",
"value-collection": "loginAccounts",
"value-path": "accountIdGuid",
"value-title": "name"
},
"type": "string"
},
{
"name": "envelopeId",
"in": "path",
"description": "Envelope id",
"required": true,
"x-ms-summary": "Envelope",
"x-ms-test-value": "insert envelope id",
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/ListDocumentsResponse"
}
}
},
"deprecated": false,
"x-ms-visibility": "advanced"
}
},
"/signers/accounts/{accountId}/templates/{templateId}/recipients": {
"get": {
"tags": [
Expand Down
32 changes: 32 additions & 0 deletions certified-connectors/DocuSignDemo/script.csx
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,13 @@ public class Script : ScriptBase
this.Context.Request.RequestUri = uriBuilder.Uri;
}

if ("ListEnvelopeDocuments".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
var uriBuilder = new UriBuilder(this.Context.Request.RequestUri);
uriBuilder.Path = uriBuilder.Path.Replace("/envelopeDocuments", "/documents");
this.Context.Request.RequestUri = uriBuilder.Uri;
}

if ("OnEnvelopeStatusChanges".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
var uriBuilder = new UriBuilder(this.Context.Request.RequestUri);
Expand Down Expand Up @@ -1739,6 +1746,31 @@ public class Script : ScriptBase
response.Content = new StringContent(newBody.ToString(), Encoding.UTF8, "application/json");
}

if ("ListEnvelopeDocuments".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
var body = ParseContentAsJObject(await response.Content.ReadAsStringAsync().ConfigureAwait(false), false);
var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query);
JArray envelopeDocuments = new JArray();
JObject newBody = new JObject();

if (body["envelopeDocuments"] == null)
{
throw new ConnectorException(HttpStatusCode.BadRequest, "ValidationFailure: Envelope do not contain documents");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Envelope does not contain any documents

}

foreach(var document in body["envelopeDocuments"] as JArray ?? new JArray())
{
envelopeDocuments.Add(new JObject()
{
["documentId"] = document["documentId"],
["name"] = document["name"]
});
}

newBody["envelopeDocuments"] = envelopeDocuments;
response.Content = new StringContent(newBody.ToString(), Encoding.UTF8, "application/json");
}

if ("GetDynamicSigners".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
var body = ParseContentAsJObject(await response.Content.ReadAsStringAsync().ConfigureAwait(false), false);
Expand Down