Skip to content

Commit 050a0ed

Browse files
author
nianiB9
committed
updates to examples and launcher
1 parent 2f2a2c8 commit 050a0ed

File tree

3 files changed

+62
-57
lines changed

3 files changed

+62
-57
lines changed

examples/Maestro/eg001TriggerWorkflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ echo ""
4444
#apx-snippet-start:GetWorkflowsList
4545
response=$(mktemp /tmp/response-wftmp.XXXXXX)
4646
Status=$(
47-
curl -w '%{http_code}' --request GET "${base_path}/accounts/60b2b6db-7d3b-4bf8-95ba-a516bf479749/workflows" \
47+
curl -w '%{http_code}' --request GET "${base_path}/accounts/${account_id}/workflows" \
4848
"${Headers[@]}" \
4949
--output ${response}
5050
)
@@ -68,7 +68,7 @@ workflow_id=$(grep -B 1 '"name": "Example workflow - send invite to signer"' $re
6868
# Get the trigger URL
6969
# workflow_id comes from the response of the Workflows: getWorkflowsList endpoint
7070
response=$(mktemp /tmp/response-wftmp.XXXXXX)
71-
Status=$(curl -s -w "%{http_code}\n" -i --request GET "${base_path}/accounts/60b2b6db-7d3b-4bf8-95ba-a516bf479749/workflows/8fdfb076-bfbe-4709-a8c0-1a7f886903ad/trigger-requirements" \
71+
Status=$(curl -s -w "%{http_code}\n" -i --request GET "${base_path}/accounts/${account_id}/workflows/${workflow_id}/trigger-requirements" \
7272
"${Headers[@]}" \
7373
--output ${response})
7474
#apx-snippet-end:GetWorkflowTriggerRequirements
Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
# #!/bin/bash
2-
# # https://developers.docusign.com/docs/maestro-api/maestro101/embed-workflow/
3-
# # Embed a Maestro workflow after it has been triggered
1+
#!/bin/bash
2+
# https://developers.docusign.com/docs/maestro-api/maestro101/embed-workflow/
3+
# Generates an embeddable Maestro workflow URL using the workflow ID
44

5-
# # Check that we're in a bash shell
6-
# if [[ $SHELL != *"bash"* ]]; then
7-
# echo "PROBLEM: Run these scripts from within the bash shell."
8-
# fi
5+
# Ensure bash shell
6+
if [[ $SHELL != *"bash"* ]]; then
7+
echo "PROBLEM: Run these scripts from within the bash shell."
8+
exit 1
9+
fi
910

10-
# # Step 1: Obtain your OAuth token
11-
# ACCESS_TOKEN=$(cat config/ds_access_token.txt)
11+
# Step 1: Load required config values
12+
ACCESS_TOKEN=$(cat config/ds_access_token.txt)
13+
account_id=$(cat config/API_ACCOUNT_ID)
14+
workflow_id=$(cat config/WORKFLOW_ID)
1215

13-
# # Step 2: Read the account ID
14-
# account_id=$(cat config/API_ACCOUNT_ID)
16+
# Step 2: Validate workflow ID exists
17+
if [ -z "$workflow_id" ]; then
18+
echo "❌ ERROR: No workflow ID found. Please run the trigger workflow script first."
19+
exit 1
20+
fi
1521

16-
# # Step 3: Read the workflow ID created by the trigger workflow script
17-
# workflow_id=$(cat config/WORKFLOW_ID)
22+
# Step 3: Set Maestro API base path
23+
base_path="https://api-d.docusign.net/maestro/v1"
1824

19-
# # Step 4: Verify a workflow has been created
20-
# if [ -z "$workflow_id" ]; then
21-
# echo "❌ ERROR: No workflow found. Please trigger a workflow before running this embed script."
22-
# exit 0
23-
# fi
25+
# Step 4: Prepare API headers
26+
declare -a Headers=(
27+
'--header' "Authorization: Bearer ${ACCESS_TOKEN}"
28+
'--header' "Content-Type: application/json"
29+
'--header' "Accept: application/json"
30+
)
2431

25-
# # Step 5: Construct your API headers
26-
# declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
27-
# '--header' "Accept: application/json" \
28-
# '--header' "Content-Type: application/json")
32+
# Step 5: Prepare POST body with returnUrl
33+
request_data=$(mktemp /tmp/request-embed.XXXXXX)
34+
printf \
35+
'{
36+
"returnUrl": "https://example.com/return"
37+
}' > $request_data
2938

30-
# # Step 6: Prepare request body
31-
# request_data=$(mktemp /tmp/request-embed.XXXXXX)
32-
# printf \
33-
# '{
34-
# "returnUrl": "https://example.com/return"
35-
# }' > $request_data
39+
# Step 6: Make API call to get embed URL
40+
response=$(mktemp /tmp/response-embed.XXXXXX)
41+
Status=$(curl -s -w "%{http_code}\n" -i --request POST \
42+
"${base_path}/accounts/${account_id}/workflows/${workflow_id}/embed_url" \
43+
"${Headers[@]}" \
44+
--data-binary @$request_data \
45+
--output ${response})
3646

37-
# # Step 7: Make the POST request to generate the embed URL
38-
# response=$(mktemp /tmp/response-embed.XXXXXX)
39-
# Status=$(curl -s -w "%{http_code}\n" -i --request POST "https://api-d.docusign.net/maestro/v1/accounts/${account_id}/workflows/${workflow_id}/embed_url" \
40-
# "${Headers[@]}" \
41-
# --data-binary @$request_data \
42-
# --output ${response})
47+
# Step 7: Handle errors
48+
if [[ "$Status" -gt "201" ]]; then
49+
echo "❌ ERROR: Failed to generate embed URL"
50+
cat $response
51+
rm "$request_data" "$response"
52+
exit 1
53+
fi
4354

44-
# # Step 8: Handle the response
45-
# if [[ "$Status" -gt "201" ]]; then
46-
# echo ""
47-
# echo "❌ ERROR: Unable to generate embed URL for the workflow"
48-
# echo ""
49-
# cat $response
50-
# rm "$request_data"
51-
# rm "$response"
52-
# exit 0
53-
# fi
55+
# Step 8: Extract and display embed URL
56+
embed_url=$(grep '"url":' $response | sed -n 's/.*"url": "\([^"]*\)".*/\1/p')
5457

55-
# echo ""
56-
# echo "✅ Embed URL successfully generated:"
57-
# embed_url=$(grep '"url":' $response | sed -n 's/.*"url": "\([^"]*\)".*/\1/p')
58-
# echo $embed_url
58+
echo ""
59+
echo "✅ Embed URL successfully generated:"
60+
echo "$embed_url"
5961

60-
# # Optional: Output embed code for iframe usage
61-
# echo ""
62-
# echo "📎 Use this in your HTML:"
63-
# echo "<iframe src=\"$embed_url\" width=\"100%\" height=\"600\" frameborder=\"0\" allowfullscreen></iframe>"
62+
echo ""
63+
echo "📎 You can use this HTML iframe to embed the workflow:"
64+
echo "<iframe src=\"$embed_url\" width=\"100%\" height=\"600\" frameborder=\"0\" allowfullscreen></iframe>"
6465

65-
# # Clean up
66-
# rm "$request_data"
67-
# rm "$response"
66+
# Cleanup
67+
rm "$request_data" "$response"

launcher.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ function startMaestro() {
968968
PS3='Select the action : '
969969
select CHOICE in \
970970
"Trigger_Workflow" \
971+
"Embed_Workflow" \
971972
"Home"; do
972973
case "$CHOICE" in
973974

@@ -978,6 +979,10 @@ function startMaestro() {
978979
bash examples/Maestro/eg001TriggerWorkflow.sh
979980
startMaestro
980981
;;
982+
Embed_Workflow)
983+
bash examples/Maestro/eg002EmbedWorkflow.sh
984+
startMaestro
985+
;;
981986
*)
982987
echo "Default action..."
983988
startMaestro

0 commit comments

Comments
 (0)