This is the spec for the rails engine used for Turing's Backend Module 3.
Rails Engine is a project that exposes the data that powers a mock E-Commerce Application via APIs. In total, there are 14 endpoints exposed for front end developers to consume.
Fork
a copy of the repo to your Github accountClone
the forked repo onto your local computer- Run
bundle
- Run
rails db:{drop,create,migrate,seed}
- Run
rails s
to fire up yourlocalhost:3000
- This project is not currently hosted or deployed. As such, consumption and review of the API endpoints take place only in the
local
environment
- This project is not currently hosted or deployed. As such, consumption and review of the API endpoints take place only in the
-
http://localhost:3000/api/v1/merchants
GET
Get all merchants: Returns all of the current merchant records in the database. Results are defaulted to return 20 merchants per page, however, the user can specify how many merchants they would like returned on each page by manipulating theper_page
query param.
-
http://localhost:3000/api/v1/merchants/{{merchant_id}}
GET
Get one merchant: Returns an individual merchant record, based on the merchant's database id.
-
http://localhost:3000/api/v1/merchants/{{merchant_id}}/items
GET
Get a merchant's items: Returns all items which belong to an individual merchant.
-
http://localhost:3000/api/v1/items
GET
Get all items: Returns all of the current item records in the database. Results are defaulted to return 20 items per page, however, the user can specify how many items they would like returned on each page by manipulating theper_page
query param.
-
http://localhost:3000/api/v1/items/{{item_id}}
GET
Get one item: Returns an individual item record, based on the item's database id.
-
http://localhost:3000/api/v1/items
POST
Create (then delete) one item: Creates an item based on input params and then deletes the created item.
-
http://localhost:3000/api/v1/items/{{item_id}}
PUT
Update one item: Updates an item based on input params.
-
http://localhost:3000/api/v1/items/{{item_id}}/merchant
GET
Get an item's merchant: Returns the merchant record that a given item belongs to.
-
http://localhost:3000/api/v1/merchants/find?name
GET
Find one merchant by name fragment: Returns a merchant record based on aname
query param.
-
http://localhost:3000/api/v1/items/find_all
GET
Find all items by name fragment: Returns all item records based on aname
query param.
-
http://localhost:3000/api/v1/revenue/merchants
GET
Get merchants with most revenue: Returns a quantity of top selling merchants based on their revenue. Revenue is determined bysuccessful transaction result
andshipped invoices
. The user inputs a query param,quantity
, which determines the number of merchants which will be returned.
-
http://localhost:3000/api/v1/merchants/most_items
GET
Get merchants who have sold the most items: Returns a quantity of top selling merchants based on the number of their items which have sold. Items are considered sold when there is asuccessful transaction result
and ashipped invoice
. The user inputs a query param,quantity
, which determines the number of merchants which will be returned.
-
http://localhost:3000/api/v1/revenue/merchants/{{merchant_id}}
GET
Get revenue of a single merchant: Returns the revenue of a single merchant. Revenue is determined bysuccessful transaction result
andshipped invoices
.
-
http://localhost:3000/api/v1/revenue/items
GET
Get items with most revenue: Returns a quantity of top selling items based on the revenue generated by item. Revenue is determined bysuccessful transaction result
andshipped invoices
. The user inputs a query param,quantity
, which determines the number of items which will be returned.