Rales Engine is an api for sales data that returns record, relationship, and business intelligence endpoints.
Ruby Versions and Setup
-
Ruby version 2.4.1
-
Rails version 5.2.3
-
Configuration: Create a project folder for this repo. Move into it and clone this repo into that project folder. After cloning the repo, run
bundle installin the terminal to install gems. -
Database creation:
Runbundle exec rake db:{create, migrate}to set up the database. To import the csv data into the application, runrake import:allin the terminal. This will take some time. -
How to run the test suite
From the terminal, runrspecto run the test files within rales_engine.
To run against the spec harness provided by Turing School, clone the repo into the project folder (adjacent to the clone of rales_engine). Then, within in one terminal window, run the rales_engine on localhost with the commandrails s. In another terminal window, navigate into the spec harness repo and runrake.
Rales Engine is an API for sales data that returns record, relationship, and business intelligence endpoints.
Rales Engine includes six main resources:
- customers
- merchants
- items
- invoices
- invoice_items
- transactions
Each of the six rales_engine resources can be queried through the following api endpoints:
Record Endpoints:
- Index of all resources:
/api/v1/<resource>, e.g./api/v1/merchants - Show a single resource:
/api/v1/<resource>/:id, e.g./api/v1/merchants/1 - Find a resource with a query:
/api/v1/merchants/find?<query_parameter>, e.g./api/v1/merchants/find?name=Schroeder-Jerde - Find all of a resource with a query:
/api/v1/merchants/find_all?<query_parameter>, e.g./api/v1/merchants/find_all?name=Cummings-Thiel - Find a random resource:
api/v1/<resource>/random, e.g.api/v1/merchants/random
Query Parameters for Records:
All records can be queried with id and timestamps created_at and updated_at
- Merchants
name
- Items
namedescriptionunit_pricemerchant_id
- Customers
first_namelast_name
- Invoices
statusmerchant_idcustomer_id
- InvoiceItems
quantityunit_priceinvoice_iditem_id
- Transactions
credit_card_number(this is made up data)credit_card_expiration_dateresultinvoice_id
Relationship Endpoints
Merchants
- GET
/api/v1/merchants/:id/itemsreturns a collection of items associated with that merchant - GET
/api/v1/merchants/:id/invoicesreturns a collection of invoices associated with that merchant from their known orders
Invoices
- GET
/api/v1/invoices/:id/transactionsreturns a collection of associated transactions - GET
/api/v1/invoices/:id/invoice_itemsreturns a collection of associated invoice items - GET
/api/v1/invoices/:id/itemsreturns a collection of associated items - GET
/api/v1/invoices/:id/customerreturns the associated customer - GET
/api/v1/invoices/:id/merchantreturns the associated merchant
Invoice Items
- GET
/api/v1/invoice_items/:id/invoicereturns the associated invoice - GET
/api/v1/invoice_items/:id/itemreturns the associated item
Items
- GET
/api/v1/items/:id/invoice_itemsreturns a collection of associated invoice items - GET
/api/v1/items/:id/merchant returnsthe associated merchant
Transactions
- GET
/api/v1/transactions/:id/invoicereturns the associated invoice
Customers
- GET
/api/v1/customers/:id/invoicesreturns a collection of associated invoices - GET
/api/v1/customers/:id/transactionsreturns a collection of associated transactions
Business Intelligence Endpoints
Merchants
- GET
/api/v1/merchants/most_revenue?quantity=xreturns the top x merchants ranked by total revenue - GET
/api/v1/merchants/revenue?date=x returnsthe total revenue for date x across all merchants - GET
/api/v1/merchants/:id/favorite_customerreturns the customer who has conducted the most total number of successful transactions.
Items
- GET
/api/v1/items/most_revenue?quantity=xreturns the top x items ranked by total revenue generated - GET
/api/v1/items/:id/best_dayreturns the date with the most sales for the given item using the invoice date. If there are multiple days with equal number of sales, return the most recent day.
Customers
- GET
/api/v1/customers/:id/favorite_merchantreturns a merchant where the customer has conducted the most successful transactions
