Implement account handling for Nordigen

This commit is contained in:
2022-03-22 21:56:35 +00:00
parent 2ca518962c
commit 7b38e487cf
5 changed files with 259 additions and 15 deletions

View File

@@ -496,10 +496,26 @@ class IRCCommands(object):
auth_url = tx.truelayer.create_auth_url(account)
msg(f"Auth URL for {account}: {auth_url}")
class nsignin(object):
name = "nsignin"
authed = True
helptext = "Generate a Nordigen signin URL. Usage: nsignin <country> <bank>"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 3:
country = spl[1]
bank_name = spl[2]
auth_url = tx.sinks.nordigen.create_auth_url(country, bank_name)
if not auth_url:
msg("Could not find bank.")
return
msg(f"Auth URL for {bank_name}: {auth_url}")
class accounts(object):
name = "accounts"
authed = True
helptext = "Get a list of acccounts. Usage: accounts <account>"
helptext = "Get a list of acccounts from TrueLayer. Usage: accounts <account>"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
@@ -509,6 +525,18 @@ class IRCCommands(object):
for account in accounts["results"]:
msg(f"{account['account_id']} {account['display_name']} {account['currency']}")
class naccounts(object):
name = "naccounts"
authed = True
helptext = "Get a list of acccounts from Nordigen. Usage: naccounts"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 1:
accounts = tx.sinks.nordigen.get_all_account_info()
for name, account in accounts.items():
msg(f"{name} {account['account_id']} {account['details']} {account['currency']}")
class transactions(object):
name = "transactions"
authed = True
@@ -533,7 +561,7 @@ class IRCCommands(object):
class mapaccount(object):
name = "mapaccount"
authed = True
helptext = "Enable an account_id at a bank for use. Usage: mapaccount <bank> <account_id>"
helptext = "Enable an account_id at a bank for use in TrueLayer. Usage: mapaccount <bank> <account_id>"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
@@ -546,6 +574,21 @@ class IRCCommands(object):
return
msg(f"Mapped account ID {account_id} at bank {bank} to {account_name}")
class nmapaccount(object):
name = "nmapaccount"
authed = True
helptext = "Enable an account_id at a bank for use in Nordigen. Usage: nmapaccount <bank> <account_id>"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 2:
account_id = spl[1]
account_name = tx.sinks.nordigen.map_account(account_id)
if not account_name:
msg(f"Failed to map the account")
return
msg(f"Mapped account ID {account_id} to {account_name}")
class unmapped(object):
name = "unmapped"
authed = True