This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import click | ||
import json | ||
import sys | ||
|
||
from datetime import datetime | ||
from datetime import timedelta | ||
from getpass import getpass | ||
|
||
from revolut import Revolut, __version__, get_token_step1, get_token_step2 | ||
|
||
|
||
_CLI_DEVICE_ID = 'revolut_cli' | ||
_URL_GET_TRANSACTIONS = 'https://api.revolut.com/user/current/transactions' | ||
|
||
|
||
@click.command() | ||
@click.option( | ||
'--token', '-t', | ||
envvar="REVOLUT_TOKEN", | ||
type=str, | ||
help='your Revolut token (or set the env var REVOLUT_TOKEN)', | ||
) | ||
@click.option( | ||
'--language', '-l', | ||
type=str, | ||
help='language ("fr" or "en"), for the csv header and separator', | ||
default='fr' | ||
) | ||
@click.option( | ||
'--from_date', '-t', | ||
type=click.DateTime(formats=["%Y-%m-%d"]), | ||
help='transactions lookback date in YYYY-MM-DD format (ex: "2019-10-26"). Default 30 days back', | ||
default=(datetime.now()-timedelta(days=30)).strftime("%Y-%m-%d") | ||
) | ||
@click.option( | ||
'--reverse', '-r', | ||
is_flag=True, | ||
help='reverse the order of the transactions displayed', | ||
) | ||
def main(token, language, from_date, reverse): | ||
""" Get the account balances on Revolut """ | ||
if token is None: | ||
print("You don't seem to have a Revolut token. Use 'revolut_cli' to obtain one") | ||
sys.exit() | ||
|
||
rev = Revolut(device_id=_CLI_DEVICE_ID, token=token) | ||
account_transactions = rev.get_account_transactions(from_date) | ||
print(account_transactions.csv(lang=language, reverse=reverse)) | ||
|
||
if __name__ == "__main__": | ||
main() |