1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
use crate::api::*;
use crate::{ApiError, ByteStream, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub struct InboundParsingClient {
pub http_client: HttpClient,
}
impl InboundParsingClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
/// This endpoint will show the list of all the events for the received emails. When no date range is provided, the last 30 days of events are returned by default.
///
/// # Arguments
///
/// * `sender` - Email address of the sender.
/// * `start_date` - Mandatory if endDate is used. Starting date (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.SSSZ) from which you want to fetch the list. Maximum time period that can be selected is 30 days. Must not be in the future.
/// * `end_date` - Mandatory if startDate is used. Ending date (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.SSSZ) till which you want to fetch the list. Maximum time period that can be selected is 30 days. Must not be in the future.
/// * `limit` - Number of documents returned per page
/// * `offset` - Index of the first document on the page
/// * `sort` - Sort the results in the ascending/descending order of record creation
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use brevo_rust::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// api_key: Some("<value>".to_string()),
/// ..Default::default()
/// };
/// let client = BrevoClient::new(config).expect("Failed to build client");
/// client
/// .inbound_parsing
/// .get_inbound_email_events(
/// &GetInboundEmailEventsQueryRequest {
/// ..Default::default()
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn get_inbound_email_events(
&self,
request: &GetInboundEmailEventsQueryRequest,
options: Option<RequestOptions>,
) -> Result<GetInboundEmailEventsResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
"inbound/events",
None,
QueryBuilder::new()
.string("sender", request.sender.clone())
.string("startDate", request.start_date.clone())
.string("endDate", request.end_date.clone())
.int("limit", request.limit.clone())
.int("offset", request.offset.clone())
.serialize("sort", request.sort.clone())
.build(),
options,
)
.await
}
/// This endpoint will show the list of all events history for one particular received email.
///
/// # Arguments
///
/// * `uuid` - UUID to fetch events specific to received email
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use brevo_rust::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// api_key: Some("<value>".to_string()),
/// ..Default::default()
/// };
/// let client = BrevoClient::new(config).expect("Failed to build client");
/// client
/// .inbound_parsing
/// .get_inbound_email_events_by_uuid(&"uuid".to_string(), None)
/// .await;
/// }
/// ```
pub async fn get_inbound_email_events_by_uuid(
&self,
uuid: &str,
options: Option<RequestOptions>,
) -> Result<GetInboundEmailEventsByUuidResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("inbound/events/{}", uuid),
None,
None,
options,
)
.await
}
/// This endpoint will retrieve inbound attachment with download token.
///
/// # Arguments
///
/// * `download_token` - Token to fetch a particular attachment
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// Streaming file download (use .into_bytes() to collect or stream chunks)
///
/// # Examples
///
/// ```no_run
/// use brevo_rust::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// api_key: Some("<value>".to_string()),
/// ..Default::default()
/// };
/// let client = BrevoClient::new(config).expect("Failed to build client");
/// client
/// .inbound_parsing
/// .get_inbound_email_attachment(&"downloadToken".to_string(), None)
/// .await;
/// }
/// ```
pub async fn get_inbound_email_attachment(
&self,
download_token: &str,
options: Option<RequestOptions>,
) -> Result<ByteStream, ApiError> {
self.http_client
.execute_stream_request(
Method::GET,
&format!("inbound/attachments/{}", download_token),
None,
None,
options,
)
.await
}
}