diff --git a/pom.xml b/pom.xml
index f10194d..d9697a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -191,7 +191,7 @@
org.apache.commons
commons-lang3
- 3.10
+ 3.11
test
diff --git a/src/main/java/de/svenkubiak/jpushover/http/PushoverRequest.java b/src/main/java/de/svenkubiak/jpushover/http/PushoverRequest.java
index 8880bed..d581a9c 100644
--- a/src/main/java/de/svenkubiak/jpushover/http/PushoverRequest.java
+++ b/src/main/java/de/svenkubiak/jpushover/http/PushoverRequest.java
@@ -11,6 +11,7 @@ import java.time.Duration;
import java.util.Map;
import java.util.NavigableMap;
import java.util.Objects;
+import java.util.OptionalLong;
/**
*
@@ -29,11 +30,18 @@ public class PushoverRequest {
jPushoverResponse
.httpStatus(httpResponse.statusCode())
.response(httpResponse.body())
- .isSuccessful((httpResponse.statusCode() == 200) ? true : false);
+ .isSuccessful((httpResponse.statusCode() == 200) ? true : false)
+ .limit(getHeaderValue(httpResponse, "X-Limit-App-Limit").orElse(0))
+ .remaining(getHeaderValue(httpResponse, "X-Limit-App-Remaining").orElse(0))
+ .reset(getHeaderValue(httpResponse, "X-Limit-App-Reset").orElse(0));
return jPushoverResponse;
}
-
+
+ private OptionalLong getHeaderValue(HttpResponse httpResponse, String header) {
+ return httpResponse.headers().firstValueAsLong(header);
+ }
+
private HttpResponse getResponse(String body, String url, String proxyHost, int proxyPort) throws IOException, InterruptedException {
var httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
diff --git a/src/main/java/de/svenkubiak/jpushover/http/PushoverResponse.java b/src/main/java/de/svenkubiak/jpushover/http/PushoverResponse.java
index 3bbb49f..c1a81d8 100644
--- a/src/main/java/de/svenkubiak/jpushover/http/PushoverResponse.java
+++ b/src/main/java/de/svenkubiak/jpushover/http/PushoverResponse.java
@@ -7,9 +7,12 @@ package de.svenkubiak.jpushover.http;
*/
public class PushoverResponse {
private String pushoverResponse;
- private int pushoverHttpStatus;
private boolean pushoverSuccessful;
-
+ private int pushoverHttpStatus;
+ private long pushoverLimit;
+ private long pushoverRemaining;
+ private long pushoverReset;
+
public PushoverResponse response(String response) {
this.pushoverResponse = response;
return this;
@@ -24,6 +27,21 @@ public class PushoverResponse {
this.pushoverSuccessful = successful;
return this;
}
+
+ public PushoverResponse limit(long limit) {
+ this.pushoverLimit = limit;
+ return this;
+ }
+
+ public PushoverResponse remaining(long remaining) {
+ this.pushoverRemaining = remaining;
+ return this;
+ }
+
+ public PushoverResponse reset(long reset) {
+ this.pushoverReset = reset;
+ return this;
+ }
/**
* @return The pushover response
@@ -45,4 +63,25 @@ public class PushoverResponse {
public boolean isSuccessful() {
return pushoverSuccessful;
}
+
+ /**
+ * @return The API rate limit
+ */
+ public long getLimit() {
+ return pushoverLimit;
+ }
+
+ /**
+ * @return The remaining allowed API requests
+ */
+ public long getRemaining() {
+ return pushoverRemaining;
+ }
+
+ /**
+ * @return The API rate limit reset timestamp
+ */
+ public long getReset() {
+ return pushoverReset;
+ }
}
\ No newline at end of file