def get_current_account(monzo: MonzoAPI) -> MonzoAccount: log.debug("Getting current account...") current_account = list( filter(lambda x: x.type == "uk_retail", monzo.accounts())) if len(current_account) == 1: log.debug(f"Got {current_account}...") return current_account[0] else: return None
def init_monzo(merchants=True): client = MonzoAPI() # Get the ID of the first account linked to the access token account_id = client.accounts()[1].id print("[Monzo] Retrieving transactions...") transactions = client.transactions(account_id) # Get client.transaction( print("[Monzo] Retrieving merchants...") for item in transactions: if merchants: item.merchant = client.transaction(item.id, expand_merchant=True).merchant identifier = item.merchant.name if hasattr(item.merchant, 'name') else item.merchant print("[Monzo] Retrieved merchant {}.".format(identifier)) print("Done.") return transactions