This repository is a demo of api rest with Rails
- Ruby 2.5+
- Sqlite
git clone https://github.com/madeindjs/market_place_api_6
cd market_place_api_6
bundle install
rake db:create
rake db:migrate
Before use api create user and obtain his token. Use this token for every action on endpoint
curl -X POST -d 'user[email]=toto@toto.fr' -d 'user[password]=toto1234' localhost:3000/api/v1/users
curl -X POST -d 'user[email]=toto@toto.fr' -d 'user[password]=toto1234' localhost:3000/api/v1/tokens
export TKN="eyJhbG...WqaXAcnE" # from /api/v1/tokens
curl -X POST -H "Authorization: $TKN" -d "product[title]=Bag" -d "product[price]=10" localhost:3000/api/v1/products
curl -X PATCH -H "Authorization: $TKN" -d "product[published]=true" -d "product[quantity]=2" localhost:3000/api/v1/products/19
curl -H "Authorization: $TKN" localhost:3000/api/v1/products
curl -X DELETE -H "Authorization: $TKN" localhost:3000/api/v1/products/19
export TKN="eyJhbG...WqaXAcnE" # from /api/v1/tokens
curl -X POST -H "Authorization: $TKN" -d "order[product_ids_and_quantities][][product_id]=20" -d "order[product_ids_and_quantities][][quantity]=1" localhost:3000/api/v1/orders
curl -H "Authorization: $TKN" localhost:3000/api/v1/orders
curl -H "Authorization: $TKN" localhost:3000/api/v1/orders/7