mercedes

package
v0.0.0-...-f385b4b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BffUriEMEA                 = "https://bff.emea-prod.mobilesdk.mercedes-benz.com"
	WidgetUriEMEA              = "https://widget.emea-prod.mobilesdk.mercedes-benz.com"
	BffUriAPAC                 = "https://bff.amap-prod.mobilesdk.mercedes-benz.com"
	WidgetUriAPAC              = "https://widget.amap-prod.mobilesdk.mercedes-benz.com"
	BffUriNORAM                = "https://bff.amap-prod.mobilesdk.mercedes-benz.com"
	WidgetUriNORAM             = "https://widget.amap-prod.mobilesdk.mercedes-benz.com"
	IdUri                      = "https://id.mercedes-benz.com"
	ClientId                   = "01398c1c-dc45-4b42-882b-9f5ba9f175f1"
	RisApplicationVersionEMEA  = "1.44.0"
	RisSdkVersionEMEA          = "2.150.1"
	RisApplicationVersionAPAC  = "1.44.0"
	RisSdkVersionAPAC          = "2.150.1"
	RisApplicationVersionNORAM = "3.42.0"
	RisSdkVersionNORAM         = "2.150.1"
	RisOsVersion               = "17.3"
	RisOsName                  = "ios"
	XApplicationNameEMEA       = "mycar-store-ece"
	XApplicationNameAPAC       = "mycar-store-ap"
	XApplicationNameNORAM      = "mycar-store-us"
	UserAgent                  = "MyCar/%s (com.daimler.ris.mercedesme.%s.ios; %s %s) Alamofire/5.4.0"
	UserAgentAPAC              = "mycar-store-ap v%s, %s %s, SDK %s"
	Locale                     = "en-GB"
	CountryCode                = "EN"
)

Variables

View Source
var OAuth2Config = &oauth2.Config{

	Endpoint: oauth2.Endpoint{

		TokenURL:  fmt.Sprintf("%s/as/token.oauth2", IdUri),
		AuthStyle: oauth2.AuthStyleInParams,
	},
	Scopes: []string{"not_needed", "handled", "elsewhere"},
}

OAuth2Config is the OAuth2 configuration for authenticating with the MercedesAPI.

View Source
var Regions = map[string]string{
	"apac":  "Asia-Pacific",
	"ece":   "ECE",
	"noram": "North-America",
}

Functions

func MapChargeStatus

func MapChargeStatus(lookup int) api.ChargeStatus

Types

type API

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

API is an api.Vehicle implementation for Mercedes-Benz cars

func NewAPI

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

func (*API) Status

func (v *API) Status(vin string) (StatusResponse, error)

func (*API) Vehicles

func (v *API) Vehicles() ([]string, error)

type ErrorInfo

type ErrorInfo struct {
	ErrorCode    int
	ErrorMessage string
	ErrorDetails string
}

func (ErrorInfo) Error

func (e ErrorInfo) Error() error

type Helper

type Helper struct {
	*http.Client
}

Helper provides utility primitives

type Identity

type Identity struct {
	*request.Helper
	oauth2.TokenSource

	Sessionid string
	// contains filtered or unexported fields
}

func NewIdentity

func NewIdentity(log *util.Logger, token *oauth2.Token, account string, region string) (*Identity, error)

NewIdentity creates Mercedes identity

func (*Identity) RefreshToken

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

type PinRequest

type PinRequest struct {
	EmailOrPhoneNumber string `json:"emailOrPhoneNumber"`
	CountryCode        string `json:"countryCode"`
	Nonce              string `json:"nonce"`
}

type PinResponse

type PinResponse struct {
	IsEmail  bool   `json:"isEmail"`
	UserName string `json:"username"`
}

type Provider

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

func NewProvider

func NewProvider(api *API, vin string, 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 api.VehicleOdometer interface

func (*Provider) Position

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

Position implements the api.VehiclePosition 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)

Status implements the api.ChargeState interface

type SetupAPI

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

func NewSetupAPI

func NewSetupAPI(log *util.Logger, account string, region string) *SetupAPI

func (*SetupAPI) RequestAccessToken

func (vs *SetupAPI) RequestAccessToken(nonce string, pin string) (*oauth2.Token, error)

func (*SetupAPI) RequestPin

func (vs *SetupAPI) RequestPin() (bool, *string, error)

type StatusResponse

type StatusResponse struct {
	VehicleInfo struct {
		Odometer struct {
			Value int
			Unit  string
		}
		Timestamp time.Time
	}
	EvInfo struct {
		Battery struct {
			ChargingStatus  int
			DistanceToEmpty struct {
				Value int
				Unit  string
			}
			StateOfCharge   float64 // 75
			EndOfChargeTime int     // Minutes after midnight
			TotalRange      int     // 17
		}
		Timestamp time.Time
	}
	LocationResponse struct {
		TimeStamp time.Time
		Longitude float64
		Latitude  float64
	}
	Timestamp time.Time
}

type Vehicle

type Vehicle struct {
	Fin string
	Vin string
}

type VehiclesResponse

type VehiclesResponse struct {
	AssignedVehicles []Vehicle
}

Directories

Path Synopsis
pb

Jump to

Keyboard shortcuts

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