From ed659c192079cc630faa1204047cb8def04417ba Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 13 Jun 2026 15:33:07 -0400 Subject: [PATCH] Cleanup --- src/caller/mod.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/caller/mod.rs b/src/caller/mod.rs index 9791854..408cfc0 100644 --- a/src/caller/mod.rs +++ b/src/caller/mod.rs @@ -1,6 +1,7 @@ pub mod endpoints { pub const ROOT: &str = "/"; + /// Constant for adding Contact endpoint pub const ADD_CONTACT: &str = "/api/v1/contact/new"; } @@ -29,6 +30,15 @@ pub mod contact { impl AddContactRequest { pub fn is_valid(&self) -> bool { + if self.phone_number.is_empty() + || self.first_name.is_empty() + || self.last_name.is_empty() + || self.user_id.is_nil() + { + false + } else { + true + } } } } @@ -67,7 +77,7 @@ pub mod contact { (status = 500, description = "Error creating Contact", body = super::response::AddContactResponse) ) )] - pub async fn create_metadata( + pub async fn create_contact( axum::Extension(pool): axum::Extension, axum::Json(payload): axum::Json, ) -> ( @@ -77,7 +87,10 @@ pub mod contact { let mut response = super::response::AddContactResponse::default(); if payload.is_valid() { - (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + ( + axum::http::StatusCode::NOT_IMPLEMENTED, + axum::Json(response), + ) } else { response.message = String::from("Request body is not valid"); (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) @@ -85,11 +98,3 @@ pub mod contact { } } } - -/* -"phone_number": "+16303831708", -"first_name": "Bob", -"last_name": "De-buildor", -"nickname": "Bob", -"user_id": "{{user_id}}" -*/