Skip to content

Commit dcf4764

Browse files
paigesrossiInbarGazitkarissarjacobsen
authored
Adding Navigator API (#97)
* Updating the web-form-config.json for the Web Forms example * adding Navigator example and structure * ssl issue and codeDepot * Get Single Agreement (#98) * Get Single Agreement Signed-off-by: karissarjacobsen <[email protected]> * add code depot tags to navigator 2 --------- Signed-off-by: karissarjacobsen <[email protected]> Co-authored-by: inbargazit <[email protected]> Co-authored-by: karissarjacobsen <[email protected]> Co-authored-by: Karissa Jacobsen <[email protected]>
1 parent 1a13471 commit dcf4764

File tree

6 files changed

+201
-1
lines changed

6 files changed

+201
-1
lines changed

OAuth/code_grant.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
$scope = "signature webforms_read webforms_instance_read webforms_instance_write";
2929
elseif($api_version == "Maestro") :
3030
$scope = "signature aow_manage";
31+
elseif($api_version == "Navigator") :
32+
$scope = "signature adm_store_unified_repo_read";
3133
endif;
3234

3335
function generateCodeVerifier() {

OAuth/jwt.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
} else if ($api_version == "WebForms") {
3333
$scope = "signature impersonation webforms_read webforms_instance_read webforms_instance_write";
3434
} else if ($api_version == "Maestro") {
35-
$scope = "signature aow_manage";
35+
$scope = "signature aow_manage";
36+
} else if ($api_version == "Navigator") {
37+
$scope = "signature adm_store_unified_repo_read";
3638
}
3739

3840
$body = encodeBase64URL(

OAuth/jwt_auth.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
"signature", "aow_manage"
6161
]
6262

63+
NAVIGATOR_SCOPES = [
64+
"signature", "adm_store_unified_repo_read"
65+
]
66+
6367
class DSClient:
6468

6569
ds_app = None
@@ -83,6 +87,8 @@ def _jwt_auth(cls):
8387
use_scopes = NOTARY_SCOPES
8488
elif (API_VERSION == "Maestro"):
8589
use_scopes = MAESTRO_SCOPES
90+
elif (API_VERSION == "Navigator"):
91+
use_scopes = NAVIGATOR_SCOPES
8692
else:
8793
use_scopes = SCOPES
8894

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Check that we're in a bash shell
2+
if [[ $SHELL != *"bash"* ]]; then
3+
echo "PROBLEM: Run these scripts from within the bash shell."
4+
fi
5+
6+
ds_access_token_path="config/ds_access_token.txt"
7+
agreements="config/AGREEMENTS.txt"
8+
9+
# Obtain your OAuth token
10+
# Note: Substitute these values with your own
11+
ACCESS_TOKEN=$(cat ${ds_access_token_path})
12+
13+
# Set up variables for full code example
14+
# Note: Substitute these values with your own
15+
ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
16+
base_path="https://api-d.docusign.com/v1"
17+
18+
#ds-snippet-start:Navigator1Step2
19+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
20+
'--header' "Accept: application/json" \
21+
'--header' "Content-Type: application/json")
22+
#ds-snippet-end:Navigator1Step2
23+
24+
# List agreements
25+
#ds-snippet-start:Navigator1Step3
26+
response=$(mktemp /tmp/response-cw.XXXXXX)
27+
Status=$(curl -w '%{http_code}' -i --ssl-no-revoke --request GET ${base_path}/accounts/${ACCOUNT_ID}/agreements \
28+
"${Headers[@]}" \
29+
--output ${response})
30+
#ds-snippet-end:Navigator1Step3
31+
32+
if [[ "$Status" -gt "399" ]] ; then
33+
echo ""
34+
echo "Listing agreements..."
35+
echo ""
36+
cat $response
37+
exit 0
38+
fi
39+
40+
echo ""
41+
echo "Response:"
42+
cat $response
43+
echo ""
44+
45+
# Extract id and file_name from each data object in the $response file
46+
> "$agreements" # Clear the output file at the beginning
47+
capture_id=false
48+
49+
# Process each line in the $response file
50+
while read -r line; do
51+
# Check for "id" and capture it if found
52+
case "$line" in
53+
*'"id"':*)
54+
# Extract the id value
55+
id="${line#*\"id\": \"}"
56+
id="${id%%\",*}"
57+
capture_id=true
58+
;;
59+
*'"file_name"':*)
60+
if $capture_id; then
61+
# Extract the file_name value
62+
file_name="${line#*\"file_name\": \"}"
63+
file_name="${file_name%%\"*}"
64+
65+
# Write id and file_name to the output file
66+
echo "$id $file_name" >> "$agreements"
67+
68+
# Reset the capture flag
69+
capture_id=false
70+
fi
71+
;;
72+
esac
73+
done < "$response"
74+
75+
# Remove the temporary files
76+
rm "$response"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Check that we're in a bash shell
2+
if [[ $SHELL != *"bash"* ]]; then
3+
echo "PROBLEM: Run these scripts from within the bash shell."
4+
fi
5+
6+
ds_access_token_path="config/ds_access_token.txt"
7+
agreements="config/AGREEMENTS.txt"
8+
9+
# Obtain your OAuth token
10+
# Note: Substitute these values with your own
11+
ACCESS_TOKEN=$(cat ${ds_access_token_path})
12+
13+
# Set up variables for full code example
14+
# Note: Substitute these values with your own
15+
ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
16+
base_path="https://api-d.docusign.com/v1"
17+
18+
# Check if agreements file exists and has content
19+
if [[ ! -s "$agreements" ]]; then
20+
echo "Please run Navigator example 1: List_Agreements first to get a list of agreements."
21+
exit 0
22+
fi
23+
24+
#Display list of agreements
25+
# Initialize an array to hold the file_names
26+
file_names=()
27+
28+
# Read each line from AGREEMENTS.txt and populate file_names array
29+
while IFS=' ' read -r id file_name; do
30+
file_names+=("$file_name")
31+
done < $agreements
32+
33+
# Display the file_name options to the user for selection
34+
echo "Please select an agreement:"
35+
select chosen_name in "${file_names[@]}"; do
36+
if [[ -n "$chosen_name" ]]; then
37+
# Find the matching line and extract the corresponding id
38+
AGREEMENT_ID=$(grep -w "$chosen_name" "$agreements" | awk '{print $1}')
39+
echo "You selected: $chosen_name"
40+
echo "AGREEMENT_ID: $AGREEMENT_ID"
41+
break
42+
else
43+
echo "Invalid selection. Please try again."
44+
fi
45+
done
46+
47+
#ds-snippet-start:Navigator2Step2
48+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
49+
'--header' "Accept: application/json" \
50+
'--header' "Content-Type: application/json")
51+
#ds-snippet-end:Navigator2Step2
52+
53+
# Get Agreement
54+
#ds-snippet-start:Navigator2Step3
55+
response=$(mktemp /tmp/response-neg-002.XXXXXX)
56+
Status=$(curl -w '%{http_code}' -i --request GET ${base_path}/accounts/${ACCOUNT_ID}/agreements/${AGREEMENT_ID} \
57+
"${Headers[@]}" \
58+
--output ${response})
59+
#ds-snippet-end:Navigator2Step3
60+
61+
62+
if [[ "$Status" -gt "399" ]] ; then
63+
echo ""
64+
echo "Error: "
65+
echo ""
66+
cat $response
67+
exit 0
68+
fi
69+
70+
echo ""
71+
echo "Response:"
72+
cat $response
73+
echo ""
74+
75+
76+
# Remove the temporary files
77+
rm "$response"

