refactorings and updated readme.md
This commit is contained in:
parent
70cc6aa712
commit
9c26be1068
18
README.md
18
README.md
@ -21,26 +21,26 @@ Usage
|
|||||||
2) Use the JPushover object with the required informations were you want
|
2) Use the JPushover object with the required informations were you want
|
||||||
|
|
||||||
JPushover.build()
|
JPushover.build()
|
||||||
.token("MyToken")
|
.wihtToken("MyToken")
|
||||||
.user("MyUser")
|
.withUser("MyUser")
|
||||||
.message("MyMessage")
|
.withMessage("MyMessage")
|
||||||
.push();
|
.push();
|
||||||
|
|
||||||
You can additionally add all available options from the official [Pushover documentation][2]
|
You can additionally add all available options from the official [Pushover documentation][2]
|
||||||
|
|
||||||
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 = JPushover().build()
|
boolean valid = JPushover.build()
|
||||||
.token("MyToken")
|
.withToken("MyToken")
|
||||||
.user("MyUser")
|
.withUser("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.build()
|
JPushoverResponse jPushoverResponse = JPushover.build()
|
||||||
.token("MyToken")
|
.withToken("MyToken")
|
||||||
.user("MyUser")
|
.withUser("MyUser")
|
||||||
.message("MyMessage")
|
.withMessage("MyMessage")
|
||||||
.push();
|
.push();
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
@ -42,8 +42,8 @@ public class JPushover {
|
|||||||
private Sound pushoverSound;
|
private Sound pushoverSound;
|
||||||
|
|
||||||
public JPushover() {
|
public JPushover() {
|
||||||
this.sound(Sound.PUSHOVER);
|
this.withSound(Sound.PUSHOVER);
|
||||||
this.priority(Priority.NORMAL);
|
this.withPriority(Priority.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,7 @@ public class JPushover {
|
|||||||
* @param token The pushover API token
|
* @param token The pushover API token
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover token(String token) {
|
public final JPushover withToken(String token) {
|
||||||
this.pushoverToken = token;
|
this.pushoverToken = token;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ public class JPushover {
|
|||||||
* @param user The username
|
* @param user The username
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover user(String user) {
|
public final JPushover withUser(String user) {
|
||||||
this.pushoverUser = user;
|
this.pushoverUser = user;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ public class JPushover {
|
|||||||
* @param retry Number of seconds
|
* @param retry Number of seconds
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover retry(String retry) {
|
public final JPushover withRetry(String retry) {
|
||||||
this.pushoverRetry = retry;
|
this.pushoverRetry = retry;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ public class JPushover {
|
|||||||
* @param expire Number of seconds
|
* @param expire Number of seconds
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover expire(String expire) {
|
public final JPushover withExpire(String expire) {
|
||||||
this.pushoverExpire = expire;
|
this.pushoverExpire = expire;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class JPushover {
|
|||||||
* @param message The message to sent
|
* @param message The message to sent
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover message(String message) {
|
public final JPushover withMessage(String message) {
|
||||||
this.pushoverMessage = message;
|
this.pushoverMessage = message;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ public class JPushover {
|
|||||||
* @param device The device name
|
* @param device The device name
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover device(String device) {
|
public final JPushover withDevice(String device) {
|
||||||
this.pushoverDevice = device;
|
this.pushoverDevice = device;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public class JPushover {
|
|||||||
* @param title The title
|
* @param title The title
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover title(String title) {
|
public final JPushover withTitle(String title) {
|
||||||
this.pushoverTitle = title;
|
this.pushoverTitle = title;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public class JPushover {
|
|||||||
* @param url The url
|
* @param url The url
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover url(String url) {
|
public final JPushover withUrl(String url) {
|
||||||
this.pushoverUrl = url;
|
this.pushoverUrl = url;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ public class JPushover {
|
|||||||
*
|
*
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover html() {
|
public final JPushover enableHtml() {
|
||||||
this.pushoverHtml = true;
|
this.pushoverHtml = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ public class JPushover {
|
|||||||
* @param urlTitle The url title
|
* @param urlTitle The url title
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover urlTitle(String urlTitle) {
|
public final JPushover withUrlTitle(String urlTitle) {
|
||||||
this.pushoverUrlTitle = urlTitle;
|
this.pushoverUrlTitle = urlTitle;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ public class JPushover {
|
|||||||
* @param timestamp The Unix timestamp
|
* @param timestamp The Unix timestamp
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover timestamp(String timestamp) {
|
public final JPushover withTimestamp(String timestamp) {
|
||||||
this.pushoverTimestamp = timestamp;
|
this.pushoverTimestamp = timestamp;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ public class JPushover {
|
|||||||
* @param priority The priority enum
|
* @param priority The priority enum
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover priority(Priority priority) {
|
public final JPushover withPriority(Priority priority) {
|
||||||
this.pushoverPriority = priority;
|
this.pushoverPriority = priority;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ public class JPushover {
|
|||||||
* @param sound THe sound enum
|
* @param sound THe sound enum
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover sound(Sound sound) {
|
public final JPushover withSound(Sound sound) {
|
||||||
this.pushoverSound = sound;
|
this.pushoverSound = sound;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ public class JPushover {
|
|||||||
* @param callback The callback URL
|
* @param callback The callback URL
|
||||||
* @return JPushover instance
|
* @return JPushover instance
|
||||||
*/
|
*/
|
||||||
public final JPushover callback(String callback) {
|
public final JPushover withCallback(String callback) {
|
||||||
this.pushoverCallback = callback;
|
this.pushoverCallback = callback;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -25,46 +25,46 @@ public class TestJPushover {
|
|||||||
public void TestValues(){
|
public void TestValues(){
|
||||||
final JPushover push = new JPushover();
|
final JPushover push = new JPushover();
|
||||||
|
|
||||||
push.callback(CALLBACK);
|
push.withCallback(CALLBACK);
|
||||||
assertEquals(push.getCallback(), CALLBACK);
|
assertEquals(push.getCallback(), CALLBACK);
|
||||||
|
|
||||||
push.device(DEVICE);
|
push.withDevice(DEVICE);
|
||||||
assertEquals(push.getDevice(), DEVICE);
|
assertEquals(push.getDevice(), DEVICE);
|
||||||
|
|
||||||
push.expire(EXPIRE);
|
push.withExpire(EXPIRE);
|
||||||
assertEquals(push.getExpire(), EXPIRE);
|
assertEquals(push.getExpire(), EXPIRE);
|
||||||
|
|
||||||
push.message(MESSAGE);
|
push.withMessage(MESSAGE);
|
||||||
assertEquals(push.getMessage(), MESSAGE);
|
assertEquals(push.getMessage(), MESSAGE);
|
||||||
|
|
||||||
push.priority(Priority.HIGH);
|
push.withPriority(Priority.HIGH);
|
||||||
assertEquals(push.getPriority(), Priority.HIGH);
|
assertEquals(push.getPriority(), Priority.HIGH);
|
||||||
|
|
||||||
push.retry(RETRY);
|
push.withRetry(RETRY);
|
||||||
assertEquals(push.getRetry(), RETRY);
|
assertEquals(push.getRetry(), RETRY);
|
||||||
|
|
||||||
push.sound(Sound.ALIEN);
|
push.withSound(Sound.ALIEN);
|
||||||
assertEquals(push.getSound(), Sound.ALIEN);
|
assertEquals(push.getSound(), Sound.ALIEN);
|
||||||
|
|
||||||
push.timestamp(TIMESTAMP);
|
push.withTimestamp(TIMESTAMP);
|
||||||
assertEquals(push.getTimestamp(), TIMESTAMP);
|
assertEquals(push.getTimestamp(), TIMESTAMP);
|
||||||
|
|
||||||
push.title(TITLE);
|
push.withTitle(TITLE);
|
||||||
assertEquals(push.getTitle(), TITLE);
|
assertEquals(push.getTitle(), TITLE);
|
||||||
|
|
||||||
push.token(TOKEN);
|
push.withToken(TOKEN);
|
||||||
assertEquals(push.getToken(), TOKEN);
|
assertEquals(push.getToken(), TOKEN);
|
||||||
|
|
||||||
push.url(URL);
|
push.withUrl(URL);
|
||||||
assertEquals(push.getUrl(), URL);
|
assertEquals(push.getUrl(), URL);
|
||||||
|
|
||||||
push.urlTitle(URL_TITLE);
|
push.withUrlTitle(URL_TITLE);
|
||||||
assertEquals(push.getUrlTitle(), URL_TITLE);
|
assertEquals(push.getUrlTitle(), URL_TITLE);
|
||||||
|
|
||||||
push.user(USER);
|
push.withUser(USER);
|
||||||
assertEquals(push.getUser(), USER);
|
assertEquals(push.getUser(), USER);
|
||||||
|
|
||||||
push.html();
|
push.enableHtml();
|
||||||
assertTrue(push.isHtml());
|
assertTrue(push.isHtml());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user