It's a solution for the online shop cart.
git clone https://github.com/luchiago/shopping-cart-challenge.git
cd shopping-cart-challenge
ruby -v
The ouput should start with something like ruby 2.6.3
If not, install the right ruby version using asdf (it could take a while):
asdf install ruby 2.6.3
asdf local ruby 2.6.3
Using Bundler
bundle install
rails -v
The ouput should start with something like
rails 6.0.0
rails db:create db:migrate
rails s
Returns json data with all products and cart costs after send products amount
-
URL
/api/v1/cart
-
Method:
PATCH
-
Headers Params Must have a token to identify the user
{ Authorization : string }
-
Data Params
{ cart : { apple : integer, banana : integer, orange: integer } }
-
Success Response:
- Code: 200
- Content:
{ apple : integer, banana : integer, orange: integer, subtotal : integer, shipping : integer, total : integer}
- Code: 200
Returns json data with all products and cart costs
-
URL
/api/v1/cart
-
Method:
GET
-
Headers Params Must have a token to identify the user
{ Authorization : string }
-
Success Response:
- Code: 200
Content:{ apple : integer, banana : integer, orange: integer, subtotal : integer, shipping : integer, total : integer}
- Code: 200
Returns json data with the new coupon id
-
URL
/api/v1/cart
-
Method:
POST
-
Headers Params Must have a token to identify the user
{ Authorization : string }
-
Data Params
{ coupon : { name : string } }
-
Success Response:
- Code: 200
- Content:
{id : integer, name : string, user_id : integer, created_at : string,updated_at : string}
- Code: 200
-
Error Response:
- Code: 400
- Content:
{ message : "invalid" }
- Code: 400
Returns json data with all products and cart costs
-
URL
/api/v1/coupon/:id
-
Method:
DELETE
-
Headers Params Must have a token to identify the user
{ Authorization : string }
-
URL Params
id = integer
-
Success Response:
- Code: 200
- Content:
{id : integer, name : string, user_id : integer, created_at : string,updated_at : string}
- Code: 200
-
Error Response:
- Code: 404
Content:{ message : "not found" }
- Code: 404