Delete scheduled message event endpoint (#19)
textsender_api PR / Rustfmt (pull_request) Successful in 56s
textsender_api PR / Check (pull_request) Successful in 1m32s
textsender_api PR / Clippy (pull_request) Successful in 1m37s

Reviewed-on: phoenix/textsender_api#19
This commit was merged in pull request #19.
This commit is contained in:
2026-06-19 16:02:53 -04:00
parent c1557d09f6
commit 3a387813d7
7 changed files with 206 additions and 5 deletions
+49
View File
@@ -67,6 +67,8 @@ pub mod response {
}
pub use CreateScheduleMessageEventResponse as GetScheduledMessageEventResponse;
pub use CreateScheduleMessageEventResponse as DeleteScheduledMessageEventResponse;
}
pub mod endpoint {
@@ -355,4 +357,51 @@ pub mod endpoint {
(axum::http::StatusCode::OK, axum::Json(response))
}
/// Endpoint to delete the Scheduled Message Event
#[utoipa::path(
delete,
path = crate::caller::endpoints::DELETE_SCHEDULED_MESSAGE_EVENT,
params(("id" = uuid::Uuid, Path, description = "Scheduled Message Event Id")),
responses(
(status = 200, description = "Deleted", body = super::response::DeleteScheduledMessageEventResponse),
(status = 400, description = "Bad request", body = super::response::DeleteScheduledMessageEventResponse),
(status = 500, description = "Error deleting", body = super::response::DeleteScheduledMessageEventResponse)
)
)]
pub async fn delete_scheduled_message_event(
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
) -> (
axum::http::StatusCode,
axum::Json<super::response::DeleteScheduledMessageEventResponse>,
) {
let mut response = super::response::DeleteScheduledMessageEventResponse::default();
match scheduling_repo::sched_msg_event::get(&pool, &id).await {
Ok(scheduled_message_event) => {
match scheduling_repo::sched_msg_event::delete(&pool, &scheduled_message_event)
.await
{
Ok(_) => {
response.message = String::from(super::super::super::response::SUCCESSFUL);
response.data.push(scheduled_message_event);
(axum::http::StatusCode::OK, axum::Json(response))
}
Err(err) => {
eprintln!("Error: {err:?}");
response.message = String::from("Error deleting");
(
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
}
}
}
Err(err) => {
eprintln!("Error: {err:?}");
response.message = String::from("Bad request");
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
}
}
}
}