polestar

package
v0.0.0-...-cd27ee2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiURI   = "https://pc-api.polestar.com/eu-north-1"
	ApiURIv1 = ApiURI + "/my-star"
	ApiURIv2 = ApiURI + "/mystar-v2"
)
View Source
const OAuthURI = "https://polestarid.eu.polestar.com"

Variables

View Source
var OAuth2Config = &oauth2.Config{
	ClientID:    "polmystar",
	RedirectURL: "https://www.polestar.com/sign-in-callback",
	Endpoint: oauth2.Endpoint{
		AuthURL:  OAuthURI + "/as/authorization.oauth2",
		TokenURL: OAuthURI + "/as/token.oauth2",
	},
	Scopes: []string{
		"openid", "profile", "email", "customer:attributes",
	},
}

https://polestarid.eu.polestar.com/.well-known/openid-configuration

Functions

func NewIdentity

func NewIdentity(log *util.Logger, user, password string) (oauth2.TokenSource, error)

NewIdentity creates Polestar identity

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(log *util.Logger, identity oauth2.TokenSource) *API

func (*API) Odometer

func (v *API) Odometer(ctx context.Context, vin string) (OdometerData, error)

func (*API) Status

func (v *API) Status(ctx context.Context, vin string) (BatteryData, error)

func (*API) Vehicles

func (v *API) Vehicles(ctx context.Context) ([]ConsumerCar, error)

type BatteryData

type BatteryData struct {
	BatteryChargeLevelPercentage       float64
	ChargerConnectionStatus            string
	ChargingStatus                     string
	EstimatedChargingTimeToFullMinutes int
	EstimatedDistanceToEmptyKm         int
	EventUpdatedTimestamp              EventUpdatedTimestamp
}

type ConsumerCar

type ConsumerCar struct {
	VIN                       string
	InternalVehicleIdentifier string
}

type EventUpdatedTimestamp

type EventUpdatedTimestamp struct {
	ISO time.Time
}

type Identity

type Identity struct {
	*request.Helper
	// contains filtered or unexported fields
}

func (*Identity) RefreshToken

func (v *Identity) RefreshToken(token *oauth2.Token) (*oauth2.Token, error)

type OdometerData

type OdometerData struct {
	OdometerMeters        float64
	EventUpdatedTimestamp EventUpdatedTimestamp
}

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(log *util.Logger, api *API, vin string, timeout, cache time.Duration) *Provider

func (*Provider) FinishTime

func (v *Provider) FinishTime() (time.Time, error)

FinishTime implements the api.VehicleFinishTimer interface

func (*Provider) Odometer

func (v *Provider) Odometer() (float64, error)

Odometer implements the Provider.VehicleOdometer interface

func (*Provider) Range

func (v *Provider) Range() (int64, error)

Range implements the api.VehicleRange interface

func (*Provider) Soc

func (v *Provider) Soc() (float64, error)

Soc implements the api.Vehicle interface

func (*Provider) Status

func (v *Provider) Status() (api.ChargeStatus, error)

Range implements the api.VehicleRange interface

type Token

type Token struct {
	AccessToken  string `graphql:"access_token"`
	RefreshToken string `graphql:"refresh_token"`
	ExpiresIn    int    `graphql:"expires_in"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL