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