|
| 1 | +#!/bin/bash |
| 2 | +# Resume a paused workflow instance |
| 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 | + |
| 9 | +# Check that there is a workflow |
| 10 | +workflow_id=$(cat config/WORKFLOW_ID) |
| 11 | +if [ -z "$workflow_id" ]; then |
| 12 | + echo "Please run example 1 to create and trigger a workflow before running this example." |
| 13 | + exit 0 |
| 14 | +fi |
| 15 | + |
| 16 | +# Obtain your OAuth token |
| 17 | +# Note: Substitute these values with your own |
| 18 | +ACCESS_TOKEN=$(cat config/ds_access_token.txt) |
| 19 | + |
| 20 | +# Set up variables |
| 21 | +# Note: Substitute these values with your own |
| 22 | +ACCOUNT_ID=$(cat config/API_ACCOUNT_ID) |
| 23 | +base_path="https://api-d.docusign.com/v1" |
| 24 | + |
| 25 | +# Construct your API headers |
| 26 | +#ds-snippet-start:Maestro3Step2 |
| 27 | +declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \ |
| 28 | + '--header' "Accept: application/json" \ |
| 29 | + '--header' "Content-Type: application/json") |
| 30 | +#ds-snippet-end:Maestro3Step2 |
| 31 | + |
| 32 | +echo "" |
| 33 | +echo "Attempting to resume the Workflow..." |
| 34 | +echo "" |
| 35 | + |
| 36 | +# Make the API call to resume |
| 37 | +#ds-snippet-start:Maestro3Step3 |
| 38 | +response=$(mktemp /tmp/response-wftmp.XXXXXX) |
| 39 | +Status=$( |
| 40 | + curl -w '%{http_code}' --request POST "${base_path}/accounts/${ACCOUNT_ID}/workflows/${workflow_id}/actions/resume" \ |
| 41 | + "${Headers[@]}" \ |
| 42 | + --output ${response} |
| 43 | +) |
| 44 | + |
| 45 | +if [[ "$Status" -gt "201" ]]; then |
| 46 | + echo "" |
| 47 | + echo "Unable to resume workflow: ${workflow_id}" |
| 48 | + echo "" |
| 49 | + cat $response |
| 50 | + exit 0 |
| 51 | +fi |
| 52 | + |
| 53 | +echo "" |
| 54 | +echo "Workflow has been resumed." |
| 55 | +echo "" |
| 56 | +echo "Response:" |
| 57 | +cat $response |
| 58 | +echo "" |
| 59 | +#ds-snippet-end:Maestro3Step3 |
| 60 | + |
| 61 | +# Remove the temporary files |
| 62 | +rm "$response" |
0 commit comments