hammem / monarchmoney

Python API for Monarch Money
MIT License
124 stars 24 forks source link

No attribute 'update_account' #109

Closed Exohayvan closed 1 week ago

Exohayvan commented 1 month ago

When I run the following:

import asyncio
from monarchmoney import MonarchMoney
import traceback

async def main():
    email = 'email-here'
    password = 'password-here'

    mm = MonarchMoney()
    try:
        print("Attempting to login...")
        await mm.login(email, password)
        print("Login successful")

        # Fetch account information
        accounts_data = await mm.get_accounts()
        print("Accounts fetched successfully")

        # Access the list of accounts within the returned dictionary
        accounts = accounts_data['accounts']

        # Specify the account name you want to find
        account_name_to_find = 'test'  # Replace with the actual account name

        # Search for the account by name
        account_id_to_update = None
        for account in accounts:
            if account['displayName'] == account_name_to_find:
                account_id_to_update = account['id']
                break

        if account_id_to_update:
            print(f"Account ID for '{account_name_to_find}' found: {account_id_to_update}")

            # Attempt to update account balance
            print("Attempting to update account balance...")
            new_balance = 1000.0  # Replace with the new balance you want to set
            try:
                update_response = await mm.update_account(account_id_to_update, balance=new_balance)
                print(f"\nAccount update response: {update_response}")
            except Exception as e:
                print(f"An error occurred while updating the account: {e}")
                traceback.print_exc()  # Print the full traceback for bug reporting

        else:
            print(f"Account with name '{account_name_to_find}' not found.")

    except Exception as e:
        print(f"An error occurred: {e}")
        traceback.print_exc()  # Print the full traceback for bug reporting

# Run the main function
asyncio.run(main())

It spits out an error stating 'MonarchMoney' object has no attribute 'update_account':

Traceback (most recent call last):
  File "/Users/trevoroler/Desktop/antminer/./monarch.py", line 41, in main
    update_response = await mm.update_account(account_id_to_update, balance=new_balance)
                            ^^^^^^^^^^^^^^^^^
AttributeError: 'MonarchMoney' object has no attribute 'update_account'. Did you mean: 'delete_account'?

I even tried checking the attributes:

['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_get_current_date', '_get_end_of_current_month', '_get_graphql_client', '_get_start_of_current_month', '_headers', '_login_user', '_multi_factor_authenticate', '_session_file', '_timeout', '_token', 'create_manual_account', 'create_transaction', 'create_transaction_category', 'create_transaction_tag', 'delete_account', 'delete_session', 'delete_transaction', 'delete_transaction_categories', 'delete_transaction_category', 'get_account_history', 'get_account_holdings', 'get_account_snapshots_by_type', 'get_account_type_options', 'get_accounts', 'get_aggregate_snapshots', 'get_budgets', 'get_cashflow', 'get_cashflow_summary', 'get_institutions', 'get_recent_account_balances', 'get_recurring_transactions', 'get_subscription_details', 'get_transaction_categories', 'get_transaction_category_groups', 'get_transaction_details', 'get_transaction_splits', 'get_transaction_tags', 'get_transactions', 'get_transactions_summary', 'gql_call', 'interactive_login', 'is_accounts_refresh_complete', 'load_session', 'login', 'multi_factor_authenticate', 'request_accounts_refresh', 'request_accounts_refresh_and_wait', 'save_session', 'set_budget_amount', 'set_timeout', 'set_token', 'set_transaction_tags', 'timeout', 'token', 'update_transaction', 'update_transaction_splits', 'upload_account_balance_history']

I do not see the attribute anywhere. I even tried to take the login token and request the data directly from the API and nothing. Was this function removed?

hammem commented 1 week ago

@Exohayvan , apologies, this error was due to the code not being released to pypi yet. If you run pip install monarchmoney --upgrade from your command line and try again, it should work now!

Exohayvan commented 1 week ago

I will try it out! Thank you!