+fn request_livedns_gandi(api_key: &str, url_fragment: &str) -> Result<Value> {
+ let url = format!("https://api.gandi.net/v5/livedns/{}", url_fragment);
+ let client = reqwest::blocking::Client::new();
+
+ match client.get(&url).header("Authorization", format!("Apikey {}", api_key)).send() {
+ Ok(resp) =>
+ if resp.status().is_success() {
+ let content = resp.text().unwrap();
+ Ok(serde_json::from_str(&content).unwrap())
+ } else {
+ Err(Box::new(Error { message: format!("Request unsuccessful: {:#?}", resp) }))
+ },
+ Err(error) =>
+ Err(Box::new(Error { message: format!("Error during request: {:?}", error) }))
+ }
+}
+
+fn get_current_record_ip(api_key: &str) -> Result<Ipv4Addr> {
+
+ request_livedns_gandi(api_key, "domains/euphorik.ch/records/home/A")?; // TODO...
+ // .map()
+ //.map(|json_value| json_value["rrset_values"][0].as_str().unwrap())
+
+ Result::Err(Box::new(Error { message: String::new() }))
+
+
+ //let url = "https://api.gandi.net/v5/livedns/domains/euphorik.ch/records";
+ //let url = "https://api.gandi.net/v5/livedns/domains"; // ?sharing_id="
+ //let url = "https://api.gandi.net/v5/organization/organizations";
+ //let url = "https://api.gandi.net/v5/livedns/domains/euphorik.ch/records/home/A";
+
+ /*
+ let client = reqwest::blocking::Client::new();
+
+ match client.get(url).header("Authorization", format!("Apikey {}", api_key)).send() {
+ Ok(resp) =>
+ if resp.status().is_success() {
+ let content = resp.text().unwrap();
+
+ let json: Value = serde_json::from_str(&content).unwrap();
+ let prout = json["rrset_values"][0].as_str().unwrap();
+ println!("IP: {}", prout);