Skip to content

A Spring Boot project to implement a RESTful API for managing user information

Notifications You must be signed in to change notification settings

LazarenkoDmytro/users-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Users API

The Users API is a Spring Boot-based RESTful service that manages user profiles. It offers capabilities to create, retrieve, update, and delete user information, as well as additional functionalities such as filtering users by their date of birth.

Getting Started

Prerequisites

  • Java 11 or higher
  • Maven 3.6 or higher

Running the Application

To run the application, execute the following command in the root directory:

mvn spring-boot:run

This will start the application on http://localhost:8080.

API Endpoints

Create a User

  • URL: /users

  • Method: POST

  • Body:

    {

     "email": "[email protected]",

     "firstName": "John",

     "lastName": "Doe",

     "dateOfBirth": "1990-01-01",

     "address": "123 Main St",

     "phoneNumber": "123-456-7890"

    }

  • Success Response:

    • Code: 201 Created
    • Content: User details with links to user resource

Retrieve All Users

  • URL: /users
  • Method: GET
  • Success Response:
    • Code: 200 OK
    • Content: List of users with associated resources

Get User by Email

  • URL: /users/{email}
  • Method: GET
  • URL Params: email=[string]
  • Success Response:
    • Code: 200 OK
    • Content: User details

Update User Information

  • URL: /users/{email}

  • Method: PATCH

  • URL Params: email=[string]

  • Body:

    {

     "firstName": "Jane"

    }

  • Success Response:

    • Code: 200 OK
    • Content: Updated user details

Replace User

  • URL: /users/{email}

  • Method: PUT

  • URL Params: email=[string]

  • Body:

    {

     "email": "[email protected]",

     "firstName": "Jane",

     "lastName": "Doe",

     "dateOfBirth": "1990-02-01",

     "address": "123 Main St",

     "phoneNumber": "123-456-7890"

    }

  • Success Response:

    • Code: 201 Created
    • Content: New user details

Delete User

  • URL: /users/{email}
  • Method: DELETE
  • URL Params: email=[string]
  • Success Response:
    • Code: 204 No Content

Filter Users by Birth Date Range

  • URL: /users/by-birthdate-range
  • Method: GET
  • Query Params:
    • from: YYYY-MM-DD
    • to: YYYY-MM-DD
  • Success Response:
    • Code: 200 OK
    • Content: List of users born within the specified date range

Error Handling

The API uses standard HTTP response codes to indicate the success or failure of requests:

  • 200 OK: The request was successful.
  • 400 Bad Request: The request was malformed or invalid.
  • 404 Not Found: The specified resource was not found.
  • 500 Internal Server Error: An error occurred on the server.

Testing

Unit and integration tests are provided under the src/test/java directory. Use the following command to run the tests:

mvn test

About

A Spring Boot project to implement a RESTful API for managing user information

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages