Skip to content

Commit a572e61

Browse files
committed
Merge branch 'master' of https://github.com/docusign/eg-03-curl
2 parents 21d0a18 + 7625f1e commit a572e61

9 files changed

+825
-0
lines changed

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,30 @@ This repo includes bash scripts that use curl to demonstrate:
7979
1. **Send an envelope with a remote (email) signer using Identity Verification.**
8080
[Source.](./examples/eg023SigningViaEmailWithIDVAuthentication.sh)
8181
This example sends an envelope using remote (email) signing requiring the recipient to validate their identity via a government issued ID.
82+
1. **Create a permissions profile to set against a user group.**
83+
[Source.](./examples/eg024CreatingPermissionProfiles.sh)
84+
This example creates a permissions profile that can be used to set account permissions for the different user groups associated with your account.
85+
1. **Set a permissions profile against a user group.**
86+
[Source.](./examples/eg025SettingPermissionProfiles.sh)
87+
This example updates a user group by setting the permissions profile.
88+
1. **Update individual settings on a permissions profile.**
89+
[Source.](./examples/eg026UpdatingIndividualPermission.sh)
90+
This example updates a user group by setting the permissions profile.
91+
1. **Delete a permissions profile**
92+
[Source.](./examples/eg027DeletingPermissions.sh)
93+
This example deletes a permissions profile.
94+
1. **Creating a brand**
95+
[Source.](./examples/eg028CreatingABrand.sh)
96+
This example creates a brand on your account that can be used to override style elements on envelopes.
97+
1. **Apply a brand to an envelope**
98+
[Source.](./examples/eg029ApplyingBrandEnvelope.sh)
99+
This example sends a branded envelope.
100+
1. **Apply a brand to a template**
101+
[Source.](./examples/eg030ApplyingBrandTemplate.sh)
102+
This example sends a branded templated envelope.
103+
1. **Sending bulk envelopes to multiple recipients**
104+
[Source.](./examples/eg031BulkSending.sh)
105+
This example creates and sends a bulk envelope by generating a bulk recipient list and initiating a bulk send.
82106

83107
## Installation
84108

