1use reqwest::StatusCode;
2
3use super::client::DexcomClient;
4
5impl DexcomClient {
6 pub(crate) fn post(
7 &self,
8 endpoint: &str,
9 json: serde_json::Value,
10 params: Vec<(&str, &str)>,
11 ) -> Result<reqwest::blocking::Response, Box<dyn std::error::Error>> {
12 let resp = self.reqwest_client
13 .post(format!("{}/{}", self.base_url, endpoint))
14 .header("Accept-Encoding", "application/json")
15 .json(&json)
16 .query(¶ms)
17 .send();
18
19 match resp {
20 Ok(r) => {
21 if r.status() != StatusCode::OK {
22 println!("Error: {:?}", r.text().unwrap());
26 return Err("server-side dexcom error".into());
27 }
28
29 Ok(r)
30 },
31 Err(e) => Err(Box::new(e)),
32 }
33 }
34}