libeufin

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

commit 0c6663d76ac97a741c47a710dd3def40c0921021
parent 4bc5f38f571a45d427f73813ec3846bf59413afa
Author: MS <ms@taler.net>
Date:   Mon, 10 Jul 2023 14:28:30 +0200

Fetching transactions from the bank.

The CLI gives the options to select a time frame.

Diffstat:
Mcli/bin/libeufin-cli | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli @@ -957,19 +957,26 @@ def delete_payment(obj, account_name, payment_uuid): @click.option( "--range-type", default="all", - help="Admitted values: all, latest, previous-days, since-last", + help="Admitted values: all, latest, previous-days, since-last, time-frame", ) @click.option("--level", default="all", help="Admitted values: report, statement, all") +@click.option("--start", help="If --range-type is 'time-frame', this option holds the (inclusive) starting date in the format YYYY-MM-DD. If missing, it defaults to 1970-01-01.") +@click.option("--end", help="If --range-type is 'time-frame', this option holds the (inclusive) ending date in the format YYYY-MM-DD. If missing, it defaults to the present date.") @click.argument("account-name") @click.pass_obj -def fetch_transactions(obj, account_name, range_type, level): +def fetch_transactions(obj, account_name, range_type, level, start, end): url = urljoin_nodrop( obj.nexus_base_url, "/bank-accounts/{}/fetch-transactions".format(account_name) ) + body = dict(rangeType=range_type, level=level) + if range_type == "time-frame": + start_value = start if start else "1970-01-01" + end_value = end if end else datetime.today().strftime("%Y-%m-%d") + body.update(dict(start=start_value, end=end_value)) try: resp = requests.post( url, - json=dict(rangeType=range_type, level=level), + json=body, auth=auth.HTTPBasicAuth(obj.username, obj.password), ) except Exception as e: