use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
use uuid::Uuid;
pub struct NotificationlogsClient {
pub http_client: HttpClient,
}
impl NotificationlogsClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
pub async fn search_notification_logs(
&self,
request: &SearchNotificationLogsRequest,
options: Option<RequestOptions>,
) -> Result<Vec<NotificationLog>, ApiError> {
self.http_client
.execute_request(
Method::POST,
"/v2/notificationlogs",
Some(serde_json::to_value(&request.body).map_err(ApiError::Serialization)?),
QueryBuilder::new()
.serialize("PageSize", request.page_size.clone())
.int("Page", request.page.clone())
.build(),
options,
)
.await
}
pub async fn get_notification_log(
&self,
uuid: &Uuid,
options: Option<RequestOptions>,
) -> Result<NotificationLogDetail, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("/v2/notificationlogs/{}", uuid),
None,
None,
options,
)
.await
}
pub async fn retry_notification_log(
&self,
uuid: &Uuid,
options: Option<RequestOptions>,
) -> Result<NotificationLogDetail, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("/v2/notificationlogs/{}/retry", uuid),
None,
None,
options,
)
.await
}
pub async fn bulk_retry_notification_logs(
&self,
request: &BulkRetryRequest,
options: Option<RequestOptions>,
) -> Result<(), ApiError> {
self.http_client
.execute_request(
Method::POST,
"/v2/notificationlogs/retry",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
}