aboutsummaryrefslogtreecommitdiffstats
path: root/beancount_extras_kris7t/importers/transferwise/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'beancount_extras_kris7t/importers/transferwise/client.py')
-rw-r--r--beancount_extras_kris7t/importers/transferwise/client.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/beancount_extras_kris7t/importers/transferwise/client.py b/beancount_extras_kris7t/importers/transferwise/client.py
index a4b6629..5198122 100644
--- a/beancount_extras_kris7t/importers/transferwise/client.py
+++ b/beancount_extras_kris7t/importers/transferwise/client.py
@@ -25,8 +25,8 @@ def _parse_date_arg(date_str: str) -> dt.date:
25def _import_config(config_path: str) -> Importer: 25def _import_config(config_path: str) -> Importer:
26 import runpy 26 import runpy
27 27
28 config = runpy.run_path(config_path) 28 config = runpy.run_path(config_path) # type: ignore
29 importer = config['TRANSFERWISE_CONFIG'] # type: ignore 29 importer = config['TRANSFERWISE_CONFIG']
30 if isinstance(importer, Importer): 30 if isinstance(importer, Importer):
31 LOG.info('Loaded configuration from %s', config_path) 31 LOG.info('Loaded configuration from %s', config_path)
32 return importer 32 return importer
@@ -65,7 +65,7 @@ def _get_last_transaction_date(ledger_path: str, skip_references: Set[str]) -> O
65def _get_date_range(from_date: Optional[dt.date], 65def _get_date_range(from_date: Optional[dt.date],
66 to_date: dt.date, 66 to_date: dt.date,
67 ledger_path: Optional[str]) -> Tuple[dt.date, dt.date, Set[str]]: 67 ledger_path: Optional[str]) -> Tuple[dt.date, dt.date, Set[str]]:
68 skip_references = set() 68 skip_references: Set[str] = set()
69 if not from_date and ledger_path: 69 if not from_date and ledger_path:
70 from_date = _get_last_transaction_date(ledger_path, skip_references) 70 from_date = _get_last_transaction_date(ledger_path, skip_references)
71 if not from_date: 71 if not from_date:
@@ -79,6 +79,7 @@ def _get_secrets(importer: Importer,
79 proxy_uri: Optional[str]) -> Tuple[str, Optional[str]]: 79 proxy_uri: Optional[str]) -> Tuple[str, Optional[str]]:
80 import urllib.parse 80 import urllib.parse
81 81
82 uri_parts: Optional[urllib.parse.SplitResult]
82 if proxy_uri: 83 if proxy_uri:
83 uri_parts = urllib.parse.urlsplit(proxy_uri) 84 uri_parts = urllib.parse.urlsplit(proxy_uri)
84 else: 85 else:
@@ -122,7 +123,7 @@ def _get_secrets(importer: Importer,
122 proxy_uri = uri 123 proxy_uri = uri
123 else: 124 else:
124 LOG.info('No proxy password secret was found in SecretService') 125 LOG.info('No proxy password secret was found in SecretService')
125 assert api_key # Make pyright happy 126 assert api_key # Make mypy happy
126 return api_key, proxy_uri 127 return api_key, proxy_uri
127 128
128 129
@@ -141,8 +142,9 @@ def _fetch_statements(importer: Importer,
141 uri_prefix = f'https://api.transferwise.com/v3/profiles/{importer.profile_id}/' + \ 142 uri_prefix = f'https://api.transferwise.com/v3/profiles/{importer.profile_id}/' + \
142 f'borderless-accounts/{importer.borderless_account_id}/statement.json' + \ 143 f'borderless-accounts/{importer.borderless_account_id}/statement.json' + \
143 f'?intervalStart={from_time_str}&intervalEnd={to_time_str}&type=COMPACT&currency=' 144 f'?intervalStart={from_time_str}&intervalEnd={to_time_str}&type=COMPACT&currency='
145 beancount_version = beancount.__version__ # type: ignore # noqa: unused-type-ignore
144 headers = { 146 headers = {
145 'User-Agent': f'Beancount {beancount.__version__} Transferwise importer {__copyright__}', 147 'User-Agent': f'Beancount {beancount_version} Transferwise importer {__copyright__}',
146 'Authorization': f'Bearer {api_key}', 148 'Authorization': f'Bearer {api_key}',
147 } 149 }
148 proxy_dict: Dict[str, str] = {} 150 proxy_dict: Dict[str, str] = {}