Skip to content

Latest commit

 

History

History
90 lines (65 loc) · 3.76 KB

README.md

File metadata and controls

90 lines (65 loc) · 3.76 KB

📦 Shipping Cost Service

spring java Sistema Mercado Swagger Sistema Mercado

Getting StartedAPI EndpointsDatabase

This is a microservice to calculate the shipping cost based in the distance from origin to destination and the price per kilometers.

🚀 Getting started

This project was created to calculate shipping cost in a delivery. For this, I consumed two services, the first one is to return the location based in a CEP and the last one is to calculate the distance in meters based in two locations. If you want take a look in the code, be confortable to clone this project:

git clone https://github.com/Venicode/shipping-cost-service

Prerequisites

To running this project, you must have all prerequisites below:

Starting

When download to shipping-cost-service.jar is done, move this file whatever you want and open a command prompt. Then, check the path's file and type the command below:

C:\path\to\file>java -jar shipping-cost-service.jar

If you do this correctly, the api server will run:

print-shipping

After that, you can access the swagger page: http://localhost:8080/swagger-ui/index.html#/

📍 API Endpoints

Example to request something: http://localhost:8080/initialConfig

All endpoints that you can use in the application group by entities:

Initial Config Endpoints


POST /initialConfig - register a cep to origin and a cost per km to calculate the final shipping cost.

PUT /initialConfig/{id} - Update the initial config informations.

Shipping Cost Endpoint


GET /shippingcost/{cep}&idInitialConfig={id}&apikey={key} - Retrieve a map with the shipping cost, initial config (which parameter was applied to calculated), duration in minutes and the distante in kilometers.

Example to response:

{
  "shippingCost": 89.7112,
  "initialConfig": {
    "id": 1,
    "cepOrigin": "18608336",
    "costPerKm": 0.4
  },
  "origin": "Botucatu",
  "destination": "Campinas",
  "durationMinutes": 154.13333333333333,
  "km": 224.278
}

📝 Database

For this project, I chose the H2 Database, it stores data in memomy, being ideal for testing, where it doesn't not persist the data on disk. So, when closing the terminal, all data will be lost.