chore: refactor

This commit is contained in:
andig 2021-12-10 17:29:30 +01:00
parent 8faa36a477
commit 55ecbbaf78
2 changed files with 56 additions and 54 deletions

View file

@ -4,7 +4,6 @@ import (
"fmt"
"net/http"
"net/url"
"time"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
@ -40,14 +39,6 @@ func NewAPI(log *util.Logger, identity oauth2.TokenSource, realm, id string) *AP
return v
}
// Vehicle is a single vehicle
type Vehicle struct {
ID string `json:"id"`
Label string `json:"label"`
Pictures []string `json:"pictures"`
VIN string `json:"vin"`
}
// Vehicles implements the /vehicles response
func (v *API) Vehicles() ([]Vehicle, error) {
data := url.Values{
@ -72,51 +63,6 @@ func (v *API) Vehicles() ([]Vehicle, error) {
return res.Embedded.Vehicles, err
}
// Status is the /status response
type Status struct {
Battery struct {
Capacity int64
Health struct {
Capacity int64
Resistance int64
}
}
Charging struct {
ChargingMode string
ChargingRate int64
NextDelayedTime string
Plugged bool
RemainingTime string
Status string
}
Preconditionning struct {
AirConditioning struct {
UpdatedAt time.Time
Status string // Disabled
}
}
Energy []Energy
Odometer struct {
Mileage float64
} `json:"timed.odometer"`
}
// Energy is the /status partial energy response
type Energy struct {
UpdatedAt time.Time
Type string // Fuel/Electric
Level int
Autonomy int
Charging struct {
Plugged bool
Status string // InProgress
RemainingTime Duration
ChargingRate int
ChargingMode string // "Slow"
NextDelayedTime Duration
}
}
// Status implements the /vehicles/<vid>/status response
func (v *API) Status(vid string) (Status, error) {
data := url.Values{

56
vehicle/psa/types.go Normal file
View file

@ -0,0 +1,56 @@
package psa
import "time"
// Vehicle is a single vehicle
type Vehicle struct {
ID string `json:"id"`
Label string `json:"label"`
Pictures []string `json:"pictures"`
VIN string `json:"vin"`
}
// Status is the /status response
type Status struct {
Battery struct {
Capacity int64
Health struct {
Capacity int64
Resistance int64
}
}
Charging struct {
ChargingMode string
ChargingRate int64
NextDelayedTime string
Plugged bool
RemainingTime string
Status string
}
Preconditionning struct {
AirConditioning struct {
UpdatedAt time.Time
Status string // Disabled
}
}
Energy []Energy
Odometer struct {
Mileage float64
} `json:"timed.odometer"`
}
// Energy is the /status partial energy response
type Energy struct {
UpdatedAt time.Time
Type string // Fuel/Electric
Level int
Autonomy int
Charging struct {
Plugged bool
Status string // InProgress
RemainingTime Duration
ChargingRate int
ChargingMode string // "Slow"
NextDelayedTime Duration
}
}