Closed chbndrhnns closed 6 years ago
I see the problem. I think I delegated that responsibility to the caller. Presumably, if you're passing a connection object you know you should initialize it at some point. Otherwise, just omit te connection object, pass email and password and the connection will be created and initialized for you inside the nYnabClientFactory.
If you're taking responsibility for creating the connection, you're taking the responsibility for initializing it, I think that's alright ? init_session starts the session with nynab server, with a certain expiration period for the tokens etc. the caller (your code or whatever) should decide when to init I think, not me.
A middle ground would be to fail gracefully in case the connection has not been initialized before trying to sync or whatever
Failing gracefully is ok for me. I just tried https://github.com/scottrobertson/fintech-to-ynab and noticed the init did not take place there which is why it failed starting up.
Does logging an error and raising a nYnabConnectionError exception count as failing gracefully for your use case ? at least it's a bit more verbose than just "unknown api error invalid_token" :-)
Definitely!
…is given to the factory or if it is created there.
Otherwise something like this fails: