sendgrid2/request/
put_subusers_subuser_name_monitor.rs1use serde_json::json;
2use crate::model::*;
3use crate::SendgridClient;
4pub struct PutSubusersSubuserNameMonitorRequest<'a> {
8 pub(crate) client: &'a SendgridClient,
9 pub subuser_name: String,
10 pub email: String,
11 pub frequency: f64,
12}
13impl<'a> PutSubusersSubuserNameMonitorRequest<'a> {
14 pub async fn send(self) -> anyhow::Result<Monitor> {
15 let mut r = self
16 .client
17 .client
18 .put(
19 &format!(
20 "/v3/subusers/{subuser_name}/monitor", subuser_name = self
21 .subuser_name
22 ),
23 );
24 r = r.push_json(json!({ "email" : self.email }));
25 r = r.push_json(json!({ "frequency" : self.frequency }));
26 r = self.client.authenticate(r);
27 let res = r.send().await.unwrap().error_for_status();
28 match res {
29 Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
30 Err(res) => {
31 let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
32 Err(anyhow::anyhow!("{:?}", text))
33 }
34 }
35 }
36}