Skip to content

Commit b3f0a21

Browse files
Merge pull request #14 from sriharip-docusign/ecf_update
FLOW-276: Update Envelope Custom Fields Step
2 parents 5b4a3d0 + 04011b3 commit b3f0a21

File tree

2 files changed

+195
-10
lines changed

2 files changed

+195
-10
lines changed

certified-connectors/DocuSignDemo/apiDefinition.swagger.json

Lines changed: 133 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,9 @@
642642
"tags": [
643643
"DocuSign"
644644
],
645-
"summary": "Get envelope custom fields",
646-
"description": "Get envelope custom fields.",
647-
"operationId": "GetEnvelopeCustomFields",
645+
"summary": "Get envelope custom field",
646+
"description": "Get details for the specified envelope custom field.",
647+
"operationId": "GetEnvelopeCustomField",
648648
"consumes": [
649649
"application/json",
650650
"text/json",
@@ -715,6 +715,98 @@
715715
"deprecated": false,
716716
"x-ms-no-generic-test": true,
717717
"x-ms-visibility": "important"
718+
},
719+
"put": {
720+
"tags":[
721+
"DocuSign"
722+
],
723+
"summary": "Update envelope custom field",
724+
"description": "Update value for the specified envelope custom field",
725+
"operationId": "UpdateEnvelopeCustomField",
726+
"consumes":[
727+
"application/json",
728+
"text/json",
729+
"application/xml",
730+
"text/xml",
731+
"application/x-www-form-urlencoded"
732+
],
733+
"produces":[
734+
"application/json",
735+
"text/json",
736+
"application/xml",
737+
"text/xml"
738+
],
739+
"parameters":[
740+
{
741+
"name": "accountId",
742+
"in": "path",
743+
"description": "Account id",
744+
"required": true,
745+
"x-ms-summary": "Account",
746+
"x-ms-test-value": "insert account id",
747+
"x-ms-dynamic-values": {
748+
"operationId": "GetLoginAccounts",
749+
"value-collection": "loginAccounts",
750+
"value-path": "accountIdGuid",
751+
"value-title": "name"
752+
},
753+
"type": "string"
754+
},
755+
{
756+
"name": "envelopeId",
757+
"in": "path",
758+
"description": "Envelope id",
759+
"required": true,
760+
"x-ms-summary": "Envelope",
761+
"x-ms-test-value": "insert envelope id",
762+
"type": "string"
763+
},
764+
{
765+
"name": "fieldId",
766+
"in": "query",
767+
"description": "Custom Field ID",
768+
"required": true,
769+
"x-ms-summary": "Field ID",
770+
"type": "string"
771+
},
772+
{
773+
"name": "fieldType",
774+
"in":"query",
775+
"description": "Custom Field Type",
776+
"required":true,
777+
"x-ms-summary": "Field Type",
778+
"type":"string",
779+
"enum":["Text", "List"],
780+
"default": "Text"
781+
},
782+
{
783+
"name": "name",
784+
"in": "query",
785+
"description": "Custom Field Name",
786+
"required": true,
787+
"x-ms-summary": "Name",
788+
"type": "string"
789+
},
790+
{
791+
"name": "value",
792+
"in": "query",
793+
"description": "Custom Field Value",
794+
"required": true,
795+
"x-ms-summary": "Value",
796+
"type": "string"
797+
}
798+
],
799+
"responses": {
800+
"200": {
801+
"description": "OK",
802+
"schema": {
803+
"$ref": "#/definitions/UpdateEnvelopeCustomFieldResponse"
804+
}
805+
}
806+
},
807+
"deprecated":false,
808+
"x-ms-visibility": "important",
809+
"x-ms-no-generic-test": true
718810
}
719811
},
720812
"/accounts/{accountId}/envelopes/{envelopeId}/views/sender": {
@@ -1687,7 +1779,7 @@
16871779
}
16881780
},
16891781
"deprecated": false,
1690-
"x-ms-visibility": "important"
1782+
"x-ms-visibility": "internal"
16911783
}
16921784
},
16931785
"/accounts/{accountId}/folders": {
@@ -3386,14 +3478,49 @@
33863478
"x-ms-summary": "Field ID",
33873479
"x-ms-visibility": "important"
33883480
},
3481+
"fieldType": {
3482+
"description": "The type of the envelope custom field.",
3483+
"type": "string",
3484+
"x-ms-summary": "Field Type",
3485+
"x-ms-visibility": "important"
3486+
},
33893487
"name": {
33903488
"description": "The name of the envelope custom field.",
33913489
"type": "string",
33923490
"x-ms-summary": "Name",
33933491
"x-ms-visibility": "important"
3394-
}
3492+
}
33953493
}
3396-
},
3494+
},
3495+
"UpdateEnvelopeCustomFieldResponse": {
3496+
"type": "object",
3497+
"properties": {
3498+
"fieldId": {
3499+
"description": "The id of the envelope custom field.",
3500+
"type": "string",
3501+
"x-ms-summary": "Field ID",
3502+
"x-ms-visibility": "important"
3503+
},
3504+
"fieldType": {
3505+
"description": "The type of the envelope custom field.",
3506+
"type": "string",
3507+
"x-ms-summary": "Field Type",
3508+
"x-ms-visibility": "important"
3509+
},
3510+
"name": {
3511+
"description": "The name of the envelope custom field.",
3512+
"type": "string",
3513+
"x-ms-summary": "Name",
3514+
"x-ms-visibility": "important"
3515+
},
3516+
"value": {
3517+
"description": "The value of the envelope custom field.",
3518+
"type": "string",
3519+
"x-ms-summary": "Value",
3520+
"x-ms-visibility": "important"
3521+
}
3522+
}
3523+
},
33973524
"Folder": {
33983525
"type": "object",
33993526
"properties": {

certified-connectors/DocuSignDemo/script.csx

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,37 @@ public class Script : ScriptBase
887887

888888
return newBody;
889889
}
890+
891+
private JObject UpdateEnvelopeCustomFieldBodyTransformation(JObject body)
892+
{
893+
var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query);
894+
var textCustomFields = new JArray();
895+
var listCustomFields = new JArray();
896+
var fieldType = query.Get("fieldType");
897+
var customField = new JObject() {
898+
["fieldId"] = query.Get("fieldId"),
899+
["name"] = query.Get("name"),
900+
["value"] = query.Get("value")
901+
};
902+
903+
if (fieldType.Equals("Text"))
904+
{
905+
textCustomFields.Add(customField);
906+
}
907+
908+
if (fieldType.Equals("List"))
909+
{
910+
listCustomFields.Add(customField);
911+
}
912+
913+
var newBody = new JObject()
914+
{
915+
["textCustomFields"] = textCustomFields,
916+
["listCustomFields"] = listCustomFields
917+
};
918+
919+
return newBody;
920+
}
890921

