Skip to content

Commit

Permalink
Merge 43690ef into 7a8eb9e
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasulejoseph committed Oct 5, 2018
2 parents 7a8eb9e + 43690ef commit 779de90
Show file tree
Hide file tree
Showing 18 changed files with 459 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .coverage

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ before_script:

install:
- pip install -r requirements.txt
- pip install pytest-cov

script:
- coverage run --source=. -m unittest discover
- nosetests -v --with-coverage --cover-package="app"
- coverage report

after_success:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Database to back end the fast food fast api
# Build status
[![Build Status](https://travis-ci.com/Kasulejoseph/fast-food-fast-db.svg?branch=develop)](https://travis-ci.com/Kasulejoseph/fast-food-fast-db)
[![Maintainability](https://api.codeclimate.com/v1/badges/0259c2b03a263108f0ac/maintainability)](https://codeclimate.com/github/Kasulejoseph/fast-food-fast-db/maintainability)
[![Coverage Status](https://coveralls.io/repos/github/Kasulejoseph/fast-food-fast-db/badge.svg)](https://coveralls.io/github/Kasulejoseph/fast-food-fast-db)
[![Coverage Status](https://coveralls.io/repos/github/Kasulejoseph/fast-food-fast-db/badge.svg?branch=develop)](https://coveralls.io/github/Kasulejoseph/fast-food-fast-db?branch=develop)
## Prerequisites
``` - Python3.6
- Flask
Expand Down
2 changes: 2 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from flask import Flask
from flasgger import Swagger
from app.views.orders import main
from app.auth.views import auth
from app.auth import views
from instance.config import app_config

app = Flask(__name__, instance_relative_config=True)
app.config.from_object(app_config["development"])
Swagger(app)
app.register_blueprint(main)
app.register_blueprint(auth)
3 changes: 3 additions & 0 deletions app/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from werkzeug.security import generate_password_hash, check_password_hash
from flask_restful import Api, Resource
from flask import make_response, Blueprint, request, jsonify
from flasgger import swag_from
auth = Blueprint('auth', __name__)
db = Database()
api = Api(auth)
Expand All @@ -17,6 +18,7 @@ class RegisterUser(Resource):
"""
Class to register a user via api
"""
@swag_from('../doc/signup.yml')
def post(self):
"""
User creates an account
Expand Down Expand Up @@ -65,6 +67,7 @@ class LoginUser(Resource):
"""
Class to register a user via api
"""
@swag_from('../doc/login.yml')
def post(self):
"""
User login if he supplies correct credentials
Expand Down
50 changes: 50 additions & 0 deletions app/doc/add_menu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Menu
---
tags:
- add item
parameters:
- name: body
description: Add a food item to menu
in: body
required: true
schema:
type: object
required:
- "meal"
- "description"
- "price"
properties:
meal:
type: "string"
example: "pizza"
description:
type: "string"
example: "good one"
price:
type: integer
format:
example: 90000

responses:
201:
description: successfully Added
schema:
type: object
properties:
message:
type: string
enum:
- "successfully added to menu"
401:
description: Failed to add a menu
schema:
type: object
properties:
message:
type: string
enum:
- "Error adding a menu"
- "No field should be left empty"
- 'price must be integer'
- 'Description and Dish must be string format'
- 'order request contains spaces only'
47 changes: 47 additions & 0 deletions app/doc/create_order.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Orders
---
tags:
- Create Order
parameters:
- name: body
description: User request for an order
in: body
required: true
schema:
type: object
required:
- "meal_id"
properties:
meal_id:
type: integer
example: 1

responses:
201:
description: successfully submitted
schema:
type: object
properties:
message:
type: string
enum:
- "Order successfully submited"
401:
description: invalid inputs
schema:
type: object
properties:
message:
type: string
enum:
- 'menu ids should be of integer data types only'
- 'Zero is not a menu id'
404:
description: Not found
schema:
type: object
properties:
message:
type: string
enum:
- "No item for that id"
26 changes: 26 additions & 0 deletions app/doc/get_all_orders.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Orders
---
tags:
- Get all orders requests from users
responses:
200:
description: order list
schema:
type: object
properties:
message:
type: string
enum:
- "success"

409:
description: Not permitted
schema:
type: object
properties:
message:
type: string
enum:
- "You dont have permission to access this route"


27 changes: 27 additions & 0 deletions app/doc/get_history.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Orders
---
tags:
- fetch user previous order history
responses:
200:
description: previous history

404:
description: Not found
schema:
type: object
properties:
message:
type: string
enum:
- 'You have not ordered from the site yet'
security:
- JWT:
description: Pass in jwt token. i.e Bearer <jwt>
type: apiKey
scheme: bearer
name: token
in: header
bearerFormat: JWT


26 changes: 26 additions & 0 deletions app/doc/get_menu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Menu
---
tags:
- Get food items on menu
responses:
200:
description: menu today
schema:
type: object
properties:
message:
type: string
enum:
- "On menu today"

404:
description: Empty menu
schema:
type: object
properties:
message:
type: string
enum:
- "nothing on menu today"


35 changes: 35 additions & 0 deletions app/doc/get_order_id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Orders
---
tags:
- Get One
responses:
200:
description: Admin gets an order by order id
schema:
type: object
properties:
message:
type: string
enum:
- "Order by:user"

404:
description: Not found
schema:
type: object
properties:
message:
type: string
enum:
- "No order by that Id"
409:
description: Not permited
schema:
type: object
properties:
message:
type: string
enum:
- 'You dont have permission to access this route'


59 changes: 59 additions & 0 deletions app/doc/login.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
User log in
---
tags:
- User login
parameters:
- name: body
description: Post request for user log in
in: body
required: true
schema:
type: object
required:
- "username"
- "password"
properties:
username:
type: "string"
example: "kasule@gmail.com"
password:
type: "string"
format: password
example: "********"
responses:
200:
description: You have succesfully logged in
schema:
type: object
properties:
message:
type: string
enum:
- "You have succesfully logged in"
400:
description: Failed to login
schema:
type: object
properties:
message:
type: string
enum:
- "wrong username or password credentials"
401:
description: incorrect credentials
schema:
type: string
properties:
message:
type: string
enum:
- "incorect username"
202:
description: Invalid credentials
schema:
type: string
properties:
message:
type: string
enum:
- "username must all be string or ivalid email"
Loading

0 comments on commit 779de90

Please sign in to comment.