use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.impl.DeviceImpl in project smarthome by eclipse.
the class DsAPIImpl method getApartmentDevices.
@Override
public List<Device> getApartmentDevices(String token) {
String response = transport.execute(SimpleRequestBuilder.buildNewJsonRequest(ClassKeys.APARTMENT).addFunction(FunctionKeys.GET_DEVICES).addParameter(ParameterKeys.TOKEN, token).buildRequestString());
JsonObject responseObj = JSONResponseHandler.toJsonObject(response);
if (JSONResponseHandler.checkResponse(responseObj) && responseObj.get(JSONApiResponseKeysEnum.RESULT.getKey()) instanceof JsonArray) {
JsonArray array = (JsonArray) responseObj.get(JSONApiResponseKeysEnum.RESULT.getKey());
List<Device> deviceList = new LinkedList<Device>();
for (int i = 0; i < array.size(); i++) {
if (array.get(i) instanceof JsonObject) {
deviceList.add(new DeviceImpl((JsonObject) array.get(i)));
}
}
return deviceList;
}
return new LinkedList<Device>();
}
Aggregations