Skip to content

Commit

Permalink
Merge pull request #3 from dnbasta/dev
Browse files Browse the repository at this point in the history
bugfixed attribute references
  • Loading branch information
dnbasta authored Apr 13, 2024
2 parents f7fb1ea + 85ed01f commit 1e4851c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ynabapiimport/ynabapiimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def __init__(self, secret_id: str, secret_key: str, token: str,
self._ynab_client = YnabClient(token=token, account_id=account_id, budget_id=budget_id)
self._api_client = NordigenClient(secret_id=secret_id, secret_key=secret_key)
self._api_client.generate_token()
self._account_client = AccountClient.from_api_client(client=self._api_client, reference=self._reference,
resource_id=resource_id)
self._account_client = AccountClient.from_api_client(client=self._api_client, reference=self.reference,
resource_id=self.resource_id)

@classmethod
def from_yaml(cls, path: str):
Expand Down Expand Up @@ -83,7 +83,7 @@ def import_transactions(self, startdate: date = None, memo_regex: str = None) ->
transactions = [mc.clean(t) for t in transactions]

i = self._ynab_client.insert(transactions)
self.logger.info(f"inserted {i} transactions for {self._reference}")
self.logger.info(f"inserted {i} transactions for {self.reference}")
return i

def compare_balances(self):
Expand All @@ -96,7 +96,7 @@ def compare_balances(self):
yb = self._ynab_client.fetch_balance()
if yb not in ab.values() and yb not in [b - ap for b in ab.values()]:
raise BalancesDontMatchError({'api': ab, 'ynab': yb, 'pending': ap})
self.logger.info(f'balances match for {self._reference}')
self.logger.info(f'balances match for {self.reference}')

def create_auth_link(self, institution_id: str, use_max_historical_days: bool = False,
delete_current_auth: bool = False) -> str:
Expand All @@ -109,13 +109,13 @@ def create_auth_link(self, institution_id: str, use_max_historical_days: bool =
:raises ReferenceNotValidError: if reference string contains illegal characters
:raises ReferenceNotUniqueError: if existing connection already uses the reference
"""
rh = RequisitionHandler(client=self._api_client, reference=self._reference)
rh = RequisitionHandler(client=self._api_client, reference=self.reference)
if delete_current_auth:
rh.delete_current_requisition()
self.logger.info(f'deleted auth for reference {self._reference}')
self.logger.info(f'deleted auth for reference {self.reference}')
auth_link = rh.create_requisition_auth_link(institution_id=institution_id,
use_max_historical_days=use_max_historical_days)
self.logger.info(f'created auth link for {institution_id} under reference {self._reference}')
self.logger.info(f'created auth link for {institution_id} under reference {self.reference}')
return auth_link

def fetch_institutions(self, countrycode: str) -> List[dict]:
Expand All @@ -124,7 +124,7 @@ def fetch_institutions(self, countrycode: str) -> List[dict]:
:param countrycode: ISO2 country code
:return: List of available institutions in country with as with name, institution_id and max_history_days
"""
rh = RequisitionHandler(client=self._api_client, reference=self._reference)
rh = RequisitionHandler(client=self._api_client, reference=self.reference)
institutions = rh.get_institutions(countrycode=countrycode)
self.logger.info(f'fetched list with {len(institutions)} institutions for countrycode {countrycode}')
return institutions
Expand All @@ -138,7 +138,7 @@ def test_memo_regex(self, memo_regex: str) -> List[dict]:
transactions = self._account_client.fetch_transactions(date.today() - timedelta(days=90))
mc = MemoCleaner(memo_regex=memo_regex)
r = [{t.memo: mc.clean(t).memo} for t in transactions]
self.logger.info(f'tested memo regex on {len(r)} transactions from {self._reference}')
self.logger.info(f'tested memo regex on {len(r)} transactions from {self.reference}')
return r

@staticmethod
Expand Down

0 comments on commit 1e4851c

Please sign in to comment.