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/itemsreturns a collection of items associated with that merchantGET /api/v1/merchants/:id/invoicesreturns a collection of invoices associated with that merchant from their known orders
GET /api/v1/invoices/:id/transactionsreturns a collection of associated transactionsGET /api/v1/invoices/:id/invoice_itemsreturns a collection of associated invoice itemsGET /api/v1/invoices/:id/itemsreturns a collection of associated itemsGET /api/v1/invoices/:id/customerreturns the associated customerGET /api/v1/invoices/:id/merchantreturns the associated merchant
GET /api/v1/invoice_items/:id/invoicereturns the associated invoiceGET /api/v1/invoice_items/:id/itemreturns the associated item
GET /api/v1/items/:id/invoice_itemsreturns a collection of associated invoice itemsGET /api/v1/items/:id/merchantreturns the associated merchant
GET /api/v1/transactions/:id/invoicereturns the associated invoice
GET /api/v1/customers/:id/invoicesreturns a collection of associated invoicesGET /api/v1/customers/:id/transactionsreturns a collection of associated transactions
GET /api/v1/merchants/most_revenue?quantity=xreturns the topxmerchants ranked by total revenue
GET /api/v1/merchants/:id/revenuereturns the total revenue for that merchant across all transactionsGET /api/v1/merchants/:id/revenue?date=xreturns the total revenue for that merchant for a specific invoice datexGET /api/v1/merchants/:id/favorite_customerreturns the customer who has conducted the most total number of successful transactions.GET /api/v1/merchants/:id/customers_with_pending_invoicesreturns a collection of customers which have pending (unpaid) invoices
GET /api/v1/customers/:id/favorite_merchantreturns a merchant where the customer has conducted the most successful transactions