Some changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s

This commit is contained in:
2025-06-01 12:04:24 -04:00
parent ef145bdf9a
commit b477017411
4 changed files with 20 additions and 23 deletions

View File

@ -434,7 +434,6 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
// GET Requests
if method == "GET" {
resp, _ = c.httpClient.
// SetBaseURL(MOBILE_API_SERVER[c.country]).
R().
SetQueryParams(params).
Get(requestUrl)
@ -467,9 +466,7 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
c.logger.Error("error while parsing json", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
}
if !r.Success {
c.logger.Error("request is not successfull", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
} else {
if r.Success {
var sr ServiceRequest
err := json.Unmarshal(r.Data, &sr)
if err != nil {
@ -485,7 +482,7 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
SetBaseURL(MOBILE_API_SERVER[c.country]).
R().
SetQueryParams(map[string]string{
"serviceRequestId": *sr.ServiceRequestID,
"serviceRequestId": sr.ServiceRequestID,
}).
Get(pollingUrl)
resBytes, _ := io.ReadAll(resp.Body)
@ -519,7 +516,8 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
time.Sleep(3 * time.Second)
}
}
} else {
c.logger.Error("request is not successfull", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
}
return resBytes

View File

@ -22,7 +22,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
cfg.Logger.Debug("printting config", "config", cfg)
cfg.Logger.Debug("printing config", "config", cfg)
ms, _ := mysubaru.New(cfg)

View File

@ -2,10 +2,9 @@ module example
go 1.24
require git.savin.nyc/alex/mysubaru v0.0.0-20250530191823-fb8f151e05c9
require git.savin.nyc/alex/mysubaru v0.0.0-20250601152656-ef145bdf9ae5
require (
github.com/Jeffail/gabs/v2 v2.7.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
golang.org/x/net v0.40.0 // indirect

View File

@ -150,7 +150,7 @@ type VehicleStatus struct {
EventDateStrCarUser string `json:"eventDateStrCarUser"` // + 2023-12-06T21:09+0000
Latitude float64 `json:"latitude"` // + 40.700183
Longitude float64 `json:"longitude"` // + -74.401372
Heading int `json:"positionHeadingDegree"` // + "154"
Heading int `json:"positionHeadingDegree,string"` // + "154"
DistanceToEmptyFuelMiles float64 `json:"distanceToEmptyFuelMiles"` // + 209.4
DistanceToEmptyFuelKilometers int `json:"distanceToEmptyFuelKilometers"` // + 337
DistanceToEmptyFuelMiles10s int `json:"distanceToEmptyFuelMiles10s"` // + 210
@ -158,14 +158,14 @@ type VehicleStatus struct {
AvgFuelConsumptionMpg float64 `json:"avgFuelConsumptionMpg"` // + 18.4
AvgFuelConsumptionLitersPer100Kilometers float64 `json:"avgFuelConsumptionLitersPer100Kilometers"` // + 12.8
RemainingFuelPercent int `json:"remainingFuelPercent"` // + 82
TirePressureFrontLeft string `json:"tirePressureFrontLeft"` // + "2275"
TirePressureFrontRight string `json:"tirePressureFrontRight"` // + "2344"
TirePressureRearLeft string `json:"tirePressureRearLeft"` // + "2413"
TirePressureRearRight string `json:"tirePressureRearRight"` // + "2344"
TirePressureFrontLeftPsi string `json:"tirePressureFrontLeftPsi"` // + "33"
TirePressureFrontRightPsi string `json:"tirePressureFrontRightPsi"` // + "34"
TirePressureRearLeftPsi string `json:"tirePressureRearLeftPsi"` // + "35"
TirePressureRearRightPsi string `json:"tirePressureRearRightPsi"` // + "34"
TirePressureFrontLeft int `json:"tirePressureFrontLeft,string"` // + "2275"
TirePressureFrontRight int `json:"tirePressureFrontRight,string"` // + "2344"
TirePressureRearLeft int `json:"tirePressureRearLeft,string"` // + "2413"
TirePressureRearRight int `json:"tirePressureRearRight,string"` // + "2344"
TirePressureFrontLeftPsi int `json:"tirePressureFrontLeftPsi,string"` // + "33"
TirePressureFrontRightPsi int `json:"tirePressureFrontRightPsi,string"` // + "34"
TirePressureRearLeftPsi int `json:"tirePressureRearLeftPsi,string"` // + "35"
TirePressureRearRightPsi int `json:"tirePressureRearRightPsi,string"` // + "34"
TyreStatusFrontLeft string `json:"tyreStatusFrontLeft"` // + "UNKNOWN"
TyreStatusFrontRight string `json:"tyreStatusFrontRight"` // + "UNKNOWN"
TyreStatusRearLeft string `json:"tyreStatusRearLeft"` // + "UNKNOWN"
@ -253,15 +253,15 @@ type VehicleCondition struct {
// ServiceRequest .
// "dataName": "remoteServiceStatus"
type ServiceRequest struct {
ServiceRequestID *string `json:"serviceRequestId,omitempty"` // 4S4BTGND8L3137058_1640294426029_19_@NGTP
ServiceRequestID string `json:"serviceRequestId,omitempty"` // 4S4BTGND8L3137058_1640294426029_19_@NGTP
Success bool `json:"success"` // false | true
Cancelled bool `json:"cancelled"` // false | true
RemoteServiceType string `json:"remoteServiceType"` // unlock | lock | locate | vehicleStatus | lightsOnly | engineStart | engineStop | phevChargeNow | condition
RemoteServiceState string `json:"remoteServiceState"` // started | finished | stopping
SubState *string `json:"subState,omitempty"` // null
ErrorCode *string `json:"errorCode,omitempty"` // null:null
Result json.RawMessage `json:"result,omitempty"` // null
UpdateTime *time.Time `json:"updateTime,omitempty"` // timestamp
SubState string `json:"subState,omitempty"` // null
ErrorCode string `json:"errorCode,omitempty"` // null:null
Result json.RawMessage `json:"result,omitempty"` // struct
UpdateTime time.Time `json:"updateTime,omitempty"` // timestamp
Vin string `json:"vin"` // 4S4BTGND8L3137058
}