Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open to a possible API refactor? #107

Open
mreinstein opened this issue Apr 24, 2016 · 4 comments
Open

open to a possible API refactor? #107

mreinstein opened this issue Apr 24, 2016 · 4 comments

Comments

@mreinstein
Copy link
Contributor

what I'd like to change:

  • expose a getToken(email, password, callbackFn)
  • don't store the token internally in the module. pass it in with each call. (e.g, get_charge_state( vid, token, cb )
  • remove the JSONBig module dependency. Rather than fixing the id field, use the id_s field, which tesla already includes for vehicles. One less dependency.
  • support promises (any function calls that omit a callback would return a promise)

if any/all of these changes would be welcome, I'd be happy to send some PRs.

One thing to note, this would be a significant API change. We'd have to mark this as 2.x to respect semver.

@hjespers thoughts?

@hjespers
Copy link
Owner

Open to this. It's due for refactoring. If backward compatibility is broken I would want to take the opportunity to add better error handling that is more like request() and to unbundled all the examples that have taken on a life of their own.

@mseminatore
Copy link

@mreinstein A small note to say that the TeslaJS library does something similar for token handling.

@hjespers
Copy link
Owner

Agreed on removing JSONbig dependency. This was added long before tesla added the id_s field so it's time for it to go.

@hjespers
Copy link
Owner

Finally finished the token handling enhancement request. Not necessary to pass it into every call. I created at set_token() function that sets it once and uses it for the remainder of the session. Also added "token" as an optional parameter where ever username and password was used before. Calling any function which used to take username/email and password with a token will now set the token for use in all other functions just as they were before.

On the JSONbig dependancy I still would need it or "id" and "id_s" would not resolve to the same values no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants