2023-10-23 16:17:50 +11:00
|
|
|
use heck::ToKebabCase;
|
|
|
|
use serde::Deserialize;
|
|
|
|
use std::collections::{BTreeMap, HashMap};
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
#[serde(rename_all = "UPPERCASE")]
|
2023-10-24 12:30:48 +11:00
|
|
|
pub struct TimdorrEndpoint {
|
2023-10-23 16:17:50 +11:00
|
|
|
#[serde(rename = "TYPE")]
|
|
|
|
method: String,
|
|
|
|
uri: String,
|
|
|
|
auth: bool,
|
|
|
|
}
|
|
|
|
|
2023-10-24 12:30:48 +11:00
|
|
|
pub fn parse(json_str: &str) -> HashMap<String, TimdorrEndpoint> {
|
|
|
|
let map: HashMap<String, TimdorrEndpoint> = serde_json::from_str(json_str).unwrap();
|
2023-10-23 16:17:50 +11:00
|
|
|
|
|
|
|
// rename all the keys to kebab-case
|
|
|
|
map.into_iter()
|
|
|
|
.map(|(k, v)| (k.to_kebab_case(), v))
|
2023-10-24 12:30:48 +11:00
|
|
|
.collect::<HashMap<String, TimdorrEndpoint>>()
|
2023-10-23 16:17:50 +11:00
|
|
|
}
|