post_management_api_verifications.sh (962B)
1 #!/bin/bash 2 # sends POST request to the swiyu verifier and generates a qr code from the verification_url in the response. 3 # 4 # requires: 5 # - jq 6 # - qrencode. 7 if [ $# -eq 0 ]; then 8 echo "Error: No JSON request file provided" 9 echo "Usage: $0 <json_file>" 10 exit 1 11 fi 12 13 # Determine the input file (add .json if not present and file doesn't exist) 14 if [ -f "$1" ]; then 15 input_file="$1" 16 elif [ -f "${1}.json" ]; then 17 input_file="${1}.json" 18 else 19 echo "Error: File '$1' or '${1}.json' not found" 20 exit 1 21 fi 22 23 base_name="${input_file%.json}" 24 25 response_file="${base_name}_response.json" 26 qr_code_file="${base_name}_qr_code.png" 27 28 curl -v -X POST http://localhost:8080/management/api/verifications \ 29 -H "Accept: application/json" \ 30 -H "Content-Type: application/json" \ 31 -d @"$input_file" \ 32 | tee "$response_file" | jq -r '.verification_url' | tee /dev/tty | xargs qrencode -o "$qr_code_file" 33 34 # open .png with default image viewer app 35 open "$qr_code_file" 36