Refactor vehicle command functions to improve readability and maintainability
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:
11
vehicle.go
11
vehicle.go
@ -226,6 +226,7 @@ func (v *Vehicle) Lock() (chan string, error) {
|
||||
"forceKeyInCar": "false"}
|
||||
reqUrl := MOBILE_API_VERSION + urlToGen(apiURLs["API_LOCK"], v.getAPIGen())
|
||||
pollingUrl := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
||||
|
||||
ch := make(chan string)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
@ -250,6 +251,7 @@ func (v *Vehicle) Unlock() (chan string, error) {
|
||||
"unlockDoorType": "ALL_DOORS_CMD"} // FRONT_LEFT_DOOR_CMD | ALL_DOORS_CMD
|
||||
reqUrl := MOBILE_API_VERSION + urlToGen(apiURLs["API_UNLOCK"], v.getAPIGen())
|
||||
pollingUrl := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
||||
|
||||
ch := make(chan string)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
@ -287,6 +289,7 @@ func (v *Vehicle) EngineStart() (chan string, error) {
|
||||
}
|
||||
reqUrl := MOBILE_API_VERSION + apiURLs["API_G2_REMOTE_ENGINE_START"]
|
||||
pollingUrl := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
||||
|
||||
ch := make(chan string)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
@ -337,11 +340,13 @@ func (v *Vehicle) LightsStart() (chan string, error) {
|
||||
if v.getAPIGen() == FEATURE_G1_TELEMATICS {
|
||||
pollingUrl = MOBILE_API_VERSION + apiURLs["API_G1_HORN_LIGHTS_STATUS"]
|
||||
}
|
||||
|
||||
ch := make(chan string)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
v.executeServiceRequest(params, reqUrl, pollingUrl, ch, 1)
|
||||
}()
|
||||
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
@ -362,6 +367,7 @@ func (v *Vehicle) LightsStop() (chan string, error) {
|
||||
if v.getAPIGen() == FEATURE_G1_TELEMATICS {
|
||||
pollingUrl = MOBILE_API_VERSION + apiURLs["API_G1_HORN_LIGHTS_STATUS"]
|
||||
}
|
||||
|
||||
ch := make(chan string)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
@ -388,6 +394,7 @@ func (v *Vehicle) HornStart() (chan string, error) {
|
||||
if v.getAPIGen() == FEATURE_G1_TELEMATICS {
|
||||
pollingUrl = MOBILE_API_VERSION + apiURLs["API_G1_HORN_LIGHTS_STATUS"]
|
||||
}
|
||||
|
||||
ch := make(chan string)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
@ -414,6 +421,7 @@ func (v *Vehicle) HornStop() (chan string, error) {
|
||||
if v.getAPIGen() == FEATURE_G1_TELEMATICS {
|
||||
pollingUrl = MOBILE_API_VERSION + apiURLs["API_G1_HORN_LIGHTS_STATUS"]
|
||||
}
|
||||
|
||||
ch := make(chan string)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
@ -442,9 +450,8 @@ func (v *Vehicle) ChargeOn() (chan string, error) {
|
||||
v.executeServiceRequest(params, reqUrl, pollingUrl, ch, 1)
|
||||
}()
|
||||
return ch, nil
|
||||
} else {
|
||||
return nil, errors.New("not an EV car")
|
||||
}
|
||||
return nil, errors.New("not an EV car")
|
||||
}
|
||||
|
||||
// GetLocation
|
||||
|
Reference in New Issue
Block a user