libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit a6513ad4a27426cdd24d233393ce8dc54495d079
parent eb73f8c98c0f9fe09676070bd5d61807df29bc2d
Author: MS <ms@taler.net>
Date:   Thu, 11 Jun 2020 17:03:45 +0200

augmenting cli with sandbox functionality

Diffstat:
Mcli/libeufin-cli-new | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+), 0 deletions(-)

diff --git a/cli/libeufin-cli-new b/cli/libeufin-cli-new @@ -29,6 +29,12 @@ def bank_connection(ctx): def bank_accounts(ctx): pass + +@cli.group() +@click.pass_context +def sandbox(ctx): + pass + @bank_connection.command(help="make new Ebics bank connection") @click.option("--connection-name", help="Connection ID", required=True) @click.option("--ebics-url", help="EBICS URL", required=True) @@ -163,4 +169,85 @@ def transactions(obj, account_name, nexus_user_id, nexus_password, nexus_base_ur return print(resp.content.decode("utf-8")) + +@sandbox.command(help="activate a Ebics host") +@click.option("--host-id", help="Ebics host ID", required=True) +@click.argument("sandbox-base-url") +def make_ebics_host(obj, host_id, sandbox_base_url): + url = urljoin(sandbox_base_url, "/admin/ebics/host") + try: + post(url, json=dict(hostID=host_id, ebicsVersion="2.5")) + except Exception: + print("Could not reach sandbox") + return + print(resp.content.decode("utf-8")) + +@sandbox.command(help="activate a Ebics subscriber") +@click.argument("sandbox-base-url") +def activate_ebics_subscriber(obj, host_id, partner_id, user_id, sandbox_base_url): + url = urljoin(sandbox_base_url, "/admin/ebics/subscribers") + try: + post(url, json=dict(hostID=host_id, partnerID=partner_id, userID=user_id)) + except Exception: + print("Could not reach sandbox") + return + print(resp.content.decode("utf-8")) + +@sandbox.command(help="associate a bank account to a Ebics subscriber") +@click.option("--iban", help="IBAN", required=True) +@click.option("--bic", help="BIC", required=True) +@click.option("--person-name", help="bank account owner name", required=True) +@click.option("--account-name", help="label of this bank account", required=True) +@click.option("--ebics_user_id", help="user ID of the Ebics subscriber", required=True) +@click.option("--ebics_host_id", help="host ID of the Ebics subscriber", required=True) +@click.option("--ebics_partner_id", help="partner ID of the Ebics subscriber", required=True) +@click.argument("sandbox-base-url") +def associate_bank_account(obj, iban, bic, person_name, account_name, + ebics_user_id, ebics_host_id, ebics_partner_id, sandbox_base_url): + url = urljoin(sandbox_base_url, "/admin/ebics/bank-accounts") + body = dict( + subscriber=dict(userID=ebics_user_id, partnerID=ebics_partner_id, hostID=ebics_host_id), + iban=iban, bic=bic, name=person_name, label=account_name + ) + + try: + post(url, json=body) + except Exception: + print("Could not reach sandbox") + return + print(resp.content.decode("utf-8")) + +@sandbox.command(help="book a payment in the sandbox") +@click.option("--creditor-iban", help="IBAN receiving the payment") +@click.option("--creditor-bic", help="BIC receiving the payment") +@click.option("--creditor-name", help="Name of the person who is receiving the payment") +@click.option("--debtor-iban", help="IBAN sending the payment") +@click.option("--debtor-bic", help="BIC sending the payment") +@click.option("--debtor-name", help="name of the person who is sending the payment") +@click.option("--amount", help="amount, no currency") +@click.option("--currency", help="currency") +@click.option("--subject", help="Payment subject") +@click.argument("sandbox-base-url") +def book_payment(obj, creditor_iban, creditor_bic, creditor_name, debtor_iban, + debtor_bic, debtor_name, amount, currency, subject, sandbox_base_url): + + url = urljoin(sandbox_base_url, "/admin/payments") + body = json( + creditorIban=creditor_iban, + creditorBic=creditor_bic, + creditorName=creditor_name, + debitorIban=debitor_iban, + debitorBic=debitor_bic, + debitorName=debitor_name, + amount=amount, + currency=currency, + subject=subject + ) + try: + resp = post(url, json=body) + except Exception: + print("Could not reach sandbox") + return + print(resp.content.decode("utf-8")) + cli()