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:
34
vehicle.go
34
vehicle.go
@ -483,7 +483,6 @@ func (v *Vehicle) GetClimatePresets() {
|
||||
v.selectVehicle()
|
||||
reqURL := MOBILE_API_VERSION + apiURLs["API_G2_FETCH_RES_SUBARU_PRESETS"]
|
||||
resp := v.client.execute(reqURL, GET, map[string]string{}, "", false)
|
||||
|
||||
v.client.logger.Debug("subaru climate presets http output", "body", resp)
|
||||
|
||||
tmp := struct {
|
||||
@ -546,32 +545,37 @@ func (v *Vehicle) GetClimateUserPresets() {
|
||||
reqURL := MOBILE_API_VERSION + apiURLs["API_G2_FETCH_RES_USER_PRESETS"]
|
||||
resp := v.client.execute(reqURL, GET, map[string]string{}, "", false)
|
||||
|
||||
respParsed, err := gabs.ParseJSON(resp)
|
||||
if err != nil {
|
||||
v.client.logger.Error("error while parsing json", "request", "GetClimateUserPresets", "error", err.Error())
|
||||
}
|
||||
v.client.logger.Debug("user climate presets parsed http output", "body", respParsed)
|
||||
v.client.logger.Debug("user climate presets parsed http output", "body", resp)
|
||||
|
||||
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
|
||||
data, ok := respParsed.Path("data").Data().(string)
|
||||
if !ok {
|
||||
v.client.logger.Error("error while parsing data json", "request", "GetClimateUserPresets", "error", err.Error())
|
||||
tmp := struct {
|
||||
Success bool `json:"success"`
|
||||
ErrorCode string `json:"errorCode"`
|
||||
DataName string `json:"dataName"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
}{}
|
||||
err := json.Unmarshal(resp, &tmp)
|
||||
if err != nil {
|
||||
v.client.logger.Error("error while parsing json", "request", "GetClimatePresets", "error", err.Error())
|
||||
}
|
||||
v.client.logger.Debug("subaru climate presets parsed http output", "body", tmp)
|
||||
|
||||
var cProfiles []ClimateProfile
|
||||
err = json.Unmarshal([]byte(data), &cProfiles)
|
||||
v.client.logger.Debug("climate user presets", "data", data)
|
||||
|
||||
err = json.Unmarshal([]byte(tmp.Data), &cProfiles)
|
||||
if err != nil {
|
||||
v.client.logger.Error("error while parsing climate user presets json", "request", "GetClimateUserPresets", "error", err.Error())
|
||||
v.client.logger.Error("error while parsing json", "request", "GetClimatePresets", "error", err.Error())
|
||||
}
|
||||
v.client.logger.Debug("subaru climate presets parsed http output", "body", cProfiles)
|
||||
|
||||
if len(cProfiles) > 0 {
|
||||
for _, cp := range cProfiles {
|
||||
if _, ok := v.ClimateProfiles[cp.PresetType+cp.Name]; ok {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
} else {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
if _, ok := v.ClimateProfiles[cp.PresetType+cp.Name]; ok {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
} else {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user