stefan-kaestle / openhab2-addons

Add-ons for openHAB 2.x
Eclipse Public License 2.0
16 stars 1 forks source link

add "doHttpRequest" function to wrap the Bosch SHC Request code at one single place #48

Closed GerdZanker closed 3 years ago

GerdZanker commented 4 years ago

Add a new request function into BoschHttpClient to make simple calls like doHttpRequest("smarthome/devices") possible. We have at least three places in BoschSHCBridgeHandler'' where we create http requests with duplicated code parts which can be replaced by the `´doHttpRequest function.

Here an example

public ContentResponse doHttpRequest(String restData) throws InterruptedException, TimeoutException, ExecutionException {
return GET("https://" + m_ipAddress + ":8444/" + restData)
.header("Content-Type", "application/json").header("Accept", "application/json")
.send();
}
coeing commented 4 years ago

The BoschSHCBridgeHandler has already some helper methods which could be used instead of creating a request from zero:

We should use those first in the places where the requests are created and add an additional method afterwards if we still see a need :)

coeing commented 4 years ago

@GerdZanker Did you find the methods I mentioned? Do you still see a need for additional methods?

coeing commented 3 years ago

@GerdZanker Should we close this issue or do you see the need for more helper methods than the ones mentioned above?

GerdZanker commented 3 years ago

We close this issue. In the meantime our code is refactored multiple times and better compared to last summer.