Skip to content
87 changes: 86 additions & 1 deletion certified-connectors/DocuSignDemo/apiDefinition.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
}
}
},
"x-ms-summary": "Tab"
"x-ms-summary": "Tab"
}
}
],
Expand Down Expand Up @@ -3154,6 +3154,91 @@
"deprecated": false,
"x-ms-no-generic-test": true,
"x-ms-visibility": "advanced"
},
"put": {
"tags": [
"DocuSign"
],
"summary": "Update envelope recipient tabs values",
"description": "Updates one or more tabs for a recipient in a draft envelope.",
"operationId": "UpdateRecipientTabsValues",
"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",
"required": true,
"type": "string",
"description": "Envelope id",
"x-ms-summary": "Envelope",
"x-ms-test-value": "insert envelope id"
},
{
"name": "recipientId",
"in": "path",
"required": true,
"type": "string",
"description": "Recipient id",
"x-ms-summary": "Recipient",
"x-ms-test-value": "insert recipient id"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"tabType": {
"enum": [
"Text",
"Note"
],
"type": "string",
"description": "Tab type",
"x-ms-summary": "Type",
"x-ms-test-value": "select tab type"
},
"tabId": {
"type": "string",
"x-ms-summary": "Id",
"description": "Id"
},
"value": {
"type": "string",
"x-ms-summary": "Value",
"description": "Value"
}
}
},
"x-ms-summary": "Tab"
}
}
],
"responses": {
"200": {
"description": "OK"
}
},
"deprecated": false,
"x-ms-visibility": "important",
"x-ms-no-generic-test": true
}
},
"/accounts/{accountId}/envelopes/{envelopeId}/recipients/{recipientId}/recipientTabs": {
Expand Down
34 changes: 34 additions & 0 deletions certified-connectors/DocuSignDemo/script.csx
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,35 @@ public class Script : ScriptBase

body["documents"] = documents;
return body;
}

private async Task UpdateRecipientTabsValuesBodyTransformation()
{
var body = ParseContentAsJArray(await this.Context.Request.Content.ReadAsStringAsync().ConfigureAwait(false), true);
var tabs = new JObject();

var tabsMap = new Dictionary<string, string>() {
{ "Text", "textTabs" },
{ "Note", "noteTabs" },
};

foreach (var tab in body)
{
var tabType = tab["tabType"].ToString();
tabType = tabsMap.ContainsKey(tabType) ? tabsMap[tabType] : tabType;
var tabsForType = tabs[tabType] as JArray ?? new JArray();

tabsForType.Add(new JObject
{
["tabId"] = tab["tabId"],
["value"] = tab["value"]
});

tabs[tabType] = tabsForType;
}

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

private JObject AddRecipientTabsBodyTransformation(JObject body)
Expand Down Expand Up @@ -1602,6 +1631,11 @@ public class Script : ScriptBase
await this.TransformRequestJsonBody(this.AddRecipientTabsBodyTransformation).ConfigureAwait(false);
}

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

if ("UpdateEnvelopePrefillTabs".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
await this.UpdateEnvelopePrefillTabsBodyTransformation().ConfigureAwait(false);
Expand Down