Giter Site home page Giter Site logo

flight-booking-app's Introduction

FLIGHT BOOKING API

Build Status Coverage Status

Setup

Before you start, make sure you have the following installed on your machine.

Clone the repository with:

$ git clone https://github.com/marthamareal/flight-booking-app.git
$ flight-booking-app

Install Python version of your choice with pyenv. eg

$ pyenv install 3.5.0  

Create and activate a virtual environment with:

$ pyenv virtualenv 3.6.5 flight-app  # you can use other python versions eg 3.5.0
$ pyenv activate flight-app 

setup database

  • create database called flight-app with your Postgres.

Rename the .env.sample file to .env and modify the variables with your credentials.

Source the variables with:

$ source .env

Install dependencies with:

$ pip install -r requirements.txt

Apply migrations and run the server:

$ python manage.py migrate
$ python manage.py runserver

Testing the application

$ python manage.py test
# with coverage
$ coverage run --source='.' ./manage.py test && coverage report && coverage html

Endpoints:

Authentication:

POST /api/auth/users/login/

Example request body:

{
    "email": "[email protected]",
    "password": "jakejake"
}

No authentication required, returns a User

Required fields: emailpassword

Registration:

POST /api/auth/users/

Example request body:

{
    "email": "[email protected]",
    "password": "jakejake",
    "first_name": "jake",
    "last_name": "jake",
    "phone": "+256-789-889-979"
}

No authentication required, returns a User

Required fields: email,  password

Create Flight

POST /api/flights/create/

Example request body:

{
    "provider": "Kenya airwqs",
    "origin": "ebb",
    "destination": "jkia",
    "arrival_time": "2012-09-04T21:00:00Z",
    "departure_time": "2012-09-04T18:00:00Z",
    "seats": ["2A", "2B"]
}

Authentication required (must be admin)

Get Flights

GET /api/flights

Authentication required, returns a list of Flights

Book a Flight

POST api/flights/booking/:flight/

Example request body:

{
    "seat": "2A"
}

Authentication required

field seat is optional, if not provided, a seat is assigned to you automatically

Cancel Booking

PUT api/flights/booking/:booking/cancel/

Authentication required

Get bookings on a given date

PUT api/flights/booking/:flight/:date/

Authentication required

Upload Passport photo

PUT api/auth/users/passport/upload/

Authentication required

Deployment

The API is deployed using Heroku

Check out the deployed application here

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.