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-challenger-postal-converter (1209B)


      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 # "postal" address type (and otherwise exit with failure),
      8 # and finally move the .address values to
      9 # the "ADDRESS_*" fields.
     10 #
     11 # Uses JQ to convert!
     12 exec jq 'if .address_type!="postal" and .address_type !="postal-ch" then halt_error(4) else (. | .id?) |= (. | tostring) | .FORM_ID="challenger-postal" | .FORM_VERSION=0 | .CONTACT_NAME=.address.CONTACT_NAME | .ADDRESS_LINES=.address.ADDRESS_LINES | if .address_type=="postal" then .ADDRESS_COUNTRY=.address.ADDRESS_COUNTRY else .ADDRESS_COUNTRY="CH" end | del(.address) | del(.address_type) end'
     13 
     14 # Example input:
     15 # {
     16 #   "id": 1,
     17 #   "address": {
     18 #     "CONTACT_NAME": "Richard Stallman",
     19 #     "ADDRESS_LINES": "Bundesgasse 1\n1234 Bern"
     20 #   },
     21 #   "address_type": "postal-ch",
     22 #   "expires": {
     23 #     "t_s": 1775590216
     24 #   }
     25 # }
     26 #
     27 # Example output:
     28 #
     29 # {
     30 #   "id": "1",
     31 #   "expires": {
     32 #     "t_s": 1775590216
     33 #   }
     34 #   "CONTACT_NAME": "Richard Stallman"
     35 #   "ADDRESS_LIENS": "Bundesgasse 1\n1234 Bern"
     36 #   "ADDRESS_COUNTRY": "CH"
     37 # }
     38 #