Compare commits
2 Commits
9ec0ec5309
...
439d4dc15b
Author | SHA1 | Date | |
---|---|---|---|
439d4dc15b | |||
5fe6cc55f5 |
@ -251,10 +251,10 @@ func New(config *config.Config) (*Client, error) {
|
|||||||
client.registerDevice()
|
client.registerDevice()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO: create a list of the car with currently present data
|
||||||
fmt.Printf("Parcing cars: %d\n", len(respParsed.Path("data.vehicles").Children()))
|
client.logger.Debug("parcing cars assigned to the account", "quantity", len(respParsed.Path("data.vehicles").Children()))
|
||||||
for _, vehicle := range respParsed.Path("data.vehicles").Children() {
|
for _, vehicle := range respParsed.Path("data.vehicles").Children() {
|
||||||
fmt.Printf("CAR: %s\n", vehicle.Path("vin").Data().(string))
|
client.logger.Debug("parsing car", "vin", vehicle.Path("vin").Data().(string))
|
||||||
client.listOfVins = append(client.listOfVins, vehicle.Path("vin").Data().(string))
|
client.listOfVins = append(client.listOfVins, vehicle.Path("vin").Data().(string))
|
||||||
}
|
}
|
||||||
client.currentVin = respParsed.Path("data.vehicles.0.vin").Data().(string)
|
client.currentVin = respParsed.Path("data.vehicles.0.vin").Data().(string)
|
||||||
|
98
vehicle.go
98
vehicle.go
@ -531,6 +531,8 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
reqURL := MOBILE_API_VERSION + urlToGen(apiURLs["API_VEHICLE_STATUS"], v.getAPIGen())
|
reqURL := MOBILE_API_VERSION + urlToGen(apiURLs["API_VEHICLE_STATUS"], v.getAPIGen())
|
||||||
resp := v.client.execute(reqURL, GET, map[string]string{}, "", false)
|
resp := v.client.execute(reqURL, GET, map[string]string{}, "", false)
|
||||||
|
|
||||||
|
v.client.logger.Debug("http request output", "request", "GetVehicleStatus", "body", resp)
|
||||||
|
|
||||||
if v.client.isResponseSuccessfull(resp) {
|
if v.client.isResponseSuccessfull(resp) {
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -571,15 +573,22 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
door := Door{}
|
newdoor := Door{}
|
||||||
door.Position = submatchall[0]
|
newdoor.Position = submatchall[0]
|
||||||
if len(submatchall) >= 3 {
|
if len(submatchall) >= 3 {
|
||||||
door.SubPosition = submatchall[1]
|
newdoor.SubPosition = submatchall[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
door.Status = child.Data().(string)
|
for _, door := range v.Doors {
|
||||||
door.Updated = time.Now()
|
if door.Position == newdoor.Position && door.SubPosition == newdoor.SubPosition {
|
||||||
v.Doors = append(v.Doors, &door)
|
door.Status = child.Data().(string)
|
||||||
|
door.Updated = time.Now()
|
||||||
|
} else {
|
||||||
|
newdoor.Status = child.Data().(string)
|
||||||
|
newdoor.Updated = time.Now()
|
||||||
|
v.Doors = append(v.Doors, &newdoor)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "door") && strings.HasSuffix(key, "Status") {
|
if strings.HasPrefix(key, "door") && strings.HasSuffix(key, "Status") {
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
@ -588,15 +597,22 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
door := Door{}
|
newdoor := Door{}
|
||||||
door.Position = submatchall[0]
|
newdoor.Position = submatchall[0]
|
||||||
if len(submatchall) >= 3 {
|
if len(submatchall) >= 3 {
|
||||||
door.SubPosition = submatchall[1]
|
newdoor.SubPosition = submatchall[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
door.Status = child.Data().(string)
|
for _, door := range v.Doors {
|
||||||
door.Updated = time.Now()
|
if door.Position == newdoor.Position && door.SubPosition == newdoor.SubPosition {
|
||||||
v.Doors = append(v.Doors, &door)
|
door.Status = child.Data().(string)
|
||||||
|
door.Updated = time.Now()
|
||||||
|
} else {
|
||||||
|
newdoor.Status = child.Data().(string)
|
||||||
|
newdoor.Updated = time.Now()
|
||||||
|
v.Doors = append(v.Doors, &newdoor)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
@ -605,15 +621,22 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
window := Window{}
|
newwindow := Window{}
|
||||||
window.Position = submatchall[0]
|
newwindow.Position = submatchall[0]
|
||||||
if len(submatchall) >= 3 {
|
if len(submatchall) >= 3 {
|
||||||
window.SubPosition = submatchall[1]
|
newwindow.SubPosition = submatchall[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
window.Status = child.Data().(string)
|
for _, window := range v.Windows {
|
||||||
window.Updated = time.Now()
|
if window.Position == newwindow.Position && window.SubPosition == newwindow.SubPosition {
|
||||||
v.Windows = append(v.Windows, &window)
|
window.Status = child.Data().(string)
|
||||||
|
window.Updated = time.Now()
|
||||||
|
} else {
|
||||||
|
newwindow.Status = child.Data().(string)
|
||||||
|
newwindow.Updated = time.Now()
|
||||||
|
v.Windows = append(v.Windows, &newwindow)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Psi") {
|
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Psi") {
|
||||||
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
||||||
@ -701,15 +724,22 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
door := Door{}
|
newdoor := Door{}
|
||||||
door.Position = submatchall[0]
|
newdoor.Position = submatchall[0]
|
||||||
if len(submatchall) >= 3 {
|
if len(submatchall) >= 3 {
|
||||||
door.SubPosition = submatchall[1]
|
newdoor.SubPosition = submatchall[1]
|
||||||
}
|
}
|
||||||
door.Status = child.Data().(string)
|
|
||||||
door.Updated = time.Now()
|
|
||||||
v.Doors = append(v.Doors, &door)
|
|
||||||
|
|
||||||
|
for _, door := range v.Doors {
|
||||||
|
if door.Position == newdoor.Position && door.SubPosition == newdoor.SubPosition {
|
||||||
|
door.Status = child.Data().(string)
|
||||||
|
door.Updated = time.Now()
|
||||||
|
} else {
|
||||||
|
newdoor.Status = child.Data().(string)
|
||||||
|
newdoor.Updated = time.Now()
|
||||||
|
v.Doors = append(v.Doors, &newdoor)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
@ -717,14 +747,22 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
window := Window{}
|
newwindow := Window{}
|
||||||
window.Position = submatchall[0]
|
newwindow.Position = submatchall[0]
|
||||||
if len(submatchall) >= 3 {
|
if len(submatchall) >= 3 {
|
||||||
window.SubPosition = submatchall[1]
|
newwindow.SubPosition = submatchall[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, window := range v.Windows {
|
||||||
|
if window.Position == newwindow.Position && window.SubPosition == newwindow.SubPosition {
|
||||||
|
window.Status = child.Data().(string)
|
||||||
|
window.Updated = time.Now()
|
||||||
|
} else {
|
||||||
|
newwindow.Status = child.Data().(string)
|
||||||
|
newwindow.Updated = time.Now()
|
||||||
|
v.Windows = append(v.Windows, &newwindow)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.Status = child.Data().(string)
|
|
||||||
window.Updated = time.Now()
|
|
||||||
v.Windows = append(v.Windows, &window)
|
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Unit") {
|
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Unit") {
|
||||||
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
||||||
|
Reference in New Issue
Block a user