More changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 23s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 23s
This commit is contained in:
29
client.go
29
client.go
@ -275,16 +275,26 @@ func (c *Client) SelectVehicle(vin string) VehicleData {
|
|||||||
"_": timestamp()}
|
"_": timestamp()}
|
||||||
reqURL := MOBILE_API_VERSION + apiURLs["API_SELECT_VEHICLE"]
|
reqURL := MOBILE_API_VERSION + apiURLs["API_SELECT_VEHICLE"]
|
||||||
resp := c.execute(reqURL, GET, params, "", false)
|
resp := c.execute(reqURL, GET, params, "", false)
|
||||||
|
c.logger.Debug("http request output", "request", "SelectVehicle", "body", resp)
|
||||||
|
|
||||||
var vData VehicleData
|
var r Response
|
||||||
respParsed, err := gabs.ParseJSON([]byte(resp))
|
err := json.Unmarshal(resp, &r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
c.logger.Error("error while parsing json", "request", "SelectVehicle", "error", err.Error())
|
||||||
}
|
}
|
||||||
c.logger.Debug("http request output", "request", "SelectVehicle", "body", respParsed)
|
|
||||||
|
|
||||||
vdString := respParsed.Path("data").String()
|
if r.Success {
|
||||||
json.Unmarshal([]byte(vdString), &vData)
|
var vd VehicleData
|
||||||
|
err = json.Unmarshal(r.Data, &vd)
|
||||||
|
if err != nil {
|
||||||
|
c.logger.Error("error while parsing json", "request", "GetClimatePresets", "error", err.Error())
|
||||||
|
}
|
||||||
|
c.logger.Debug("http request output", "request", "GetVehicleStatus", "body", resp)
|
||||||
|
|
||||||
|
return vd
|
||||||
|
} else {
|
||||||
|
return VehicleData{}
|
||||||
|
}
|
||||||
|
|
||||||
// resp := c.execute(reqURL, GET, params, "", false)
|
// resp := c.execute(reqURL, GET, params, "", false)
|
||||||
// logger.Debugf("SELECT VEHICLE OUTPUT >> %v\n", string([]byte(resp)))
|
// logger.Debugf("SELECT VEHICLE OUTPUT >> %v\n", string([]byte(resp)))
|
||||||
@ -309,7 +319,6 @@ func (c *Client) SelectVehicle(vin string) VehicleData {
|
|||||||
// # Something else is probably wrong with the backend server context - try resetting
|
// # Something else is probably wrong with the backend server context - try resetting
|
||||||
// self.reset_session()
|
// self.reset_session()
|
||||||
// raise SubaruException("Failed to switch vehicle %s - resetting session." % js_resp.get("errorCode"))
|
// raise SubaruException("Failed to switch vehicle %s - resetting session." % js_resp.get("errorCode"))
|
||||||
return vData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVehicles .
|
// GetVehicles .
|
||||||
@ -321,8 +330,9 @@ func (c *Client) GetVehicles() []*Vehicle {
|
|||||||
"_": timestamp()}
|
"_": timestamp()}
|
||||||
reqURL := MOBILE_API_VERSION + apiURLs["API_SELECT_VEHICLE"]
|
reqURL := MOBILE_API_VERSION + apiURLs["API_SELECT_VEHICLE"]
|
||||||
resp := c.execute(reqURL, GET, params, "", false)
|
resp := c.execute(reqURL, GET, params, "", false)
|
||||||
|
c.logger.Debug("http request output", "request", "GetVehicles", "body", resp)
|
||||||
|
|
||||||
respParsed, err := gabs.ParseJSON([]byte(resp))
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Error("error while parsing json", "request", "GetVehicles", "error", err.Error())
|
c.logger.Error("error while parsing json", "request", "GetVehicles", "error", err.Error())
|
||||||
}
|
}
|
||||||
@ -333,9 +343,6 @@ func (c *Client) GetVehicles() []*Vehicle {
|
|||||||
|
|
||||||
json.Unmarshal([]byte(vdString), &vData)
|
json.Unmarshal([]byte(vdString), &vData)
|
||||||
|
|
||||||
// fmt.Printf("VEHICLE STRING: %+v\n\n", vdString)
|
|
||||||
// fmt.Printf("VEHICLE DATA: %+v\n\n", vData)
|
|
||||||
|
|
||||||
vehicle := &Vehicle{
|
vehicle := &Vehicle{
|
||||||
Vin: vin,
|
Vin: vin,
|
||||||
CarName: vData.VehicleName,
|
CarName: vData.VehicleName,
|
||||||
|
@ -285,6 +285,10 @@ type ErrorResponse struct {
|
|||||||
// startConfiguration: [ START_CLIMATE_CONTROL_ONLY_ALLOW_KEY_IN_IGNITION | START_ENGINE_ALLOW_KEY_IN_IGNITION ]
|
// startConfiguration: [ START_CLIMATE_CONTROL_ONLY_ALLOW_KEY_IN_IGNITION | START_ENGINE_ALLOW_KEY_IN_IGNITION ]
|
||||||
// runTimeMinutes: [ 10 ]
|
// runTimeMinutes: [ 10 ]
|
||||||
|
|
||||||
|
type VehicleHealth struct {
|
||||||
|
VehicleHealthItems []VehicleHealthItem `json:"vehicleHealthItems"`
|
||||||
|
LastUpdatedDate int64 `json:"lastUpdatedDate"`
|
||||||
|
}
|
||||||
type VehicleHealthItem struct {
|
type VehicleHealthItem struct {
|
||||||
B2cCode string `json:"b2cCode"`
|
B2cCode string `json:"b2cCode"`
|
||||||
FeatureCode string `json:"featureCode"`
|
FeatureCode string `json:"featureCode"`
|
||||||
|
13
vehicle.go
13
vehicle.go
@ -8,8 +8,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Jeffail/gabs/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var parts = map[string]map[string][]string{
|
var parts = map[string]map[string][]string{
|
||||||
@ -961,12 +959,19 @@ func (v *Vehicle) GetVehicleHealth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if r.Success {
|
if r.Success {
|
||||||
_, err := gabs.ParseJSON(resp)
|
var vh VehicleHealth
|
||||||
|
err = json.Unmarshal(r.Data, &vh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.client.logger.Error("error while parsing json", "request", "GetVehicleHealth", "error", err.Error())
|
v.client.logger.Error("error while parsing json", "request", "GetVehicleHealth", "error", err.Error())
|
||||||
}
|
}
|
||||||
// TODO:
|
v.client.logger.Debug("http request output", "request", "GetVehicleHealth", "body", resp)
|
||||||
|
|
||||||
|
// TODO: Loop over all the Vehicle Health Items
|
||||||
|
|
||||||
|
} else {
|
||||||
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // GetClimateSettings .
|
// // GetClimateSettings .
|
||||||
|
Reference in New Issue
Block a user