Some updates
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:
19
client.go
19
client.go
@ -226,7 +226,7 @@ func New(config *config.Config) (*Client, error) {
|
||||
resp := client.auth()
|
||||
respParsed, err := gabs.ParseJSON(resp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
client.logger.Error("error which parsing json", "request", "auth", "error", err.Error())
|
||||
}
|
||||
|
||||
if client.isResponseSuccessfull(resp) {
|
||||
@ -281,6 +281,7 @@ func (c *Client) SelectVehicle(vin string) VehicleData {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c.logger.Debug("http request output", "request", "SelectVehicle", "body", respParsed)
|
||||
|
||||
vdString := respParsed.Path("data").String()
|
||||
json.Unmarshal([]byte(vdString), &vData)
|
||||
@ -325,6 +326,7 @@ func (c *Client) GetVehicles() []*Vehicle {
|
||||
if err != nil {
|
||||
c.logger.Error("error which parsing json", "request", "GetVehicles", "error", err.Error())
|
||||
}
|
||||
c.logger.Debug("http request output", "request", "GetVehicles", "body", respParsed)
|
||||
|
||||
vData := VehicleData{}
|
||||
vdString := respParsed.Path("data").String()
|
||||
@ -377,13 +379,12 @@ func (c *Client) GetVehicleByVIN(vin string) *Vehicle {
|
||||
if err != nil {
|
||||
c.logger.Error("error which parsing json", "request", "GetVehicleByVIN", "error", err.Error())
|
||||
}
|
||||
c.logger.Debug("http request output", "request", "GetVehicleByVIN", "body", respParsed)
|
||||
|
||||
vData := VehicleData{}
|
||||
vdString := respParsed.Path("data").String()
|
||||
json.Unmarshal([]byte(vdString), &vData)
|
||||
|
||||
// fmt.Printf("VEHICLE DATA: %+v\n\n", vData)
|
||||
|
||||
vehicle = &Vehicle{
|
||||
Vin: vin,
|
||||
CarName: vData.VehicleName,
|
||||
@ -542,17 +543,23 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
||||
if method == "POST" {
|
||||
if json {
|
||||
// POST > JSON Body
|
||||
resp, _ = c.httpClient.R().
|
||||
resp, _ = c.httpClient.
|
||||
R().
|
||||
SetBody(params).
|
||||
Post(requestUrl)
|
||||
} else {
|
||||
// POST > Form Data
|
||||
resp, _ = c.httpClient.R().
|
||||
resp, _ = c.httpClient.
|
||||
R().
|
||||
SetFormData(params).
|
||||
Post(requestUrl)
|
||||
}
|
||||
}
|
||||
resBytes, _ := io.ReadAll(resp.Body)
|
||||
resBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
c.logger.Error("error while getting body", "error", err.Error())
|
||||
}
|
||||
fmt.Printf("RESP BODY: %s\n", string(resBytes))
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// return
|
||||
|
Reference in New Issue
Block a user