@@ -148,6 +172,15 @@ bash eg020SigningViaEmailWithSmsAuthentication.sh
148172
bash eg021SigningViaEmailWithPhoneAuthentication.sh
149173
bash eg022SigningViaEmailWithKnoweldgeBasedAuthentication.sh
150174
bash eg023SigningViaEmailWithIDVAuthentication.sh
175+
bash eg024CreatingPermissionProfiles.sh
176+
bash eg025SettingPermissionProfiles.sh
177+
bash eg026UpdatingIndividualPermission.sh
178+
bash eg027DeletingPermissions.sh
179+
bash eg028CreatingABrand.sh
180+
bash eg029ApplyingBrandEnvelope.sh
181+
bash eg030ApplyingBrandTemplate.sh
182+
bash eg031BulkSending.sh
183+
151184
152185
# Note: to use example 14 you must also configure a
153186
# payment gateway for your account.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Create Permission Profile
2+
3+
# Step 1: Obtain your OAuth token
4+
# Note: Substitute these values with your own
5+
# Set up variables for full code example
6+
ACCESS_TOKEN="{ACCESS_TOKEN}"
7+
API_ACCOUNT_ID="{ACCOUNT_ID}"
8+
9+
# Check that we're in a bash shell
10+
if [[ $SHELL != *"bash"* ]]; then
11+
echo "PROBLEM: Run these scripts from within the bash shell."
12+
fi
13+
BASE_PATH="https://demo.docusign.net/restapi"
14+
15+
# Step 2: Construct your API headers
16+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
17+
'--header' "Accept: application/json" \
18+
'--header' "Content-Type: application/json")
19+
20+
# Step 3: Construct the request body for your pemisison profile
21+
# Create a temporary file to store the request body
22+
request_data=$(mktemp /tmp/request-perm-001.XXXXXX)
23+
printf \
24+
'{
25+
"permissionProfileName": "Ipsum Reader",
26+
"settings" : {
27+
"useNewDocuSignExperienceInterface":0,
28+
"allowBulkSending":"true",
29+
"allowEnvelopeSending":"true",
30+
"allowSignerAttachments":"true",
31+
"allowTaggingInSendAndCorrect":"true",
32+
"allowWetSigningOverride":"true",
33+
"allowedAddressBookAccess":"personalAndShared",
34+
"allowedTemplateAccess":"share",
35+
"enableRecipientViewingNotifications":"true",
36+
"enableSequentialSigningInterface":"true",
37+
"receiveCompletedSelfSignedDocumentsAsEmailLinks":"false",
38+
"signingUiVersion":"v2",
39+
"useNewSendingInterface":"true",
40+
"allowApiAccess":"true",
41+
"allowApiAccessToAccount":"true",
42+
"allowApiSendingOnBehalfOfOthers":"true",
43+
"allowApiSequentialSigning":"true",
44+
"enableApiRequestLogging":"true",
45+
"allowDocuSignDesktopClient":"false",
46+
"allowSendersToSetRecipientEmailLanguage":"true",
47+
"allowVaulting":"false",
48+
"allowedToBeEnvelopeTransferRecipient":"true",
49+
"enableTransactionPointIntegration":"false",
50+
"powerFormRole":"admin",
51+
"vaultingMode":"none"
52+
}
53+
}' >> $request_data
54+
55+
# Step 4: a) Call the eSignature API
56+
# b) Display the JSON response
57+
# Create a temporary file to store the response
58+
response=$(mktemp /tmp/response-perm.XXXXXX)
59+
60+
Status=$(curl -w '%{http_code}' -i --request POST ${BASE_PATH}/v2.1/accounts/${API_ACCOUNT_ID}/permission_profiles \
61+
"${Headers[@]}" \
62+
--data-binary @${request_data} \
63+
--output ${response})
64+
65+
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response
66+
if [[ "$Status" -gt "201" ]] ; then
67+
echo ""
68+
echo "Unable to create a new permissions profile."
69+
echo ""
70+
cat $response
71+
exit 1
72+
fi
73+
74+
echo ""
75+
echo "Response:"
76+
cat $response
77+
echo ""
78+
79+
# Remove the temporary files
80+
rm "$request_data"
81+
rm "$response"
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Setting a permission profile
2+
3+
# Step 1: Obtain your OAuth token
4+
# Set up variables for full code example
5+
# Note: Substitute these values with your own
6+
ACCESS_TOKEN="{ACCESS_TOKEN}"
7+
API_ACCOUNT_ID="{API_ACCOUNT_ID}"
8+
PROFILE_ID="{PROFILE_ID}"
9+
GROUP_ID="{GROUP_ID}"
10+
11+
12+
# Check that we're in a bash shell
13+
if [[ $SHELL != *"bash"* ]]; then
14+
echo "PROBLEM: Run these scripts from within the bash shell."
15+
fi
16+
BASE_PATH="https://demo.docusign.net/restapi"
17+
18+
# Step 2: Construct your API headers
19+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
20+
'--header' "Accept: application/json" \
21+
'--header' "Content-Type: application/json")
22+
23+
# Step 3: Construct your request body
24+
# Create a temporary file to store the request body
25+
request_data=$(mktemp /tmp/request-perm-001.XXXXXX)
26+
printf \
27+
"{
28+
\"groups\": [
29+
{
30+
\"groupId\": "${GROUP_ID}",
31+
\"permissionProfileId\": "${PROFILE_ID}"
32+
}
33+
]
34+
}}" >> $request_data
35+
36+
# Step 4: a) Call the eSignature API
37+
# b) Display the JSON response
38+
# Create a temporary file to store the response
39+
response=$(mktemp /tmp/response-perm.XXXXXX)
40+
41+
Status=$(curl -w '%{http_code}' -i --request PUT ${BASE_PATH}/v2.1/accounts/${API_ACCOUNT_ID}/groups \
42+
"${Headers[@]}" \
43+
--data-binary @${request_data} \
44+
--output ${response})
45+
46+
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response
47+
if [[ "$Status" -gt "201" ]] ; then
48+
echo ""
49+
echo "Unable to set group permissions profile."
50+
echo ""
51+
cat $response
52+
exit 1
53+
fi
54+
55+
echo ""
56+
echo "Response:"
57+
cat $response
58+
echo ""
59+
60+
# Remove the temporary files
61+
rm "$request_data"
62+
rm "$response"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Updating Individual Permissions
2+
3+
# Step 1: Obtain your OAuth token
4+
# Note: Substitute these values with your own
5+
# Set up variables for full code example
6+
ACCESS_TOKEN="{ACCESS_TOKEN}"
7+
API_ACCOUNT_ID="{API_ACCOUNT_ID}"
8+
PERMISSION_PROFILE_ID="{PERMISSION_PROFILE_ID}"
9+
10+
# Check that we're in a bash shell
11+
if [[ $SHELL != *"bash"* ]]; then
12+
echo "PROBLEM: Run these scripts from within the bash shell."
13+
fi
14+
base_path="https://demo.docusign.net/restapi"
15+
16+
# Step 2: Construct your API headers
17+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
18+
'--header' "Accept: application/json" \
19+
'--header' "Content-Type: application/json")
20+
21+
# Step 3: Construct the request body for your pemisison profile
22+
# Create a temporary file to store the request body
23+
request_data=$(mktemp /tmp/request-perm-001.XXXXXX)
24+
printf \
25+
'{
26+
"permissionProfileName": "Ipsum Reader",
27+
"settings" : {
28+
"useNewDocuSignExperienceInterface":0,
29+
"allowBulkSending":"true",
30+
"allowEnvelopeSending":"true",
31+
"allowSignerAttachments":"true",
32+
"allowTaggingInSendAndCorrect":"true",
33+
"allowWetSigningOverride":"true",
34+
"allowedAddressBookAccess":"personalAndShared",
35+
"allowedTemplateAccess":"share",
36+
"enableRecipientViewingNotifications":"true",
37+
"enableSequentialSigningInterface":"true",
38+
"receiveCompletedSelfSignedDocumentsAsEmailLinks":"false",
39+
"signingUiVersion":"v2",
40+
"useNewSendingInterface":"true",
41+
"allowApiAccess":"true",
42+
"allowApiAccessToAccount":"true",
43+
"allowApiSendingOnBehalfOfOthers":"true",
44+
"allowApiSequentialSigning":"true",
45+
"enableApiRequestLogging":"true",
46+
"allowDocuSignDesktopClient":"false",
47+
"allowSendersToSetRecipientEmailLanguage":"true",
48+
"allowVaulting":"false",
49+
"allowedToBeEnvelopeTransferRecipient":"true",
50+
"enableTransactionPointIntegration":"false",
51+
"powerFormRole":"admin",
52+
"vaultingMode":"none"
53+
}
54+
}' >> $request_data
55+
56+
# Step 4: a) Call the eSignature API
57+
# b) Display the JSON response
58+
# Create a temporary file to store the response
59+
response=$(mktemp /tmp/response-perm.XXXXXX)
60+
61+
Status=$(curl -w '%{http_code}' -i --request POST ${BASE_PATH}/v2.1/accounts/${API_ACCOUNT_ID}/permission_profiles/${PERMISSION_PROFILE_ID} \
62+
"${Headers[@]}" \
63+
--data-binary @${request_data} \
64+
--output ${response})
65+
66+
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response
67+
if [[ "$Status" -gt "201" ]] ; then
68+
echo ""
69+
echo "Updating Individual Permission Settings failed."
70+
echo ""
71+
cat $response
72+
exit 1
73+
fi
74+
75+
echo ""
76+
echo "Response:"
77+
cat $response
78+
echo ""
79+
80+
# Remove the temporary files
81+
rm "$request_data"
82+
rm "$response"

