- This is the base repo for the Rails Engine used for Turing's Backend Module 3.
- This is the frontend repo: Rails Driver
- This is our completed repo for Rails Engine
- Navigate here to see the list of possible calls and to try them out!
- This application is an api which exposes data for merchants and their items. It makes use of advanced ActiveRecord quiries to return various different endpoints.
- Rails Driver is the frontend of this project, which holds a spec harness to test call our api.
- The project description is found here
- The project requirements are found here
- Logan Riffell - GitHub
- This project uses a rake task to seed the database from csv files:
rake seed:csv
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
A step by step series of examples that tell you how to get a development env running
-
Clone Rails Engine
-
Clone Rails Driver
-
Install gem packages:
bundle install
-
Setup the database:
rails db:create
rails db:migrate
rake seed:csv
(Run the rake task to import the data from each csv file into the database)
- Be sure you already ran
bundle install
bundle exec rspec spec/requests/api/v1/merchants
ORbundle exec rspec spec/requests/api/v1/items
- To run all tests at once simply run
bundle exec rspec
- run the Rails Engine server with
rails s
- In a new terminal window cd into Rails Driver and run
bundle exec rspec spec/features/harness_spec.rb
- Factory Bot
- Faker
- RSpec
- Shoulda-matchers
- Simplecov
- Capybara
- figaro
- faraday
- json
- fast_jsonapi
- activerecord-reset-pk-sequence
get '/api/v1/items'
responds with all items currently in the databaseget '/api/v1/items/:id'
responds with one item based on it's idpost 'api/v1/items'
creates an item in the databaseput 'api/v1/items/:id'
updates an item in the database based on it's iddelete 'api/v1/items/:id'
deletes an item in the database based on it's id
get '/api/v1/merchants'
responds with all merchants currently in the databaseget '/api/v1/merchants/:id'
responds with one merchant based on it's idpost 'api/v1/merchants'
creates a merchant in the databaseput 'api/v1/merchants/:id'
updates a merchant in the database based on it's iddelete 'api/v1/merchants/:id'
deletes a merchant in the database based on it's id
get '/api/v1/items/:id/merchant'
responds with the merchant that sells the item with that id
get '/api/v1/merchants/:id/items'
responds with a list of items sold by the merchant with that id
get 'api/v1/item/find?:attribute=:value'
responds with the item that has the same or similar :value for the specified :attributeget 'api/v1/item/find_all?:attribute=:value'
responds with all items that have the same or similar :value for the specified :attribute
- :attributes - name, description, unit_price, merchant_id
get 'api/v1/merchants/find?name=Als+Toy+Barn'
responds with the merchant that has the same or similar :value for the specified :attributeget 'api/v1/merchants/find_all?name=barn'
responds with all merchants that have the same or similar :value for the specified :attribute
- :attributes - name
get 'api/v1/merchants/most_revenue?quantity=2'
responds with a list ofquantity
size based on the merchants with the most revenueget 'api/v1/merchants/most_items?quantity=2'
responds with a list ofquantity
size based on the merchants with the most items succsessfully soldget 'api/v1/revenue?start=2020-10-20&end=2020-10-23'
responds with the total revenue earned by all merchants within the dates specifiedget 'api/v1/merchants/:id/revenue'
responds with the total revenue of one merchant based on the id