-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/docusign/eg-03-curl
- Loading branch information
Showing
9 changed files
with
825 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Create Permission Profile | ||
|
||
# Step 1: Obtain your OAuth token | ||
# Note: Substitute these values with your own | ||
# Set up variables for full code example | ||
ACCESS_TOKEN="{ACCESS_TOKEN}" | ||
API_ACCOUNT_ID="{ACCOUNT_ID}" | ||
|
||
# Check that we're in a bash shell | ||
if [[ $SHELL != *"bash"* ]]; then | ||
echo "PROBLEM: Run these scripts from within the bash shell." | ||
fi | ||
BASE_PATH="https://demo.docusign.net/restapi" | ||
|
||
# Step 2: Construct your API headers | ||
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \ | ||
'--header' "Accept: application/json" \ | ||
'--header' "Content-Type: application/json") | ||
|
||
# Step 3: Construct the request body for your pemisison profile | ||
# Create a temporary file to store the request body | ||
request_data=$(mktemp /tmp/request-perm-001.XXXXXX) | ||
printf \ | ||
'{ | ||
"permissionProfileName": "Ipsum Reader", | ||
"settings" : { | ||
"useNewDocuSignExperienceInterface":0, | ||
"allowBulkSending":"true", | ||
"allowEnvelopeSending":"true", | ||
"allowSignerAttachments":"true", | ||
"allowTaggingInSendAndCorrect":"true", | ||
"allowWetSigningOverride":"true", | ||
"allowedAddressBookAccess":"personalAndShared", | ||
"allowedTemplateAccess":"share", | ||
"enableRecipientViewingNotifications":"true", | ||
"enableSequentialSigningInterface":"true", | ||
"receiveCompletedSelfSignedDocumentsAsEmailLinks":"false", | ||
"signingUiVersion":"v2", | ||
"useNewSendingInterface":"true", | ||
"allowApiAccess":"true", | ||
"allowApiAccessToAccount":"true", | ||
"allowApiSendingOnBehalfOfOthers":"true", | ||
"allowApiSequentialSigning":"true", | ||
"enableApiRequestLogging":"true", | ||
"allowDocuSignDesktopClient":"false", | ||
"allowSendersToSetRecipientEmailLanguage":"true", | ||
"allowVaulting":"false", | ||
"allowedToBeEnvelopeTransferRecipient":"true", | ||
"enableTransactionPointIntegration":"false", | ||
"powerFormRole":"admin", | ||
"vaultingMode":"none" | ||
} | ||
}' >> $request_data | ||
|
||
# Step 4: a) Call the eSignature API | ||
# b) Display the JSON response | ||
# Create a temporary file to store the response | ||
response=$(mktemp /tmp/response-perm.XXXXXX) | ||
|
||
Status=$(curl -w '%{http_code}' -i --request POST ${BASE_PATH}/v2.1/accounts/${API_ACCOUNT_ID}/permission_profiles \ | ||
"${Headers[@]}" \ | ||
--data-binary @${request_data} \ | ||
--output ${response}) | ||
|
||
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response | ||
if [[ "$Status" -gt "201" ]] ; then | ||
echo "" | ||
echo "Unable to create a new permissions profile." | ||
echo "" | ||
cat $response | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
echo "Response:" | ||
cat $response | ||
echo "" | ||
|
||
# Remove the temporary files | ||
rm "$request_data" | ||
rm "$response" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Setting a permission profile | ||
|
||
# Step 1: Obtain your OAuth token | ||
# Set up variables for full code example | ||
# Note: Substitute these values with your own | ||
ACCESS_TOKEN="{ACCESS_TOKEN}" | ||
API_ACCOUNT_ID="{API_ACCOUNT_ID}" | ||
PROFILE_ID="{PROFILE_ID}" | ||
GROUP_ID="{GROUP_ID}" | ||
|
||
|
||
# Check that we're in a bash shell | ||
if [[ $SHELL != *"bash"* ]]; then | ||
echo "PROBLEM: Run these scripts from within the bash shell." | ||
fi | ||
BASE_PATH="https://demo.docusign.net/restapi" | ||
|
||
# Step 2: Construct your API headers | ||
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \ | ||
'--header' "Accept: application/json" \ | ||
'--header' "Content-Type: application/json") | ||
|
||
# Step 3: Construct your request body | ||
# Create a temporary file to store the request body | ||
request_data=$(mktemp /tmp/request-perm-001.XXXXXX) | ||
printf \ | ||
"{ | ||
\"groups\": [ | ||
{ | ||
\"groupId\": "${GROUP_ID}", | ||
\"permissionProfileId\": "${PROFILE_ID}" | ||
} | ||
] | ||
}}" >> $request_data | ||
|
||
# Step 4: a) Call the eSignature API | ||
# b) Display the JSON response | ||
# Create a temporary file to store the response | ||
response=$(mktemp /tmp/response-perm.XXXXXX) | ||
|
||
Status=$(curl -w '%{http_code}' -i --request PUT ${BASE_PATH}/v2.1/accounts/${API_ACCOUNT_ID}/groups \ | ||
"${Headers[@]}" \ | ||
--data-binary @${request_data} \ | ||
--output ${response}) | ||
|
||
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response | ||
if [[ "$Status" -gt "201" ]] ; then | ||
echo "" | ||
echo "Unable to set group permissions profile." | ||
echo "" | ||
cat $response | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
echo "Response:" | ||
cat $response | ||
echo "" | ||
|
||
# Remove the temporary files | ||
rm "$request_data" | ||
rm "$response" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Updating Individual Permissions | ||
|
||
# Step 1: Obtain your OAuth token | ||
# Note: Substitute these values with your own | ||
# Set up variables for full code example | ||
ACCESS_TOKEN="{ACCESS_TOKEN}" | ||
API_ACCOUNT_ID="{API_ACCOUNT_ID}" | ||
PERMISSION_PROFILE_ID="{PERMISSION_PROFILE_ID}" | ||
|
||
# Check that we're in a bash shell | ||
if [[ $SHELL != *"bash"* ]]; then | ||
echo "PROBLEM: Run these scripts from within the bash shell." | ||
fi | ||
base_path="https://demo.docusign.net/restapi" | ||
|
||
# Step 2: Construct your API headers | ||
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \ | ||
'--header' "Accept: application/json" \ | ||
'--header' "Content-Type: application/json") | ||
|
||
# Step 3: Construct the request body for your pemisison profile | ||
# Create a temporary file to store the request body | ||
request_data=$(mktemp /tmp/request-perm-001.XXXXXX) | ||
printf \ | ||
'{ | ||
"permissionProfileName": "Ipsum Reader", | ||
"settings" : { | ||
"useNewDocuSignExperienceInterface":0, | ||
"allowBulkSending":"true", | ||
"allowEnvelopeSending":"true", | ||
"allowSignerAttachments":"true", | ||
"allowTaggingInSendAndCorrect":"true", | ||
"allowWetSigningOverride":"true", | ||
"allowedAddressBookAccess":"personalAndShared", | ||
"allowedTemplateAccess":"share", | ||
"enableRecipientViewingNotifications":"true", | ||
"enableSequentialSigningInterface":"true", | ||
"receiveCompletedSelfSignedDocumentsAsEmailLinks":"false", | ||
"signingUiVersion":"v2", | ||
"useNewSendingInterface":"true", | ||
"allowApiAccess":"true", | ||
"allowApiAccessToAccount":"true", | ||
"allowApiSendingOnBehalfOfOthers":"true", | ||
"allowApiSequentialSigning":"true", | ||
"enableApiRequestLogging":"true", | ||
"allowDocuSignDesktopClient":"false", | ||
"allowSendersToSetRecipientEmailLanguage":"true", | ||
"allowVaulting":"false", | ||
"allowedToBeEnvelopeTransferRecipient":"true", | ||
"enableTransactionPointIntegration":"false", | ||
"powerFormRole":"admin", | ||
"vaultingMode":"none" | ||
} | ||
}' >> $request_data | ||
|
||
# Step 4: a) Call the eSignature API | ||
# b) Display the JSON response | ||
# Create a temporary file to store the response | ||
response=$(mktemp /tmp/response-perm.XXXXXX) | ||
|
||
Status=$(curl -w '%{http_code}' -i --request POST ${BASE_PATH}/v2.1/accounts/${API_ACCOUNT_ID}/permission_profiles/${PERMISSION_PROFILE_ID} \ | ||
"${Headers[@]}" \ | ||
--data-binary @${request_data} \ | ||
--output ${response}) | ||
|
||
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response | ||
if [[ "$Status" -gt "201" ]] ; then | ||
echo "" | ||
echo "Updating Individual Permission Settings failed." | ||
echo "" | ||
cat $response | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
echo "Response:" | ||
cat $response | ||
echo "" | ||
|
||
# Remove the temporary files | ||
rm "$request_data" | ||
rm "$response" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Delete a permission profile | ||
|
||
# Step 1: Obtain your OAuth token | ||
# Note: Substitute these values with your own | ||
# Set up variables for full code example | ||
ACCESS_TOKEN="{ACCESS_TOKEN}" | ||
API_ACCOUNT_ID="{ACCOUNT_ID}" | ||
PROFILE_ID="{PROFILE_ID]" | ||
|
||
# Check that we're in a bash shell | ||
if [[ $SHELL != *"bash"* ]]; then | ||
echo "PROBLEM: Run these scripts from within the bash shell." | ||
fi | ||
BASE_PATH="https://demo.docusign.net/restapi" | ||
|
||
#Step 2: Construct your API headers | ||
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \ | ||
'--header' "Accept: application/json" \ | ||
'--header' "Content-Type: application/json") | ||
|
||
# Step 3: a) Call the eSignature API | ||
# b) Display the JSON response | ||
# Create a temporary file to store the response | ||
response=$(mktemp /tmp/response-perm.XXXXXX) | ||
|
||
Status=$(curl -w '%{http_code}' -i --request DELETE ${BASE_PATH}/v2.1/accounts/${APIAccountID}/permission_profiles/${PROFILE_ID} \ | ||
"${Headers[@]}" \ | ||
--output ${response}) | ||
|
||
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response | ||
if [[ "$Status" -gt "201" ]] ; then | ||
echo "" | ||
echo "Unable to delete the permission profile." | ||
echo "" | ||
cat $response | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
echo "Response:" | ||
cat $response | ||
echo "" | ||
|
||
# Remove the temporary files | ||
rm "$request_data" | ||
rm "$response" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Creating a brand | ||
|
||
# Step 1: Obtain your OAuth token | ||
# Note: Substitute these values with your own | ||
# Set up variables for full code example | ||
ACCESS_TOKEN="{ACCESS_TOKEN}" | ||
API_ACCOUNT_ID="{API_ACCOUNT_ID}" | ||
|
||
# Check that we're in a bash shell | ||
if [[ $SHELL != *"bash"* ]]; then | ||
echo "PROBLEM: Run these scripts from within the bash shell." | ||
fi | ||
BASE_PATH="https://demo.docusign.net/restapi" | ||
|
||
# Step 2: Construct your API headers | ||
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \ | ||
'--header' "Accept: application/json" \ | ||
'--header' "Content-Type: application/json") | ||
|
||
# Step 3: Construct the request body | ||
# Create a temporary file to store the request body | ||
request_data=$(mktemp /tmp/request-brand-001.XXXXXX) | ||
printf \ | ||
'{ | ||
"brandName": "Sample Corp.", | ||
"defaultBrandLanguage": "en" | ||
}' >> $request_data | ||
|
||
# Step 4: a) Call the eSignature API | ||
# b) Display the JSON response | ||
# Create a temporary file to store the response | ||
response=$(mktemp /tmp/response-brand.XXXXXX) | ||
|
||
Status=$(curl -w '%{http_code}' -i --request POST ${BASE_PATH}/v2.1/accounts/${API_ACCOUNT_ID}/brands \ | ||
"${Headers[@]}" \ | ||
--data-binary @${request_data} \ | ||
--output ${response}) | ||
|
||
# If the Status code returned is greater than 201 (OK/Accepted), display an error message along with the API response | ||
if [[ "$Status" -gt "201" ]] ; then | ||
echo "" | ||
echo "Creating a new brand has failed." | ||
echo "" | ||
cat $response | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
echo "Response:" | ||
cat $response | ||
echo "" | ||
|
||
# Remove the temporary files | ||
rm "$request_data" | ||
rm "$response" |
Oops, something went wrong.