Set of API endpoints to be consumed by a store manager application
The Program offers the following set of endpoints:
| EndPoint | Functionality | Notes |
|---|---|---|
| GET /products | Fetch all products | Get all available products. |
| GET /products/[productId] | Fetch a single product record | Get a specific product using the |
| GET /sales | Fetch all sale records | Get all sale records. |
| GET /sales/[saleId] | Fetch a single sale record | Get a specific sale record using its id |
| POST /sales | Create a sale order | Create a sale record. |
| POST /products | Create a product | Create a product. |
These instructions will get you a copy of the program on your local machine for development and testing purposes. The instructions are tailored for uses of LINUX OS particularly UBUNTU
What things you will need to run the application
Python3
version: 3.6
Pip for python3
$ sudo apt-get install python3-pip
Flask to build the application
version: 1.0.2
$ pip install flask
Virtualenv to create a virtual environment
version: 16.0.0
Pytest to perform tests
version: 3.9.1
$ pip install pytest -U
Alternatively, run pip install -r requirements.txt to install all the necessary tools
Flask - microframework for Python
To have a copy of the project on your machine, run the command below in your preferred directory:
git clone https://github.com/dxania/Store_Manager_APIs.git
After cloning, you will have a folder named Store_Manager_APIs
- Navigate to
Store_Manager_APIs - Create a virtual environment by running:
python3 -m venv <name of virtualenvironment> - Activate the virtual environment
source <name of virtualenvironment>/bin/activateYou should see the name of the virtual environment placed right before your current path/directory in brackets() - Run the application
export FLASK_APP=store_mgr.pythenflask run - Follow the instructions
- Run
pytestorpytest tests/<test_file_name>in the directory of the project to run unit tests - Test with Postman by pasting the url http://127.0.0.1:5000/api/v1/products for Products or http://127.0.0.1:5000/api/v1/sales for Sales into the url section and call the GET/POST methods accordingly. (For the POST requests, enter the data as raw application/json)
Deployed on heroku. Visit the this link to interact with the deployed app