A Business Intelligence Focused API. Built from scratch.
Explore the docs »
·
Report Bug
·
Request Feature
- About the Project
- Built With
- Getting Started
- Prerequisites
- Installation
- Usage
- Endpoints
- Roadmap
- License
- Contact
- Acknowledgements
Customer Built Business Class API using using Rails and Ruby
- (Ruby 2.5.1)
- (Rails 5.1.7)
To get a local copy up and running follow these simple steps.
- FastAPI
-
Clone the repo
git clone https://github.com/jobannon/rails_eng.git
-
Setup the Database
bundle exec rails db:drop bundle exec rails db:create bundle exec rails db:migrate bundle exec rails db:seed
-
Populate our API with data using a custom built rake file
rake import:all_import
-
Test Suite Usage
bundle exec rspec
This API is divided into 6 resource tables. All resources are exposed. |
---|
customers |
transactions |
invoices |
merchants |
items |
invoiceitems |
All resource endponts are exposed for an "index" and "show" action
Index
-
Example
GET /api/v1/merchants
-
Usage
GET /api/v1/<resource>
-
Output
{ "data": [ { "id": "1", "type": "merchant", "attributes": { "name": "Mike's Awesome Store", } }, { "id": "2", "type": "merchant", "attributes": { "name": "Store of Fate", } }, { "id": "3", "type": "merchant", "attributes": { "name": "This is the limit of my creativity", } } ] }
Show
-
Example
GET /api/v1/merchants/:id
-
Usage
GET /api/v1/resource
-
Output
{ "data": { "id": "1", "type": "merchant", "attributes": { "name": "Store Name" } } }
-
Usage
GET /api/v1/merchants/find?parameters
Param search resource attribute id based on id name based on name created_at based on table.timestamp updated_at based on table.timestamp -
All queries will return the first record
-
Output
{ "data": { "id": "1", "type": "merchant", "attributes": { "name": "Store Name" } } }
- Very similar to a single finder but will return the complete collection matching the search criteria
sh GET /api/v1/merchants/find_all?parameters
- Returns a random resource within a collection
api/v1/merchants/random
- This was built with
RANDOM
method in SQL
-
Following relationships were built into each resource table and are reflected in the schema
GET request Returns >Merchants GET /api/v1/merchants/:id/items returns a collection of items associated with that merchant GET /api/v1/merchants/:id/items returns a collection of items associated with that merchant GET /api/v1/merchants/:id/invoices returns a collection of invoices associated with that merchant from their known orders >Invoices GET /api/v1/invoices/:id/transactions returns a collection of associated transactions GET /api/v1/invoices/:id/invoice_items returns a collection of associated invoice items GET /api/v1/invoices/:id/items returns a collection of associated items GET /api/v1/invoices/:id/customer returns the associated customer GET /api/v1/invoices/:id/merchant returns the associated merchant >Invoice Items GET /api/v1/invoice_items/:id/invoice returns the associated invoice GET /api/v1/invoice_items/:id/item returns the associated item >Items GET /api/v1/items/:id/invoice_items returns a collection of associated invoice items GET /api/v1/items/:id/merchant returns the associated merchant >Transactions GET /api/v1/transactions/:id/invoice returns the associated invoice >Customers GET /api/v1/customers/:id/invoices returns a collection of associated invoices GET /api/v1/customers/:id/transactions returns a collection of associated transactions
-
Business Intelligence Queries
GET request Returns >All Merchants GET /api/v1/merchants/most_revenue?quantity=x returns the top x merchants ranked by total revenue GET /api/v1/merchants/revenue?date=x returns the total revenue for date x across all merchants >Single Merchant GET /api/v1/merchants/:id/favorite_customer returns the customer who has conducted the most total number of successful transactions >Items GET /api/v1/items/most_revenue?quantity=x returns the top x items ranked by total revenue generated GET /api/v1/items/:id/best_day returns the date with the most sales for the given item using the invoice date. If there are multiple days, return the most recent day >Customers GET /api/v1/customers/:id/favorite_merchant returns a merchant where the customer has conducted the most successful transactions
-
SEE ISSUES
See the open issues for a list of proposed features (and known issues).
Distributed under License. See LICENSE
for more information.
@jtobannon - [email protected]
https://github.com/jobannon/rails_eng
- Turing School of Software and Design (www.turing.io)