1- # List envelopes and their status
2- # List changes for the last 10 days
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- base_path=" https://demo.docusign.net/restapi"
1+ # Redirect to the DocuSign console web tool
92
103# Configuration
114# 1. Obtain an OAuth access token from
@@ -16,30 +9,74 @@ access_token='{ACCESS_TOKEN}'
169# the default picture.
1710account_id=' {ACCOUNT_ID}'
1811
19- echo " "
20- echo " Sending the list envelope status request to DocuSign..."
21- echo " Results:"
22- echo " "
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"
2317
24- # Calculate the from_date query parameter and use the ISO 8601 format.
25- # Example:
26- # from_date=2018-09-30T07:43:12+03:00
27- # For a Mac, 10 days in the past:
28- if date -v -10d & > /dev/null ; then
29- # Mac
30- from_date=` date -v -10d ' +%Y-%m-%dT%H:%M:%S%z' `
31- else
32- # Not a Mac
33- from_date=` date --date=' -10 days' ' +%Y-%m-%dT%H:%M:%S%z' `
18+ # Check that we have an envelope id
19+ if [ ! -f ../ENVELOPE_ID ]; then
20+ echo " "
21+ echo " PROBLEM: An envelope id is needed. Fix: execute script eg002SigningViaEmail.sh"
22+ echo " "
23+ exit -1
3424fi
25+ envelope_id=` cat ../ENVELOPE_ID`
26+
27+ # The returnUrl is normally your own web app. DocuSign will redirect
28+ # the signer to returnUrl when the signing ceremony completes.
29+ # For this example, we'll use http://httpbin.org/get to show the
30+ # query parameters passed back from DocuSign
31+
32+ # The web tool console can be opened in either of two views:
33+ echo " "
34+ PS3=' Select the console view: '
35+ options=(" Front page" " Envelope view" )
36+ select opt in " ${options[@]} "
37+ do
38+ case $opt in
39+ " Front page" )
40+ json=' {"returnUrl": "http://httpbin.org/get"}'
41+ break
42+ ;;
43+ " Envelope view" )
44+ json=" {\" returnUrl\" : \" http://httpbin.org/get\" ,
45+ \" envelopeId\" : \" ${envelope_id} \" }"
46+ break
47+ ;;
48+ esac
49+ done
50+
51+ echo " "
52+ echo " Requesting the console view url"
53+ echo " "
3554
55+ response=$( mktemp /tmp/response-eg-012.XXXXXX)
3656curl --header " Authorization: Bearer ${access_token} " \
3757 --header " Content-Type: application/json" \
38- --get \
39- --data-urlencode " from_date=${from_date} " \
40- --request GET ${base_path} /v2/accounts/${account_id} /envelopes
58+ --data-binary " ${json} " \
59+ --request POST ${base_path} /v2/accounts/${account_id} /views/console
4160
4261echo " "
62+ echo " Results:"
63+ echo " "
64+ cat $response
65+ console_url=` cat $response | grep url | sed ' s/.*\"url\": \"//' | sed ' s/\".*//' `
66+ echo " "
67+ printf " The console URL is ${console_url} \n"
68+ printf " It is only valid for a couple of minutes. Attempting to automatically open your browser...\n"
69+ if which xdg-open & > /dev/null ; then
70+ xdg-open " $console_url "
71+ elif which open & > /dev/null ; then
72+ open " $console_url "
73+ elif which start & > /dev/null ; then
74+ start " $console_url "
75+ fi
76+
77+ # cleanup
78+ rm " $response "
79+
4380echo " "
4481echo " Done."
4582echo " "
0 commit comments