Documentation ¶
Overview ¶
Package account implements functions for managing a Tesla account.
Index ¶
- Variables
- type Account
- func (a *Account) Get(ctx context.Context, endpoint string) ([]byte, error)
- func (a *Account) GetVehicle(ctx context.Context, vin string, privateKey authentication.ECDHPrivateKey, ...) (*vehicle.Vehicle, error)
- func (a *Account) Post(ctx context.Context, endpoint string, data []byte) ([]byte, error)
- func (a *Account) SendVehicleFleetAPICommand(ctx context.Context, vin, endpoint string, command interface{}) ([]byte, error)
- func (a *Account) UpdateKey(ctx context.Context, publicKey *ecdh.PublicKey, name string) error
Constants ¶
This section is empty.
Variables ¶
var ( // UserAgent is sent in HTTP requests. // // The default value is "<main package name>/<commit hash> tesla-sdk/<version>". UserAgent = buildUserAgent() )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // The default UserAgent is constructed from the global UserAgent, but can be overridden. UserAgent string Host string // contains filtered or unexported fields }
Account allows interaction with a Tesla account.
func New ¶
New returns an Account that can be used to fetch a vehicle.Vehicle.
func (*Account) Get ¶
Get sends an HTTP GET request to endpoint.
The endpoint should contain only the path (e.g., "api/1/vehicles/foo"); the domain is determined by the a.Host.
func (*Account) GetVehicle ¶
func (a *Account) GetVehicle(ctx context.Context, vin string, privateKey authentication.ECDHPrivateKey, sessions *cache.SessionCache) (*vehicle.Vehicle, error)
GetVehicle returns the Vehicle belonging to the account with the provided vin.
Providing a nil privateKey is allowed, but a privateKey is required for most Vehicle interactions. Typically, the privateKey will only be nil when connecting to the Vehicle to send an AddKeyRequest; see documentation in pkg/github.com/Nikola-Software/tesla-vehicle-command/pkg/vehicle. The sessions parameter may also be nil, but providing a cache.SessionCache avoids a round-trip handshake with the Vehicle in subsequent connections.
func (*Account) Post ¶
Post sends an HTTP POST request to endpoint.
The endpoint should contain only the path (e.g., "api/1/vehicles/foo"); the domain is determined by the ServerConfig used to create the Account. Returns the HTTP body of the response.
func (*Account) SendVehicleFleetAPICommand ¶
func (a *Account) SendVehicleFleetAPICommand(ctx context.Context, vin, endpoint string, command interface{}) ([]byte, error)
SendVehicleFleetAPICommand sends a command to a vehicle through the REST API.
The command must support JSON serialization.