From 90241688e0849163ba2473bc4b01952e4d58157d Mon Sep 17 00:00:00 2001 From: Harshita Vinnakota Date: Sun, 16 Jul 2023 22:39:21 -0700 Subject: [PATCH 1/6] UI added --- .../DocuSignDemo/apiDefinition.swagger.json | 94 +++++++++++++++++++ certified-connectors/DocuSignDemo/script.csx | 39 ++++++++ 2 files changed, 133 insertions(+) diff --git a/certified-connectors/DocuSignDemo/apiDefinition.swagger.json b/certified-connectors/DocuSignDemo/apiDefinition.swagger.json index 7edc02d1b4..57459978fc 100644 --- a/certified-connectors/DocuSignDemo/apiDefinition.swagger.json +++ b/certified-connectors/DocuSignDemo/apiDefinition.swagger.json @@ -2035,6 +2035,25 @@ "x-ms-summary": "Envelope", "type": "string" }, + { + "name": "signatureType", + "in": "query", + "description": "DocuSign standards-based-signature (SBS) types.", + "x-ms-summary": "SBS type", + "x-ms-visibility": "advanced", + "type": "string", + "enum": [ + "Electronic Signatures", + "AES digital signatures", + "QES digital signatures" + ], + "x-ms-dynamic-values": { + "operationId": "StaticResponseForSignatureTypes", + "value-collection": "SBSTypes", + "value-path": "type", + "value-title": "name" + } + }, { "name": "recipientType", "in": "query", @@ -2323,6 +2342,25 @@ "x-ms-summary": "Recipient id", "type": "string" }, + { + "name": "signatureType", + "in": "query", + "description": "DocuSign standards-based-signature (SBS) types.", + "x-ms-summary": "SBS type", + "x-ms-visibility": "advanced", + "type": "string", + "enum": [ + "Electronic Signatures", + "AES digital signatures", + "QES digital signatures" + ], + "x-ms-dynamic-values": { + "operationId": "StaticResponseForSignatureTypes", + "value-collection": "SBSTypes", + "value-path": "type", + "value-title": "name" + } + }, { "name": "recipientType", "in": "query", @@ -3529,6 +3567,25 @@ "x-ms-visibility": "internal" } }, + "/signature_types": { + "get": { + "tags": [ + "StaticResponse" + ], + "description": "Get signature types.", + "operationId": "StaticResponseForSignatureTypes", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/SignatureTypesResponse" + } + } + }, + "deprecated": false, + "x-ms-visibility": "internal" + } + }, "/anchortab_schema": { "get": { "tags": [ @@ -3571,6 +3628,12 @@ "required": true, "type": "string", "x-ms-summary": "recipient type" + }, + { + "name": "signatureType", + "in": "query", + "type": "string", + "x-ms-summary": "signature type" } ], "responses": { @@ -4323,6 +4386,9 @@ "parameters": { "recipientType": { "parameter": "recipientType" + }, + "signatureType": { + "parameter": "signatureType" } }, "value-path": "Schema" @@ -4833,6 +4899,19 @@ } } }, + "SignatureTypesResponse":{ + "type": "object", + "properties": { + "tabTypes": { + "description": "Signature types", + "type": "array", + "items": { + "$ref": "#/definitions/SignatureType" + }, + "x-ms-summary": "Signature types" + } + } + }, "FontNamesResponse": { "type": "object", "properties": { @@ -4902,6 +4981,21 @@ } } }, + "SignatureType": { + "type": "object", + "properties": { + "name": { + "description": "Display name of the signature type.", + "type": "string", + "x-ms-summary": "Name" + }, + "type": { + "description": "Type of the signature.", + "type": "string", + "x-ms-summary": "Type" + } + } + }, "FontName": { "type": "object", "properties": { diff --git a/certified-connectors/DocuSignDemo/script.csx b/certified-connectors/DocuSignDemo/script.csx index 7ba247e22c..e59028e060 100644 --- a/certified-connectors/DocuSignDemo/script.csx +++ b/certified-connectors/DocuSignDemo/script.csx @@ -121,6 +121,29 @@ public class Script : ScriptBase response["recipientTypes"] = recipientTypesArray; } + if (operationId.Equals("StaticResponseForSignatureTypes", StringComparison.OrdinalIgnoreCase)) + { + var signatureTypesArray = new JArray(); + + string [,] signatureTypes = { + { "UniversalSignaturePen_ImageOnly" , "Electronic Signatures" }, + { "UniversalSignaturePen_OpenTrust_Hash_TSP", "AES digital signatures" }, + { "docusign_eu_qualified_idnow_tsp", "QES digital signatures" } + }; + + for (var i = 0; i < signatureTypes.GetLength(0); i++) + { + var signatureTypeObject = new JObject() + { + ["type"] = signatureTypes[i,0], + ["name"] = signatureTypes[i,1] + }; + signatureTypesArray.Add(signatureTypeObject); + } + + response["signatureType"] = signatureTypesArray; + } + if (operationId.StartsWith("StaticResponseForFont", StringComparison.OrdinalIgnoreCase)) { var fontNamesArray = new JArray(); @@ -403,6 +426,7 @@ public class Script : ScriptBase { var query = HttpUtility.ParseQueryString(context.Request.RequestUri.Query); var recipientType = query.Get("recipientType"); + var signatureType = query.Get("signatureType"); response["name"] = "dynamicSchema"; response["title"] = "dynamicSchema"; @@ -474,6 +498,21 @@ public class Script : ScriptBase ["x-ms-summary"] = "* Email" }; } + + if (signatureType.Equals("AES digital signatures", StringComparison.OrdinalIgnoreCase)) + { + response["schema"]["properties"]["options"] = new JObject + { + ["type"] = "string", + ["x-ms-summary"] = "* Signature Options", + ["x-ms-test-value"] = "Input the options: oneTimePassword or sms" + }; + response["schema"]["properties"]["options value"] = new JObject + { + ["type"] = "string", + ["x-ms-summary"] = "* Signature Options Value" + }; + } } return CreateJsonContent(response.ToString()); From 2b85fb4776193bc0eba2a2fc16e0c0c8a3b96be0 Mon Sep 17 00:00:00 2001 From: Harshita Vinnakota Date: Tue, 18 Jul 2023 08:40:14 -0700 Subject: [PATCH 2/6] Updated the text and rearranged the Signature type position --- .../DocuSignDemo/apiDefinition.swagger.json | 49 ++++++++--------- certified-connectors/DocuSignDemo/script.csx | 53 ++++++++++++------- 2 files changed, 58 insertions(+), 44 deletions(-) diff --git a/certified-connectors/DocuSignDemo/apiDefinition.swagger.json b/certified-connectors/DocuSignDemo/apiDefinition.swagger.json index 57459978fc..4691f8a425 100644 --- a/certified-connectors/DocuSignDemo/apiDefinition.swagger.json +++ b/certified-connectors/DocuSignDemo/apiDefinition.swagger.json @@ -2035,25 +2035,6 @@ "x-ms-summary": "Envelope", "type": "string" }, - { - "name": "signatureType", - "in": "query", - "description": "DocuSign standards-based-signature (SBS) types.", - "x-ms-summary": "SBS type", - "x-ms-visibility": "advanced", - "type": "string", - "enum": [ - "Electronic Signatures", - "AES digital signatures", - "QES digital signatures" - ], - "x-ms-dynamic-values": { - "operationId": "StaticResponseForSignatureTypes", - "value-collection": "SBSTypes", - "value-path": "type", - "value-title": "name" - } - }, { "name": "recipientType", "in": "query", @@ -2187,6 +2168,25 @@ "x-ms-visibility": "advanced", "type": "integer" }, + { + "name": "signatureType", + "in": "query", + "description": "DocuSign standards-based-signature (SBS) types.", + "x-ms-summary": "Signature type", + "x-ms-visibility": "advanced", + "type": "string", + "enum": [ + "DS Electronic (SES)", + "DS EU Advanced (AES)", + "DS EU Qualified (QES)" + ], + "x-ms-dynamic-values": { + "operationId": "StaticResponseForSignatureTypes", + "value-collection": "signatureTypes", + "value-path": "type", + "value-title": "name" + } + }, { "name": "additionalRecipientParams", "in": "body", @@ -2346,17 +2346,17 @@ "name": "signatureType", "in": "query", "description": "DocuSign standards-based-signature (SBS) types.", - "x-ms-summary": "SBS type", + "x-ms-summary": "Signature type", "x-ms-visibility": "advanced", "type": "string", "enum": [ - "Electronic Signatures", - "AES digital signatures", - "QES digital signatures" + "DS Electronic (SES)", + "DS EU Advanced (AES)", + "DS EU Qualified (QES)" ], "x-ms-dynamic-values": { "operationId": "StaticResponseForSignatureTypes", - "value-collection": "SBSTypes", + "value-collection": "signatureTypes", "value-path": "type", "value-title": "name" } @@ -3632,6 +3632,7 @@ { "name": "signatureType", "in": "query", + "required": false, "type": "string", "x-ms-summary": "signature type" } diff --git a/certified-connectors/DocuSignDemo/script.csx b/certified-connectors/DocuSignDemo/script.csx index e59028e060..cf5659b4f9 100644 --- a/certified-connectors/DocuSignDemo/script.csx +++ b/certified-connectors/DocuSignDemo/script.csx @@ -126,9 +126,9 @@ public class Script : ScriptBase var signatureTypesArray = new JArray(); string [,] signatureTypes = { - { "UniversalSignaturePen_ImageOnly" , "Electronic Signatures" }, - { "UniversalSignaturePen_OpenTrust_Hash_TSP", "AES digital signatures" }, - { "docusign_eu_qualified_idnow_tsp", "QES digital signatures" } + { "UniversalSignaturePen_ImageOnly" , "DS Electronic (SES)" }, + { "UniversalSignaturePen_OpenTrust_Hash_TSP", "DS EU Advanced (AES)" }, + { "docusign_eu_qualified_idnow_tsp", "DS EU Qualified (QES)" } }; for (var i = 0; i < signatureTypes.GetLength(0); i++) @@ -141,7 +141,7 @@ public class Script : ScriptBase signatureTypesArray.Add(signatureTypeObject); } - response["signatureType"] = signatureTypesArray; + response["signatureTypes"] = signatureTypesArray; } if (operationId.StartsWith("StaticResponseForFont", StringComparison.OrdinalIgnoreCase)) @@ -426,7 +426,12 @@ public class Script : ScriptBase { var query = HttpUtility.ParseQueryString(context.Request.RequestUri.Query); var recipientType = query.Get("recipientType"); - var signatureType = query.Get("signatureType"); + var signatureType = ""; + + if (!string.IsNullOrEmpty(query.Get("signatureType"))) + { + signatureType = query.Get("signatureType"); + } response["name"] = "dynamicSchema"; response["title"] = "dynamicSchema"; @@ -436,6 +441,29 @@ public class Script : ScriptBase ["properties"] = new JObject() }; + if (signatureType.Equals("DS EU Advanced (AES)", StringComparison.OrdinalIgnoreCase)) + { + string aesMethodItems = @"[ + 'Access Code', + 'SMS' + ]"; + response["schema"]["properties"]["aesMethod"] = new JObject + { + ["type"] = "string", + ["x-ms-summary"] = "* AES Method", + ["description"] = "AES Method", + ["enum"] = JArray.Parse(aesMethodItems) + + + }; + response["schema"]["properties"]["aesMethodValue"] = new JObject + { + ["type"] = "string", + ["x-ms-summary"] = "* AES Method Value", + ["description"] = "AES Method Value" + }; + } + if (recipientType.Equals("inPersonSigners", StringComparison.OrdinalIgnoreCase)) { response["schema"]["properties"]["hostName"] = new JObject @@ -498,21 +526,6 @@ public class Script : ScriptBase ["x-ms-summary"] = "* Email" }; } - - if (signatureType.Equals("AES digital signatures", StringComparison.OrdinalIgnoreCase)) - { - response["schema"]["properties"]["options"] = new JObject - { - ["type"] = "string", - ["x-ms-summary"] = "* Signature Options", - ["x-ms-test-value"] = "Input the options: oneTimePassword or sms" - }; - response["schema"]["properties"]["options value"] = new JObject - { - ["type"] = "string", - ["x-ms-summary"] = "* Signature Options Value" - }; - } } return CreateJsonContent(response.ToString()); From 4f22fbe58d4aaa106434f88efcbe2cc67d4de6bb Mon Sep 17 00:00:00 2001 From: Harshita Vinnakota Date: Fri, 21 Jul 2023 09:09:25 -0700 Subject: [PATCH 3/6] Add signatureType implementation --- certified-connectors/DocuSignDemo/script.csx | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/certified-connectors/DocuSignDemo/script.csx b/certified-connectors/DocuSignDemo/script.csx index cf5659b4f9..934d9e68d6 100644 --- a/certified-connectors/DocuSignDemo/script.csx +++ b/certified-connectors/DocuSignDemo/script.csx @@ -1424,6 +1424,47 @@ public class Script : ScriptBase additionalNotifications.Add(additionalNotification); signers[0]["additionalNotifications"] = additionalNotifications; } + + if (!string.IsNullOrEmpty(query.Get("signatureType"))) + { + var signatureType = query.Get("signatureType"); + + var signatureTypeMap = new Dictionary() { + {"DS Electronic (SES)", "UniversalSignaturePen_ImageOnly"}, + {"DS EU Advanced (AES)", "UniversalSignaturePen_OpenTrust_Hash_TSP"}, + {"DS EU Qualified (QES)", "idv_docusign_eu_qualified"}, + }; + + if (signatureType.Equals("DS EU Advanced (AES)")) + { + var aesMethod = body["aesMethod"].Equals("SMS")? "sms" : "oneTimePassword"; + var recipientSignatureProviders = new JArray + { + new JObject() + { + ["signatureProviderName"] = signatureTypeMap[query.Get("signatureType")], + ["signatureProviderOptions"] = new JObject() + { + [aesMethod] = body["aesMethodValue"] + } + } + }; + + signers[0]["recipientSignatureProviders"] = recipientSignatureProviders; + } + else + { + var recipientSignatureProviders = new JArray + { + new JObject() + { + ["signatureProviderName"] = signatureTypeMap[query.Get("signatureType")] + } + }; + + signers[0]["recipientSignatureProviders"] = recipientSignatureProviders; + } + } } private void AddParamsForSelectedRecipientType(JArray signers, JObject body) From c88d3604409830fb58cb79da76cdcbf4af833b39 Mon Sep 17 00:00:00 2001 From: Harshita Vinnakota Date: Fri, 21 Jul 2023 13:56:28 -0700 Subject: [PATCH 4/6] modularize the signatureType block --- certified-connectors/DocuSignDemo/script.csx | 77 +++++++++----------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/certified-connectors/DocuSignDemo/script.csx b/certified-connectors/DocuSignDemo/script.csx index 934d9e68d6..f9940ff428 100644 --- a/certified-connectors/DocuSignDemo/script.csx +++ b/certified-connectors/DocuSignDemo/script.csx @@ -1206,6 +1206,11 @@ public class Script : ScriptBase AddCoreRecipientParams(signers, body); AddParamsForSelectedRecipientType(signers, body); + if (!string.IsNullOrEmpty(query.Get("signatureType"))) + { + AddParamsForSelectedSignatureType(signers, body); + } + body[recipientType] = signers; var uriBuilder = new UriBuilder(this.Context.Request.RequestUri); @@ -1424,47 +1429,6 @@ public class Script : ScriptBase additionalNotifications.Add(additionalNotification); signers[0]["additionalNotifications"] = additionalNotifications; } - - if (!string.IsNullOrEmpty(query.Get("signatureType"))) - { - var signatureType = query.Get("signatureType"); - - var signatureTypeMap = new Dictionary() { - {"DS Electronic (SES)", "UniversalSignaturePen_ImageOnly"}, - {"DS EU Advanced (AES)", "UniversalSignaturePen_OpenTrust_Hash_TSP"}, - {"DS EU Qualified (QES)", "idv_docusign_eu_qualified"}, - }; - - if (signatureType.Equals("DS EU Advanced (AES)")) - { - var aesMethod = body["aesMethod"].Equals("SMS")? "sms" : "oneTimePassword"; - var recipientSignatureProviders = new JArray - { - new JObject() - { - ["signatureProviderName"] = signatureTypeMap[query.Get("signatureType")], - ["signatureProviderOptions"] = new JObject() - { - [aesMethod] = body["aesMethodValue"] - } - } - }; - - signers[0]["recipientSignatureProviders"] = recipientSignatureProviders; - } - else - { - var recipientSignatureProviders = new JArray - { - new JObject() - { - ["signatureProviderName"] = signatureTypeMap[query.Get("signatureType")] - } - }; - - signers[0]["recipientSignatureProviders"] = recipientSignatureProviders; - } - } } private void AddParamsForSelectedRecipientType(JArray signers, JObject body) @@ -1491,6 +1455,37 @@ public class Script : ScriptBase } } + private void AddParamsForSelectedSignatureType(JArray signers, JObject body) + { + var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query); + + var signatureType = query.Get("signatureType"); + var signatureTypeMap = new Dictionary() { + {"DS Electronic (SES)", "UniversalSignaturePen_ImageOnly"}, + {"DS EU Advanced (AES)", "UniversalSignaturePen_OpenTrust_Hash_TSP"}, + {"DS EU Qualified (QES)", "idv_docusign_eu_qualified"}, + }; + + var recipientSignatureProviders = new JArray + { + new JObject + { + ["signatureProviderName"] = signatureTypeMap[signatureType] + } + }; + + if (signatureType.Equals("DS EU Advanced (AES)")) + { + var aesMethod = body["aesMethod"].Equals("SMS") ? "sms" : "oneTimePassword"; + recipientSignatureProviders[0]["signatureProviderOptions"] = new JObject + { + [aesMethod] = body["aesMethodValue"] + }; + } + + signers[0]["recipientSignatureProviders"] = recipientSignatureProviders; + } + private int GenerateId() { DateTimeOffset now = DateTimeOffset.UtcNow; From 05298021e3cdea88a28196f5f94bdf5cd55b121a Mon Sep 17 00:00:00 2001 From: Harshita Vinnakota Date: Fri, 21 Jul 2023 14:47:20 -0700 Subject: [PATCH 5/6] Optimized code --- certified-connectors/DocuSignDemo/script.csx | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/certified-connectors/DocuSignDemo/script.csx b/certified-connectors/DocuSignDemo/script.csx index f9940ff428..bd119f8382 100644 --- a/certified-connectors/DocuSignDemo/script.csx +++ b/certified-connectors/DocuSignDemo/script.csx @@ -426,12 +426,7 @@ public class Script : ScriptBase { var query = HttpUtility.ParseQueryString(context.Request.RequestUri.Query); var recipientType = query.Get("recipientType"); - var signatureType = ""; - - if (!string.IsNullOrEmpty(query.Get("signatureType"))) - { - signatureType = query.Get("signatureType"); - } + var signatureType = query.Get("signatureType") ?? ""; response["name"] = "dynamicSchema"; response["title"] = "dynamicSchema"; @@ -443,18 +438,12 @@ public class Script : ScriptBase if (signatureType.Equals("DS EU Advanced (AES)", StringComparison.OrdinalIgnoreCase)) { - string aesMethodItems = @"[ - 'Access Code', - 'SMS' - ]"; response["schema"]["properties"]["aesMethod"] = new JObject { ["type"] = "string", ["x-ms-summary"] = "* AES Method", ["description"] = "AES Method", - ["enum"] = JArray.Parse(aesMethodItems) - - + ["enum"] = new JArray("Access Code", "SMS") }; response["schema"]["properties"]["aesMethodValue"] = new JObject { @@ -1476,7 +1465,7 @@ public class Script : ScriptBase if (signatureType.Equals("DS EU Advanced (AES)")) { - var aesMethod = body["aesMethod"].Equals("SMS") ? "sms" : "oneTimePassword"; + var aesMethod = (body["aesMethod"].Equals("SMS")) ? "sms" : "oneTimePassword"; recipientSignatureProviders[0]["signatureProviderOptions"] = new JObject { [aesMethod] = body["aesMethodValue"] From 2db979b699fde284af7fd568eb404376317116c4 Mon Sep 17 00:00:00 2001 From: Harshita Vinnakota Date: Tue, 25 Jul 2023 19:15:40 -0700 Subject: [PATCH 6/6] REmoved enum --- .../DocuSignDemo/apiDefinition.swagger.json | 10 ---------- certified-connectors/DocuSignDemo/script.csx | 12 +++--------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/certified-connectors/DocuSignDemo/apiDefinition.swagger.json b/certified-connectors/DocuSignDemo/apiDefinition.swagger.json index 4691f8a425..16679ca37d 100644 --- a/certified-connectors/DocuSignDemo/apiDefinition.swagger.json +++ b/certified-connectors/DocuSignDemo/apiDefinition.swagger.json @@ -2175,11 +2175,6 @@ "x-ms-summary": "Signature type", "x-ms-visibility": "advanced", "type": "string", - "enum": [ - "DS Electronic (SES)", - "DS EU Advanced (AES)", - "DS EU Qualified (QES)" - ], "x-ms-dynamic-values": { "operationId": "StaticResponseForSignatureTypes", "value-collection": "signatureTypes", @@ -2349,11 +2344,6 @@ "x-ms-summary": "Signature type", "x-ms-visibility": "advanced", "type": "string", - "enum": [ - "DS Electronic (SES)", - "DS EU Advanced (AES)", - "DS EU Qualified (QES)" - ], "x-ms-dynamic-values": { "operationId": "StaticResponseForSignatureTypes", "value-collection": "signatureTypes", diff --git a/certified-connectors/DocuSignDemo/script.csx b/certified-connectors/DocuSignDemo/script.csx index bd119f8382..a428a41af3 100644 --- a/certified-connectors/DocuSignDemo/script.csx +++ b/certified-connectors/DocuSignDemo/script.csx @@ -436,7 +436,7 @@ public class Script : ScriptBase ["properties"] = new JObject() }; - if (signatureType.Equals("DS EU Advanced (AES)", StringComparison.OrdinalIgnoreCase)) + if (signatureType.Equals("UniversalSignaturePen_OpenTrust_Hash_TSP", StringComparison.OrdinalIgnoreCase)) { response["schema"]["properties"]["aesMethod"] = new JObject { @@ -1447,23 +1447,17 @@ public class Script : ScriptBase private void AddParamsForSelectedSignatureType(JArray signers, JObject body) { var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query); - var signatureType = query.Get("signatureType"); - var signatureTypeMap = new Dictionary() { - {"DS Electronic (SES)", "UniversalSignaturePen_ImageOnly"}, - {"DS EU Advanced (AES)", "UniversalSignaturePen_OpenTrust_Hash_TSP"}, - {"DS EU Qualified (QES)", "idv_docusign_eu_qualified"}, - }; var recipientSignatureProviders = new JArray { new JObject { - ["signatureProviderName"] = signatureTypeMap[signatureType] + ["signatureProviderName"] = signatureType } }; - if (signatureType.Equals("DS EU Advanced (AES)")) + if (signatureType.Equals("UniversalSignaturePen_OpenTrust_Hash_TSP")) { var aesMethod = (body["aesMethod"].Equals("SMS")) ? "sms" : "oneTimePassword"; recipientSignatureProviders[0]["signatureProviderOptions"] = new JObject