891922
private void ParseCustomFields(JObject body, JArray textCustomFields, JArray listCustomFields)
892923
{
@@ -1387,6 +1418,11 @@ public class Script : ScriptBase
13871418
await this.TransformRequestJsonBody(this.AddVerificationToRecipientBodyTransformation).ConfigureAwait(false);
13881419
}
13891420

1421+
if ("UpdateEnvelopeCustomField".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
1422+
{
1423+
await this.TransformRequestJsonBody(this.UpdateEnvelopeCustomFieldBodyTransformation).ConfigureAwait(false);
1424+
}
1425+
13901426
if ("GenerateEmbeddedSigningURL".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
13911427
{
13921428
await this.TransformRequestJsonBody(this.GenerateEmbeddedSigningURLBodyTransformation).ConfigureAwait(false);
@@ -1678,9 +1714,9 @@ public class Script : ScriptBase
16781714
};
16791715

16801716
response.Content = new StringContent(newBody.ToString(), Encoding.UTF8, "application/json");
1681-
}
1717+
}
16821718

1683-
if ("GetEnvelopeCustomFields".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
1719+
if ("GetEnvelopeCustomField".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
16841720
{
16851721
var body = ParseContentAsJObject(await response.Content.ReadAsStringAsync().ConfigureAwait(false), false);
16861722
var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query);
@@ -1691,7 +1727,7 @@ public class Script : ScriptBase
16911727
{
16921728
if (customField["name"].ToString().Equals(customFieldName))
16931729
{
1694-
customField["type"] = "text";
1730+
customField["fieldType"] = "Text";
16951731
responseCustomField = customField as JObject;
16961732
break;
16971733
}
@@ -1701,7 +1737,7 @@ public class Script : ScriptBase
17011737
{
17021738
if (customField["name"].ToString().Equals(customFieldName))
17031739
{
1704-
customField["type"] = "list";
1740+
customField["fieldType"] = "List";
17051741
responseCustomField = customField as JObject;
17061742
break;
17071743
}
@@ -1710,6 +1746,28 @@ public class Script : ScriptBase
17101746
response.Content = new StringContent(responseCustomField.ToString(), Encoding.UTF8, "application/json");
17111747
}
17121748

1749+
if ("UpdateEnvelopeCustomField".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
1750+
{
1751+
var body = ParseContentAsJObject(await response.Content.ReadAsStringAsync().ConfigureAwait(false), false);
1752+
var responseCustomField = new JObject();
1753+
1754+
foreach (var customField in (body["textCustomFields"] as JArray) ?? new JArray())
1755+
{
1756+
responseCustomField = customField as JObject;
1757+
responseCustomField["fieldType"] = "Text";
1758+
break;
1759+
}
1760+
1761+
foreach (var customField in (body["listCustomFields"] as JArray) ?? new JArray())
1762+
{
1763+
responseCustomField = customField as JObject;
1764+
responseCustomField["fieldType"] = "List";
1765+
break;
1766+
}
1767+
1768+
response.Content = new StringContent(responseCustomField.ToString(), Encoding.UTF8, "application/json");
1769+
}
1770+
17131771
if ("AddRecipientToEnvelopeV2".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
17141772
{
17151773
var body = ParseContentAsJObject(await response.Content.ReadAsStringAsync().ConfigureAwait(false), false);

0 commit comments

Comments
 (0)