examples/eg027DeletingPermissions.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Delete a permission profile
2+
3+
# Step 1: Obtain your OAuth token
4+
# Note: Substitute these values with your own
5+
# Set up variables for full code example
6+
ACCESS_TOKEN="{ACCESS_TOKEN}"
7+
API_ACCOUNT_ID="{ACCOUNT_ID}"
8+
PROFILE_ID="{PROFILE_ID]"
9+
10+
# Check that we're in a bash shell
11+
if [[ $SHELL != *"bash"* ]]; then
12+
echo "PROBLEM: Run these scripts from within the bash shell."
13+
fi
14+
BASE_PATH="https://demo.docusign.net/restapi"
15+
16+
#Step 2: Construct your API headers
17+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
18+
'--header' "Accept: application/json" \
19+
'--header' "Content-Type: application/json")
20+
21+
# Step 3: a) Call the eSignature API
22+
# b) Display the JSON response
23+
# Create a temporary file to store the response
24+
response=$(mktemp /tmp/response-perm.XXXXXX)
25+
26+
Status=$(curl -w '%{http_code}' -i --request DELETE ${BASE_PATH}/v2.1/accounts/${APIAccountID}/permission_profiles/${PROFILE_ID} \
27+
"${Headers[@]}" \
28+
--output ${response})
29+
30+
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response
31+
if [[ "$Status" -gt "201" ]] ; then
32+
echo ""
33+
echo "Unable to delete the permission profile."
34+
echo ""
35+
cat $response
36+
exit 1
37+
fi
38+
39+
echo ""
40+
echo "Response:"
41+
cat $response
42+
echo ""
43+
44+
# Remove the temporary files
45+
rm "$request_data"
46+
rm "$response"

