nissan

package
v0.0.0-...-722e3e0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion         = "protocol=1.0,resource=2.1"
	ClientID           = "a-ncb-prod-android"
	ClientSecret       = "3LBs0yOx2XO-3m4mMRW27rKeJzskhfWF0A8KUtnim8i/qYQPl8ZItp3IaqJXaYj_"
	Scope              = "openid profile vehicles"
	AuthBaseURL        = "https://prod.eu.auth.kamereon.org/kauth"
	Realm              = "a-ncb-prod"
	RedirectURI        = "org.kamereon.service.nci:/oauth2redirect"
	CarAdapterBaseURL  = "https://alliance-platform-caradapter-prod.apps.eu.kamereon.io/car-adapter"
	UserAdapterBaseURL = "https://alliance-platform-usersadapter-prod.apps.eu.kamereon.io/user-adapter"
	UserBaseURL        = "https://nci-bff-web-prod.apps.eu.kamereon.io/bff-web"
)

api constants

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func NewAPI

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

func (*API) Battery

func (v *API) Battery() (Response, error)

Battery provides battery api response

func (*API) ChargingAction

func (v *API) ChargingAction(action Action) (Response, error)

ChargingAction provides actions/charging-start api response

func (*API) Vehicles

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

type Action

type Action string
const (
	ActionChargeStart Action = "start"
	ActionChargeStop  Action = "stop"
)

type Auth

type Auth struct {
	AuthID    string         `json:"authId"`
	Template  string         `json:"template"`
	Stage     string         `json:"stage"`
	Header    string         `json:"header"`
	Callbacks []AuthCallback `json:"callbacks"`
}

type AuthCallback

type AuthCallback struct {
	Type   string              `json:"type"`
	Output []AuthCallbackValue `json:"output"`
	Input  []AuthCallbackValue `json:"input"`
}

type AuthCallbackValue

type AuthCallbackValue struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Identity

type Identity struct {
	*request.Helper
	oauth2.TokenSource
}

func NewIdentity

func NewIdentity(log *util.Logger) *Identity

NewIdentity creates Nissan identity

func (*Identity) Login

func (v *Identity) Login(user, password string) error

func (*Identity) RefreshToken

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

type Payload

type Payload struct {
	Type       string                 `json:"type"`
	Attributes map[string]interface{} `json:"attributes,omitempty"`
}

type Provider

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

Provider is a kamereon provider

func NewProvider

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

NewProvider returns a kamereon provider

func (*Provider) FinishTime

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

FinishTime implements the api.VehicleFinishTimer 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) StartCharge

func (v *Provider) StartCharge() error

StartCharge implements the api.VehicleStartCharge interface

func (*Provider) Status

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

Status implements the api.ChargeState interface

func (*Provider) StopCharge

func (v *Provider) StopCharge() error

StopCharge implements the api.VehicleStopCharge interface

type Request

type Request struct {
	Data Payload `json:"data"`
}

Request structure for kamereon api

type Response

type Response struct {
	Data struct {
		Type, ID   string     // battery refresh
		Attributes attributes `json:"attributes"`
	} `json:"data"`
}

Response structure for kamereon api

type Token

type Token struct {
	TokenID    string `json:"tokenId"`
	SuccessURL string `json:"successUrl"`
	Realm      string `json:"realm"`
}

type Vehicle

type Vehicle struct {
	VIN        string
	ModelName  string
	PictureURL string
}

type Vehicles

type Vehicles struct {
	Data []Vehicle
}

Jump to

Keyboard shortcuts

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