First one #8

Merged
phoenix merged 42 commits from get_it_going into v0.2.0 2026-06-13 19:49:15 -04:00
Showing only changes of commit ed659c1920 - Show all commits
+15 -10
View File
@@ -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<sqlx::PgPool>,
axum::Json(payload): axum::Json<super::request::AddContactRequest>,
) -> (
@@ -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}}"
*/