Skip to content

Commit 59d3c11

Browse files
committed
use base_path var
1 parent 119ca8e commit 59d3c11

File tree

8 files changed

+40
-33
lines changed

8 files changed

+40
-33
lines changed

Examples/eg001EmbeddedSigning.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fi
1616
# The envelope will be sent first to the signer.
1717
# After it is signed, a copy is sent to the cc person.
1818

19+
base_path="https://demo.docusign.com/restapi"
1920
# temp files:
2021
request_data=$(mktemp /tmp/request-eg-001.XXXXXX)
2122
response=$(mktemp /tmp/response-eg-001.XXXXXX)
@@ -33,9 +34,8 @@ printf \
3334
"documents": [
3435
{
3536
"documentBase64": "' > $request_data
36-
cat $doc1_base64 >> $request_data
37-
printf \
38-
'",
37+
cat $doc1_base64 >> $request_data
38+
printf '",
3939
"name": "Lorem Ipsum",
4040
"fileExtension": "pdf",
4141
"documentId": "1"
@@ -76,7 +76,7 @@ printf \
7676
curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
7777
--header "Content-Type: application/json" \
7878
--data-binary @${request_data} \
79-
--request POST https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/envelopes \
79+
--request POST ${base_path}/v2/accounts/{ACCOUNT_ID}/envelopes \
8080
--output ${response}
8181

8282
echo ""
@@ -85,8 +85,8 @@ cat $response
8585
echo ""
8686

8787
# pull out the envelopeId
88-
ENVELOPE_ID=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\": \"//' | sed 's/\",//' | tr -d '\r'`
89-
echo "EnvelopeId: ${ENVELOPE_ID}"
88+
envelope_id=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\": \"//' | sed 's/\",.*//'`
89+
echo "EnvelopeId: ${envelope_id}"
9090

9191
# Step 2. Create a recipient view (a signing ceremony view)
9292
# that the signer will directly open in their browser to sign.
@@ -108,23 +108,23 @@ curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
108108
"userName": "{USER_FULLNAME}",
109109
"clientUserId": 1000,
110110
}' \
111-
--request POST https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/envelopes/${ENVELOPE_ID}/views/recipient \
111+
--request POST ${base_path}/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}/views/recipient \
112112
--output ${response}
113113

114114
echo ""
115115
echo "Response:"
116116
cat $response
117117
echo ""
118118

119-
SIGNING_CEREMONY_URL=`cat $response | grep url | sed 's/.*\"url\": \"//' | sed 's/\"//' | tr -d '\r'`
119+
signing_ceremony_url=`cat $response | grep url | sed 's/.*\"url\": \"//' | sed 's/\".*//'`
120120
echo ""
121121
echo "Attempting to automatically open your browser to the signing ceremony url..."
122122
if which open > /dev/null 2>/dev/null
123123
then
124-
open "$SIGNING_CEREMONY_URL"
124+
open "$signing_ceremony_url"
125125
elif which start > /dev/null
126126
then
127-
start "$SIGNING_CEREMONY_URL"
127+
start "$signing_ceremony_url"
128128
fi
129129

130130
# cleanup

Examples/eg002SigningViaEmail.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
if [[ $SHELL != *"bash"* ]]; then
55
echo "PROBLEM: Run these scripts from within the bash shell."
66
fi
7+
base_path="https://demo.docusign.com/restapi"
78

89
# document 1 (html) has tag **signature_1**
910
# document 2 (docx) has tag /sn1/
@@ -106,16 +107,16 @@ printf \
106107
curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
107108
--header "Content-Type: application/json" \
108109
--data-binary @${request_data} \
109-
--request POST https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/envelopes \
110+
--request POST ${base_path}/v2/accounts/{ACCOUNT_ID}/envelopes \
110111
--output $response
111112

112113
echo ""
113114
cat $response
114115

115116
# pull out the envelopeId
116-
ENVELOPE_ID=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\": \"//' | sed 's/\",//' | tr -d '\r'`
117+
envelope_id=`cat $response | grep envelopeId | sed 's/.*\"envelopeId\": \"//' | sed 's/\",//' | tr -d '\r'`
117118
# Save the envelope id for use by other scripts
118-
echo ${ENVELOPE_ID} > ../ENVELOPE_ID
119+
echo ${envelope_id} > ../ENVELOPE_ID
119120

120121
# cleanup
121122
rm "$request_data"

Examples/eg003ListEnvelopes.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
if [[ $SHELL != *"bash"* ]]; then
66
echo "PROBLEM: Run these scripts from within the bash shell."
77
fi
8+
base_path="https://demo.docusign.com/restapi"
89

910
echo ""
1011
echo "Sending the list envelope status request to DocuSign..."
@@ -22,7 +23,7 @@ curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
2223
--header "Content-Type: application/json" \
2324
--get \
2425
--data-urlencode "from_date=${from_date}" \
25-
--request GET https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/envelopes
26+
--request GET ${base_path}/v2/accounts/{ACCOUNT_ID}/envelopes
2627

2728
echo ""
2829
echo ""

Examples/eg004EnvelopeInfo.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Get the envelope's details
2-
# This script uses the envelope_id stored in ../ENVELOPE_ID.
3-
# The ENVELOPE_ID file is created by example eg002SigningViaEmail.sh or
2+
# This script uses the envelope_id stored in ../envelope_id.
3+
# The envelope_id file is created by example eg002SigningViaEmail.sh or
44
# can be manually created.
55

66

77
# Check that we're in a bash shell
88
if [[ $SHELL != *"bash"* ]]; then
99
echo "PROBLEM: Run these scripts from within the bash shell."
1010
fi
11+
base_path="https://demo.docusign.com/restapi"
1112

