From d5c016e4d48f8ec825fe7ff434b3f1e93cf059ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Thu, 25 May 2023 23:10:46 +0200 Subject: [PATCH] Expand year url, prepare check. --- fetch_fio.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/fetch_fio.sh b/fetch_fio.sh index f29560e..8b2b8e6 100644 --- a/fetch_fio.sh +++ b/fetch_fio.sh @@ -139,6 +139,15 @@ download_file() { done } +# +# Downloads single year +# $1 - apikey +# $2 - year +# $3 - destination file name +download_year() { + echo "${APIURI}/periods/$1/$2-01-01/$2-12-31/transactions.csv" +} + # Current year (last in seq) CYEAR=`date +%Y` @@ -171,13 +180,15 @@ while read accnt ; do continue fi - # Log action + # Iterate over years for year in `seq $YEAR $CYEAR` ; do + # Log action log "Processing account $ACCNO for $year" - - # Fetch CSV from bank - CSVNAME="$BANK_DIR/$ACCNO.csv" - #download_file "${APIURI}/periods/${APIKEY}/2015-01-01/2025-01-31/transactions.csv" "$CSVNAME" + + # Check whether it needs fetching + CSVNAME="$BANK_DIR_PARTS/$ACCNO-$year.csv" + echo "CSVNAME=$CSVNAME" + download_year "$APIKEY" $year $CSVNAME done done < "$APIKEYS_FILE"