2020-07-27 21:03:45 +02:00
2018-10-06 07:49:05 +02:00
fix
2019-02-01 14:43:54 +01:00
2018-01-21 18:22:36 +01:00
2020-07-27 12:39:08 +02:00
2018-07-23 09:58:21 +02:00

Maven Central

JPushover

A simple, minimal (18 KB), zero-dependency convenient class for sending messages to Pushover in Java.

Supports Messages API and Glances API, synchronous and asynchronous sending.

Requires Java 11.

Usage

  1. Add the jpushover dependency to your pom.xml:
<dependency>
    <groupId>de.svenkubiak</groupId>
    <artifactId>jpushover</artifactId>
    <version>x.x.x</version>
</dependency>
  1. Use the JPushover object with the required informations were you want
JPushover.newMessage()
	.withToken("MyToken")
	.withUser("MyUser")
	.withMessage("MyMessage")
	.push();

JPushover.newGlance()
	.withToken("MyToken")
	.withUser("MyUser")
	.withText("MyText")
	.push();		

When using the Message API you can additionally add available options from the official Pushover documentation

You can also validate a user and token using the following method

boolean valid = JPushover.newMessage()
	.withToken("MyToken")
	.withUser("MyUser")
	.validate();

If you want more information and/or the response from the Pushover API, use the PushoverResponse object.

PushoverResponse PushoverResponse = JPushover.newMessage()
	.withToken("MyToken")
	.withUser("MyUser")
	.withMessage("MyMessage")
	.push();

The PushoverResponse will return the raw HTTP status code, along with the raw JSON response and a convenient boolean if the request was successful or not. Additionally you get the rate limit information along with the response (rate limit, remaining, reset timestamp).

Sending a Message or Glance asynchronous is simple. Just call the pushAsync() method instead of push(). Examples:

JPushover.newMessage()
	.withToken("MyToken")
	.withUser("MyUser")
	.withMessage("MyMessage")
	.pushAsync();

JPushover.newGlance()
	.withToken("MyToken")
	.withUser("MyUser")
	.withText("MyText")
	.pushAsync();		

If you are using pushAsync remember to shutdown the ExecutorService that is handling the tasks by calling:

AsyncService.getInstance().shutdown();	
Description
Java 11 compatible fork of https://github.com/svenkubiak/JPushover
Readme 269 KiB
Languages
Java 99.5%
Shell 0.5%