JagCesar / Tesla-API

A iOS, macOS, watchOS and tvOS framework written in Swift to communicate with Teslas vehicle API
MIT License
34 stars 6 forks source link

Create Token class #5

Closed JagCesar closed 7 years ago

JagCesar commented 7 years ago

The sign in method completion block now sends a Token instance instead of a dictionary. This class does not has an optional constructor since we require it to always have valid data. Instead, this constructor will throw an error if the dictionary it received was invalid.

This is awesome because it means that this class handles what error is thrown. For now we throw APIError, but in the future there may be many different kind of errors. Or maybe APIError will have a property which defines what kind of error happened.