1213
# Check that we have an envelope id
1314
if [ ! -f ../ENVELOPE_ID ]; then
@@ -25,7 +26,7 @@ echo ""
2526

2627
curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
2728
--header "Content-Type: application/json" \
28-
--request GET https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}
29+
--request GET ${base_path}/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}
2930

3031
echo ""
3132
echo ""

Examples/eg005EnvelopeRecipients.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Get the envelope recipients' details
2-
# This script uses the envelope_id stored in ../ENVELOPE_ID.
3-
# The ENVELOPE_ID file is created by example eg002SigningViaEmail.sh or
2+
# This script uses the envelope_id stored in ../envelope_id.
3+
# The envelope_id file is created by example eg002SigningViaEmail.sh or
44
# can be manually created.
55

66

77
# Check that we're in a bash shell
88
if [[ $SHELL != *"bash"* ]]; then
99
echo "PROBLEM: Run these scripts from within the bash shell."
1010
fi
11+
base_path="https://demo.docusign.com/restapi"
1112

1213
# Check that we have an envelope id
1314
if [ ! -f ../ENVELOPE_ID ]; then
@@ -25,7 +26,7 @@ echo ""
2526

2627
curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
2728
--header "Content-Type: application/json" \
28-
--request GET https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}/recipients
29+
--request GET ${base_path}/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}/recipients
2930

3031
echo ""
3132
echo ""

Examples/eg006EnvelopeDocs.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# List the envelope's documents
2-
# This script uses the envelope_id stored in ../ENVELOPE_ID.
3-
# The ENVELOPE_ID file is created by example eg002SigningViaEmail.sh or
2+
# This script uses the envelope_id stored in ../envelope_id.
3+
# The envelope_id file is created by example eg002SigningViaEmail.sh or
44
# can be manually created.
55

6-
76
# Check that we're in a bash shell
87
if [[ $SHELL != *"bash"* ]]; then
98
echo "PROBLEM: Run these scripts from within the bash shell."
109
fi
10+
base_path="https://demo.docusign.com/restapi"
1111

1212
# Check that we have an envelope id
13-
if [ ! -f ../ENVELOPE_ID ]; then
13+
if [ ! -f ../envelope_id ]; then
1414
echo ""
1515
echo "PROBLEM: An envelope id is needed. Fix: execute script eg002SigningViaEmail.sh"
1616
echo ""
1717
exit -1
1818
fi
19-
envelope_id=`cat ../ENVELOPE_ID`
19+
envelope_id=`cat ../envelope_id`
2020

2121
echo ""
2222
echo "Sending the EnvelopeDocuments::list request to DocuSign..."
@@ -25,7 +25,7 @@ echo ""
2525

2626
curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
2727
--header "Content-Type: application/json" \
28-
--request GET https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}/documents
28+
--request GET ${base_path}/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}/documents
2929

3030
echo ""
3131
echo ""

Examples/eg007EnvelopeGetDoc.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
# Download a document from an envelope
2-
# This script uses the envelope_id stored in ../ENVELOPE_ID.
3-
# The ENVELOPE_ID file is created by example eg002SigningViaEmail.sh or
2+
# This script uses the envelope_id stored in ../envelope_id.
3+
# The envelope_id file is created by example eg002SigningViaEmail.sh or
44
# can be manually created.
55

66
output_file="envelope_document."
7+
78
# Check that we're in a bash shell
89
if [[ $SHELL != *"bash"* ]]; then
910
echo "PROBLEM: Run these scripts from within the bash shell."
1011
fi
12+
base_path="https://demo.docusign.com/restapi"
1113

1214
# Check that we have an envelope id
13-
if [ ! -f ../ENVELOPE_ID ]; then
15+
if [ ! -f ../envelope_id ]; then
1416
echo ""
1517
echo "PROBLEM: An envelope id is needed. Fix: execute script eg002SigningViaEmail.sh"
1618
echo ""
1719
exit -1
1820
fi
19-
envelope_id=`cat ../ENVELOPE_ID`
21+
envelope_id=`cat ../envelope_id`
2022

2123
doc_choice=1
2224
output_file_extension=pdf
@@ -56,7 +58,7 @@ echo ""
5658

5759
curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
5860
--header "Content-Type: application/json" \
59-
--request GET https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}/documents/${doc_choice} \
61+
--request GET ${base_path}/v2/accounts/{ACCOUNT_ID}/envelopes/${envelope_id}/documents/${doc_choice} \
6062
--output ${output_file}${output_file_extension}
6163

6264
echo ""

Examples/eg008CreateTemplate.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
if [[ $SHELL != *"bash"* ]]; then
77
echo "PROBLEM: Run these scripts from within the bash shell."
88
fi
9+
base_path="https://demo.docusign.com/restapi"
910

1011
# Step 1. List the account's templates
1112
echo ""
@@ -17,7 +18,7 @@ curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
1718
--header "Content-Type: application/json" \
1819
--get \
1920
--data-urlencode "search_text=${template_name}" \
20-
--request GET https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/templates \
21+
--request GET ${base_path}/v2/accounts/{ACCOUNT_ID}/templates \
2122
--output $response
2223

2324
# pull out the templateId if it was returned
@@ -174,7 +175,7 @@ printf \
174175
curl --header "Authorization: Bearer {ACCESS_TOKEN}" \
175176
--header "Content-Type: application/json" \
176177
--data-binary @${request_data} \
177-
--request POST https://demo.docusign.net/restapi/v2/accounts/{ACCOUNT_ID}/templates \
178+
--request POST ${base_path}/v2/accounts/{ACCOUNT_ID}/templates \
178179
--output $response
179180

180181
echo ""

0 commit comments

Comments
 (0)