v1
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
1410
Cargo.lock
generated
Normal file
1410
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
Cargo.toml
Normal file
19
Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "globalenter"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "globalenter"
|
||||
test = false
|
||||
bench = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.11.14", features = ["json"] }
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
webbrowser = "0.8.7"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
chrono = "0.4.23"
|
||||
2
build.sh
Normal file
2
build.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
cargo build --target x86_64-pc-windows-gnu --release
|
||||
cargo build --release
|
||||
1
rustfmt.toml
Normal file
1
rustfmt.toml
Normal file
@@ -0,0 +1 @@
|
||||
tab_spaces=2
|
||||
26
sample.json
Normal file
26
sample.json
Normal file
@@ -0,0 +1,26 @@
|
||||
[
|
||||
{
|
||||
"locationId": 5023,
|
||||
"startTimestamp": "2023-03-03T06:15",
|
||||
"endTimestamp": "2023-03-03T06:30",
|
||||
"active": true,
|
||||
"duration": 15,
|
||||
"remoteInd": false
|
||||
},
|
||||
{
|
||||
"locationId": 5023,
|
||||
"startTimestamp": "2023-04-03T06:15",
|
||||
"endTimestamp": "2023-04-03T06:30",
|
||||
"active": true,
|
||||
"duration": 15,
|
||||
"remoteInd": false
|
||||
},
|
||||
{
|
||||
"locationId": 5023,
|
||||
"startTimestamp": "2023-04-03T06:30",
|
||||
"endTimestamp": "2023-04-03T06:45",
|
||||
"active": true,
|
||||
"duration": 15,
|
||||
"remoteInd": false
|
||||
}
|
||||
]
|
||||
60
src/main.rs
Normal file
60
src/main.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use std::process::exit;
|
||||
|
||||
use chrono::{DateTime, Datelike, Local, Timelike};
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::time::error::Error;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use webbrowser::open_browser;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Appointment {
|
||||
locationId: u32,
|
||||
startTimestamp: String,
|
||||
endTimestamp: String,
|
||||
active: bool,
|
||||
duration: u32,
|
||||
remoteInd: bool,
|
||||
}
|
||||
|
||||
const TIME: u64 = 3000;
|
||||
// const LOCATION_ID: u32 = 14321;
|
||||
const LOCATION_ID: u32 = 5023;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
loop {
|
||||
look_for_appointments().await;
|
||||
sleep(Duration::from_millis(TIME)).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn look_for_appointments() {
|
||||
let data = get_data().await.unwrap();
|
||||
|
||||
for appointment in data {
|
||||
let time = appointment.startTimestamp + ":00-05:00";
|
||||
let at = DateTime::parse_from_rfc3339(&time).unwrap();
|
||||
|
||||
println!(
|
||||
"Appointment found on {}/{}/{} at {}:{}",
|
||||
at.day(),
|
||||
at.month(),
|
||||
at.year(),
|
||||
at.hour(),
|
||||
at.minute(),
|
||||
);
|
||||
open_browser(webbrowser::Browser::Default, "https://ttp.cbp.dhs.gov/credential/v1/login?app=GOES-prod&lang=en&state=en:IonIgXB4I9qt02S6cgKydMVA9HXHC1vq").unwrap();
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_data() -> Result<Vec<Appointment>, Error> {
|
||||
let res = reqwest::get(format!(
|
||||
"https://ttp.cbp.dhs.gov/schedulerapi/slots?orderBy=soonest&limit=3&locationId={}&minimum=1",
|
||||
LOCATION_ID
|
||||
))
|
||||
.await;
|
||||
let body: Vec<Appointment> = res.unwrap().json().await.unwrap();
|
||||
Ok(body)
|
||||
}
|
||||
Reference in New Issue
Block a user