This API provides robust functionality for managing orders, products, and customers in your business. It offers features such as creating customers and products, placing orders, and searching for orders by date.
This project is built with the following technology stack:
- Spring Boot 3.1.4: A robust framework for building Java applications.
- Hibernate: An object-relational mapping (ORM) library for efficient database interactions.
- Liquibase: A database schema version control and migration tool.
- Clone this repository.
git clone https://github.com/bitalizer/order-api.gitThis API allows you to manage orders, products, and customers.
To create a new customer, send a POST request to:
POST /api/v1/customers
{
"full_name": "John Doe",
"email": "johndoe@example.com",
"phone_number": "123-456-7890",
"registration_code": "ABC123"
}To create a new product, send a POST request to:
POST /api/v1/products{
"name": "Sample Product",
"sku_code": "SKU123",
"unit_price": "19.99"
}To place a new order, send a POST request to:
POST /api/v1/ordersInclude the order details and order lines in the request body.
{
"order_lines": [
{
"quantity": 5,
"product_id": 1
},
{
"quantity": 31,
"product_id": 2
}
],
"customer_id": 1
}To change the quantity of products in an order line, send a PUT request to:
PUT /api/v1/orders/{order_id}/order-lines/{order_line_id}/quantityInclude the new quantity in the request body.
{
"quantity": 60
}To search for orders, use the following endpoint with query parameters:
GET /api/v1/orders/search?product_id=1&customer_id=1&date_from=2023-01-01&date_to=2023-12-31Modify the query parameters as needed to perform specific searches.
Before running the application, configure these environment variables for the database connection:
- DB_HOST: Hostname or IP address of the PostgreSQL server (default:
localhost). - DB_PORT: Port number for the PostgreSQL server (default:
5432). - DB_NAME: Name of the target database
- DB_USER: Database username
- DB_PASSWORD: Database user's password