taler-exchange-kyc-oauth2-nda.sh (795B)
1 #!/bin/bash 2 # This file is in the public domain. 3 # 4 # This code converts (some of) the JSON output from NDA into the GNU Taler 5 # specific KYC attribute data (again in JSON format). 6 # 7 8 # Die if anything goes wrong. 9 set -eu 10 11 # First, extract everything from stdin. 12 J=$(jq '{"status":.status,"id":.data.id,"last":.data.last_name,"first":.data.first_name,"phone":.data.phone}') 13 14 STATUS=$(echo "$J" | jq -r '.status') 15 if [ "$STATUS" != "success" ] 16 then 17 return 1 18 fi 19 20 # Next, combine some fields into larger values. 21 FULLNAME=$(echo "$J" | jq -r '[.first_name,.last_name]|join(" ")') 22 23 echo "$J" \ 24 | jq \ 25 --arg full_name "${FULLNAME}" \ 26 '{"FORM_ID": "oauth2-nda-form","FULL_NAME": $full_name, "phone": .phone, "id": .id}' \ 27 | jq \ 28 'del(..|select(.==null))' 29 30 exit 0