use reqwest::Response;
use crate::client::error::QStashError;
use super::Client;
#[derive(Debug)]
pub struct DlqRequest {
pub cursor: Option<u32>,
}
impl Client {
async fn _get_dead_letter_queue(
&self,
request: Option<DlqRequest>,
) -> Result<Response, QStashError> {
let mut path = match self
.base_url
.join(&format!("/{}/dlq/messages", self.version))
{
Ok(p) => p,
Err(e) => {
let formated_string = e.to_string();
tracing::error!(formated_string);
return Err(QStashError::PublishError);
}
};
if let Some(request) = request {
if let Some(cursor) = request.cursor {
path.set_query(Some(&format!("cursor={}", cursor)));
}
};
let response = match self.http.get(path).send().await {
Ok(r) => {
tracing::debug!("{:?}", r);
r
}
Err(e) => {
let formated_string = e.to_string();
tracing::error!(formated_string);
return Err(QStashError::EventError);
}
};
Ok(response)
}
}