Rails Engine is a RESTful API that serves up business intelligence analytics (like revenue across date range and top-selling merchant) to an e-commerce platform that aggregates several merchants.
$ git clone git@github.com:leahriffell/rails_engine.git
# or clone your own fork
$ cd rails_engine
- Ruby 2.5.3
- Rails 5.2.4.4
bundle install
rails db:create
rails db:migrate
rails db:seed
rails s
This is only an API (no frontend view). To access the frontend repo, head to https://github.com/leahriffell/rails_driver.
- Run with $ bundle exec rspec. All tests should be passing.
- All requests sent to
http://localhost:3000/api/v1
# Get all items
GET http://localhost:3000/api/v1/items
# Create new item
POST http://localhost:3000/api/v1/items
# Show 1 item
GET http://localhost:3000/api/v1/items/:id
# Update existing item
PATCH http://localhost:3000/api/v1/items/:id
# Destroy an item
DELETE http://localhost:3000/api/v1/items/:id
# Get all merchants
GET http://localhost:3000/api/v1/merchants
# Create new merchants
POST http://localhost:3000/api/v1/merchants
# Show 1 merchants
GET http://localhost:3000/api/v1/merchants/:id
# Update existing merchants
PATCH http://localhost:3000/api/v1/merchants/:id
# Destroy a merchant
DELETE http://localhost:3000/api/v1/merchants/:id
GET /api/v1/merchants/:id/items
GET /api/v1/items/:id/merchants
-
Can query by: name*, description*, unit_price, merchant_id, created_at, updated_at
-
- search is case insensitive and will also fetch partial matches
# Search for 1 Item
GET /api/v1/items/find?<attribute>=<value>
# Search for all Items that match criteria
GET /api/v1/items/find_all?<attribute>=<value>
- Can query by: name (search is case insensitive and will also fetch partial matches)
# Search for 1 Merchant
GET /api/v1/merchants/find?<attribute>=<value>
# Search for all Merchants that match criteria
GET /api/v1/merchants/find_all?<attribute>=<value>
- Returns a variable number of merchants ranked by total revenue
GET /api/v1/merchants/most_revenue?quantity=x
# x is the number of merchants to be returned
- Returns a variable number of merchants ranked by total number of items sold
GET /api/v1/merchants/most_items?quantity=x
# x is the number of merchants to be returned
- Return the total revenue across all merchants between the given dates
GET /api/v1/revenue?start=<start_date>&end=<end_date>
- Returns the total revenue for a single merchant
GET /api/v1/merchants/:id/revenue
- In ranking endpoints (by revenue, by number of items sold), include merchants that have $0 revenue
- Return as 0 instead of not displaying in result set
- Add sad path tests