public ICTomorrowIncrementMeterResponse incrementMeter( int consumerId, int offerId, Integer incrementValue, String freeText) throws ICTomorrowApiException { try { FormEncodedPayload data = new FormEncodedPayload() .withField("update_type", Integer.toString(METER_OPERATION_INCREMENT)); addOptionalParameter(data, "increment_value", incrementValue); addOptionalParameter(data, "Free_text", freeText); HttpResponse res = client.put(meterUrl(consumerId, offerId), data); Element resultElement = getResultElement(res); Element meterElement = resultElement.getFirstChildElement("meter"); Boolean incrementGranted = Boolean.valueOf(meterElement.getFirstChildElement("granted").getValue().trim()); Boolean notificationLimitReached = Boolean.valueOf( meterElement.getFirstChildElement("notificationLimitReached").getValue().trim()); Boolean maximumLimitReached = Boolean.valueOf( meterElement.getFirstChildElement("maximumLimitReached").getValue().trim()); // ICTomorrowMeter meter = parseMeter(resultElement); return new ICTomorrowIncrementMeterResponse( incrementGranted, notificationLimitReached, maximumLimitReached); } catch (HttpException e) { throw new ICTomorrowApiException("Exception while incrementing meter", e); } }
public ICTomorrowMeter updateMeterLimits( int consumerId, int offerId, Integer notificationUpdateAmount, Integer maximumUpdateAmount) throws ICTomorrowApiException { try { FormEncodedPayload data = new FormEncodedPayload() .withField("update_type", Integer.toString(METER_OPERATION_UPDATE_LIMITS)); addOptionalParameter(data, "notification_update_amount", notificationUpdateAmount); addOptionalParameter(data, "maximum_update_amount", maximumUpdateAmount); HttpResponse res = client.put(meterUrl(consumerId, offerId), data); return parseMeter(getResultElement(res).getFirstChildElement("meter")); } catch (HttpException e) { throw new ICTomorrowApiException("Exception while updating meter limits", e); } }