taler-exchange-helper-measure-inform-investigate (2859B)
1 #!/bin/bash 2 # 3 # This file is part of TALER 4 # Copyright (C) 2024 Taler Systems SA 5 # 6 # TALER is free software; you can redistribute it and/or modify it under the 7 # terms of the GNU General Public License as published by the Free Software 8 # Foundation; either version 3, or (at your option) any later version. 9 # 10 # TALER is distributed in the hope that it will be useful, but WITHOUT ANY 11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License along with 15 # TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/license> 16 # 17 18 # Hard error reporting on. 19 set -eu 20 21 22 23 # Exit, with error message (hard failure) 24 function exit_fail() { 25 echo " FAIL: " "$@" >&2 26 EXIT_STATUS=1 27 exit "$EXIT_STATUS" 28 } 29 30 CONF="$HOME/.config/taler-exchange.conf" 31 VERBOSE=0 32 33 while getopts 'ac:hirvV' OPTION; 34 do 35 case "$OPTION" in 36 a) 37 # No attributes are required. 38 exit 0 39 ;; 40 c) 41 # shellcheck disable=SC2034 42 CONF="$OPTARG" 43 ;; 44 h) 45 echo "This is a KYC measure program that flags and account for manual investigation and informs the user about it." 46 echo 'Supported options:' 47 echo ' -a -- show required attributes' 48 # shellcheck disable=SC2016 49 echo ' -c $CONF -- set configuration' 50 echo ' -h -- print this help' 51 echo ' -i -- show required inputs' 52 echo ' -r -- show required context' 53 echo ' -v -- show version' 54 echo ' -V -- be verbose' 55 exit 0 56 ;; 57 i) 58 # Need current rules. 59 echo "current_rules" 60 echo "default_rules" 61 exit 0 62 ;; 63 r) 64 # No context is required. 65 exit 0 66 ;; 67 v) 68 echo "$0 v0.0.0" 69 exit 0 70 ;; 71 V) 72 VERBOSE=1 73 ;; 74 ?) 75 exit_fail "Unrecognized command line option" 76 ;; 77 esac 78 done 79 80 if [ 1 = "$VERBOSE" ] 81 then 82 echo "Running $0" 1>&2 83 fi 84 85 # See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlProgramInput 86 # for the full JSON with possible inputs. 87 88 # First, extract inputs we need 89 CURRENT_RULES=$(jq '.current_rules // .default_rules // error("neither current_rules nor default_rules provided")') 90 91 # Finally, output the new rules. 92 # See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome 93 # for the required output format. 94 95 exec jq -n \ 96 --argjson nr "$CURRENT_RULES" \ 97 '{"new_rules":$nr,"to_investigate":true,"new_measures":"inform-investigate"}'