Skip to content

Commit a59a2c4

Browse files
committed
Updating Our SMSDelivery Example to support WhatsApp as well as SMS
1 parent 1472cde commit a59a2c4

File tree

4 files changed

+71
-50
lines changed

4 files changed

+71
-50
lines changed

launcher-csharp/eSignature/Controllers/SMSDelivery.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public SMSDelivery(DSConfiguration config, LauncherTexts launcherTexts, IRequest
2525

2626
[HttpPost]
2727
[SetViewBag]
28-
public IActionResult Create(string signerName, string signerCountryCode, string signerPhoneNumber, string ccName, string ccCountryCode, string ccPhoneNumber)
28+
public IActionResult Create(string signerName, string signerCountryCode, string signerPhoneNumber, string ccName, string ccCountryCode, string ccPhoneNumber, string deliveryMethod)
2929
{
3030
// Check the token with minimal buffer time.
3131
bool tokenOk = this.CheckToken(3);
@@ -57,7 +57,8 @@ public IActionResult Create(string signerName, string signerCountryCode, string
5757
ccPhoneNumber,
5858
this.Config.DocDocx,
5959
this.Config.DocPdf,
60-
this.RequestItemsService.Status);
60+
this.RequestItemsService.Status,
61+
deliveryMethod);
6162

6263
this.RequestItemsService.EnvelopeId = envelopeId;
6364

launcher-csharp/eSignature/Examples/SMSDelivery.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ public class SMSDelivery
2828
/// <param name="docPdf">String of bytes representing the document (pdf).</param>
2929
/// <param name="docDocx">String of bytes representing the Word document (docx).</param>
3030
/// <param name="envStatus">Status to set the envelope to.</param>
31+
/// <param name="deliveryMethod">SMS or WhatsApp</param>
3132
/// <returns>EnvelopeId for the new envelope.</returns>
32-
public static string SendRequestViaSMS(string accessToken, string basePath, string accountId, string signerName, string signerCountryCode, string signerPhoneNumber, string ccName, string ccCountryCode, string ccPhoneNumber, string docDocx, string docPdf, string envStatus)
33+
public static string SendRequestViaSMS(string accessToken, string basePath, string accountId, string signerName, string signerCountryCode, string signerPhoneNumber, string ccName, string ccCountryCode, string ccPhoneNumber, string docDocx, string docPdf, string envStatus, string deliveryMethod)
3334
{
34-
EnvelopeDefinition env = MakeEnvelope(signerName, signerCountryCode, signerPhoneNumber, ccName, ccCountryCode, ccPhoneNumber, docDocx, docPdf, envStatus);
35+
EnvelopeDefinition env = MakeEnvelope(signerName, signerCountryCode, signerPhoneNumber, ccName, ccCountryCode, ccPhoneNumber, docDocx, docPdf, envStatus, deliveryMethod);
3536

3637
//ds-snippet-start:eSign37Step3
3738
var docuSignClient = new DocuSignClient(basePath);
@@ -44,7 +45,7 @@ public static string SendRequestViaSMS(string accessToken, string basePath, stri
4445
}
4546

4647
//ds-snippet-start:eSign37Step2
47-
private static EnvelopeDefinition MakeEnvelope(string signerName, string signerCountryCode, string signerPhoneNumber, string ccName, string ccCountryCode, string ccPhoneNumber, string docDocx, string docPdf, string envStatus)
48+
private static EnvelopeDefinition MakeEnvelope(string signerName, string signerCountryCode, string signerPhoneNumber, string ccName, string ccCountryCode, string ccPhoneNumber, string docDocx, string docPdf, string envStatus, string deliveryMethod)
4849
{
4950
// Data for this method
5051
// signerName
@@ -107,7 +108,7 @@ private static EnvelopeDefinition MakeEnvelope(string signerName, string signerC
107108
Name = signerName,
108109
RecipientId = "1",
109110
RoutingOrder = "1",
110-
DeliveryMethod = "SMS",
111+
DeliveryMethod = deliveryMethod,
111112
PhoneNumber = new RecipientPhoneNumber
112113
{
113114
CountryCode = signerCountryCode,
@@ -126,7 +127,7 @@ private static EnvelopeDefinition MakeEnvelope(string signerName, string signerC
126127
Name = ccName,
127128
RecipientId = "2",
128129
RoutingOrder = "2",
129-
DeliveryMethod = "SMS",
130+
DeliveryMethod = deliveryMethod,
130131
PhoneNumber = new RecipientPhoneNumber
131132
{
132133
CountryCode = ccCountryCode,

launcher-csharp/eSignature/Views/SMSDelivery/Eg037.cshtml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
int ccCountryCodeInputNumber = 3;
77
int ccNumberInputNumber = 4;
88
int ccSignerNameInputNumber = 5;
9+
int deliveryMethodNumber = 6;
10+
int deliveryMethodSMS = 7;
11+
int deliveryMthodWhatsApp = 8;
912
}
1013

1114
<h4>@Html.Raw(ViewBag.CodeExampleText.ExampleName)</h4>
@@ -31,6 +34,13 @@
3134
</p>
3235

3336
<form class="eg" action="" method="post" data-busy="form">
37+
<div class="form-group">
38+
<p><b>@Html.Raw(ViewBag.CodeExampleText.Forms[formNumber].Inputs[deliveryMethodNumber].InputName)</b></p>
39+
<input type="radio" checked="checked" name="deliveryMethod" value="SMS" />
40+
<label>@Html.Raw(ViewBag.CodeExampleText.Forms[formNumber].Inputs[deliveryMethodSMS].InputName)</label>
41+
<input type="radio" name="deliveryMethod" value="WhatsApp"/>
42+
<label>@Html.Raw(ViewBag.CodeExampleText.Forms[formNumber].Inputs[deliveryMthodWhatsApp].InputName)</label>
43+
</div>
3444
<div class="form-group">
3545
<label for="signerCountryCode">
3646
@Html.Raw(ViewBag.CodeExampleText.Forms[formNumber].Inputs[countryCodeInputNumber].InputName)

manifest/CodeExamplesManifest.json

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -250,49 +250,58 @@
250250
],
251251
"ResultsPageText": ""
252252
},
253-
{
254-
"ExampleNumber": 37,
255-
"CFREnabled": "NonCFR",
256-
"ExampleName": "Request a signature by SMS delivery",
257-
"ExampleDescription": "Sends a signature request via an SMS message.",
258-
"LinksToAPIMethod": [
259-
{
260-
"Path": "https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/",
261-
"PathName": "Envelopes::create"
262-
}
263-
],
264-
"Forms": [
265-
{
266-
"Inputs": [
267-
{
268-
"InputName": "Signer Country Code",
269-
"InputPlaceholder": "1"
270-
},
271-
{
272-
"InputName": "Signer Phone Number",
273-
"InputPlaceholder": "4155551212"
274-
},
275-
{
276-
"InputName": "Signer Name",
277-
"InputPlaceholder": "Pat Johnson"
278-
},
279-
{
280-
"InputName": "CC Country Code",
281-
"InputPlaceholder": "1"
282-
},
283-
{
284-
"InputName": "CC Phone Number",
285-
"InputPlaceholder": "4155551212"
286-
},
287-
{
288-
"InputName": "CC Name",
289-
"InputPlaceholder": "Pat Johnson"
290-
}
291-
]
292-
}
293-
],
294-
"ResultsPageText": "The envelope has been created and sent!<br />Envelope ID {0}."
295-
},
253+
{
254+
"ExampleNumber": 37,
255+
"CFREnabled": "NonCFR",
256+
"ExampleName": "Request a signature by SMS or WhatsApp delivery",
257+
"ExampleDescription": "Sends a signature request via an SMS or WhatsApp message.",
258+
"LinksToAPIMethod": [
259+
{
260+
"Path": "https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/",
261+
"PathName": "Envelopes::create"
262+
}
263+
],
264+
"Forms": [
265+
{
266+
"Inputs": [
267+
{
268+
"InputName": "Signer Country Code",
269+
"InputPlaceholder": "1"
270+
},
271+
{
272+
"InputName": "Signer Phone Number",
273+
"InputPlaceholder": "4155551212"
274+
},
275+
{
276+
"InputName": "Signer Name",
277+
"InputPlaceholder": "Pat Johnson"
278+
},
279+
{
280+
"InputName": "CC Country Code",
281+
"InputPlaceholder": "1"
282+
},
283+
{
284+
"InputName": "CC Phone Number",
285+
"InputPlaceholder": "4155551212"
286+
},
287+
{
288+
"InputName": "CC Name",
289+
"InputPlaceholder": "Pat Johnson"
290+
},
291+
{
292+
"InputName": "Delivery Method:"
293+
},
294+
{
295+
"InputName": "SMS"
296+
},
297+
{
298+
"InputName": "WhatsApp"
299+
}
300+
]
301+
}
302+
],
303+
"ResultsPageText": "The envelope has been created and sent!<br />Envelope ID {0}."
304+
},
296305
{
297306
"ExampleNumber": 14,
298307
"CFREnabled": "NonCFR",

0 commit comments

Comments
 (0)