Skip to content

Commit 0cd2f92

Browse files
Merge pull request #7 from sriharip-docusign/flow_206_207
Merge SMS related code changes from Angel + Custom field bug fixes
2 parents 96b1c74 + 4d261e9 commit 0cd2f92

File tree

2 files changed

+67
-50
lines changed

2 files changed

+67
-50
lines changed

certified-connectors/DocuSignDemo/apiDefinition.swagger.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,11 +1291,27 @@
12911291
{
12921292
"name": "roleName",
12931293
"in": "query",
1294-
"description": " Role name associated with the recipient.",
1294+
"description": "Role name associated with the recipient.",
12951295
"x-ms-summary": "Role name",
12961296
"x-ms-visibility": "advanced",
12971297
"type": "string"
12981298
},
1299+
{
1300+
"name": "countryCode",
1301+
"in": "query",
1302+
"description": "For SMS notifications, the country code, without leading + sign.",
1303+
"x-ms-summary": "SMS Country Code",
1304+
"x-ms-visibility": "advanced",
1305+
"type": "integer"
1306+
},
1307+
{
1308+
"name": "phoneNumber",
1309+
"in": "query",
1310+
"description": " For SMS notifications, the phone number without the country code.",
1311+
"x-ms-summary": "SMS Phone Number",
1312+
"x-ms-visibility": "advanced",
1313+
"type": "integer"
1314+
},
12991315
{
13001316
"name": "additionalRecipientParams",
13011317
"in": "body",

certified-connectors/DocuSignDemo/script.csx

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ public class Script : ScriptBase
3030
catch (ConnectorException ex)
3131
{
3232
var response = new HttpResponseMessage(ex.StatusCode);
33-
response.Content = CreateJsonContent(ex.JsonMessage());
33+
34+
if(ex.Message.Contains("ValidationFailure:"))
35+
{
36+
response.Content = CreateJsonContent(ex.JsonMessage());
37+
}
38+
else
39+
{
40+
response.Content = CreateJsonContent(ex.Message);
41+
}
42+
3443
return response;
3544
}
3645
}
@@ -311,33 +320,14 @@ public class Script : ScriptBase
311320
{
312321
response["schema"]["properties"]["countryCode"] = new JObject
313322
{
314-
["type"] = "string",
315-
["x-ms-summary"] = "* Country Code (+)"
323+
["type"] = "integer",
324+
["x-ms-summary"] = "* Country Code, without the leading + sign."
316325
};
317326
response["schema"]["properties"]["phoneNumber"] = new JObject
318327
{
319-
["type"] = "string",
328+
["type"] = "integer",
320329
["x-ms-summary"] = "* Recipient's Phone Number"
321330
};
322-
response["schema"]["properties"]["workflowID"] = new JObject
323-
{
324-
["type"] = "string",
325-
["x-ms-dynamic-values"] = new JObject
326-
{
327-
["operationId"] = "GetWorkflowIDs",
328-
["parameters"] = new JObject
329-
{
330-
["accountId"] = new JObject
331-
{
332-
["parameter"] = "accountId"
333-
}
334-
},
335-
["value-collection"] = "workFlowIds",
336-
["value-path"] = "type",
337-
["value-title"] = "name",
338-
},
339-
["x-ms-summary"] = "* Workflow IDs"
340-
};
341331
}
342332
else if (verificationType.Equals("Access Code", StringComparison.OrdinalIgnoreCase))
343333
{
@@ -886,16 +876,16 @@ public class Script : ScriptBase
886876
customField["show"] = "true";
887877
}
888878

