Skip to content

mercyy21/hng_stage_two

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Official Documentation for this Repository

Author - Mercy Awopetu Tolulope

This documentation provides instructions on how to use and interact with the API endpoints created

Endpoints

1. Get Person by Name

  • URL: /api/{name}
  • Method: GET
  • Description: Retrieves details of a person by their name.
  • Request Parameters: {name} (String) -Name of the person
  • Sample Request: curl -X GET http://localhost:8080/api/john
  • Expected Response (200 OK):
[
	{
		"id": 1,
		"name": "John Doe"
	}
]

2. Get Person by ID

  • URL: /api/{user_id}
  • Method: GET
  • Description: Retrieves details of a person by their ID.
  • Request Parameters: {user_id} (Long) -User ID of the person
  • Sample Request: curl -X GET http://localhost:8080/api/1
  • Expected Response (200 OK):
[
	{
		"id": 1,
		"name": "John Doe"
	}
]

3. Create Person

  • URL: /api/
  • Method: POST
  • Description: Creates a new person.
  • Request Body: JSON object with name (String)
  • Sample Request: curl -X POST -H "Content-Type: application/json" -d '{"name": "Alice Johnson"}' http://localhost:8080/api
  • Expected Response (201 Created):
[
	{
		"id": 4,
		"name": "Alice Johnson"
	}
]

4. Update person

  • URL: /api/{user_id}
  • Method: PUT
  • Description: Updates details of an existing person by their ID.
  • Request Parameters: {id} (Long) - ID of the person.
  • Request Body: JSON object with updated name (String).
  • Sample Request: curl -X PUT -H "Content-Type: application/json" -d '{"name": "Alice Smith"}' http://localhost:8080/api/4
  • Expected Response (200 OK)
{
	"id": 4,
	"name": "Alice Smith",
	"age": 26
}

5. Delete Person

URL: /api/{user_id}

  • Method: DELETE
  • Description: Deletes details of a person by their ID.
  • Request Parameters: {id} (Long) - ID of the person.
  • Sample Request: curl -X DELETE http://localhost:8080/api/4
  • Expected Response (204 No Content): No response body

Limitations and Assumptions

  • Error handling and validation for other use cases are not extensively covered in this API but should be implemented for a production-ready API
  • The name property is not sufficient enough to describe a person, other properties should be added on in the future.

Setting up and Deploying the API

To set up and deploy the API follow these steps:

  1. Clone the GitHub Repository: Link to Repository.
  2. Navigate to the project directory.
  3. Configure your database connection in application.properties.
  4. Build the project using maven or your preferred build tool.
  5. Run the application.
  6. Your API should be accessible at http://localhost:8080/api

For more detailed instructions on how to interact with the endpoints, please refer to the README.md in the repository

Live Link to the API: Link

A link to the UML Class Diagram can also be found here: UML Diagram

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •