sendgrid_api/spam_reports_api.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct SpamReportsApi {
5 pub client: Client,
6}
7
8impl SpamReportsApi {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 SpamReportsApi { client }
12 }
13
14 /**
15 * Retrieve all spam reports.
16 *
17 * This function performs a `GET` to the `/suppression/spam_reports` endpoint.
18 *
19 * **This endpoint allows you to retrieve all spam reports.**
20 *
21 * **Parameters:**
22 *
23 * * `start_time: i64` -- The start of the time range when a spam report was created (inclusive). This is a unix timestamp.
24 * * `end_time: i64` -- The end of the time range when a spam report was created (inclusive). This is a unix timestamp.
25 * * `limit: i64` -- Limit the number of results to be displayed per page.
26 * * `offset: i64` -- Paging offset. The point in the list to begin displaying results.
27 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
28 */
29 pub async fn get_suppression_spam_reports(
30 &self,
31 start_time: i64,
32 end_time: i64,
33 limit: i64,
34 offset: i64,
35 ) -> ClientResult<crate::Response<Vec<crate::types::SpamReportsResponse>>> {
36 let mut query_args: Vec<(String, String)> = Default::default();
37 if end_time > 0 {
38 query_args.push(("end_time".to_string(), end_time.to_string()));
39 }
40 if limit > 0 {
41 query_args.push(("limit".to_string(), limit.to_string()));
42 }
43 if offset > 0 {
44 query_args.push(("offset".to_string(), offset.to_string()));
45 }
46 if start_time > 0 {
47 query_args.push(("start_time".to_string(), start_time.to_string()));
48 }
49 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
50 let url = self
51 .client
52 .url(&format!("/suppression/spam_reports?{}", query_), None);
53 self.client
54 .get(
55 &url,
56 crate::Message {
57 body: None,
58 content_type: None,
59 },
60 )
61 .await
62 }
63 /**
64 * Retrieve all spam reports.
65 *
66 * This function performs a `GET` to the `/suppression/spam_reports` endpoint.
67 *
68 * As opposed to `get_suppression_spam_reports`, this function returns all the pages of the request at once.
69 *
70 * **This endpoint allows you to retrieve all spam reports.**
71 */
72 pub async fn get_all_suppression_spam_reports(
73 &self,
74 start_time: i64,
75 end_time: i64,
76 offset: i64,
77 ) -> ClientResult<crate::Response<Vec<crate::types::SpamReportsResponse>>> {
78 let mut query_args: Vec<(String, String)> = Default::default();
79 if end_time > 0 {
80 query_args.push(("end_time".to_string(), end_time.to_string()));
81 }
82 if offset > 0 {
83 query_args.push(("offset".to_string(), offset.to_string()));
84 }
85 if start_time > 0 {
86 query_args.push(("start_time".to_string(), start_time.to_string()));
87 }
88 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
89 let url = self
90 .client
91 .url(&format!("/suppression/spam_reports?{}", query_), None);
92 self.client
93 .get_all_pages(
94 &url,
95 crate::Message {
96 body: None,
97 content_type: None,
98 },
99 )
100 .await
101 }
102 /**
103 * Delete spam reports.
104 *
105 * This function performs a `DELETE` to the `/suppression/spam_reports` endpoint.
106 *
107 * **This endpoint allows you to delete your spam reports.**
108 *
109 * Deleting a spam report will remove the suppression, meaning email will once again be sent to the previously suppressed address. This should be avoided unless a recipient indicates they wish to receive email from you again. You can use our [bypass filters](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) to deliver messages to otherwise suppressed addresses when exceptions are required.
110 *
111 * There are two options for deleting spam reports:
112 *
113 * 1. You can delete all spam reports by setting the `delete_all` field to `true` in the request body.
114 * 2. You can delete a list of select spam reports by specifying the email addresses in the `emails` array of the request body.
115 *
116 * **Parameters:**
117 *
118 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
119 */
120 pub async fn delete_suppression_spam_reports(
121 &self,
122 body: &crate::types::DeleteSuppressionBlocksRequest,
123 ) -> ClientResult<crate::Response<crate::types::Help>> {
124 let url = self.client.url("/suppression/spam_reports", None);
125 self.client
126 .delete(
127 &url,
128 crate::Message {
129 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
130 content_type: Some("application/json".to_string()),
131 },
132 )
133 .await
134 }
135 /**
136 * Retrieve a specific spam report.
137 *
138 * This function performs a `GET` to the `/suppression/spam_reports/{email}` endpoint.
139 *
140 * **This endpoint allows you to retrieve a specific spam report by email address.**
141 *
142 * **Parameters:**
143 *
144 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
145 */
146 pub async fn get_suppression_spam_reports_email(
147 &self,
148 email: &str,
149 ) -> ClientResult<crate::Response<Vec<crate::types::SpamReportsResponse>>> {
150 let url = self.client.url(
151 &format!(
152 "/suppression/spam_reports/{}",
153 crate::progenitor_support::encode_path(email),
154 ),
155 None,
156 );
157 self.client
158 .get(
159 &url,
160 crate::Message {
161 body: None,
162 content_type: None,
163 },
164 )
165 .await
166 }
167 /**
168 * Retrieve a specific spam report.
169 *
170 * This function performs a `GET` to the `/suppression/spam_reports/{email}` endpoint.
171 *
172 * As opposed to `get_suppression_spam_reports_email`, this function returns all the pages of the request at once.
173 *
174 * **This endpoint allows you to retrieve a specific spam report by email address.**
175 */
176 pub async fn get_all_suppression_spam_reports_email(
177 &self,
178 email: &str,
179 ) -> ClientResult<crate::Response<Vec<crate::types::SpamReportsResponse>>> {
180 let url = self.client.url(
181 &format!(
182 "/suppression/spam_reports/{}",
183 crate::progenitor_support::encode_path(email),
184 ),
185 None,
186 );
187 self.client
188 .get_all_pages(
189 &url,
190 crate::Message {
191 body: None,
192 content_type: None,
193 },
194 )
195 .await
196 }
197 /**
198 * Delete a specific spam report.
199 *
200 * This function performs a `DELETE` to the `/suppression/spam_reports/{email}` endpoint.
201 *
202 * **This endpoint allows you to delete a specific spam report by email address.**
203 *
204 * Deleting a spam report will remove the suppression, meaning email will once again be sent to the previously suppressed address. This should be avoided unless a recipient indicates they wish to receive email from you again. You can use our [bypass filters](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) to deliver messages to otherwise suppressed addresses when exceptions are required.
205 *
206 * **Parameters:**
207 *
208 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
209 */
210 pub async fn delete_suppression_spam_reports_email(
211 &self,
212 email: &str,
213 ) -> ClientResult<crate::Response<crate::types::Help>> {
214 let url = self.client.url(
215 &format!(
216 "/suppression/spam_reports/{}",
217 crate::progenitor_support::encode_path(email),
218 ),
219 None,
220 );
221 self.client
222 .delete(
223 &url,
224 crate::Message {
225 body: None,
226 content_type: None,
227 },
228 )
229 .await
230 }
231}