This project implements a RESTful API for managing product details and products. It provides endpoints to perform CRUD operations on product details and retrieve product information.
- Java 8+
- Maven
-
Insert Product
- Method: (POST)
- Endpoint:
/api/products
- Request Body: ProductDetails JSON object
- Response: ProductDetails JSON object
- Example Request Body:
{ "name": "", "expirationDate": "2078-12-02", "manufacturer": "", "price": 10.5, "available": true }
-
Update productDetails:
- Method: PUT
- Endpoint:
/api/products
- Request Body: ProductDetails JSON object
- Response: ProductDetails JSON object
- Example Request Body:
{ "id": "name": "", "expirationDate": "2078-12-02", "manufacturer": "", "price": 10.5, "available": true }
-
**Delete Product **:
- Method: DELETE
- Endpoint:
/api/products?id=
- Path Variable: ID of the product to delete
-
Get Product Details by ID:
- Method: GET
- Endpoint:
/api/products/productDetailsById?id=
- Path Variable: ID of the product to retrieve
- Response: ProductDetails JSON object
-
Get Product Details by Name:
- Method: GET
- Endpoint:
/api/products/productDetailsByName?searchKey=
- Query Parameter: Name of the product to retrieve
- Response: ProductDetails JSON object
-
Get All Products:
- Method: GET
- Endpoint:
/api/products
- Response: List of Product JSON objects
-
Get Product by ID:
- Method: GET
- Endpoint:
/api/products/productById?id=
- Path Variable: ID of the product to retrieve
- Response: Product JSON object
The APIs are documented using Swagger. You can access the Swagger UI by navigating to /swagger-ui.html
after starting the application.
A Postman collection containing requests for each EndPoint , import this collection into Postman to test the APIs.
Test cases are written using RestTemplate to ensure the functionality of the API.
You can interact with the API using any REST client or HTTP testing tool. The API uses JSON for request and response data(Jakson).
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.16.1</version>
</dependency>