Welcome! This guide will help you understand how to interact with the cart controllers for levels 1, 2, and 3. It provides information on the input required for each controller and the corresponding output.
Our application consists of three levels of cart controllers:
- Level 1: Basic cart functionality.
- Level 2: Enhanced cart functionality with delivery fee calculation.
- Level 3: Advanced cart functionality with discounts and delivery fee calculation.
POST /level1/carts/checkout
- articles: Array of article objects containing
id
,name
, andprice
. - carts: Array of cart objects containing
id
anditems
, where each item includesarticle_id
andquantity
. - Payload format: JSON data
- Returns a JSON object with the
carts
key containing an array of carts with their total prices.
POST /level2/carts/checkout
- articles: Array of article objects containing
id
,name
, andprice
. - carts: Array of cart objects containing
id
anditems
, where each item includesarticle_id
andquantity
. - delivery_fees: Optional array of delivery fee objects with transaction volume ranges and prices.
- Payload format: JSON data
- Returns a JSON object with the
carts
key containing an array of carts with their total prices including delivery fees.
POST /level3/carts/checkout
- articles: Array of article objects containing
id
,name
, andprice
. - carts: Array of cart objects containing
id
anditems
, where each item includesarticle_id
andquantity
. - delivery_fees: Optional array of delivery fee objects with transaction volume ranges and prices.
- discounts: Optional array of discount objects with article IDs, type (amount or percentage), and value.
- Payload format: JSON data
- Returns a JSON object with the
carts
key containing an array of carts with their total prices including discounts and delivery fees.
To run the unit tests for the cart controllers, follow these steps:
- Make sure you have Ruby and RSpec installed on your machine.
- Navigate to the project directory in your terminal.
- Run the command
rspec
to execute all unit tests.