sendgrid_api/stats.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct Stats {
5 pub client: Client,
6}
7
8impl Stats {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 Stats { client }
12 }
13
14 /**
15 * Retrieve global email statistics.
16 *
17 * This function performs a `GET` to the `/stats` endpoint.
18 *
19 * **This endpoint allows you to retrieve all of your global email statistics between a given date range.**
20 *
21 * Parent accounts will see aggregated stats for their account and all subuser accounts. Subuser accounts will only see their own stats.
22 *
23 * **Parameters:**
24 *
25 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
26 * * `offset: i64` -- The point in the list to begin retrieving results.
27 * * `offset: i64` -- The point in the list to begin retrieving results.
28 * * `aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy` -- How to group the statistics. Must be either "day", "week", or "month".
29 * * `start_date: &str` -- The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.
30 * * `end_date: &str` -- The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.
31 */
32 pub async fn get_page(
33 &self,
34 offset: i64,
35 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
36 start_date: &str,
37 end_date: &str,
38 ) -> ClientResult<crate::Response<Vec<crate::types::GetStatsResponseData>>> {
39 let mut query_args: Vec<(String, String)> = Default::default();
40 if !aggregated_by.to_string().is_empty() {
41 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
42 }
43 if !end_date.is_empty() {
44 query_args.push(("end_date".to_string(), end_date.to_string()));
45 }
46 if offset > 0 {
47 query_args.push(("offset".to_string(), offset.to_string()));
48 }
49 if !start_date.is_empty() {
50 query_args.push(("start_date".to_string(), start_date.to_string()));
51 }
52 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
53 let url = self.client.url(&format!("/stats?{}", query_), None);
54 self.client
55 .get(
56 &url,
57 crate::Message {
58 body: None,
59 content_type: None,
60 },
61 )
62 .await
63 }
64 /**
65 * Retrieve global email statistics.
66 *
67 * This function performs a `GET` to the `/stats` endpoint.
68 *
69 * As opposed to `get`, this function returns all the pages of the request at once.
70 *
71 * **This endpoint allows you to retrieve all of your global email statistics between a given date range.**
72 *
73 * Parent accounts will see aggregated stats for their account and all subuser accounts. Subuser accounts will only see their own stats.
74 */
75 pub async fn get_all(
76 &self,
77 offset: i64,
78 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
79 start_date: &str,
80 end_date: &str,
81 ) -> ClientResult<crate::Response<Vec<crate::types::GetStatsResponseData>>> {
82 let mut query_args: Vec<(String, String)> = Default::default();
83 if !aggregated_by.to_string().is_empty() {
84 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
85 }
86 if !end_date.is_empty() {
87 query_args.push(("end_date".to_string(), end_date.to_string()));
88 }
89 if offset > 0 {
90 query_args.push(("offset".to_string(), offset.to_string()));
91 }
92 if !start_date.is_empty() {
93 query_args.push(("start_date".to_string(), start_date.to_string()));
94 }
95 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
96 let url = self.client.url(&format!("/stats?{}", query_), None);
97 self.client
98 .get_all_pages(
99 &url,
100 crate::Message {
101 body: None,
102 content_type: None,
103 },
104 )
105 .await
106 }
107 /**
108 * Retrieve email statistics by country and state/province.
109 *
110 * This function performs a `GET` to the `/geo/stats` endpoint.
111 *
112 * **This endpoint allows you to retrieve your email statistics segmented by country and state/province.**
113 *
114 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
115 *
116 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html).
117 *
118 * **Parameters:**
119 *
120 * * `country: crate::types::Country` -- The country you would like to see statistics for. Currently only supported for US and CA.
121 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
122 * * `offset: i64` -- The point in the list to begin retrieving results.
123 * * `offset: i64` -- The point in the list to begin retrieving results.
124 * * `aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy` -- How to group the statistics. Must be either "day", "week", or "month".
125 * * `start_date: &str` -- The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.
126 * * `end_date: &str` -- The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.
127 */
128 pub async fn get_geo(
129 &self,
130 country: crate::types::Country,
131 offset: i64,
132 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
133 start_date: &str,
134 end_date: &str,
135 ) -> ClientResult<crate::Response<Vec<crate::types::GetGeoStatsResponseData>>> {
136 let mut query_args: Vec<(String, String)> = Default::default();
137 if !aggregated_by.to_string().is_empty() {
138 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
139 }
140 if !country.to_string().is_empty() {
141 query_args.push(("country".to_string(), country.to_string()));
142 }
143 if !end_date.is_empty() {
144 query_args.push(("end_date".to_string(), end_date.to_string()));
145 }
146 if offset > 0 {
147 query_args.push(("offset".to_string(), offset.to_string()));
148 }
149 if !start_date.is_empty() {
150 query_args.push(("start_date".to_string(), start_date.to_string()));
151 }
152 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
153 let url = self.client.url(&format!("/geo/stats?{}", query_), None);
154 self.client
155 .get(
156 &url,
157 crate::Message {
158 body: None,
159 content_type: None,
160 },
161 )
162 .await
163 }
164 /**
165 * Retrieve email statistics by country and state/province.
166 *
167 * This function performs a `GET` to the `/geo/stats` endpoint.
168 *
169 * As opposed to `get_geo`, this function returns all the pages of the request at once.
170 *
171 * **This endpoint allows you to retrieve your email statistics segmented by country and state/province.**
172 *
173 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
174 *
175 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html).
176 */
177 pub async fn get_all_geo(
178 &self,
179 country: crate::types::Country,
180 offset: i64,
181 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
182 start_date: &str,
183 end_date: &str,
184 ) -> ClientResult<crate::Response<Vec<crate::types::GetGeoStatsResponseData>>> {
185 let mut query_args: Vec<(String, String)> = Default::default();
186 if !aggregated_by.to_string().is_empty() {
187 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
188 }
189 if !country.to_string().is_empty() {
190 query_args.push(("country".to_string(), country.to_string()));
191 }
192 if !end_date.is_empty() {
193 query_args.push(("end_date".to_string(), end_date.to_string()));
194 }
195 if offset > 0 {
196 query_args.push(("offset".to_string(), offset.to_string()));
197 }
198 if !start_date.is_empty() {
199 query_args.push(("start_date".to_string(), start_date.to_string()));
200 }
201 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
202 let url = self.client.url(&format!("/geo/stats?{}", query_), None);
203 self.client
204 .get_all_pages(
205 &url,
206 crate::Message {
207 body: None,
208 content_type: None,
209 },
210 )
211 .await
212 }
213 /**
214 * Retrieve email statistics by device type.
215 *
216 * This function performs a `GET` to the `/devices/stats` endpoint.
217 *
218 * **This endpoint allows you to retrieve your email statistics segmented by the device type.**
219 *
220 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
221 *
222 * ## Available Device Types
223 * | **Device** | **Description** | **Example** |
224 * |---|---|---|
225 * | Desktop | Email software on desktop computer. | I.E., Outlook, Sparrow, or Apple Mail. |
226 * | Webmail | A web-based email client. | I.E., Yahoo, Google, AOL, or Outlook.com. |
227 * | Phone | A smart phone. | iPhone, Android, Blackberry, etc.
228 * | Tablet | A tablet computer. | iPad, android based tablet, etc. |
229 * | Other | An unrecognized device. |
230 *
231 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
232 *
233 * **Parameters:**
234 *
235 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
236 * * `offset: i64` -- The point in the list to begin retrieving results.
237 * * `offset: i64` -- The point in the list to begin retrieving results.
238 * * `aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy` -- How to group the statistics. Must be either "day", "week", or "month".
239 * * `start_date: &str` -- The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.
240 * * `end_date: &str` -- The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.
241 */
242 pub async fn get_devices(
243 &self,
244 offset: i64,
245 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
246 start_date: &str,
247 end_date: &str,
248 ) -> ClientResult<crate::Response<Vec<crate::types::GetClientsStatsResponse>>> {
249 let mut query_args: Vec<(String, String)> = Default::default();
250 if !aggregated_by.to_string().is_empty() {
251 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
252 }
253 if !end_date.is_empty() {
254 query_args.push(("end_date".to_string(), end_date.to_string()));
255 }
256 if offset > 0 {
257 query_args.push(("offset".to_string(), offset.to_string()));
258 }
259 if !start_date.is_empty() {
260 query_args.push(("start_date".to_string(), start_date.to_string()));
261 }
262 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
263 let url = self.client.url(&format!("/devices/stats?{}", query_), None);
264 self.client
265 .get(
266 &url,
267 crate::Message {
268 body: None,
269 content_type: None,
270 },
271 )
272 .await
273 }
274 /**
275 * Retrieve email statistics by device type.
276 *
277 * This function performs a `GET` to the `/devices/stats` endpoint.
278 *
279 * As opposed to `get_devices`, this function returns all the pages of the request at once.
280 *
281 * **This endpoint allows you to retrieve your email statistics segmented by the device type.**
282 *
283 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
284 *
285 * ## Available Device Types
286 * | **Device** | **Description** | **Example** |
287 * |---|---|---|
288 * | Desktop | Email software on desktop computer. | I.E., Outlook, Sparrow, or Apple Mail. |
289 * | Webmail | A web-based email client. | I.E., Yahoo, Google, AOL, or Outlook.com. |
290 * | Phone | A smart phone. | iPhone, Android, Blackberry, etc.
291 * | Tablet | A tablet computer. | iPad, android based tablet, etc. |
292 * | Other | An unrecognized device. |
293 *
294 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
295 */
296 pub async fn get_all_devices(
297 &self,
298 offset: i64,
299 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
300 start_date: &str,
301 end_date: &str,
302 ) -> ClientResult<crate::Response<Vec<crate::types::GetClientsStatsResponse>>> {
303 let mut query_args: Vec<(String, String)> = Default::default();
304 if !aggregated_by.to_string().is_empty() {
305 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
306 }
307 if !end_date.is_empty() {
308 query_args.push(("end_date".to_string(), end_date.to_string()));
309 }
310 if offset > 0 {
311 query_args.push(("offset".to_string(), offset.to_string()));
312 }
313 if !start_date.is_empty() {
314 query_args.push(("start_date".to_string(), start_date.to_string()));
315 }
316 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
317 let url = self.client.url(&format!("/devices/stats?{}", query_), None);
318 self.client
319 .get_all_pages(
320 &url,
321 crate::Message {
322 body: None,
323 content_type: None,
324 },
325 )
326 .await
327 }
328 /**
329 * Retrieve email statistics by client type.
330 *
331 * This function performs a `GET` to the `/clients/stats` endpoint.
332 *
333 * **This endpoint allows you to retrieve your email statistics segmented by client type.**
334 *
335 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
336 *
337 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
338 *
339 * **Parameters:**
340 *
341 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
342 * * `start_date: &str` -- The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.
343 * * `end_date: &str` -- The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.
344 * * `aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy` -- How to group the statistics. Must be either "day", "week", or "month".
345 */
346 pub async fn get_clients(
347 &self,
348 start_date: &str,
349 end_date: &str,
350 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
351 ) -> ClientResult<crate::Response<Vec<crate::types::GetClientsStatsResponse>>> {
352 let mut query_args: Vec<(String, String)> = Default::default();
353 if !aggregated_by.to_string().is_empty() {
354 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
355 }
356 if !end_date.is_empty() {
357 query_args.push(("end_date".to_string(), end_date.to_string()));
358 }
359 if !start_date.is_empty() {
360 query_args.push(("start_date".to_string(), start_date.to_string()));
361 }
362 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
363 let url = self.client.url(&format!("/clients/stats?{}", query_), None);
364 self.client
365 .get(
366 &url,
367 crate::Message {
368 body: None,
369 content_type: None,
370 },
371 )
372 .await
373 }
374 /**
375 * Retrieve email statistics by client type.
376 *
377 * This function performs a `GET` to the `/clients/stats` endpoint.
378 *
379 * As opposed to `get_clients`, this function returns all the pages of the request at once.
380 *
381 * **This endpoint allows you to retrieve your email statistics segmented by client type.**
382 *
383 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
384 *
385 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
386 */
387 pub async fn get_all_clients(
388 &self,
389 start_date: &str,
390 end_date: &str,
391 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
392 ) -> ClientResult<crate::Response<Vec<crate::types::GetClientsStatsResponse>>> {
393 let mut query_args: Vec<(String, String)> = Default::default();
394 if !aggregated_by.to_string().is_empty() {
395 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
396 }
397 if !end_date.is_empty() {
398 query_args.push(("end_date".to_string(), end_date.to_string()));
399 }
400 if !start_date.is_empty() {
401 query_args.push(("start_date".to_string(), start_date.to_string()));
402 }
403 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
404 let url = self.client.url(&format!("/clients/stats?{}", query_), None);
405 self.client
406 .get_all_pages(
407 &url,
408 crate::Message {
409 body: None,
410 content_type: None,
411 },
412 )
413 .await
414 }
415 /**
416 * Retrieve stats by a specific client type.
417 *
418 * This function performs a `GET` to the `/clients/{client_type}/stats` endpoint.
419 *
420 * **This endpoint allows you to retrieve your email statistics segmented by a specific client type.**
421 *
422 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
423 *
424 * ## Available Client Types
425 * - phone
426 * - tablet
427 * - webmail
428 * - desktop
429 *
430 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
431 *
432 * **Parameters:**
433 *
434 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
435 * * `start_date: &str` -- The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.
436 * * `end_date: &str` -- The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.
437 * * `aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy` -- How to group the statistics. Must be either "day", "week", or "month".
438 */
439 pub async fn get_clients_client_type(
440 &self,
441 client_type: crate::types::ClientType,
442 start_date: &str,
443 end_date: &str,
444 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
445 ) -> ClientResult<crate::Response<Vec<crate::types::GetClientsStatsResponse>>> {
446 let mut query_args: Vec<(String, String)> = Default::default();
447 if !aggregated_by.to_string().is_empty() {
448 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
449 }
450 if !end_date.is_empty() {
451 query_args.push(("end_date".to_string(), end_date.to_string()));
452 }
453 if !start_date.is_empty() {
454 query_args.push(("start_date".to_string(), start_date.to_string()));
455 }
456 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
457 let url = self.client.url(
458 &format!(
459 "/clients/{}/stats?{}",
460 crate::progenitor_support::encode_path(&client_type.to_string()),
461 query_
462 ),
463 None,
464 );
465 self.client
466 .get(
467 &url,
468 crate::Message {
469 body: None,
470 content_type: None,
471 },
472 )
473 .await
474 }
475 /**
476 * Retrieve stats by a specific client type.
477 *
478 * This function performs a `GET` to the `/clients/{client_type}/stats` endpoint.
479 *
480 * As opposed to `get_clients_client_type`, this function returns all the pages of the request at once.
481 *
482 * **This endpoint allows you to retrieve your email statistics segmented by a specific client type.**
483 *
484 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
485 *
486 * ## Available Client Types
487 * - phone
488 * - tablet
489 * - webmail
490 * - desktop
491 *
492 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
493 */
494 pub async fn get_all_clients_client_type(
495 &self,
496 client_type: crate::types::ClientType,
497 start_date: &str,
498 end_date: &str,
499 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
500 ) -> ClientResult<crate::Response<Vec<crate::types::GetClientsStatsResponse>>> {
501 let mut query_args: Vec<(String, String)> = Default::default();
502 if !aggregated_by.to_string().is_empty() {
503 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
504 }
505 if !end_date.is_empty() {
506 query_args.push(("end_date".to_string(), end_date.to_string()));
507 }
508 if !start_date.is_empty() {
509 query_args.push(("start_date".to_string(), start_date.to_string()));
510 }
511 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
512 let url = self.client.url(
513 &format!(
514 "/clients/{}/stats?{}",
515 crate::progenitor_support::encode_path(&client_type.to_string()),
516 query_
517 ),
518 None,
519 );
520 self.client
521 .get_all_pages(
522 &url,
523 crate::Message {
524 body: None,
525 content_type: None,
526 },
527 )
528 .await
529 }
530 /**
531 * Retrieve email statistics by mailbox provider.
532 *
533 * This function performs a `GET` to the `/mailbox_providers/stats` endpoint.
534 *
535 * **This endpoint allows you to retrieve your email statistics segmented by recipient mailbox provider.**
536 *
537 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
538 *
539 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
540 *
541 * **Parameters:**
542 *
543 * * `mailbox_providers: &str` -- The mail box providers to get statistics for. You can include up to 10 by including this parameter multiple times.
544 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
545 * * `offset: i64` -- The point in the list to begin retrieving results.
546 * * `offset: i64` -- The point in the list to begin retrieving results.
547 * * `aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy` -- How to group the statistics. Must be either "day", "week", or "month".
548 * * `start_date: &str` -- The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.
549 * * `end_date: &str` -- The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.
550 */
551 pub async fn get_mailbox_providers(
552 &self,
553 mailbox_providers: &str,
554 offset: i64,
555 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
556 start_date: &str,
557 end_date: &str,
558 ) -> ClientResult<crate::Response<Vec<crate::types::GetMailboxProvidersStatsResponseData>>>
559 {
560 let mut query_args: Vec<(String, String)> = Default::default();
561 if !aggregated_by.to_string().is_empty() {
562 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
563 }
564 if !end_date.is_empty() {
565 query_args.push(("end_date".to_string(), end_date.to_string()));
566 }
567 if !mailbox_providers.is_empty() {
568 query_args.push((
569 "mailbox_providers".to_string(),
570 mailbox_providers.to_string(),
571 ));
572 }
573 if offset > 0 {
574 query_args.push(("offset".to_string(), offset.to_string()));
575 }
576 if !start_date.is_empty() {
577 query_args.push(("start_date".to_string(), start_date.to_string()));
578 }
579 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
580 let url = self
581 .client
582 .url(&format!("/mailbox_providers/stats?{}", query_), None);
583 self.client
584 .get(
585 &url,
586 crate::Message {
587 body: None,
588 content_type: None,
589 },
590 )
591 .await
592 }
593 /**
594 * Retrieve email statistics by mailbox provider.
595 *
596 * This function performs a `GET` to the `/mailbox_providers/stats` endpoint.
597 *
598 * As opposed to `get_mailbox_providers`, this function returns all the pages of the request at once.
599 *
600 * **This endpoint allows you to retrieve your email statistics segmented by recipient mailbox provider.**
601 *
602 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
603 *
604 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
605 */
606 pub async fn get_all_mailbox_providers(
607 &self,
608 mailbox_providers: &str,
609 offset: i64,
610 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
611 start_date: &str,
612 end_date: &str,
613 ) -> ClientResult<crate::Response<Vec<crate::types::GetMailboxProvidersStatsResponseData>>>
614 {
615 let mut query_args: Vec<(String, String)> = Default::default();
616 if !aggregated_by.to_string().is_empty() {
617 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
618 }
619 if !end_date.is_empty() {
620 query_args.push(("end_date".to_string(), end_date.to_string()));
621 }
622 if !mailbox_providers.is_empty() {
623 query_args.push((
624 "mailbox_providers".to_string(),
625 mailbox_providers.to_string(),
626 ));
627 }
628 if offset > 0 {
629 query_args.push(("offset".to_string(), offset.to_string()));
630 }
631 if !start_date.is_empty() {
632 query_args.push(("start_date".to_string(), start_date.to_string()));
633 }
634 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
635 let url = self
636 .client
637 .url(&format!("/mailbox_providers/stats?{}", query_), None);
638 self.client
639 .get_all_pages(
640 &url,
641 crate::Message {
642 body: None,
643 content_type: None,
644 },
645 )
646 .await
647 }
648 /**
649 * Retrieve email statistics by browser.
650 *
651 * This function performs a `GET` to the `/browsers/stats` endpoint.
652 *
653 * **This endpoint allows you to retrieve your email statistics segmented by browser type.**
654 *
655 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
656 *
657 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
658 *
659 * **Parameters:**
660 *
661 * * `browsers: &str` -- The browsers to get statistics for. You can include up to 10 different browsers by including this parameter multiple times.
662 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
663 * * `offset: i64` -- The point in the list to begin retrieving results.
664 * * `offset: i64` -- The point in the list to begin retrieving results.
665 * * `aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy` -- How to group the statistics. Must be either "day", "week", or "month".
666 * * `start_date: &str` -- The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.
667 * * `end_date: &str` -- The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.
668 */
669 pub async fn get_browsers(
670 &self,
671 browsers: &str,
672 offset: i64,
673 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
674 start_date: &str,
675 end_date: &str,
676 ) -> ClientResult<crate::Response<Vec<crate::types::GetBrowsersStatsResponseData>>> {
677 let mut query_args: Vec<(String, String)> = Default::default();
678 if !aggregated_by.to_string().is_empty() {
679 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
680 }
681 if !browsers.is_empty() {
682 query_args.push(("browsers".to_string(), browsers.to_string()));
683 }
684 if !end_date.is_empty() {
685 query_args.push(("end_date".to_string(), end_date.to_string()));
686 }
687 if offset > 0 {
688 query_args.push(("offset".to_string(), offset.to_string()));
689 }
690 if !start_date.is_empty() {
691 query_args.push(("start_date".to_string(), start_date.to_string()));
692 }
693 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
694 let url = self
695 .client
696 .url(&format!("/browsers/stats?{}", query_), None);
697 self.client
698 .get(
699 &url,
700 crate::Message {
701 body: None,
702 content_type: None,
703 },
704 )
705 .await
706 }
707 /**
708 * Retrieve email statistics by browser.
709 *
710 * This function performs a `GET` to the `/browsers/stats` endpoint.
711 *
712 * As opposed to `get_browsers`, this function returns all the pages of the request at once.
713 *
714 * **This endpoint allows you to retrieve your email statistics segmented by browser type.**
715 *
716 * **We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints.
717 *
718 * Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [Statistics Overview](https://sendgrid.com/docs/ui/analytics-and-reporting/stats-overview/).
719 */
720 pub async fn get_all_browsers(
721 &self,
722 browsers: &str,
723 offset: i64,
724 aggregated_by: crate::types::TraitStatsAdvancedBaseQueryStringsAggregatedBy,
725 start_date: &str,
726 end_date: &str,
727 ) -> ClientResult<crate::Response<Vec<crate::types::GetBrowsersStatsResponseData>>> {
728 let mut query_args: Vec<(String, String)> = Default::default();
729 if !aggregated_by.to_string().is_empty() {
730 query_args.push(("aggregated_by".to_string(), aggregated_by.to_string()));
731 }
732 if !browsers.is_empty() {
733 query_args.push(("browsers".to_string(), browsers.to_string()));
734 }
735 if !end_date.is_empty() {
736 query_args.push(("end_date".to_string(), end_date.to_string()));
737 }
738 if offset > 0 {
739 query_args.push(("offset".to_string(), offset.to_string()));
740 }
741 if !start_date.is_empty() {
742 query_args.push(("start_date".to_string(), start_date.to_string()));
743 }
744 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
745 let url = self
746 .client
747 .url(&format!("/browsers/stats?{}", query_), None);
748 self.client
749 .get_all_pages(
750 &url,
751 crate::Message {
752 body: None,
753 content_type: None,
754 },
755 )
756 .await
757 }
758}