889-
if (key.StartsWith("[List Envelope Custom Field]"))
879+
if (key.EndsWith("[Custom Field List]"))
890880
{
891-
key = key.Replace("[List Envelope Custom Field] ", "");
881+
key = key.Replace(" [Custom Field List]", "");
892882
customField["name"] = key;
893883
customField["value"] = value;
894884
listCustomFields.Add(customField);
895885
}
896886
else
897887
{
898-
key = key.Replace("[Text Envelope Custom Field] ", "");
888+
key = key.Replace(" [Custom Field Text]", "");
899889
customField["name"] = key;
900890
customField["value"] = value;
901891
textCustomFields.Add(customField);
@@ -1044,35 +1034,26 @@ public class Script : ScriptBase
10441034

10451035
if (verificationType.Equals("Phone Authentication"))
10461036
{
1047-
var identityVerification = new JObject();
1048-
var inputOptions = new JArray();
1049-
var inputObject = new JObject();
1050-
var phoneNumberList = new JArray();
1051-
var phoneNumberObject = new JObject();
1037+
var phoneAuthentication = new JObject();
1038+
var phoneNumbers = new JArray();
10521039

1053-
if (body["phoneNumber"] == null && body["countryCode"] == null && body["workflowID"] == null)
1040+
if (body["phoneNumber"] == null || body["countryCode"] == null)
10541041
{
1055-
throw new ConnectorException(HttpStatusCode.BadRequest, "Phone number or workflow ID is missing");
1042+
throw new ConnectorException(HttpStatusCode.BadRequest, "ValidationFailure: Phone number or country code is missing");
10561043
}
10571044

1058-
phoneNumberObject["Number"] = body["phoneNumber"];
1059-
phoneNumberObject["CountryCode"] = body["countryCode"];
1060-
phoneNumberList.Add(phoneNumberObject);
1045+
var phoneNumber = body["countryCode"].ToString() + body["phoneNumber"].ToString();
1046+
phoneNumbers.Add(phoneNumber);
10611047

1062-
inputObject["phoneNumberList"] = phoneNumberList;
1063-
inputObject["name"] = "phone_number_list";
1064-
inputObject["valueType"] = "PhoneNumberList";
1065-
inputOptions.Add(inputObject);
1066-
1067-
identityVerification["workflowId"] = body["workflowID"];
1068-
identityVerification["inputOptions"] = inputOptions;
1069-
recipient["identityVerification"] = identityVerification;
1048+
phoneAuthentication["senderProvidedNumbers"] = phoneNumbers;
1049+
recipient["phoneAuthentication"] = phoneAuthentication;
1050+
recipient["idCheckConfigurationName"] = "Phone Auth $";
10701051
}
10711052
else if (verificationType.Equals("Access Code"))
10721053
{
10731054
if (body["accessCode"] == null)
10741055
{
1075-
throw new ConnectorException(HttpStatusCode.BadRequest, "Access Code is missing");
1056+
throw new ConnectorException(HttpStatusCode.BadRequest, "ValidationFailure: Access Code is missing");
10761057
}
10771058

10781059
recipient["accessCode"] = body["accessCode"];
@@ -1086,7 +1067,7 @@ public class Script : ScriptBase
10861067
var identityVerification = new JObject();
10871068
if (body["workflowID"] == null)
10881069
{
1089-
throw new ConnectorException(HttpStatusCode.BadRequest, "Workflow ID is missing");
1070+
throw new ConnectorException(HttpStatusCode.BadRequest, "ValidationFailure: Workflow ID is missing");
10901071
}
10911072

10921073
identityVerification["workflowId"] = body["workflowID"];
@@ -1156,6 +1137,21 @@ public class Script : ScriptBase
11561137
{
11571138
signers[0]["roleName"] = query.Get("roleName");
11581139
}
1140+
1141+
if (!string.IsNullOrEmpty(query.Get("countryCode")) && !string.IsNullOrEmpty(query.Get("phoneNumber")))
1142+
{
1143+
var phoneNumber = new JObject();
1144+
phoneNumber["countryCode"] = query.Get("countryCode");
1145+
phoneNumber["number"] = query.Get("phoneNumber");
1146+
1147+
var additionalNotification = new JObject();
1148+
additionalNotification["secondaryDeliveryMethod"] = "SMS";
1149+
additionalNotification["phoneNumber"] = phoneNumber;
1150+
1151+
var additionalNotifications = new JArray();
1152+
additionalNotifications.Add(additionalNotification);
1153+
signers[0]["additionalNotifications"] = additionalNotifications;
1154+
}
11591155
}
11601156

11611157
private void AddParamsForSelectedRecipientType(JArray signers, JObject body)
@@ -1536,9 +1532,9 @@ public class Script : ScriptBase
15361532
var count = 0;
15371533
foreach (var customField in (body["textCustomFields"] as JArray) ?? new JArray())
15381534
{
1539-
var name = "[Text Envelope Custom Field] " + customField["name"].ToString();
1535+
var name = customField["name"].ToString() + " [Custom Field Text]";
15401536

1541-
if (customField["required"].ToString() == "true")
1537+
if (customField["required"].ToString() == "true")
15421538
{
15431539
name = "* " + name;
15441540
}
@@ -1554,7 +1550,7 @@ public class Script : ScriptBase
15541550

15551551
foreach (var customField in (body["listCustomFields"] as JArray) ?? new JArray())
15561552
{
1557-
var name = "[List Envelope Custom Field] " + customField["name"].ToString();
1553+
var name = customField["name"].ToString() + " [Custom Field List]";
15581554

15591555
if (customField["required"].ToString() == "true")
15601556
{
@@ -1625,6 +1621,11 @@ public class Script : ScriptBase
16251621
break;
16261622
}
16271623

1624+
if (newBody["errorDetails"] != null)
1625+
{
1626+
throw new ConnectorException(HttpStatusCode.BadRequest, "ValidationFailure: " + newBody["errorDetails"]["message"]);
1627+
}
1628+
16281629
response.Content = new StringContent(newBody.ToString(), Encoding.UTF8, "application/json");
16291630
}
16301631

0 commit comments

Comments
 (0)