rienafairefr / pynYNAB

a python client for the new YNAB
MIT License
138 stars 12 forks source link

nYnabClient constructor raises Exception #63

Closed bdabelow closed 3 years ago

bdabelow commented 6 years ago
$ uname -a
Linux 4.13.0-31-generic #34-Ubuntu SMP Fri Jan 19 16:34:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ python -V
Python 3.6.3

It looks like nYnabClient.__init__ was not adapted for the new interface of create_client in ClientFactory.

Traceback (most recent call last):
  File "ynab.py", line 11, in <module>
    client = nYnabClient(email=config["ynab"]["email"], password=config["ynab"]["password"], budgetname=config["ynab"]["budget_name"])
  File "/home/benjamin/Data/Computer/Python_Projects/bfin/venv/lib/python3.6/site-packages/pynYNAB/Client.py", line 21, in __new__
    return factory.create_client(passed)
  File "/home/benjamin/Data/Computer/Python_Projects/bfin/venv/lib/python3.6/site-packages/pynYNAB/ClientFactory.py",line 55, in create_client
    raise NoBudgetNameException
pynYNAB.exceptions.NoBudgetNameException: you should pass a budget_name
rienafairefr commented 6 years ago

Sorry for changing the interface on you :-) I had designed it a long time ago and when I came back to the code I wanted to change all this :-)

I'm tempted to completely remove the nYnabClient.__init__ but it might be too much. I think we should have something that closely resembles the create_client method, probably without the (*args, **kwargs), but (email, password, budget_name, connection=None). Your PR goes in the right direction I think

steffen-lorenz commented 6 years ago

Do you have a workaround until it is included?

rienafairefr commented 6 years ago

Sorry for taking that long coming back to your issue.

You can use the clientfactory directly, I think, nYnabClientFactory().create_client(email, password, budget_name, connection)

I'm working on your PR (rebasing on new commits where I'm fixing the unittests for PRs), should be integrated soon

bdabelow commented 3 years ago

PR has been merged long ago.