/// This module contains everything everything, to convert the given JSON file into Rust structs using serde. mod parser; use time::{format_description, OffsetDateTime}; use crate::{law::parser::OgdSearchResult, Error}; fn current_date() -> String { let local_date = OffsetDateTime::now_utc(); let format = format_description::parse("[year]-[month]-[day]").unwrap(); //OK local_date.format(&format).expect("Failed to format date") } fn fetch_page(law_id: usize) -> Result { Ok( ureq::post("https://data.bka.gv.at/ris/api/v2.6/Bundesrecht") .send_form(&[ ("Applikation", "BrKons"), ("Gesetzesnummer", &format!("{}", law_id)), ("DokumenteProSeite", "OneHundred"), ("Seitennummer", &format!("{}", 1)), ("Fassung.FassungVom", ¤t_date()), ])? .into_string()?, ) } pub(crate) fn parse(law_id: usize) -> Result<(), Error> { let json = fetch_page(law_id)?; let ogd_search_result: OgdSearchResult = serde_json::from_str(&json)?; Ok(()) }