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
POST /api/auth/users/login/
Example request body:
{
"email": "[email protected]",
"password": "jakejake"
}
No authentication required, returns a User
Required fields: email
, password
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
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 /api/flights
Authentication required, returns a list of Flights
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
PUT api/flights/booking/:booking/cancel/
Authentication required
PUT api/flights/booking/:flight/:date/
Authentication required
PUT api/auth/users/passport/upload/
Authentication required
The API is deployed using Heroku
Check out the deployed application here