RESTful APIs which have been used in Orders related tasks.
- Get the list of orders
- Create a new order
- Update the status of an order
- Docker as a container service.
- Apache for webserver used to process incoming request for PHP application.
- PHP is used to create backend APIs.
- Laravel Framework is a web application framework with expressive, elegant syntax and to ease the development of APIs.
- MySQL is used for database.
Make sure docker is running in your system
$ git clone https://github.com/gauravkumar07nagarro/order-apis.git
API_SUBTYPE=myapp
API_PREFIX=/
API_VERSION=v1
API_STRICT=false
API_CONDITIONAL_REQUEST=false
API_DEFAULT_FORMAT=json
API_DEBUG=false
GOOGLE_MAP_API_KEY = "YOUR-GOOGLE-API-KEY"
GOOGLE_MAP_DISTANCE_API = "https://maps.googleapis.com/maps/api/distancematrix/json"
LISTING_LIMIT=10
L5_SWAGGER_GENERATE_ALWAYS=false
Please make sure that you have changed GOOGLE_MAP_API_KEY with your google Distance Matrix API Key
$ cd order-apis
$ ./start.sh
Note : make sure start.sh is executable
Above file is used to setup your project in Docker container. It will perform below tasks:
- Creating dependencies used in project.
- Database migrations used for API operations.
- Generate swagger api documentation.
- Run all test cases.
[http://localhost:8080/documentation] (API Demo)
List of APIs will be displayed
Base Url http://localhost:8080/
METHOD | Content-type | API Endpoint | Example |
---|---|---|---|
GET | application/json | /orders?page={page}&limit={limit} | http://localhost:8080/orders?page=1&limit=10 |
POST | application/json | /orders | http://localhost:8080/orders |
PATCH | application/json | /orders/{id} | http://localhost:8080/orders/10 |
-
Method : POST
Url : http://localhost:8080/orders
Body :{ "origin": ["28.459497", "77.026634"], "destination": ["26.912434", "77.026634"] }
Response :
{ "total_distance": 226694, "status": "UNASSIGNED", "id": 2 }
Response Codes:
- 200 : OK
- 422 : Unprocessable Entitiy
-
Method : PATCH
Url : http://localhost:8080/orders/1
Body :{ "status": "TAKEN" }
Response :
{ "status": "SUCCESS" }
Response Codes:
- 200 : OK
- 422 : Unprocessable Entitiy
-
Method : GET
Url : http://localhost:8080/orders?page=1&limit=10
Response :[ { "id": 1, "total_distance": 170201, "status": "TAKEN" }, { "id": 2, "total_distance": 226694, "status": "UNASSIGNED" } ]
Response Codes:
- 200 : OK
- 422 : Unprocessable Entitiy