sendgrid2/request/
get_suppression_spam_reports_email.rs

1use serde_json::json;
2use crate::model::*;
3use crate::SendgridClient;
4/**Create this with the associated client method.
5
6That method takes required values as arguments. Set optional values using builder methods on this struct.*/
7pub struct GetSuppressionSpamReportsEmailRequest<'a> {
8    pub(crate) client: &'a SendgridClient,
9    pub on_behalf_of: Option<String>,
10    pub email: String,
11}
12impl<'a> GetSuppressionSpamReportsEmailRequest<'a> {
13    pub async fn send(self) -> anyhow::Result<SpamReportsResponse> {
14        let mut r = self
15            .client
16            .client
17            .get(&format!("/v3/suppression/spam_reports/{email}", email = self.email));
18        if let Some(ref unwrapped) = self.on_behalf_of {
19            r = r.header("on-behalf-of", &unwrapped.to_string());
20        }
21        r = self.client.authenticate(r);
22        let res = r.send().await.unwrap().error_for_status();
23        match res {
24            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
25            Err(res) => {
26                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
27                Err(anyhow::anyhow!("{:?}", text))
28            }
29        }
30    }
31    pub fn on_behalf_of(mut self, on_behalf_of: &str) -> Self {
32        self.on_behalf_of = Some(on_behalf_of.to_owned());
33        self
34    }
35}