Rails Engine is an API developed for an E-Commerce Application. The fictitious company utilizes a service-oriented architecture, and therefore utilizes this API as a separate back-end service. This repo exposes the data that powers the company's site through a RESTful JSON API in addition to custom endpoints for Business Intelligence Analytics.
Report Bug
·
Request Feature
- About the Project
- Getting Started
- Usage
- Endpoints
- Index of Resource
- Show Record
- Create Record
- Update Record
- Destroy Record
- Merchant Items Relationship
- Item Merchant Relationship
- Find One Resource By Attribute
- Find Many Resources By Attribute
- Merchants with Most Revenue
- Merchants with Most Items Sold
- Potential Revenue For Unshipped Orders
- Revenue for a Merchant
- Endpoints
Rails Engine exposes business data based on the JSON API Specification via multiple API endpoints allowing other developers access to CRUD functionality for Merchants and Items, obtaining relationship information for Merchants and Items, and exposes more complex endpoints including: merchants with the most revenue, merchants with the most items sold, revenue across a date range, and revenue for a specific merchant.
To use Rails Engine locally, you can fork or clone this repo.
Below are the commands you will need to run in your terminal once you are inside the rails-engine directory.
- Bundle Install
$ bundle exec install
- Set up Database
$ rails db:create
$ rails db:migrate
$ rails db:seed
After running your migrations, your schema will look something like this!
Run rails s
in your terminal and utilize http://localhost:3000/
as the base url in your API client of choice (Postman, etc.)
This endpoint renders a JSON representation of all records of the requested resource.
GET /api/v1/<resource>
where <resource>
is merchants
or items
This endpoint renders a JSON representation of the corresponding record.
GET /api/v1/<resource>/:id
where <resource>
is merchants
or items
This endpoint creates a record and renders a JSON representation of the new record.
POST /api/v1/<resource>
where <resource>
is merchants
or items
This endpoint updates the corresponding record and renders a JSON representation of the updated record.
PATCH /api/v1/<resource>/:id
where <resource>
is merchants
or items
This endpoint destroys the corresponding record and any associated data.
DELETE /api/v1/<resource>/:id
where <resource>
is merchants
or items
The response returns a 204 HTTP status code.
GET /api/v1/merchants/:id/items
- returns all items associated with a merchant.
GET /api/v1/items/:id/merchants
- returns the merchant associated with an item
This endpoint returns a single record that matches a set of criteria. Criteria will be input through query parameters.
GET /api/v1/<resource>/find?<attribute>=<value>
This endpoint returns all records that match a set of criteria. Criteria will be input through query parameters.
GET /api/v1/<resource>/find_all?<attribute>=<value>
This endpoint returns a variable number of merchants ranked by total revenue.
GET /api/v1/merchants/most_revenue?quantity=x
where x is the number of merchants to be returned.
This endpoint returns a variable number of merchants ranked by total number of items sold:
GET /api/v1/merchants/most_items?quantity=x
where x is the number of merchants to be returned.
This endpoint should return the potential revenue across all merchants who have unshipped orders.
GET /api/v1/revenue/unshipped
This endpoint should return the total revenue for a single merchant.
GET /api/v1/merchants/:id/revenue