mailgun_sdk/endpoints/get_whitelists.rs
1//! Request and response module for fetching whitelist records for a domain.
2//!
3//! ### Example
4//!
5//! ```no_run
6//! # use mailgun_sdk::{
7//! # Client,
8//! # ParamList,
9//! # get_whitelists::{GetWhitelistsParam, GetWhitelistsParamList},
10//! # };
11//! # let client = Client::new("", "");
12//! let request = GetWhitelistsParamList::default()
13//! .add(GetWhitelistsParam::Limit(1));
14//!
15//! let whitelists = client.get_whitelists(request).unwrap();
16//! ```
17//!
18//! [API Documentation](https://documentation.mailgun.com/en/latest/api-suppressions.html#view-all-whitelist-records)
19
20use crate::{Paging, Param, ParamError, ParamList};
21
22//- Request
23
24/// A parameter for fetching whitelist records for a domain.
25#[derive(Debug)]
26pub enum GetWhitelistsParam {
27 /// Maximum number of records to return (default: 100, max: 10000).
28 Limit(usize),
29}
30
31impl Param for GetWhitelistsParam {
32 fn try_as_tuple(&self) -> Result<(String, String), ParamError> {
33 Ok(match self {
34 Self::Limit(v) => ("limit".to_string(), v.to_string()),
35 })
36 }
37}
38
39/// List of parameters for fetching whitelist records for a domain.
40#[derive(Debug)]
41pub struct GetWhitelistsParamList {
42 pub values: Vec<GetWhitelistsParam>,
43}
44
45impl Default for GetWhitelistsParamList {
46 fn default() -> Self {
47 Self {
48 values: vec![],
49 }
50 }
51}
52
53impl ParamList for GetWhitelistsParamList {
54 type ParamType = GetWhitelistsParam;
55
56 fn add(mut self, param: Self::ParamType) -> Self {
57 self.values.push(param);
58
59 self
60 }
61}
62
63//- Response
64
65/// Response returned by get whitelist records endpoint.
66#[derive(Debug, Deserialize, Serialize)]
67pub struct GetWhitelistsResponse {
68 pub items: Vec<WhitelistItem>,
69 pub paging: Paging,
70}
71
72/// A single item found in [`GetWhitelistsResponse`](struct.GetWhitelistsResponse.html).
73#[derive(Debug, Deserialize, Serialize)]
74#[serde(rename_all = "camelCase")]
75pub struct WhitelistItem {
76 pub value: String,
77 pub reason: String,
78 pub r#type: String,
79 pub created_at: String,
80}