minor refactorings

This commit is contained in:
Sven Kubiak 2015-12-10 11:17:36 +01:00
parent ceaf8d1bc8
commit de59b39be5
6 changed files with 16 additions and 20 deletions

View File

@ -34,20 +34,20 @@ You can additionally add all available options from the official [Pushover docum
You can also validate a user and token using the following method You can also validate a user and token using the following method
boolean valid = new JPushover() boolean valid = JPushover().build()
.token("MyToken") .token("MyToken")
.user("MyUser") .user("MyUser")
.validate(); .validate();
If you want more information and/or the response from the Pushover API, use the JPushoverResponse object. If you want more information and/or the response from the Pushover API, use the JPushoverResponse object.
JPushoverResponse jPushoverResponse = JPushover() JPushoverResponse jPushoverResponse = JPushover.build()
.token("MyToken") .token("MyToken")
.user("MyUser") .user("MyUser")
.message("MyMessage") .message("MyMessage")
.push(); .push();
JPushoverResponse will return the raw HTTP status code, along with the raw JSON response and a convenient boolean if the request was successful or not. The JPushoverResponse will return the raw HTTP status code, along with the raw JSON response and a convenient boolean if the request was successful or not.
[1]: https://pushover.net [1]: https://pushover.net
[2]: https://pushover.net/api [2]: https://pushover.net/api

View File

@ -165,11 +165,6 @@
<version>4.12</version> <version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
</dependencies> </dependencies>
<distributionManagement> <distributionManagement>
<snapshotRepository> <snapshotRepository>

View File

@ -46,6 +46,10 @@ public class JPushover {
this.priority(Priority.NORMAL); this.priority(Priority.NORMAL);
} }
/**
* Creates a new JPushover instance
* @return JPushover instance
*/
public static JPushover build() { public static JPushover build() {
return new JPushover(); return new JPushover();
} }
@ -209,7 +213,7 @@ public class JPushover {
/** /**
* Callback parameter may be supplied with a publicly-accessible URL that the * Callback parameter may be supplied with a publicly-accessible URL that the
* Pushover servers will send a request to when the user has acknowledged your * pushover servers will send a request to when the user has acknowledged your
* notification. * notification.
* Only required if priority is set to emergency. * Only required if priority is set to emergency.
* *
@ -340,9 +344,9 @@ public class JPushover {
.add(Constants.EXPIRE.toString(), this.pushoverExpire) .add(Constants.EXPIRE.toString(), this.pushoverExpire)
.add(Constants.CALLBACK.toString(), this.pushoverCallback) .add(Constants.CALLBACK.toString(), this.pushoverCallback)
.add(Constants.URLTITLE.toString(), this.pushoverUrlTitle) .add(Constants.URLTITLE.toString(), this.pushoverUrlTitle)
.add(Constants.PRIORITY.toString(), this.pushoverPriority.get()) .add(Constants.PRIORITY.toString(), this.pushoverPriority.toString())
.add(Constants.TIMESTAMP.toString(), this.pushoverTimestamp) .add(Constants.TIMESTAMP.toString(), this.pushoverTimestamp)
.add(Constants.SOUND.toString(), this.pushoverSound.get()) .add(Constants.SOUND.toString(), this.pushoverSound.toString())
.add(Constants.HTML.toString(), this.pushoverHtml ? "1" : "0") .add(Constants.HTML.toString(), this.pushoverHtml ? "1" : "0")
.build(); .build();

View File

@ -26,24 +26,21 @@ public class JPushoverResponse {
} }
/** /**
* The raw Json Response from the pushover API * @return The pushover response
* @return String
*/ */
public String getResponse() { public String getResponse() {
return pushoverResponse; return pushoverResponse;
} }
/** /**
* The HTTP status from the HTTP request * @return The HTTP status
* @return int
*/ */
public int getHttpStatus() { public int getHttpStatus() {
return pushoverHttpStatus; return pushoverHttpStatus;
} }
/** /**
* True if the request to the pushover API returned HTTP code 200, false otherwise * @return true if the api returned a HTTP status code 200, false othwise
* @return boolen
*/ */
public boolean isSuccessful() { public boolean isSuccessful() {
return pushoverSuccessful; return pushoverSuccessful;

View File

@ -18,7 +18,7 @@ public enum Priority {
this.value = value; this.value = value;
} }
public String get() { public String toString() {
return this.value; return this.value;
} }
} }

View File

@ -8,7 +8,7 @@ package de.svenkubiak.jpushover.enums;
public enum Sound { public enum Sound {
PUSHOVER("pushover"), PUSHOVER("pushover"),
BIKE("bike"), BIKE("bike"),
BUGLE("bugke"), BUGLE("bugle"),
CASHREGISTET("cashregister"), CASHREGISTET("cashregister"),
CLASSICAL("classical"), CLASSICAL("classical"),
COSMIC("cosmic"), COSMIC("cosmic"),
@ -35,7 +35,7 @@ public enum Sound {
this.value = value; this.value = value;
} }
public String get() { public String toString() {
return this.value; return this.value;
} }
} }