To get started with this project, you will need to perform the following steps:
- Clone this repository to your local machine.
- Navigate to the project directory.
- Create a virtual environment: python3 -m venv env
- Activate the virtual environment: source env/bin/activate
- Install the required dependencies: pip install -r requirements.txt
- Navigate to the /app directory:
- Run: python3 app.py
To use this project, you will need to set two environment variables:
export YABALLE_SERVER_KEY=<YABBALE_SERVER_KEY>
export MONGO_DB_PASSWORD_YABALLE=<MONGO_DB_PASSWORD_YABALLE>
To add a product, create a POST request with the following endpoint:
http://127.0.0.1:5000/product/
Use this JSON object:
{
"source_id": "B07PXGQC1Q",
"source": "amazon"
}
To create a user, make a POST request to:
http://127.0.0.1:5000/user
with the following JSON object:
{
"first_name": "Fred",
"last_name": "Flinstone",
"email": "fred@flinstone.com"
}
To update a user's favorite products, you need to make a PUT request with the following URL:
http://127.0.0.1:5000/user/<users_email>/favorite
Use the following JSON object:
{
"favorite_products": [
{
"product_id": "B07J34ZVRT",
"source": "amazon"
},
{
"product_id": "485666578",
"source": "walmart"
}
]
}
To get all the user's favorite products, make a GET request with the following URL:
http://127.0.0.1:5000/user/<users_email>/favorite
Just a small note: if a user adds a product to their favorites but the product is not currently saved in MongoDB, it won't show up in the GET request.