exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

taler-exchange-kyc-oauth2-test-converter.sh (820B)


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