use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.impl.CircuitImpl in project smarthome by eclipse.
the class DsAPIImpl method getApartmentCircuits.
@Override
public List<Circuit> getApartmentCircuits(String sessionToken) {
String response = transport.execute(SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.APARTMENT).addFunction(FunctionKeys.GET_CIRCUITS).addParameter(ParameterKeys.TOKEN, sessionToken).buildRequestString());
JsonObject responseObj = JSONResponseHandler.toJsonObject(response);
if (JSONResponseHandler.checkResponse(responseObj)) {
responseObj = JSONResponseHandler.getResultJsonObject(responseObj);
if (responseObj.get(JSONApiResponseKeysEnum.CIRCUITS.getKey()).isJsonArray()) {
JsonArray array = responseObj.get(JSONApiResponseKeysEnum.CIRCUITS.getKey()).getAsJsonArray();
List<Circuit> circuitList = new LinkedList<Circuit>();
for (int i = 0; i < array.size(); i++) {
if (array.get(i).isJsonObject()) {
circuitList.add(new CircuitImpl(array.get(i).getAsJsonObject()));
}
}
return circuitList;
}
}
return new LinkedList<Circuit>();
}
Aggregations