This project is a JSON API that exposes several kinds of sales data. The original specifications of the project can be found at Original Project's Specifications
- Clone the repo
$ git clone https://github.com/hectorhuertas/rails_engine.git
- Create and migrate the database
$ rake db:setup
- Import the csv files data
$ rake import
- Run the test suite
$ rspec
- Very readable code thanks to following a strict RESTful organization of the multiple endpoints
- 100% Test coverage using SimpleCov
- Factory girl for easier testing
- Used 'responders' gem to facilitate skinny controllers for the API
- Some of the business intelligence queries go through several tables and need several calculations.
Each data category should include an index
action which
renders a JSON representation of all the appropriate records:
GET /api/v1/merchants.json
Each data category should include a show
action which
renders a JSON representation of the appropriate record:
GET /api/v1/merchants/1.json
Each data category should offer find
finders to return a single object representation like this:
GET /api/v1/merchants/find?id=12
Which would find the one merchant with ID 12
. The finder should work with any of the attributes defined on the data type and always be case insensitive.
For example:
GET /api/v1/merchants/find?name=Schroeder-Jerde
Each category should offer find_all
finders like this:
GET /api/v1/merchants/find_all?name=Cummings-Thiel
Which would find all the merchants whose name matches this query.
The finder should work with any of the attributes defined on the data type and always be case insensitive.
api/v1/merchants/random.json
returns a random merchant.
In addition to the direct queries against single resources, we would like to also be able to pull relationship data from the API.
We'll expose these relationships using nested URLs, as outlined in the sections below.
GET /api/v1/merchants/:id/items
returns a collection of items associated with that merchantGET /api/v1/merchants/:id/invoices
returns a collection of invoices associated with that merchant from their known orders
GET /api/v1/invoices/:id/transactions
returns a collection of associated transactionsGET /api/v1/invoices/:id/invoice_items
returns a collection of associated invoice itemsGET /api/v1/invoices/:id/items
returns a collection of associated itemsGET /api/v1/invoices/:id/customer
returns the associated customerGET /api/v1/invoices/:id/merchant
returns the associated merchant
GET /api/v1/invoice_items/:id/invoice
returns the associated invoiceGET /api/v1/invoice_items/:id/item
returns the associated item
GET /api/v1/items/:id/invoice_items
returns a collection of associated invoice itemsGET /api/v1/items/:id/merchant
returns the associated merchant
GET /api/v1/transactions/:id/invoice
returns the associated invoice
GET /api/v1/customers/:id/invoices
returns a collection of associated invoicesGET /api/v1/customers/:id/transactions
returns a collection of associated transactions
GET /api/v1/merchants/most_revenue?quantity=x
returns the topx
merchants ranked by total revenue
GET /api/v1/merchants/:id/revenue
returns the total revenue for that merchant across all transactionsGET /api/v1/merchants/:id/revenue?date=x
returns the total revenue for that merchant for a specific invoice datex
GET /api/v1/merchants/:id/favorite_customer
returns the customer who has conducted the most total number of successful transactions.GET /api/v1/merchants/:id/customers_with_pending_invoices
returns a collection of customers which have pending (unpaid) invoices
GET /api/v1/customers/:id/favorite_merchant
returns a merchant where the customer has conducted the most successful transactions