Skip to content

Commit fa7c552

Browse files
Update README to 1.5.0
I always forget this :(
1 parent ff87572 commit fa7c552

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

README.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
# Tzeva Adom API
2-
Async Java API that listens to `Pikud Ha'oref` and notifies registered listeners as soon as a Tzeva Adom happens.
2+
Async Java API that listens to `Pikud Ha'oref` and notifies registered listeners as soon as a Tzeva Adom happens.\
3+
Integrating it in projects(games, etc) used by many israelis, **increases** the chances of saving lives.
34

45
## How to use
5-
Let's create a notifier that stops a game when it's Tzeva Adom:
6+
Let's create a notifier that is responsible of stopping your addicting game:
67
```java
78
Game game = ...;
89

910
TzevaAdomNotifier notifier = new TzevaAdomNotifier.Builder()
10-
.every(Duration.ofSeconds(3))
1111
.onFailedRequest(exception -> LOGGER.error("Failed to request the last alert from Pikud Ha'oref", exception))
1212
.onTzevaAdom(alert ->
1313
{
1414
game.stop();
15-
game.sendMessage("There is a Tzeva Adom in: " + alert.getCity());
15+
game.sendMessage("There is a Tzeva Adom in: " + alert.getRegion());
1616
})
1717
.build();
1818

1919
notifier.listen(); //async
2020
```
21-
22-
By saving the notifier object, you can gather information while your program is running.\
23-
Here is an example:
21+
\
22+
By saving the notifier object, you can gather information while your program is running:
2423
```java
25-
notifier.listen();
24+
notifier.listen(); //async - anything else is sync
2625

2726
//sleep for a day
2827
TimeUnit.DAYS.sleep(1);
2928

30-
Set<Alert> history = notifier.getHistory();
31-
32-
LOGGER.info("There were {} alerts in the last 24 hours:", history.size());
33-
34-
for(Alert alert : history)
29+
//print all the alerts from the last day
30+
for(Alert alert : notifier.getHistory())
3531
{
36-
LOGGER.info("Alert in {} at {}", alert.getCity(), alert.getDate());
32+
LOGGER.warn("Alert at {} was in {}", alert.getCity(), alert.getDate());
3733
}
34+
35+
//check a specific city's alerts
36+
List<Alert> telAvivAlerts = notifier.getHistory().ofRegion("תל אביב");
3837
```
3938

4039
## How to import
@@ -50,15 +49,21 @@ Maven Repository:
5049
<dependency>
5150
<groupId>com.github.DavidTheExplorer</groupId>
5251
<artifactId>Tzeva-Adom-API</artifactId>
53-
<version>1.4.0</version>
52+
<version>1.5.0</version>
5453
</dependency>
5554
```
5655

5756

58-
## Customization
59-
Relevant if the endpoint of Pikud Ha'oref was changed or your alerts come from somewhere else.\
60-
\
61-
Either implement `AlertSource` or extend `JSONAlertSource` for JSON APIs, and then create your notifier like this:
62-
```java
63-
new TzevaAdomNotifier.Builder()
64-
.requestFrom(new YourAlertSource())
57+
## Builder Options
58+
Everything in the library is customizable.
59+
- If the endpoint of Pikud Ha'oref was changed or your alerts come from somewhere else:\
60+
Implement `AlertSource` and then create your notifier like this:
61+
```java
62+
new TzevaAdomNotifier.Builder()
63+
.requestFrom(new YourAlertSource())
64+
```
65+
- If you want to lower the frequency of the Tzeva Adom checks, create your notifier like this:
66+
```java
67+
new TzevaAdomNotifier.Builder()
68+
.requestEvery(Duration.ofSeconds(3))
69+
```

0 commit comments

Comments
 (0)