nissan

package
v0.0.0-...-4b6ff7e Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CarAdapterBaseURL  = "https://alliance-platform-caradapter-prod.apps.eu2.kamereon.io/car-adapter"
	UserAdapterBaseURL = "https://alliance-platform-usersadapter-prod.apps.eu2.kamereon.io/user-adapter"
	UserBaseURL        = "https://nci-bff-web-prod.apps.eu2.kamereon.io/bff-web"
)

api constants

View Source
const (
	APIVersion   = "protocol=1.0,resource=2.1"
	ClientID     = "a-ncb-prod-android"
	ClientSecret = "0sAcrtwvwEXXZp5nzQhPexSRhxUVKa0d76F4uqDvxvvKFHXpo4myoJwUuV4vuNqC"
	Scope        = "openid profile vehicles"
	Realm        = "a-ncb-prod"
	AuthURL      = "https://prod.eu2.auth.kamereon.org/kauth"
	RedirectURI  = "org.kamereon.service.nci:/oauth2redirect"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	*request.Helper
}

func NewAPI

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

func (*API) BatteryStatus

func (v *API) BatteryStatus(vin, version string) (StatusResponse, error)

BatteryStatus provides battery api response

func (*API) ChargingAction

func (v *API) ChargingAction(vin string, action Action) (ActionResponse, error)

ChargingAction provides actions/charging-start api response

func (*API) RefreshRequest

func (v *API) RefreshRequest(vin, typ string) (ActionResponse, error)

RefreshRequest requests battery status refresh

func (*API) Vehicles

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

type Action

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

type ActionResponse

type ActionResponse struct {
	Data struct {
		Type, ID string // battery refresh
	} `json:"data"`
	Errors []Error
}

type Attributes

type Attributes struct {
	ChargeStatus          float32    `json:"chargeStatus"`
	RangeHvacOff          *int       `json:"rangeHvacOff"`
	BatteryLevel          int        `json:"batteryLevel"`
	BatteryCapacity       int        `json:"batteryCapacity"`
	BatteryTemperature    int        `json:"batteryTemperature"`
	PlugStatus            int        `json:"plugStatus"`
	LastUpdateTime        *Timestamp `json:"lastUpdateTime"`
	ChargePower           int        `json:"chargePower"`
	RemainingTime         *int       `json:"chargingRemainingTime"`
	RemainingToFullFast   int        `json:"timeRequiredToFullFast"`
	RemainingToFullNormal int        `json:"timeRequiredToFullNormal"`
	RemainingToFullSlow   int        `json:"timeRequiredToFullSlow"`
	// v2
	Timestamp       *time.Time `json:"timestamp"`
	BatteryAutonomy *int       `json:"batteryAutonomy"`
}

func (*Attributes) Updated

func (a *Attributes) Updated() time.Time

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 Error

type Error struct {
	Status, Code, Detail string
}

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

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, vin, version string, expiry, cache time.Duration) *Provider

NewProvider returns a kamereon provider

func (*Provider) ChargeEnable

func (v *Provider) ChargeEnable(enable bool) error

ChargeEnable implements the api.ChargeController interface

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) Status

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

Status implements the api.ChargeState interface

type Request

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

Request structure for kamereon api

type StatusResponse

type StatusResponse struct {
	ID string
	Attributes
	Errors []Error
}

StatusResponse structure for kamereon api

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp implements JSON unmarshal

func (*Timestamp) UnmarshalJSON

func (ct *Timestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes string timestamp into time.Time

type Token

type Token struct {
	TokenID    string `json:"tokenId"`
	SuccessURL string `json:"successUrl"`
	Realm      string `json:"realm"`
	Code       int    `json:"code"`    // error response
	Reason     string `json:"reason"`  // error response
	Message    string `json:"message"` // error response
}

func (*Token) Error

func (t *Token) Error() error

func (*Token) SessionExpired

func (t *Token) SessionExpired() bool

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