Skip to content

Commit

Permalink
docs: fix correct workspace docs
Browse files Browse the repository at this point in the history
  • Loading branch information
voznik committed May 18, 2024
1 parent 50327df commit d2a4ea3
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 514 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# [](https://github.com/voiceapiai/ralertsinua/compare/v0.5.0...v) (2024-05-18)



# [0.5.0](https://github.com/voiceapiai/ralertsinua/compare/v0.3.3...v0.5.0) (2024-05-17)


### Features

* location rendering and improvements ([#8](https://github.com/voiceapiai/ralertsinua/issues/8)) ([09cdb0c](https://github.com/voiceapiai/ralertsinua/commit/09cdb0cba2dc6cf042d23d749fcd3f949a5cdea4))



## [0.3.3](https://github.com/voiceapiai/ralertsinua/compare/v0.1.1...v0.3.3) (2024-05-08)


### Features

* list widget navigation ([#3](https://github.com/voiceapiai/ralertsinua/issues/3)) ([00d7851](https://github.com/voiceapiai/ralertsinua/commit/00d78516adcbf1bf2fa70c8624dec0854ac3b0ad))
* **models:** alert models compatibility ([#7](https://github.com/voiceapiai/ralertsinua/issues/7)) ([7777f99](https://github.com/voiceapiai/ralertsinua/commit/7777f99dc7bc95d8103c4a3f7150ddc28c588363))



## [0.1.1](https://github.com/voiceapiai/ralertsinua/compare/393a3b4140641dccf058b7002d2c64d69cabb047...v0.1.1) (2024-04-15)


### Features

* canvas rendering to use Ukraine shape, add data dir & more geo files ([dc3a689](https://github.com/voiceapiai/ralertsinua/commit/dc3a689933a3d08f24528f279510b6fd280c1519))
* draw ukraine borders in terminal ([0c6722e](https://github.com/voiceapiai/ralertsinua/commit/0c6722ec4d5f797e62a8843cd3c8d9706340e10a))
* initial commit, generated from rataui example async ([393a3b4](https://github.com/voiceapiai/ralertsinua/commit/393a3b4140641dccf058b7002d2c64d69cabb047))
9 changes: 4 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Rust async API wrapper (reqwest) & TUI (ratatui) for alerts.in.ua
repository = "https://github.com/voiceapiai/ralertsinua"
categories = ["api-bindings", "geo"]
keywords = ["geo", "api", "tui", "cli"]
version = "0.5.0"
version = "0.5.1"
authors = ["voiceapiai <[email protected]>"]
license = "MIT"
edition = "2021"
Expand Down Expand Up @@ -49,13 +49,13 @@ inherits = "release"
lto = "thin"

[dependencies]
ralertsinua-geo = { path = "ralertsinua-geo", version = "0.5.0", features = [
ralertsinua-geo = { path = "ralertsinua-geo", version = "0.5.1", features = [
"tui",
] }
ralertsinua-http = { path = "ralertsinua-http", version = "0.5.0", features = [
ralertsinua-http = { path = "ralertsinua-http", version = "0.5.1", features = [
"cache",
] }
ralertsinua-models = { path = "ralertsinua-models", version = "0.5.0" }
ralertsinua-models = { path = "ralertsinua-models", version = "0.5.1" }

async-trait = "0.1.80"
bincode = "1.3.3"
Expand Down
178 changes: 25 additions & 153 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,186 +5,58 @@

<p>Rust async API wrapper (<em>reqwest</em>) & <abbr title="Terminal User Interface">TUI</abbr> (<em>ratatui</em>) for <u>alerts.in.ua</u>

![screencast](https://raw.githubusercontent.com/voiceapiai/ralertsinua/main/screencast.gif)
![screencast](https://raw.githubusercontent.com/voiceapiai/ralertsinua/main/docs/assets/screencast.gif)

#

## Introduction
The Alerts.in.ua API Client is a Rust library that simplifies access to the alerts.in.ua API service. It provides real-time information about air raid alerts and other potential threats.



## Installation
To install the Alerts.in.ua API Client, run the following command in your terminal:

### Cargo
```bash
cargo install ralertsinua
```
### Install prebuilt binaries via shell script
```bash
cargo add ralertsinua
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/voiceapiai/ralertsinua/releases/download/v0.5.0/ralertsinua-installer.sh | sh
```
### Download prebuilt binaries from the [releases page](https://github.com/voiceapiai/ralertsinua/releases/latest)

## Usage

⚠️ Before you can use this library, you need to obtain an API token by submitting an [API request form](https://alerts.in.ua/api-request).

Here's an basic example of how to use the library to get a list of active alerts:

Async:
```rust
use ralertsinua_http::{AlertsInUaClient, API_BASE_URL}

#[tokio::main]
async fn main() -> Result<()> {
# Initialize the client with your token
alerts_client = AlertsInUaClient(API_BASE_URL, "your_token");

# Get the active alerts
active_alerts = await alerts_client.get_active_alerts();

print!("active_alerts: {}", active_alerts.into());
}
```

<!--
```
or sync:
```rust
use ralertsinua_http::AlertsInUaClient
alerts_client = AlertsClient(token="your_token")
## Get the active alerts
active_alerts = alerts_client.get_active_alerts()
print(active_alerts)
```
-->

## Alerts

Alerts class is a collection of alerts and provides various methods to filter and access these alerts.

When user call `client.get_active_alerts()` it returns `Alerts` class.
## Methods

### filter(*args: str) -> Vec<Alert>
This method filters the alerts based on the given parameters.

```rust
filtered_alerts = active_alerts.filter('location_oblast', 'Донецька область','alert_type','air_raid')
```
In this example, filtered_alerts will contain all the air raid alerts that have the location oblast as 'Донецька область'.

### get_alerts_by_location_title(location_title: str) -> Vec<Alert>
This method returns all the alerts from specified location.

```rust
kyiv_alerts = active_alerts.get_alerts_by_location_title('м. Київ')
```

### get_air_raid_alerts() -> Vec<Alert>
This method returns all the alerts that are of alert type 'air_raid'.
```rust
air_raid_alerts = active_alerts.get_air_raid_alerts()
```

### get_oblast_alerts() -> Vec<Alert>
This method returns all the alerts that are of location type 'oblast'.

```rust
oblast_alerts = active_alerts.get_oblast_alerts()
```
⚠️ Provide token via environment variable `ALERTSINUA_TOKEN` or via `--token` flag. If empty, the library will try to ask you interactively one time.

### get_raion_alerts() -> Vec<Alert>
This method returns all the alerts that are of location type 'raion'.
```rust
raion_alerts = active_alerts.get_raion_alerts()
```

### get_hromada_alerts() -> Vec<Alert>
This method returns all the alerts that are of location type 'hromada'.
```rust
hromada_alerts = active_alerts.get_hromada_alerts()
```

### get_city_alerts() -> Vec<Alert>
This method returns all the alerts that are of location type 'city'.

```rust
city_alerts = active_alerts.get_city_alerts()
```

### get_alerts_by_alert_type(alert_type: str) -> Vec<Alert>
This method returns all the alerts that are of the given alert type.

```rust
artillery_shelling_alerts = active_alerts.get_alerts_by_alert_type('artillery_shelling')
```

### get_alerts_by_location_type(location_type: str) -> Vec<Alert>
This method returns all the alerts that are of the given location type.

```rust
urban_location_alerts = active_alerts.get_alerts_by_location_type('raion')
```

### get_alerts_by_oblast(oblast_title: str) -> Vec<Alert>
This method returns all the alerts that are of the given oblast title.
```bash
export ALERTSINUA_TOKEN="your_token"; ralertsinua

```rust
donetsk_oblast_alerts = active_alerts.get_alerts_by_oblast('Донецька область')
```
# or

### get_alerts_by_location_uid(location_uid: str) -> Vec<Alert>
This method returns all the alerts that have the given location uid.
```rust
location_uid_alerts = active_alerts.get_alerts_by_location_uid('123456')
```
ralertsinua --token "your_token"

### get_artillery_shelling_alerts() -> Vec<Alert>
This method returns all the alerts that are of alert type 'artillery_shelling'.
```rust
artillery_shelling_alerts = active_alerts.get_artillery_shelling_alerts()
```

### get_urban_fights_alerts() -> Vec<Alert>
This method returns all the alerts that are of alert type 'urban_fights'.
```rust
urban_fights_alerts = active_alerts.get_urban_fights_alerts()
```
Default polling interval is 30 seconds. You can change it via `ALERTSINUA_POLLING_INTERVAL_SEC` env or `--interval` flag.

### get_nuclear_alerts() -> Vec<Alert>
This method returns all the alerts that are of alert type 'nuclear'.
```rust
nuclear_alerts = active_alerts.get_nuclear_alerts()
```

### get_chemical_alerts() -> Vec<Alert>
This method returns all the alerts that are of alert type 'chemical'.
```rust
chemical_alerts = active_alerts.get_chemical_alerts()
```
```bash
export ALERTSINUA_POLLING_INTERVAL_SEC=60; ralertsinua

### get_all_alerts() -> Vec<Alert>
This method returns all alerts.
```rust
all_alerts = active_alerts.get_all_alerts()
```
or you can use shortcut:
```rust
for alert in active_alerts:
print!(alert)
```
### get_last_updated_at() -> datetime.datetime
This method returns the datetime object representing the time when the alert information was last updated (Kyiv timezone).
```rust
last_updated_at = alerts.get_last_updated_at()
```
# or

### get_disclaimer() -> str
This method returns the disclaimer associated with the alert information.
```rust
disclaimer = alerts.get_disclaimer()
ralertsinua --interval 60
```

## License
MIT 2024

## Inspitation & Credits & Thanks
- ratatui's [async template](https://github.com/ratatui-org/templates/blob/main/component/README.md#async-template)
- rspotify [rsotify](https://github.com/ramsayleung/rspotify)
- echomap [echomap](https://github.com/pjsier/echomap)
- alerts_in_ua Python client [alerts-in-ua](https://github.com/alerts-ua/alerts-in-ua-py)


*[TUI]: Terminal User Interface
8 changes: 5 additions & 3 deletions ralertsinua-geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ description = "Geo compatibility layer for alerts.in.ua"
repository = "https://github.com/voiceapiai/ralertsinua"
categories = ["api-bindings"]
keywords = ["geo", "api", "tui", "cli"]
version = "0.5.0"
version = "0.5.1"
license = "MIT"
edition = "2021"
authors = ["voiceapiai <[email protected]>"]
readme = "../README.md"
readme = "./README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -22,10 +22,12 @@ lazy_static = "1.4.0"
miette = { version = "7.2.0", features = ["serde"] }
ratatui = { version = "0.26.2", optional = true }
serde = { version = "1.0.198", features = ["derive"] }
serde_json = "1.0.116"
thiserror = "1.0"
wkt = "0.10.3"

[dev-dependencies]
serde_json = "1.0.116"

[features]
default = []
tui = ["ratatui"]
Loading

0 comments on commit d2a4ea3

Please sign in to comment.