Shipping Recommendations API
RESTful API that given different shipping options from an external API is able to recommend the same shipping options ordered by the best combination of cost and time.
Architecture
Shipping Recommendations API architecture is based on the Clean Architecture.
Execution
Running the API
You can run the API with the following command:
make run
Linting
To lint the API using golangci-lint, execute:
make lint
Testing
To test the API you can use the following command:
make test
And if you want to get coverage information, you can use:
make test-cover
To update mocks, use this command:
make build-mocks
Documentation
Swagger
You can find the documentation of the API at localhost:8080/swagger/index.html.
Examples
- List recommended shipping options
Request:
curl -X 'GET' \
'http://localhost:8080/api/v1/shipping-recommendations'
Response:
{
"shipping_recommendations": [
{
"name": "Option 2",
"type": "Custom",
"cost": 5,
"estimated_days": 4
},
{
"name": "Option 3",
"type": "Pickup",
"cost": 7,
"estimated_days": 1
},
{
"name": "Option 4",
"type": "Delivery",
"cost": 10,
"estimated_days": 3
},
{
"name": "Option 1",
"type": "Delivery",
"cost": 10,
"estimated_days": 5
}
]
}
Dependencies