examples/eg028CreatingABrand.sh

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Creating a brand
2+
3+
# Step 1: Obtain your OAuth token
4+
# Note: Substitute these values with your own
5+
# Set up variables for full code example
6+
ACCESS_TOKEN="{ACCESS_TOKEN}"
7+
API_ACCOUNT_ID="{API_ACCOUNT_ID}"
8+
9+
# Check that we're in a bash shell
10+
if [[ $SHELL != *"bash"* ]]; then
11+
echo "PROBLEM: Run these scripts from within the bash shell."
12+
fi
13+
BASE_PATH="https://demo.docusign.net/restapi"
14+
15+
# Step 2: Construct your API headers
16+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
17+
'--header' "Accept: application/json" \
18+
'--header' "Content-Type: application/json")
19+
20+
# Step 3: Construct the request body
21+
# Create a temporary file to store the request body
22+
request_data=$(mktemp /tmp/request-brand-001.XXXXXX)
23+
printf \
24+
'{
25+
26+
"brandName": "Sample Corp.",
27+
"defaultBrandLanguage": "en"
28+
29+
}' >> $request_data
30+
31+
# Step 4: a) Call the eSignature API
32+
# b) Display the JSON response
33+
# Create a temporary file to store the response
34+
response=$(mktemp /tmp/response-brand.XXXXXX)
35+
36+
Status=$(curl -w '%{http_code}' -i --request POST ${BASE_PATH}/v2.1/accounts/${API_ACCOUNT_ID}/brands \
37+
"${Headers[@]}" \
38+
--data-binary @${request_data} \
39+
--output ${response})
40+
41+
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response
42+
if [[ "$Status" -gt "201" ]] ; then
43+
echo ""
44+
echo "Creating a new brand has failed."
45+
echo ""
46+
cat $response
47+
exit 1
48+
fi
49+
50+
echo ""
51+
echo "Response:"
52+
cat $response
53+
echo ""
54+
55+
# Remove the temporary files
56+
rm "$request_data"
57+
rm "$response"

0 commit comments

Comments
 (0)