GithubHelp home page GithubHelp logo

order_api's Introduction

Restful API Using PHP

Introduction

  1. A RESTful HTTP API listening to port 8080
  2. 3 endpoints
    • create an order
    • take an order
    • list orders
  3. Using distance api from google api
  4. Mysql as DB and Laravel as PHP based Framework.
  5. Add your google distance api key to .env file before running start.sh.
  6. Run start.sh to do all the initialisation and installation using docker.

Api interface example

Place order

  • Method: POST

  • URL path: /api/orders

  • Request body:

    {
        "origin": ["START_LATITUDE", "START_LONGTITUDE"],
        "destination": ["END_LATITUDE", "END_LONGTITUDE"]
    }
    
  • Response:

    Header: HTTP 200 Body:

    {
        "id": <order_id>,
        "distance": <total_distance>,
        "status": "UNASSIGNED"
    }
    

    or

    Header: HTTP <HTTP_CODE> Body:

    {
        "error": "ERROR_DESCRIPTION"
    }

Take order

  • Method: PUT

  • URL path: /api/orders/:id

  • Request body:

    {
        "status":"TAKEN"
    }
    
  • Response: Header: HTTP 200 Body:

    {
        "status": "SUCCESS"
    }
    

    or

    Header: HTTP 409 Body:

    {
        "error": "ORDER ALREADY BEEN TAKEN"
    }
    

Order list

  • Method: GET

  • Url path: /api/orders?page=:page&limit=:limit

  • Response:

    [
        {
            "id": <order_id>,
            "distance": <total_distance>,
            "status": <ORDER_STATUS>
        },
        ...
    ]
    

    or

    Header: HTTP <HTTP_CODE> Body:

    {
        "error": "ERROR_DESCRIPTION"
    }

order_api's People

Contributors

bhardwajrahul avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.