The orders resource is a collection of order items where each item represents a product, its quantity, and its price. We implement a subordinate REST API to place order items into the order collection (e.g., /orders/{id}/ items). We also associate the order with a customer through its customer id.
Order API
-
/orders : This is the API that handles orders. The order has the following fields:
id, customer_id, address, status, [items]
-
/orders/{id}/items : This is the API that handles items inside an order. Items have the following field:
item_id, order_id, quantity, price, item_name
dev: https://nyu-order-service-sum21.us-south.cf.appdomain.cloud/
prod: https://nyu-order-service-sum21-prod.us-south.cf.appdomain.cloud/
- Install Vagrant, VirtualBox/Docker.
- Clone this repository.
Use the provided Vagrantfile
to start a virtual machine, and start the server using the Procfile
vagrant up
vagrant ssh
cd /vagrant/
cp dot-env-example .env
source .env
honcho start
The server should be visible on your local machine at http://0.0.0.0:5000
GET /orders
- returns a list of all of the orders. Takescustomer_id
anditem
for queries.GET /orders/<int:order_id>
- returns an order with the id oforder_id
or throws aNotFound
exception if it doesn't existPOST /orders
- adds an order and returns the added orderPUT /orders/<int:order_id>
- update the order with id oforder_id
or throws aNotFound
exception if it doesn't existPOST /orders/<int:order_id>/items
- adds an item to the order with id oforder_id
and return the added item or404
if the order doesn't existDELETE /orders/<int:order_id>
- deletes the order with id oforder_id
if it exists and returns a204
regardless of whether an actually deletion was performedDELETE /orders/<int:order_id>/items/<int:item_id>
- deletes the item with id ofitem_id
in the order with id oforder_id
. It returns a404
if either the order or the item doesn't exist.PUT /orders/<int:order_id>/cancel
- cancels the order with id oforder_id
. Returns200
for successful cancelling, returns404
for orders not exist, returns409
if the order in statusCompleted/Returned
.
To run unit tests with coverage:
- Logging into the VM and navigating to
/vagrant/
- Run
nosetests
To run integration test:
- Run
honcho start
after logging into the VM and navigating to/vagrant/
- In a separate terminal, navigate to
/vagrant/
and runbehave
Please assign yourself a user story from the top of "Sprint Backlog" and move it the "In Progress" column. Once you finish implementing the story on the local feature branch, push the branch and start a Pull Request. Please make sure there are no pending change requests and at least one person has approved the PR before merging. Please always use the "Squash and Merge" option