Crates.io | ralertsinua-http |
lib.rs | ralertsinua-http |
version | 0.5.2 |
source | src |
created_at | 2024-05-05 19:04:09.762951 |
updated_at | 2024-05-20 20:06:13.205834 |
description | HTTP compatibility layer for alerts.in.ua |
homepage | |
repository | https://github.com/voiceapiai/ralertsinua |
max_upload_size | |
id | 1230465 |
size | 24,612 |
Rust async API wrapper (reqwest) & TUI (ratatui) for alerts.in.ua
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.
To install the Alerts.in.ua API Client, run the following command in your terminal:
cargo add ralertsinua-http
⚠️ Before you can use this library, you need to obtain an API token by submitting an API request form.
Here's an basic example of how to use the library to get a list of active alerts:
Async:
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());
}
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.
This method filters the alerts based on the given parameters.
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 'Донецька область'.
This method returns all the alerts from specified location.
kyiv_alerts = active_alerts.get_alerts_by_location_title('м. Київ')
This method returns all the alerts that are of alert type 'air_raid'.
air_raid_alerts = active_alerts.get_air_raid_alerts()
This method returns all the alerts that are of location type 'oblast'.
oblast_alerts = active_alerts.get_oblast_alerts()
This method returns all the alerts that are of location type 'raion'.
raion_alerts = active_alerts.get_raion_alerts()
This method returns all the alerts that are of location type 'hromada'.
hromada_alerts = active_alerts.get_hromada_alerts()
This method returns all the alerts that are of location type 'city'.
city_alerts = active_alerts.get_city_alerts()
This method returns all the alerts that are of the given alert type.
artillery_shelling_alerts = active_alerts.get_alerts_by_alert_type('artillery_shelling')
This method returns all the alerts that are of the given location type.
urban_location_alerts = active_alerts.get_alerts_by_location_type('raion')
This method returns all the alerts that are of the given oblast title.
donetsk_oblast_alerts = active_alerts.get_alerts_by_oblast('Донецька область')
This method returns all the alerts that have the given location uid.
location_uid_alerts = active_alerts.get_alerts_by_location_uid('123456')
This method returns all the alerts that are of alert type 'artillery_shelling'.
artillery_shelling_alerts = active_alerts.get_artillery_shelling_alerts()
This method returns all the alerts that are of alert type 'urban_fights'.
urban_fights_alerts = active_alerts.get_urban_fights_alerts()
This method returns all the alerts that are of alert type 'nuclear'.
nuclear_alerts = active_alerts.get_nuclear_alerts()
This method returns all the alerts that are of alert type 'chemical'.
chemical_alerts = active_alerts.get_chemical_alerts()
This method returns all alerts.
all_alerts = active_alerts.get_all_alerts()
or you can use shortcut:
for alert in active_alerts:
print!(alert)
This method returns the datetime object representing the time when the alert information was last updated (Kyiv timezone).
last_updated_at = alerts.get_last_updated_at()
This method returns the disclaimer associated with the alert information.
disclaimer = alerts.get_disclaimer()
MIT 2024
*[TUI]: Terminal User Interface