launcher.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ function choices() {
181181
"Notary" \
182182
"WebForms" \
183183
"Maestro" \
184+
"Navigator (beta)" \
184185
"Exit"; do
185186
case "$METHOD" in
186187

@@ -232,6 +233,11 @@ function choices() {
232233
login $api_version
233234
startMaestro
234235
;;
236+
"Navigator (beta)")
237+
api_version="Navigator"
238+
login $api_version
239+
startNavigator
240+
;;
235241

236242
Exit)
237243
exit 0
@@ -973,6 +979,34 @@ function startMaestro() {
973979
done
974980
}
975981

982+
function startNavigator() {
983+
echo ""
984+
PS3='Select the action : '
985+
select CHOICE in \
986+
"List_Agreements" \
987+
"Get_Single_Agreement" \
988+
"Home"; do
989+
case "$CHOICE" in
990+
991+
Home)
992+
choices
993+
;;
994+
List_Agreements)
995+
bash examples/Navigator/eg001ListAgreements.sh
996+
startNavigator
997+
;;
998+
Get_Single_Agreement)
999+
bash examples/Navigator/eg002GetSingleAgreement.sh
1000+
startNavigator
1001+
;;
1002+
*)
1003+
echo "Default action..."
1004+
startNavigator
1005+
;;
1006+
esac
1007+
done
1008+
}
1009+
9761010
function continu() {
9771011

9781012
isCFR
@@ -1010,6 +1044,9 @@ function continu() {
10101044
elif [[ $api_version == "Maestro" ]]
10111045
then
10121046
startMaestro
1047+
elif [[ $api_version == "Navigator" ]]
1048+
then
1049+
startNavigator
10131050
fi
10141051
}
10151052

0 commit comments

Comments
 (0)