Skip to content

Commit

Permalink
Merge pull request #31 from sriharip-docusign/update_docgen_merge_fields
Browse files Browse the repository at this point in the history
FLOW-347: DocGen: Update merge fields
  • Loading branch information
sriharip-docusign authored May 12, 2023
2 parents 1777bfa + c264ff3 commit 518f88e
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 1 deletion.
90 changes: 89 additions & 1 deletion certified-connectors/DocuSignDemo/apiDefinition.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,96 @@
"deprecated": false,
"x-ms-no-generic-test": true,
"x-ms-visibility": "important"
},
"put": {
"tags": [
"DocuSign"
],
"summary": "Update envelope docgen form fields",
"description": "Update the docgen fields in envelope documents.",
"operationId": "UpdateDocgenFormFields",
"x-ms-no-generic-test": true,
"consumes": [
"application/json",
"text/json",
"application/xml",
"text/xml",
"application/x-www-form-urlencoded"
],
"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"
},
{
"name": "documentId",
"in": "query",
"description": "Document Id",
"required": true,
"x-ms-summary": "Document Id",
"x-ms-test-value": "insert document id guid",
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"x-ms-summary": "Name",
"description": "Name"
},
"value": {
"type": "string",
"x-ms-summary": "Value",
"description": "Value"
}
}
},
"x-ms-summary": "Field"
}
}
],
"responses": {
"201": {
"description": "OK"
}
},
"deprecated": false,
"x-ms-visibility": "important"
}
},
},
"/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}": {
"get": {
"summary": "Get envelope documents",
Expand Down
36 changes: 36 additions & 0 deletions certified-connectors/DocuSignDemo/script.csx
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,37 @@ public class Script : ScriptBase
return body;
}

private async Task UpdateDocgenFormFieldsBodyTransformation()
{
var body = ParseContentAsJArray(await this.Context.Request.Content.ReadAsStringAsync().ConfigureAwait(false), true);
var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query);
var fieldList = new JArray();
var documentId = query.Get("documentId");

foreach (var field in body)
{
fieldList.Add(new JObject
{
["name"] = field["name"],
["value"] = field["value"]
});
}

var docGenFormFields = new JArray
{
new JObject
{
["documentId"] = documentId,
["docGenFormFieldList"] = fieldList
},
};

var newBody = new JObject();
newBody["docGenFormFields"] = docGenFormFields;

this.Context.Request.Content = CreateJsonContent(newBody.ToString());
}

private async Task UpdateApiEndpoint()
{
string content = string.Empty;
Expand Down Expand Up @@ -1607,6 +1638,11 @@ public class Script : ScriptBase
await this.UpdateEnvelopePrefillTabsBodyTransformation().ConfigureAwait(false);
}

if ("UpdateDocgenFormFields".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
await this.UpdateDocgenFormFieldsBodyTransformation().ConfigureAwait(false);
}

if ("RemoveRecipientFromEnvelope".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
var newBody = new JObject();
Expand Down

0 comments on commit 518f88e

Please sign in to comment.