package main
import (
"context"
tesla "github.com/Noy/Tesla"
"log"
)
func main() {
authToken, err := tesla.RetrieveToken(context.Background(), "[email protected]", "teslaPassword")
if err != nil {
// error handling is option for you
}
log.Println(authToken) // log the result, which will be your auth token
}
package main
import (
"github.com/Noy/Tesla"
)
// Authentication
func getCarId() int64 {
authToken := "abc123"
// Use the auth token from before to authenticate with AuthTesla
auth := tesla.AuthTesla{AccessToken: authToken}
id := auth.ListVehicles()[0].ID
return id
}
package main
import (
"github.com/Noy/Tesla"
)
// Authentication
func authTesla() *tesla.AuthTesla {
var id, authToken string
// Use the auth token and ID from before to authenticate with AuthTesla
teslaCar := tesla.AuthTesla{ID: id, AccessToken: authToken}
return &teslaCar
}
//Then...
// Use this function in your desired ways.. It'll honk your car!
func honk() {
authTesla().HonkHorn()
}