nerva/clients/donki/
flr.rs1use crate::prelude::params::DefaultParams;
2use crate::prelude::{Client, Params};
3use std::error::Error;
4
5pub type FLRParams<'p> = DefaultParams<'p>;
6
7#[derive(Debug, Clone)]
8pub struct FLR {}
9
10impl Default for FLR
11{
12 fn default() -> Self { Self {} }
13}
14
15impl FLR
16{
17 pub fn new() -> Self { Self::default() }
18}
19
20impl<'p, PARAMS> Client<PARAMS> for FLR
21where
22 PARAMS: Params,
23{
24 const BASE_URL: &'static str = "https://api.nasa.gov/DONKI/FLR";
25 type Response = serde_json::Value;
26
27 fn get(&self, params: PARAMS) -> Result<Self::Response, Box<dyn Error>>
28 {
29 let base_url = <FLR as Client<PARAMS>>::BASE_URL;
30 let url_with_params = format!("{}?{}", base_url, params.into());
31 let url_with_key = crate::prelude::keys::include(&url_with_params)?;
32 let response = ureq::get(&url_with_key).call()?;
33 let json = serde_json::json!(response.into_string()?);
34 return Ok(json);
35 }
36}
37
38#[cfg(test)]
39mod flr_tests
40{
41 use super::*;
42
43 #[test]
44 fn flr_test() -> Result<(), Box<dyn Error>>
45 {
46 let flr = FLR::new();
47 let params = FLRParams::default();
48 let response = flr.get(params)?;
49 println!("{:#?}", response);
50 Ok(())
51 }
52}