mercedes

package
v0.0.0-...-0c7050d Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseURI is the Mercedes api base URI
	BaseURI        = "https://api.mercedes-benz.com/vehicledata/v2"
	SandboxBaseURI = "https://api.mercedes-benz.com/vehicledata_tryout/v2"
)
View Source
const OAuthURI = "https://ssoalpha.dvb.corpinter.net/v1"

https://ssoalpha.dvb.corpinter.net/v1/.well-known/openid-configuration

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API is the Mercedes api client

func NewAPI

func NewAPI(log *util.Logger, identity *Identity, sandbox bool) *API

NewAPI creates a new api client

func (*API) BaseURI

func (v *API) BaseURI() string

func (*API) Range

func (v *API) Range(vin string) (EVResponse, error)

Range implements the /rangeelectric response

func (*API) Soc

func (v *API) Soc(vin string) (EVResponse, error)

Soc implements the /soc response

type EVResponse

type EVResponse struct {
	Soc struct {
		Value     int64 `json:",string"`
		Timestamp int64
	}
	RangeElectric struct {
		Value     int64 `json:",string"`
		Timestamp int64
	}
}

type Identity

type Identity struct {
	*ReuseTokenSource
	// contains filtered or unexported fields
}

func NewIdentity

func NewIdentity(log *util.Logger, id, secret string, options ...IdentityOption) (*Identity, error)

TODO SessionSecret from config/persistence

func (*Identity) LoginHandler

func (v *Identity) LoginHandler() http.HandlerFunc

func (*Identity) LogoutHandler

func (v *Identity) LogoutHandler() http.HandlerFunc

func (*Identity) SetCallbackParams

func (v *Identity) SetCallbackParams(baseURL, redirectURL string, authC chan<- bool)

type IdentityOption

type IdentityOption func(c *Identity) error

func WithToken

func WithToken(t *oauth2.Token) IdentityOption

WithToken provides an oauth2.Token to the client for auth.

type Provider

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

Provider implements the vehicle api

func NewProvider

func NewProvider(api *API, vin string, cache time.Duration) *Provider

NewProvider creates a vehicle api provider

func (*Provider) Range

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

Range implements the api.VehicleRange interface

func (*Provider) Soc

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

Soc implements the api.Vehicle interface

type ReuseTokenSource

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

func (*ReuseTokenSource) Apply

func (ts *ReuseTokenSource) Apply(t *oauth2.Token)

func (*ReuseTokenSource) Token

func (ts *ReuseTokenSource) Token() (*oauth2.Token, error)

Jump to

Keyboard shortcuts

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