Rails Engine is a Ruby on Rails API built to serve as the backend for Rails Driver
To run Rails Engine locally, you can fork this repo and clone it, or clone this repo with:
git clone https://github.com/ETBassist/rails_engine.git
- Ruby 2.5.3
- Ruby on Rails 5.2.4.4
From the Command Line, after cloning this repo:
cd rails_engine
to go into the rails_engine directory- Run
bundle install
to install dependencies - Run
bundle exec rake data:import
to create database and import data (Note: You will see a warning when running this command that data may be deleted. This is fine unless you've already added data to the database) - You should now be able to run
bundle exec rspec
to see 58 passing tests - Run
rails s
to start up the Rails Server
You should now be able to visit any of the endpoints below by prefacing them with localhost:3000 to see the raw JSON response, or by using a client like Postman.
You may also clone Rails Driver into the same parent directory and see the front end in action.
For example responses and more details on each of these endpoints see ENDPOINTS.md
Available resources: merchants
or items
GET /api/v1/<resource>
Returns a JSON response of all records of the requested resource
GET /api/v1/<resource>/:id
Returns a JSON response of a single record matching the given id\
POST /api/v1/<resource>
Creates a new record of the specified resource
PATCH /api/v1/<resource>/:id
Updates the value of the specified resource and returns a JSON response containing the new attributes
DELETE /api/v1/<resource>/:id
Deletes the resource with a matching id. Will only return a status of 204 (No Content)
GET /api/v1/merchants/:id/items
ORGET /api/v1/items/:id/merchants
Same return as index of a resource, but will return records associated with the merchant or item matching the given id
GET /api/v1/<resource>/find?<attribute>=<value>
Search for a particular resource with an attribute containing the value given; will attempt to find partial and case-insensitive matches if the attribute supplied is stored as a string.
GET /api/v1/<resource>/find_all?<attribute>=<value>
Search for multiples of a particular resource with an attribute containing the value given; will attempt to find partial and case-insensitive matches if the attribute supplied is stored as a string.
GET /api/v1/merchants/most_revenue?quantity=x
Will return
x
number of merchants ordered by revenue that merchant has earned.
GET /api/v1/merchants/most_items?quantity=x
Will return
x
number of merchants ordered by items that merchant has sold.
GET /api/v1/revenue?start=<start_date>&end=<end_date>
Returns the sum of all revenue made between the specified dates.
GET /api/v1/merchants/:id/revenue
Returns the sum of all revenue a particular merchant with an id matching the one given has made.