Skip to content

Commit 48c99a1

Browse files
Notary On-Demand (#101)
* Updating the web-form-config.json for the Web Forms example * new notary example wip * moving to the Notary section * fixing Docusign capitalization * fixing file cleanup * removing signature providers * removing incorrect codeDepot markers and pulling headers out of api call * adding back signature providers * removing extra properties * adding codeDepot markers --------- Co-authored-by: inbargazit <[email protected]>
1 parent 0d9b6e0 commit 48c99a1

File tree

2 files changed

+165
-0
lines changed

2 files changed

+165
-0
lines changed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#!/bin/bash
2+
# Use embedded signing
3+
#
4+
# Check that we're in a bash shell
5+
if [[ $SHELL != *"bash"* ]]; then
6+
echo "PROBLEM: Run these scripts from within the bash shell."
7+
fi
8+
9+
ds_access_token_path="config/ds_access_token.txt"
10+
api_account_id_path="config/API_ACCOUNT_ID"
11+
document_path="demo_documents/World_Wide_Corp_lorem.pdf"
12+
13+
if [ ! -f $ds_access_token_path ]; then
14+
ds_access_token_path="../config/ds_access_token.txt"
15+
api_account_id_path="../config/API_ACCOUNT_ID"
16+
document_path="../demo_documents/World_Wide_Corp_lorem.pdf"
17+
fi
18+
19+
# Step 1: Obtain your OAuth token
20+
# Note: Substitute these values with your own
21+
ACCESS_TOKEN=$(cat ${ds_access_token_path})
22+
23+
# Set up variables for full code example
24+
# Note: Substitute these values with your own
25+
ACCOUNT_ID=$(cat ${api_account_id_path})
26+
27+
28+
# Create the envelope.
29+
# The signer recipient includes a clientUserId setting
30+
#
31+
# document 1 (pdf) has tag /sn1/
32+
# The envelope will be sent to the signer.
33+
34+
base_path="https://demo.docusign.net/restapi"
35+
36+
# temp files:
37+
request_data=$(mktemp /tmp/request-eg-001.XXXXXX)
38+
response=$(mktemp /tmp/response-eg-001.XXXXXX)
39+
doc_base64=$(mktemp /tmp/eg-001-doc.XXXXXX)
40+
41+
cat demo_documents/World_Wide_Corp_Battle_Plan_Trafalgar.docx | base64 > $doc_base64
42+
43+
echo ""
44+
echo "Sending the envelope request to Docusign..."
45+
46+
# Construct API headers
47+
48+
#ds-snippet-start:Notary4Step2
49+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
50+
'--header' "Accept: application/json" \
51+
'--header' "Content-Type: application/json")
52+
#ds-snippet-end:Notary4Step2
53+
54+
# Concatenate the different parts of the request
55+
#ds-snippet-start:Notary4Step3
56+
printf \
57+
'{
58+
"emailSubject": "Please sign this document set",
59+
"documents": [
60+
{
61+
"documentBase64": "' >> $request_data
62+
cat $doc_base64 >> $request_data
63+
printf '",
64+
"name": "Order acknowledgement",
65+
"fileExtension": "html",
66+
"documentId": "1",
67+
},
68+
],
69+
"recipients": {
70+
"signers": [
71+
{
72+
"clientUserId": "1000",
73+
"email": "'"${SIGNER_EMAIL}"'",
74+
"name": "'"${SIGNER_NAME}"'",
75+
"recipientId": "2",
76+
"routingOrder": "1",
77+
"notaryId": "1",
78+
"tabs": {
79+
"signHereTabs": [
80+
{
81+
"documentId": "1",
82+
"xPosition": "200",
83+
"yPosition": "235",
84+
"pageNumber": "1",
85+
},
86+
{
87+
"stampType": "stamp",
88+
"documentId": "1",
89+
"xPosition": "200",
90+
"yPosition": "150",
91+
"pageNumber": "1",
92+
},
93+
],
94+
},
95+
}
96+
],
97+
"notaries": [
98+
{
99+
"name": "Notary",
100+
"recipientId": "1",
101+
"routingOrder": "1",
102+
"recipientSignatureProviders": [
103+
{
104+
"sealDocumentsWithTabsOnly": "false",
105+
"signatureProviderName": "ds_authority_idv"
106+
}
107+
],
108+
"tabs": {
109+
"notarySealTabs": [
110+
{
111+
"xPosition": "300",
112+
"yPosition": "235",
113+
"documentId": "1",
114+
"pageNumber": "1",
115+
},
116+
],
117+
"signHereTabs": [
118+
{
119+
"xPosition": "300",
120+
"yPosition": "150",
121+
"documentId": "1",
122+
"pageNumber": "1",
123+
},
124+
]
125+
},
126+
"notaryType": "remote",
127+
"notarySourceType": "thirdparty",
128+
"notaryThirdPartyPartner": "onenotary"
129+
}
130+
]
131+
},
132+
"status": "sent"
133+
}' >> $request_data
134+
#ds-snippet-end:Notary4Step3
135+
136+
# Call Docusign to create the envelope
137+
138+
#ds-snippet-start:Notary4Step4
139+
curl --data-binary @${request_data} \
140+
--request POST ${base_path}/v2.1/accounts/${ACCOUNT_ID}/envelopes \
141+
"${Headers[@]}" \
142+
--output ${response}
143+
#ds-snippet-end:Notary4Step4
144+
145+
echo ""
146+
echo "Response:" `cat $response`
147+
echo ""
148+
149+
# pull out the envelopeId
150+
envelope_id=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\":\"//' | sed 's/\",.*//'`
151+
echo "EnvelopeId: ${envelope_id}"
152+
153+
154+
# cleanup
155+
rm "$request_data"
156+
rm "$response"
157+
rm "$doc_base64"
158+
159+
echo ""
160+
echo "Done."

launcher.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ function startNotary() {
897897
"Signature_Request_To_Notary_Group" \
898898
"Invite_Notary_To_Pool" \
899899
"Jurisdictions" \
900+
"Signature_Request_Third_Party_Notary" \
900901
"Home"; do
901902
case "$CHOICE" in
902903

@@ -915,6 +916,10 @@ function startNotary() {
915916
bash examples/Notary/eg003Jurisdictions.sh
916917
startNotary
917918
;;
919+
Signature_Request_Third_Party_Notary)
920+
bash examples/Notary/eg004SendWithThirdPartyNotary.sh
921+
startNotary
922+
;;
918923
*)
919924
echo "Default action..."
920925
startNotary

0 commit comments

Comments
 (0)