gauravkmr07 / order-apis

APIs For Order Related Operations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Restful APIs for Orders

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

Tools/Softwares

  • 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.

Installation

Make sure docker is running in your system

$ git clone https://github.com/gauravkumar07nagarro/order-apis.git 

Environment variables

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

Change GOOGLE_MAP_API_KEY from .env

Please make sure that you have changed GOOGLE_MAP_API_KEY with your google Distance Matrix API Key

Run Docker

$ 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.

Swagger Documentation

[http://localhost:8080/documentation] (API Demo)

List of APIs will be displayed

API Documentation & Examples

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
  • API To Create A New Order

    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
  • API To Update Status Of An Order

    Method : PATCH
    Url : http://localhost:8080/orders/1
    Body :

    { 
        "status": "TAKEN"
    }

    Response :

    {
        "status": "SUCCESS"
    }

    Response Codes:

    • 200 : OK
    • 422 : Unprocessable Entitiy
  • API To List The Orders

    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

About

APIs For Order Related Operations


Languages

Language:PHP 97.6%Language:HTML 2.1%Language:Shell 0.3%Language:TSQL 0.0%