In this repository you can find my solution for creating a sub-functionality of the food delivery application.
Business rules for different fees are stored in database and CRUD operations can be performed to manage those fees (base and extra fees). Here is the diagram of the database:
H2 database with initial data is located in database
directory. All the data is based on the business logic that was described in the exercise.
To start the application, run DeliveryApplication.java
in your IDE. By default, app is running on port 8080.
OpenAPI documentation can be found from localhost:8080/swagger-ui/index.html
and by typing v3/api-docs
into the search box (application must be started).
GET /api/delivery/fee/city/{city}/vehicle/{vehicleId}
- Calculates the delivery fee based on city and vehicle and returns a DTO object that contains of city, vehicle, base fee, extra fee and total fee. Parameters are ID-s of city and vehicle which both are required. Optional parameter is dateTime (String) that is used for doing the calculations based on the weather on this time.
POST /api/weather
- Updates weather data in the database by requesting it from Estonian Environmental Agency ("ilmateenistus.ee").
POST /api/delivery/base_fee
- Creates a new base fee rule and puts it into database. Takes in parameters: cityId, vehicleId and fee.
GET /api/delivery/base_fee
- Returns all base fees that exist currently.
PUT /api/delivery/base_fee/{id}
- Updates the fee of the given base fee entry (takes base fee ID as parameter).
DELETE /api/delivery/base_fee/{id}
- Deletes the given base fee entry (takes base fee ID as parameter).
POST /api/delivery/extra_fee/air_temperature
- Creates a new extra fee rule for air temperature.
GET /api/delivery/extra_fee/air_temperature
- Returns all extra fee rules for air temperature.
PUT /api/delivery/extra_fee/air_temperature/{id}
- Updates an existing air temperature extra fee rule entry in the database (takes extra fee rule ID as parameter).
DELETE /api/delivery/extra_fee/air_temperature/{id}
- Deletes an existing air temperature extra fee rule from the database (takes extra fee rule ID as parameter).
POST /api/delivery/extra_fee/wind_speed
- Creates a new extra fee rule for wind speed.
GET /api/delivery/extra_fee/wind_speed
- Returns all extra fee rules for wind speed.
PUT /api/delivery/extra_fee/wind_speed/{id}
- Updates an existing wind speed extra fee rule entry in the database (takes extra fee rule ID as parameter).
DELETE /api/delivery/extra_fee/wind_speed/{id}
- Deletes an existing wind speed extra fee rule from the database (takes extra fee rule ID as parameter).
POST /api/delivery/extra_fee/phenomenon
- Creates a new extra fee rule for weather phenomenon.
POST /api/delivery/extra_fee/phenomenon
- Returns all extra fee rules for weather phenomenon.
PUT /api/delivery/extra_fee/phenomenon/{id}
- Updates an existing weather phenomenon extra fee rule entry in the database (takes extra fee rule ID as parameter).
DELETE /api/delivery/extra_fee/phenomenon/{id}
- Deletes an existing weather phenomenon extra fee rule from the database (takes extra fee rule ID as parameter).