1use super::ListOptions;
2use crate::{apis::message_attempt_api, error::Result, models::*, Configuration};
3
4#[derive(Default)]
5pub struct MessageAttemptListOptions {
6 pub limit: Option<i32>,
8
9 pub iterator: Option<String>,
11
12 pub status: Option<MessageStatus>,
15
16 pub status_code_class: Option<StatusCodeClass>,
18
19 pub channel: Option<String>,
21
22 pub tag: Option<String>,
24
25 pub endpoint_id: Option<String>,
27
28 pub before: Option<String>,
32
33 pub after: Option<String>,
37
38 pub with_content: Option<bool>,
40
41 pub event_types: Option<Vec<String>>,
43}
44
45#[derive(Default)]
46pub struct MessageAttemptListByEndpointOptions {
47 pub limit: Option<i32>,
49
50 pub iterator: Option<String>,
52
53 pub status: Option<MessageStatus>,
56
57 pub status_code_class: Option<StatusCodeClass>,
59
60 pub channel: Option<String>,
62
63 pub tag: Option<String>,
65
66 pub before: Option<String>,
70
71 pub after: Option<String>,
75
76 pub with_content: Option<bool>,
78
79 pub with_msg: Option<bool>,
81
82 pub event_types: Option<Vec<String>>,
84}
85
86pub struct MessageAttempt<'a> {
87 cfg: &'a Configuration,
88}
89
90impl<'a> MessageAttempt<'a> {
91 pub(super) fn new(cfg: &'a Configuration) -> Self {
92 Self { cfg }
93 }
94
95 pub async fn list_by_msg(
103 &self,
104 app_id: String,
105 msg_id: String,
106 options: Option<MessageAttemptListOptions>,
107 ) -> Result<ListResponseMessageAttemptOut> {
108 let MessageAttemptListOptions {
109 limit,
110 iterator,
111 status,
112 status_code_class,
113 channel,
114 tag,
115 endpoint_id,
116 before,
117 after,
118 with_content,
119 event_types,
120 } = options.unwrap_or_default();
121
122 message_attempt_api::v1_period_message_attempt_period_list_by_msg(
123 self.cfg,
124 message_attempt_api::V1PeriodMessageAttemptPeriodListByMsgParams {
125 app_id,
126 msg_id,
127 limit,
128 iterator,
129 status,
130 status_code_class,
131 channel,
132 tag,
133 endpoint_id,
134 before,
135 after,
136 with_content,
137 event_types,
138 },
139 )
140 .await
141 }
142
143 pub async fn list_by_endpoint(
151 &self,
152 app_id: String,
153 endpoint_id: String,
154 options: Option<MessageAttemptListByEndpointOptions>,
155 ) -> Result<ListResponseMessageAttemptOut> {
156 let MessageAttemptListByEndpointOptions {
157 limit,
158 iterator,
159 status,
160 status_code_class,
161 channel,
162 tag,
163 before,
164 after,
165 with_content,
166 with_msg,
167 event_types,
168 } = options.unwrap_or_default();
169
170 message_attempt_api::v1_period_message_attempt_period_list_by_endpoint(
171 self.cfg,
172 message_attempt_api::V1PeriodMessageAttemptPeriodListByEndpointParams {
173 app_id,
174 endpoint_id,
175 limit,
176 iterator,
177 status,
178 status_code_class,
179 channel,
180 tag,
181 before,
182 after,
183 with_content,
184 with_msg,
185 event_types,
186 },
187 )
188 .await
189 }
190
191 pub async fn list_attempted_messages(
203 &self,
204 app_id: String,
205 endpoint_id: String,
206 options: Option<MessageAttemptListOptions>,
207 ) -> Result<ListResponseEndpointMessageOut> {
208 let MessageAttemptListOptions {
209 iterator,
210 limit,
211 event_types,
212 before,
213 after,
214 channel,
215 tag,
216 status,
217 status_code_class: _,
218 with_content,
219 endpoint_id: _,
220 } = options.unwrap_or_default();
221
222 message_attempt_api::v1_period_message_attempt_period_list_attempted_messages(
223 self.cfg,
224 message_attempt_api::V1PeriodMessageAttemptPeriodListAttemptedMessagesParams {
225 app_id,
226 endpoint_id,
227 limit,
228 iterator,
229 channel,
230 tag,
231 status,
232 before,
233 after,
234 with_content,
235 event_types,
236 },
237 )
238 .await
239 }
240
241 pub async fn list_attempted_destinations(
245 &self,
246 app_id: String,
247 msg_id: String,
248 options: Option<ListOptions>,
249 ) -> Result<ListResponseMessageEndpointOut> {
250 let ListOptions { iterator, limit } = options.unwrap_or_default();
251 message_attempt_api::v1_period_message_attempt_period_list_attempted_destinations(
252 self.cfg,
253 message_attempt_api::V1PeriodMessageAttemptPeriodListAttemptedDestinationsParams {
254 app_id,
255 msg_id,
256 iterator,
257 limit,
258 },
259 )
260 .await
261 }
262
263 pub async fn list_attempts_for_endpoint(
264 &self,
265 app_id: String,
266 msg_id: String,
267 endpoint_id: String,
268 options: Option<MessageAttemptListOptions>,
269 ) -> Result<ListResponseMessageAttemptEndpointOut> {
270 let MessageAttemptListOptions {
271 iterator,
272 limit,
273 event_types,
274 before,
275 after,
276 channel,
277 tag,
278 status,
279 status_code_class: _,
280 endpoint_id: _,
281 with_content: _,
282 } = options.unwrap_or_default();
283 message_attempt_api::v1_period_message_attempt_period_list_by_endpoint_deprecated(
284 self.cfg,
285 message_attempt_api::V1PeriodMessageAttemptPeriodListByEndpointDeprecatedParams {
286 app_id,
287 endpoint_id,
288 msg_id,
289 iterator,
290 limit,
291 event_types,
292 before,
293 after,
294 channel,
295 tag,
296 status,
297 },
298 )
299 .await
300 }
301
302 pub async fn get(
304 &self,
305 app_id: String,
306 msg_id: String,
307 attempt_id: String,
308 ) -> Result<MessageAttemptOut> {
309 message_attempt_api::v1_period_message_attempt_period_get(
310 self.cfg,
311 message_attempt_api::V1PeriodMessageAttemptPeriodGetParams {
312 app_id,
313 msg_id,
314 attempt_id,
315 },
316 )
317 .await
318 }
319
320 pub async fn resend(&self, app_id: String, msg_id: String, endpoint_id: String) -> Result<()> {
322 message_attempt_api::v1_period_message_attempt_period_resend(
323 self.cfg,
324 message_attempt_api::V1PeriodMessageAttemptPeriodResendParams {
325 app_id,
326 msg_id,
327 endpoint_id,
328 idempotency_key: None,
329 },
330 )
331 .await
332 }
333
334 pub async fn expunge_content(
337 &self,
338 app_id: String,
339 msg_id: String,
340 attempt_id: String,
341 ) -> Result<()> {
342 message_attempt_api::v1_period_message_attempt_period_expunge_content(
343 self.cfg,
344 message_attempt_api::V1PeriodMessageAttemptPeriodExpungeContentParams {
345 app_id,
346 msg_id,
347 attempt_id,
348 },
349 )
350 .await
351 }
352}