Enhance session validation handling in API endpoints and refactor vehicle-related structures for improved clarity and functionality.
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
This commit is contained in:
54
vehicle.go
54
vehicle.go
@ -12,30 +12,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// var parts = map[string]map[string][]string{
|
||||
// "door": {
|
||||
// "suffix": {"position", "status"},
|
||||
// "position1": {"front", "rear", "boot", "enginehood"},
|
||||
// "position2": {"right", "left"},
|
||||
// },
|
||||
// "window": {
|
||||
// "suffix": {"status"},
|
||||
// "position1": {"front", "rear", "sunroof"},
|
||||
// "position2": {"right", "left"},
|
||||
// },
|
||||
// "tire": {
|
||||
// "prefix": {"status"},
|
||||
// "position1": {"front", "rear"},
|
||||
// "position2": {"right", "left"},
|
||||
// },
|
||||
// "tyre": {
|
||||
// "prefix": {"pressure"},
|
||||
// "suffix": {"psi", "unit"},
|
||||
// "position1": {"front", "rear"},
|
||||
// "position2": {"right", "left"},
|
||||
// },
|
||||
// }
|
||||
|
||||
// Vehicle represents a Subaru vehicle with various attributes and methods to interact with it.
|
||||
type Vehicle struct {
|
||||
CarId int64
|
||||
@ -88,34 +64,6 @@ type Vehicle struct {
|
||||
|
||||
}
|
||||
|
||||
// ClimateProfile represents a climate control profile for a Subaru vehicle.
|
||||
type ClimateProfile struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
VehicleType string `json:"vehicleType,omitempty"` // vehicleType [ gas | phev ]
|
||||
PresetType string `json:"presetType,omitempty"` // presetType [ subaruPreset | userPreset ]
|
||||
CanEdit bool `json:"canEdit,string,omitempty"` // canEdit [ false | true ]
|
||||
Disabled bool `json:"disabled,string,omitempty"` // disabled [ false | true ]
|
||||
RunTimeMinutes int `json:"runTimeMinutes,string"` // runTimeMinutes [ 5 | 10 ]
|
||||
ClimateZoneFrontTemp int `json:"climateZoneFrontTemp,string"` // climateZoneFrontTemp: [ for _ in range(60, 85 + 1)] // climateZoneFrontTempCelsius: [for _ in range(15, 30 + 1) ]
|
||||
ClimateZoneFrontAirMode string `json:"climateZoneFrontAirMode"` // climateZoneFrontAirMode: [ WINDOW | FEET_WINDOW | FACE | FEET | FEET_FACE_BALANCED | AUTO ]
|
||||
ClimateZoneFrontAirVolume string `json:"climateZoneFrontAirVolume"` // climateZoneFrontAirVolume: [ AUTO | 2 | 4 | 7 ]
|
||||
OuterAirCirculation string `json:"outerAirCirculation"` // outerAirCirculation: [ outsideAir, recirculation ]
|
||||
HeatedRearWindowActive bool `json:"heatedRearWindowActive,string"` // heatedRearWindowActive: [ false | true ]
|
||||
AirConditionOn bool `json:"airConditionOn,string"` // airConditionOn: [ false | true ]
|
||||
HeatedSeatFrontLeft string `json:"heatedSeatFrontLeft"` // heatedSeatFrontLeft: [ OFF | LOW_HEAT | MEDIUM_HEAT | HIGH_HEAT ]
|
||||
HeatedSeatFrontRight string `json:"heatedSeatFrontRight"` // heatedSeatFrontRight: [ OFF | LOW_HEAT | MEDIUM_HEAT | HIGH_HEAT ]
|
||||
StartConfiguration string `json:"startConfiguration"` // startConfiguration [ START_ENGINE_ALLOW_KEY_IN_IGNITION (gas) | START_CLIMATE_CONTROL_ONLY_ALLOW_KEY_IN_IGNITION (phev) ]
|
||||
}
|
||||
|
||||
// GeoLocation represents the geographical location of a Subaru vehicle.
|
||||
type GeoLocation struct {
|
||||
Latitude float64 // 40.700184
|
||||
Longitude float64 // -74.401375
|
||||
Heading int // 189
|
||||
Speed float64 // 0.00
|
||||
Updated time.Time
|
||||
}
|
||||
|
||||
// Door represents a door of a Subaru vehicle with its position, sub-position, status, and lock state.
|
||||
type Door struct {
|
||||
Position string // front | rear | boot | enginehood
|
||||
@ -884,7 +832,7 @@ func (v *Vehicle) selectVehicle() {
|
||||
v.GeoLocation.Longitude = vData.VehicleGeoPosition.Longitude
|
||||
v.GeoLocation.Heading = vData.VehicleGeoPosition.Heading
|
||||
v.GeoLocation.Speed = vData.VehicleGeoPosition.Speed
|
||||
v.GeoLocation.Updated = time.Now()
|
||||
v.GeoLocation.Updated = vData.VehicleGeoPosition.Timestamp
|
||||
v.Updated = time.Now()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user