This is REST API for creating a new order, updating a order and get order list.
- Php v7.3 to develop backend support.
- MySQL v5.7 as the database.
- Lumen v5.8 Lumen is a micro web framework written in PHP, created by Laravel.
- Docker as the container service to isolate the environment.
- Apache 2 as web server
- PHPUnit for Unit and Integration Testing
- Swagger 3.0 Swagger is an open-source software framework backed by a large ecosystem of tools that helps developers design, build, document, and consume RESTful Web services.
*NOTES: Before running with Docker, it assumes that Docker environement pre-installed in your system.
1). Clone GIT repository in your desired directory..
git clone https://github.com/i-abhinav/OrdersAPI.git
2). Open .env file under src folder and Set Google MAP API key.
src/.env
GOOGLE_MAP_KEY=
3). Now open Command Line And Run start.sh shell script **
bash start.sh
OR
./start.sh
- Open URL
http://localhost:8080/swagger/
for Swagger API documenatation - You can perform GET, POST and PATCH /orders Request
http://localhost:8080/code-coverage/
With Docker
docker exec myorders_php ./vendor/bin/phpunit
With Docker
docker exec myorders_php ./vendor/bin/phpunit ./tests/Unit
With Docker
docker exec myorders_php ./vendor/bin/phpunit ./tests/Integration
-
Description: Create/Post a new Order.
-
Method:
POST
-
URL path:
http://localhost:8080/orders
-
URL endpoint:
/orders
-
Content-Type:
application/json
-
Request body:
{ "origin": ["START_LATITUDE", "START_LONGTITUDE"], "destination": ["END_LATITUDE", "END_LONGTITUDE"] }
- Example
{ "origin": ["28.644800", "77.308601"], "destination": ["19.076090", "72.877426"] }
-
Response:
Header:
HTTP 200
Body:{ "id": <order_id>, "distance": <total_distance>, "status": "UNASSIGNED" }
or
Header:
HTTP <HTTP_CODE>
Body:{ "error": "ERROR_DESCRIPTION" }
Code Description - 200 successful operation - 400 Bad Request - 422 Request Body Validation Error - 405 Method Not Allowed - 500 Internal Server Error
-
Description: Update/take a new Order.
-
Method:
PATCH
-
URL path:
http://localhost:8080/orders/:id
-
URL endpoint:
/orders/:id
-
Content-Type:
application/json
-
Request body:
{ "status": "TAKEN" }
-
Response: Header:
HTTP 200
Body:{ "status": "SUCCESS" }
or
Header:
HTTP <HTTP_CODE>
Body:{ "error": "ERROR_DESCRIPTION" }
Code Description - 200 successful operation - 400 Bad Request - 405 Method Not Allowed - 422 Validation Error - 406 Invalid ID - 409 Order Already Taken - 500 Internal Server Error
-
Description: List/get Order List.
-
Method:
GET
-
URL path:
http://localhost:8080/orders
-
URL endpoint:
/orders
-
Content-Type:
application/json
-
Response: Header:
HTTP 200
Body:[ { "id": <order_id>, "distance": <total_distance>, "status": <ORDER_STATUS> }, ... ]
or
Header:
HTTP <HTTP_CODE>
Body:{ "error": "ERROR_DESCRIPTION" }
Code Description - 200 Successful operation - 400 Bad Request - 422 Validation Error - 500 Internal Server Error
-
For Docker Implementation get help from (https://github.com/laravel-101/Laravel-Docker-Template) (https://cis.gvsu.edu/~dulimarh/jkl/php-mysql-docker/) (https://dev.to/veevidify/docker-compose-up-your-entire-laravel-apache-mysql-development-environment-45ea)
-
For Swagger Integartion get help from (https://github.com/DarkaOnLine/SwaggerLume)
-
Unit Testing - Thanks you Jeffrey Way (https://code.tutsplus.com/tutorials/testing-laravel-controllers--net-31456)
-
And obviously (Stack Overflow) (https://stackoverflow.com)