Handle multiple accounts with TrueLayer
This commit is contained in:
@@ -443,36 +443,45 @@ class IRCCommands(object):
|
||||
class signin(object):
|
||||
name = "signin"
|
||||
authed = True
|
||||
helptext = "Generate a TrueLayer signin URL."
|
||||
|
||||
@staticmethod
|
||||
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
||||
auth_url = tx.truelayer.create_auth_url()
|
||||
msg(f"Auth URL: {auth_url}")
|
||||
|
||||
class accounts(object):
|
||||
name = "accounts"
|
||||
authed = True
|
||||
helptext = "Get a list of acccounts."
|
||||
|
||||
@staticmethod
|
||||
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
||||
accounts = tx.sinks.truelayer.get_accounts()
|
||||
msg(dumps(accounts))
|
||||
|
||||
class transactions(object):
|
||||
name = "transactions"
|
||||
authed = True
|
||||
helptext = "Get a list of transactions. Usage: transactions <account_id>"
|
||||
helptext = "Generate a TrueLayer signin URL. Usage: signin <account>"
|
||||
|
||||
@staticmethod
|
||||
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
||||
if length == 2:
|
||||
account_id = spl[1]
|
||||
transactions = tx.sinks.truelayer.get_transactions(account_id)
|
||||
account = spl[1]
|
||||
auth_url = tx.truelayer.create_auth_url(account)
|
||||
msg(f"Auth URL for {account}: {auth_url}")
|
||||
|
||||
class accounts(object):
|
||||
name = "accounts"
|
||||
authed = True
|
||||
helptext = "Get a list of acccounts. Usage: accounts <account>"
|
||||
|
||||
@staticmethod
|
||||
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
||||
if length == 2:
|
||||
account = spl[1]
|
||||
accounts = tx.sinks.truelayer.get_accounts(account)
|
||||
msg(dumps(accounts))
|
||||
|
||||
class transactions(object):
|
||||
name = "transactions"
|
||||
authed = True
|
||||
helptext = "Get a list of transactions. Usage: transactions <account> <account_id>"
|
||||
|
||||
@staticmethod
|
||||
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
||||
if length == 3:
|
||||
account = spl[1]
|
||||
account_id = spl[2]
|
||||
transactions = tx.sinks.truelayer.get_transactions(account, account_id)
|
||||
for transaction in transactions:
|
||||
print(transaction)
|
||||
txid = transaction["transaction_id"]
|
||||
ptxid = transaction["provider_transaction_id"]
|
||||
txtype = transaction["transaction_type"]
|
||||
timestamp = transaction["timestamp"]
|
||||
amount = transaction["amount"]
|
||||
currency = transaction["currency"]
|
||||
recipient = transaction["counter_party_preferred_name"]
|
||||
msg(f"{timestamp} {amount}{currency} {recipient}")
|
||||
description = transaction["description"]
|
||||
msg(f"{timestamp} {txid} {ptxid} {txtype} {amount}{currency} {description}")
|
||||
|
||||
Reference in New Issue
Block a user