More changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
This commit is contained in:
25
client.go
25
client.go
@ -127,11 +127,7 @@ func (c *Client) SelectVehicle(vin string) VehicleData {
|
||||
return VehicleData{}
|
||||
}
|
||||
|
||||
// resp := c.execute(reqURL, GET, params, "", false)
|
||||
// logger.Debugf("SELECT VEHICLE OUTPUT >> %v\n", string([]byte(resp)))
|
||||
|
||||
// ERRORS
|
||||
// {"success":false,"errorCode":"vehicleNotInAccount","dataName":null,"data":null}
|
||||
|
||||
// """Select active vehicle for accounts with multiple VINs."""
|
||||
// params = {"vin": vin, "_": int(time.time())}
|
||||
@ -225,19 +221,16 @@ func (c *Client) GetVehicleByVIN(vin string) *Vehicle {
|
||||
// func getRemoteStartStatus() {}
|
||||
// func getSafetyStatus() {}
|
||||
// func getSubscriptionStatus() {}
|
||||
// func getAPIGen() {}
|
||||
// func getClimateData() {}
|
||||
// func saveClimateSettings() {}
|
||||
// func getVehicleName() {}
|
||||
// func fetch() {}
|
||||
|
||||
// Exec method executes a Client instance with the API URL
|
||||
func (c *Client) execute(requestUrl string, method string, params map[string]string, pollingUrl string, j bool, attempts ...int) []byte {
|
||||
defer timeTrack("[TIMETRK] Executing Get Request")
|
||||
defer timeTrack("[TIMETRK] Executing HTTP Request")
|
||||
var resp *resty.Response
|
||||
|
||||
// GET Requests
|
||||
if method == "GET" {
|
||||
if method == GET {
|
||||
resp, _ = c.httpClient.
|
||||
R().
|
||||
SetQueryParams(params).
|
||||
@ -245,7 +238,7 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
||||
}
|
||||
|
||||
// POST Requests
|
||||
if method == "POST" {
|
||||
if method == POST {
|
||||
if j { // POST > JSON Body
|
||||
resp, _ = c.httpClient.
|
||||
R().
|
||||
@ -273,7 +266,6 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
||||
if err != nil {
|
||||
c.logger.Error("error while parsing json", "request", "HTTP POLLING", "error", err.Error())
|
||||
}
|
||||
// {"success":false,"errorCode":"404-soa-unableToParseResponseBody","dataName":"errorResponse","data":{"errorLabel":"404-soa-unableToParseResponseBody","errorDescription":null}}
|
||||
|
||||
if pollingUrl != "" {
|
||||
switch {
|
||||
@ -296,9 +288,18 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if r.DataName == "errorResponse" {
|
||||
// {"success":false,"errorCode":"404-soa-unableToParseResponseBody","dataName":"errorResponse","data":{"errorLabel":"404-soa-unableToParseResponseBody","errorDescription":null}}
|
||||
// {"success":false,"errorCode":"vehicleNotInAccount","dataName":null,"data":null}
|
||||
var er ErrorResponse
|
||||
err := json.Unmarshal(r.Data, &er)
|
||||
if err != nil {
|
||||
c.logger.Error("error while parsing json", "request", "errorResponse", "error", err.Error())
|
||||
}
|
||||
c.logger.Error("request is not successfull", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
||||
}
|
||||
c.logger.Error("request is not successfull", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
||||
}
|
||||
|
||||
return resBytes
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user