The Rails Engine project takes in CSV data from the Black Thursday repo and creates a RESTful Rails API that includes record endpoints, relationship endpoints, and business intelligence endpoints.
Clone down the repo:
$ git clone https://github.com/julsfelic/rails_engine.git
Then change into the project directory:
$ cd rails_engine
Let's go ahead and get the database setup:
$ rake db:setup
Then import the CSV data:
$ rake import:all
There is also the option to import only specific subsets of the CSV data:
$ rake import:customers
$ rake import:invoice_items
$ rake import:invoices
$ rake import:items
$ rake import:merchants
$ rake import:transactions
Once the rake task is complete, go ahead and run the test suite to confirm that setup was completed successfully:
$ rspec
To hit our API endpoints let us start up a server:
$ rails s
And using a tool like Postman or cURL we can tell our API to return JSON data. Here is an example endpoint using cURL:
curl -XGET localhost:3000/api/v1/merchants/find_all?name=Cummings-Thiel
This will return a collection of transactions associated with the specific customer. For a full list of all the endpoints reference the official Rails Engine docs
Rails Engine uses RSpec for its test suite. To run the tests:
$ rspec
- Julian Feliciano - Initial work - julsfelic