Some changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s
This commit is contained in:
10
client.go
10
client.go
@ -434,7 +434,6 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
|||||||
// GET Requests
|
// GET Requests
|
||||||
if method == "GET" {
|
if method == "GET" {
|
||||||
resp, _ = c.httpClient.
|
resp, _ = c.httpClient.
|
||||||
// SetBaseURL(MOBILE_API_SERVER[c.country]).
|
|
||||||
R().
|
R().
|
||||||
SetQueryParams(params).
|
SetQueryParams(params).
|
||||||
Get(requestUrl)
|
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())
|
c.logger.Error("error while parsing json", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !r.Success {
|
if r.Success {
|
||||||
c.logger.Error("request is not successfull", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
|
||||||
} else {
|
|
||||||
var sr ServiceRequest
|
var sr ServiceRequest
|
||||||
err := json.Unmarshal(r.Data, &sr)
|
err := json.Unmarshal(r.Data, &sr)
|
||||||
if err != nil {
|
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]).
|
SetBaseURL(MOBILE_API_SERVER[c.country]).
|
||||||
R().
|
R().
|
||||||
SetQueryParams(map[string]string{
|
SetQueryParams(map[string]string{
|
||||||
"serviceRequestId": *sr.ServiceRequestID,
|
"serviceRequestId": sr.ServiceRequestID,
|
||||||
}).
|
}).
|
||||||
Get(pollingUrl)
|
Get(pollingUrl)
|
||||||
resBytes, _ := io.ReadAll(resp.Body)
|
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)
|
time.Sleep(3 * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
c.logger.Error("request is not successfull", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resBytes
|
return resBytes
|
||||||
|
@ -22,7 +22,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
cfg.Logger.Debug("printting config", "config", cfg)
|
cfg.Logger.Debug("printing config", "config", cfg)
|
||||||
|
|
||||||
ms, _ := mysubaru.New(cfg)
|
ms, _ := mysubaru.New(cfg)
|
||||||
|
|
||||||
|
@ -2,10 +2,9 @@ module example
|
|||||||
|
|
||||||
go 1.24
|
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 (
|
require (
|
||||||
github.com/Jeffail/gabs/v2 v2.7.0 // indirect
|
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||||
golang.org/x/net v0.40.0 // indirect
|
golang.org/x/net v0.40.0 // indirect
|
||||||
|
28
mysubaru.go
28
mysubaru.go
@ -150,7 +150,7 @@ type VehicleStatus struct {
|
|||||||
EventDateStrCarUser string `json:"eventDateStrCarUser"` // + 2023-12-06T21:09+0000
|
EventDateStrCarUser string `json:"eventDateStrCarUser"` // + 2023-12-06T21:09+0000
|
||||||
Latitude float64 `json:"latitude"` // + 40.700183
|
Latitude float64 `json:"latitude"` // + 40.700183
|
||||||
Longitude float64 `json:"longitude"` // + -74.401372
|
Longitude float64 `json:"longitude"` // + -74.401372
|
||||||
Heading int `json:"positionHeadingDegree"` // + "154"
|
Heading int `json:"positionHeadingDegree,string"` // + "154"
|
||||||
DistanceToEmptyFuelMiles float64 `json:"distanceToEmptyFuelMiles"` // + 209.4
|
DistanceToEmptyFuelMiles float64 `json:"distanceToEmptyFuelMiles"` // + 209.4
|
||||||
DistanceToEmptyFuelKilometers int `json:"distanceToEmptyFuelKilometers"` // + 337
|
DistanceToEmptyFuelKilometers int `json:"distanceToEmptyFuelKilometers"` // + 337
|
||||||
DistanceToEmptyFuelMiles10s int `json:"distanceToEmptyFuelMiles10s"` // + 210
|
DistanceToEmptyFuelMiles10s int `json:"distanceToEmptyFuelMiles10s"` // + 210
|
||||||
@ -158,14 +158,14 @@ type VehicleStatus struct {
|
|||||||
AvgFuelConsumptionMpg float64 `json:"avgFuelConsumptionMpg"` // + 18.4
|
AvgFuelConsumptionMpg float64 `json:"avgFuelConsumptionMpg"` // + 18.4
|
||||||
AvgFuelConsumptionLitersPer100Kilometers float64 `json:"avgFuelConsumptionLitersPer100Kilometers"` // + 12.8
|
AvgFuelConsumptionLitersPer100Kilometers float64 `json:"avgFuelConsumptionLitersPer100Kilometers"` // + 12.8
|
||||||
RemainingFuelPercent int `json:"remainingFuelPercent"` // + 82
|
RemainingFuelPercent int `json:"remainingFuelPercent"` // + 82
|
||||||
TirePressureFrontLeft string `json:"tirePressureFrontLeft"` // + "2275"
|
TirePressureFrontLeft int `json:"tirePressureFrontLeft,string"` // + "2275"
|
||||||
TirePressureFrontRight string `json:"tirePressureFrontRight"` // + "2344"
|
TirePressureFrontRight int `json:"tirePressureFrontRight,string"` // + "2344"
|
||||||
TirePressureRearLeft string `json:"tirePressureRearLeft"` // + "2413"
|
TirePressureRearLeft int `json:"tirePressureRearLeft,string"` // + "2413"
|
||||||
TirePressureRearRight string `json:"tirePressureRearRight"` // + "2344"
|
TirePressureRearRight int `json:"tirePressureRearRight,string"` // + "2344"
|
||||||
TirePressureFrontLeftPsi string `json:"tirePressureFrontLeftPsi"` // + "33"
|
TirePressureFrontLeftPsi int `json:"tirePressureFrontLeftPsi,string"` // + "33"
|
||||||
TirePressureFrontRightPsi string `json:"tirePressureFrontRightPsi"` // + "34"
|
TirePressureFrontRightPsi int `json:"tirePressureFrontRightPsi,string"` // + "34"
|
||||||
TirePressureRearLeftPsi string `json:"tirePressureRearLeftPsi"` // + "35"
|
TirePressureRearLeftPsi int `json:"tirePressureRearLeftPsi,string"` // + "35"
|
||||||
TirePressureRearRightPsi string `json:"tirePressureRearRightPsi"` // + "34"
|
TirePressureRearRightPsi int `json:"tirePressureRearRightPsi,string"` // + "34"
|
||||||
TyreStatusFrontLeft string `json:"tyreStatusFrontLeft"` // + "UNKNOWN"
|
TyreStatusFrontLeft string `json:"tyreStatusFrontLeft"` // + "UNKNOWN"
|
||||||
TyreStatusFrontRight string `json:"tyreStatusFrontRight"` // + "UNKNOWN"
|
TyreStatusFrontRight string `json:"tyreStatusFrontRight"` // + "UNKNOWN"
|
||||||
TyreStatusRearLeft string `json:"tyreStatusRearLeft"` // + "UNKNOWN"
|
TyreStatusRearLeft string `json:"tyreStatusRearLeft"` // + "UNKNOWN"
|
||||||
@ -253,15 +253,15 @@ type VehicleCondition struct {
|
|||||||
// ServiceRequest .
|
// ServiceRequest .
|
||||||
// "dataName": "remoteServiceStatus"
|
// "dataName": "remoteServiceStatus"
|
||||||
type ServiceRequest struct {
|
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
|
Success bool `json:"success"` // false | true
|
||||||
Cancelled bool `json:"cancelled"` // false | true
|
Cancelled bool `json:"cancelled"` // false | true
|
||||||
RemoteServiceType string `json:"remoteServiceType"` // unlock | lock | locate | vehicleStatus | lightsOnly | engineStart | engineStop | phevChargeNow | condition
|
RemoteServiceType string `json:"remoteServiceType"` // unlock | lock | locate | vehicleStatus | lightsOnly | engineStart | engineStop | phevChargeNow | condition
|
||||||
RemoteServiceState string `json:"remoteServiceState"` // started | finished | stopping
|
RemoteServiceState string `json:"remoteServiceState"` // started | finished | stopping
|
||||||
SubState *string `json:"subState,omitempty"` // null
|
SubState string `json:"subState,omitempty"` // null
|
||||||
ErrorCode *string `json:"errorCode,omitempty"` // null:null
|
ErrorCode string `json:"errorCode,omitempty"` // null:null
|
||||||
Result json.RawMessage `json:"result,omitempty"` // null
|
Result json.RawMessage `json:"result,omitempty"` // struct
|
||||||
UpdateTime *time.Time `json:"updateTime,omitempty"` // timestamp
|
UpdateTime time.Time `json:"updateTime,omitempty"` // timestamp
|
||||||
Vin string `json:"vin"` // 4S4BTGND8L3137058
|
Vin string `json:"vin"` // 4S4BTGND8L3137058
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user