(
&self,
vars: &HashMap<String, String>,
attributes: &Payload,
)
| 40 | } |
| 41 | |
| 42 | async fn send_attributes( |
| 43 | &self, |
| 44 | vars: &HashMap<String, String>, |
| 45 | attributes: &Payload, |
| 46 | ) -> Result<()> { |
| 47 | let access_token = vars.get("ThingsBoardAccessToken").cloned().ok_or_else(|| { |
| 48 | anyhow!("Device does not have ThingsBoardAccessToken variable configured") |
| 49 | })?; |
| 50 | |
| 51 | let endpoint = format!("{}/api/v1/{}/attributes", self.server, access_token); |
| 52 | let b = serde_json::to_string(&attributes)?; |
| 53 | |
| 54 | let mut headers = HeaderMap::new(); |
| 55 | headers.insert(CONTENT_TYPE, "application/json".parse().unwrap()); |
| 56 | |
| 57 | let res = get_client() |
| 58 | .post(endpoint) |
| 59 | .body(b) |
| 60 | .headers(headers) |
| 61 | .send() |
| 62 | .await?; |
| 63 | let _ = res.error_for_status()?; |
| 64 | Ok(()) |
| 65 | } |
| 66 | |
| 67 | async fn send_telemetry( |
| 68 | &self, |
no test coverage detected