Skip to content

CSCI-GA-2820-SP23-003/shopcarts

Repository files navigation

Build Status codecov

NYU DevOps - Shopcarts Service

License Python

Overview

This repository contains code for Customer Shop Cart for an e-commerce web site. This show what the API does, how to calls them and what are the expeced inputs. Also include how to run and test the code. The APIs are built using Python and the Flask web framework.

Prerequisite Software Installation

This project uses Docker and Visual Studio Code with the Remote Containers extension to provide a consistent repeatable disposable development environment for all of the labs in this course.

You will need the following software installed:

All of these can be installed manually by clicking on the links above or you can use a package manager like Homebrew on Mac of Chocolatey on Windows.

You can read more about creating these environments in this article: Creating Reproducible Development Environments

Setup

You should clone this repo, change into the repo directory and open Visual Studio Code using the code . command. VS Code will prompt you to reopen in a container and you should say yes. This will take a while as it builds the Docker image and creates a container from it to develop in.

git clone https://github.com/CSCI-GA-2820-SP23-003/shopcarts.git
cd shopcarts
code .

Note that there is a period . after the code command. This tells Visual Studio Code to open the editor and load the current folder of files.

Once the environment is loaded you should be placed at a bash prompt in the /app folder inside of the development container. This folder is mounted to the current working directory of your repository on your computer. This means that any file you edit while inside of the /app folder in the container is actually being edited on your computer. You can then commit your changes to git from either inside or outside of the container.

You can run test on this folder.

cd shopcarts
nosetests -v --with-spec --spec-color

APIS

URL Description Return code
GET / Return all REST API name, all available paths 200
GET /health Return the health status 200
GET /api/shopcarts Retrieve all shopcarts of all customers 200
POST /api/shopcarts Creates a new shopcart for a customer given customer_id 201, 409, 400
GET /api/shopcarts/int:customer_id Retrieve all the shopcarts of a customer<customer_id> 200, 404
PUT /api/shopcarts/int:customer_id Update a shop cart for customer<customer_id> with query parameter "update=True" for replacing the cart with the items provided in payload "update=False" clears the shopcart
DELETE /api/shopcarts/int:customer_id Deletes the shopcart of customer<customer_id> 204
GET /api/shopcarts/int:customer_id/items Return all the items in customer<customer_id> shopcart lists with query paramter
quantity: the exact quantity of the products to be filtered.
min_quantity: minimum quantity of the product to be filtered
max_quantity: maximum quantity of the product to be filtered
POST /api/shopcarts/int:customer_id/items Adds a new item to the customer<customer_id>'s shopcart 201, 400, 409
GET /api/shopcarts/int:customer_id/items/int:product_id Return detail information about product<product_id> in customer<customer_id> shopcart
PUT /api/shopcarts/int:customer_id/items/int:product_id Update a shop cart item<product_id> for customer<customer_id> 200, 404
DELETE /api/shopcarts/int:customer_id/items/int:product_id Delete a shop cart item<product_id> for customer<customer_id> 200, 404
PUT /api/shopcarts/int:customer_id/clear Clear the shopcart of customer<customer_id>

License

Copyright (c) John Rofrano. All rights reserved.

Licensed under the Apache License. See LICENSE

This repository is part of the NYU masters class: CSCI-GA.2820-001 DevOps and Agile Methodologies created and taught by John Rofrano, Adjunct Instructor, NYU Courant Institute, Graduate Division, Computer Science, and NYU Stern School of Business.