taler-exchange-kyc-challenger-sms-converter (904B)
1 #!/bin/bash 2 # This file is in the public domain. 3 # 4 # Challenger's /info returns the 'id' as a Number, but the 5 # exchange oauth2 plugin expects it as a String. 6 # Additionally, we need to check that we got the expected 7 # "phone" address type (and otherwise exit with failure), 8 # and finally move the .address.CONTACT_PHONE value to 9 # the "CONTACT_PHONE" field. 10 # 11 # Uses JQ to convert! 12 exec jq 'if .address_type!="phone" then halt_error(4) else (. | .id?) |= (. | tostring) | .CONTACT_PHONE=.address.CONTACT_PHONE | .FORM_ID="challenger-sms" | .FORM_VERSION=0 | del(.address) | del(.address_type) end' 13 14 # Example input: 15 # { 16 # "id": 1, 17 # "address": { 18 # "CONTACT_PHONE": "+4112345678" 19 # }, 20 # "address_type": "phone", 21 # "expires": { 22 # "t_s": 1775590216 23 # } 24 # } 25 # 26 # Example output: 27 # 28 # { 29 # "id": "1", 30 # "expires": { 31 # "t_s": 1775590216 32 # } 33 # "CONTACT_PHONE": "+4112345678" 34 # } 35 #