Rails Engine is a JSON API built with Ruby on Rails and Active Record. There are a variety of endpoints on Etsy merchant and customer data.
Please run the following commands in order to run the API locally on your machine.
git clone git@github.com:adamhundley/rails_engine.git
cd rails_engine
bundle
rake db:create db:migrate
rake db:load_csv
-
Run the test suite with the command
rspec
-
Fire up the server locally with the command
rails s
-
Navigate to
localhost:3000/api/v1/:endpoint
on your browser
To run the spec harness do the following
git clone git@github.com:turingschool/rales_engine_spec_harness.git
cd rales_engine_spec_harness
bundle exec rake
/merchants
/customers
/items
/invoices
/invoice_items
/transactions
Each data category includes an index
action which
renders a JSON representation of all the appropriate records:
GET /api/v1/merchants.json
Each data includes a show
action which
renders a JSON representation of the appropriate record:
GET /api/v1/merchants/1.json
Each data category offers 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 offers 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 works with any of the attributes defined on the data type and always be case insensitive.
api/v1/merchants/random.json
returns a random merchant.
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 revenueGET /api/v1/merchants/most_items?quantity=x
returns the topx
merchants ranked by total number of items soldGET /api/v1/merchants/revenue?date=x
returns the total revenue for datex
across all merchants
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/items/most_revenue?quantity=x
returns the topx
items ranked by total revenue generatedGET /api/v1/items/most_items?quantity=x
returns the topx
item instances ranked by total number soldGET /api/v1/items/:id/best_day
returns the date with the most sales for the given item using the invoice date
GET /api/v1/customers/:id/favorite_merchant
returns a merchant where the customer has conducted the most successful transactions