-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from epintozzi/development
Merge development to master
- Loading branch information
Showing
173 changed files
with
46,139 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
--color | ||
--format=documentation | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
# README | ||
# Rales Engine | ||
|
||
This README would normally document whatever steps are necessary to get the | ||
application up and running. | ||
This project is a JSON API which exposes the SalesEngine data schema. | ||
|
||
Things you may want to cover: | ||
Project details can be found here: [Rales Engine](http://backend.turing.io/module3/projects/rails_engine) | ||
|
||
* Ruby version | ||
Ruby Version: 2.3.1 | ||
<br> | ||
Rails Version: 5.0.0.1 | ||
|
||
* System dependencies | ||
#### Setup | ||
|
||
* Configuration | ||
To run this project: | ||
|
||
* Database creation | ||
``` | ||
git clone [email protected]:epintozzi/rales_engine.git | ||
cd rales_engine | ||
bundle install | ||
rake db:create db:migrate | ||
rake populate_database:populate_all | ||
``` | ||
Populating the database may take a few minutes, so please be patient. | ||
|
||
* Database initialization | ||
#### Testing | ||
|
||
* How to run the test suite | ||
This project uses RSpec for testing and can be run with the command `rspec` | ||
|
||
* Services (job queues, cache servers, search engines, etc.) | ||
|
||
* Deployment instructions | ||
|
||
* ... | ||
This project also employs a Spec Harness. More info on the spec harness can be found here: [Rales Engine Spec Harness](https://github.com/turingschool/rales_engine_spec_harness) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Api::V1::CustomerRandomController < ApplicationController | ||
|
||
def show | ||
random = Customer.all.count | ||
render json: Customer.find(rand(random)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class Api::V1::CustomerSearchController < ApplicationController | ||
|
||
def index | ||
render json: Customer.where(customer_params) | ||
end | ||
|
||
def show | ||
render json: Customer.find_by(customer_params) | ||
end | ||
|
||
private | ||
|
||
def customer_params | ||
params.permit(:id, :first_name, :last_name, :created_at, :updated_at) | ||
|
||
end | ||
|
||
end |
8 changes: 8 additions & 0 deletions
8
app/controllers/api/v1/customers/favorite_merchants_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Api::V1::Customers::FavoriteMerchantsController < ApplicationController | ||
|
||
def index | ||
customer = Customer.find(params[:customer_id]) | ||
render json: customer.favorite_merchant | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Customers::InvoicesController < ApplicationController | ||
|
||
def index | ||
render json: Customer.find(params[:customer_id]).invoices | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Customers::TransactionsController < ApplicationController | ||
|
||
def index | ||
render json: Customer.find(params[:customer_id]).transactions | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Api::V1::CustomersController < ApplicationController | ||
|
||
def index | ||
render json: Customer.all | ||
end | ||
|
||
def show | ||
render json: Customer.find(params[:id]) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Api::V1::InvoiceItemRandomController < ApplicationController | ||
|
||
def show | ||
random = InvoiceItem.all.count | ||
render json: InvoiceItem.find(rand(random)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Api::V1::InvoiceItemSearchController < ApplicationController | ||
|
||
def index | ||
if params[:unit_price] | ||
render json: InvoiceItem.where(unit_price: unit_price) | ||
else | ||
render json: InvoiceItem.where(invoice_item_params) | ||
end | ||
end | ||
|
||
def show | ||
if params[:unit_price] | ||
render json: InvoiceItem.find_by(unit_price: unit_price) | ||
else | ||
render json: InvoiceItem.find_by(invoice_item_params) | ||
end | ||
end | ||
|
||
private | ||
|
||
def invoice_item_params | ||
params.permit(:id, :quantity, :item_id, :invoice_id, :unit_price, :created_at, :updated_at) | ||
end | ||
|
||
def unit_price | ||
(params[:unit_price].to_d * 100).to_i | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::InvoiceItems::InvoicesController < ApplicationController | ||
|
||
def index | ||
render json: InvoiceItem.find(params[:invoice_item_id]).invoice | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::InvoiceItems::ItemsController < ApplicationController | ||
|
||
def index | ||
render json: InvoiceItem.find(params[:invoice_item_id]).item | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Api::V1::InvoiceItemsController < ApplicationController | ||
|
||
def index | ||
render json: InvoiceItem.all | ||
end | ||
|
||
def show | ||
render json: InvoiceItem.find(params[:id]) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Api::V1::InvoiceRandomController < ApplicationController | ||
|
||
def show | ||
random = Invoice.all.count | ||
render json: Invoice.find(rand(random)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Api::V1::InvoiceSearchController < ApplicationController | ||
|
||
def index | ||
render json: Invoice.where(invoice_params) | ||
end | ||
|
||
def show | ||
render json: Invoice.find_by(invoice_params) | ||
end | ||
|
||
private | ||
|
||
def invoice_params | ||
params.permit(:id, :merchant_id, :customer_id, :status, :created_at, :updated_at) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Invoices::CustomersController < ApplicationController | ||
|
||
def index | ||
render json: Invoice.find(params[:invoice_id]).customer | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Invoices::InvoiceItemsController < ApplicationController | ||
|
||
def index | ||
render json: Invoice.find(params[:invoice_id]).invoice_items | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Invoices::ItemsController < ApplicationController | ||
|
||
def index | ||
render json: Invoice.find(params[:invoice_id]).items | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Invoices::MerchantsController < ApplicationController | ||
|
||
def index | ||
render json: Invoice.find(params[:invoice_id]).merchant | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Invoices::TransactionsController < ApplicationController | ||
|
||
def index | ||
render json: Invoice.find(params[:invoice_id]).transactions | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Api::V1::InvoicesController < ApplicationController | ||
|
||
def index | ||
render json: Invoice.all | ||
end | ||
|
||
def show | ||
render json: Invoice.find(params[:id]) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Api::V1::ItemRandomController < ApplicationController | ||
|
||
def show | ||
random = Item.all.count | ||
render json: Item.find(rand(random)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Api::V1::ItemSearchController < ApplicationController | ||
|
||
def index | ||
if params[:unit_price] | ||
render json: Item.where(unit_price: unit_price) | ||
else | ||
render json: Item.where(item_params) | ||
end | ||
end | ||
|
||
def show | ||
if params[:unit_price] | ||
render json: Item.find_by(unit_price: unit_price) | ||
else | ||
render json: Item.find_by(item_params) | ||
end | ||
end | ||
|
||
private | ||
|
||
def item_params | ||
params.permit(:id, :name, :description, :unit_price, :merchant_id, :created_at, :updated_at) | ||
end | ||
|
||
def unit_price | ||
(params[:unit_price].to_d * 100).to_i | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Api::V1::Items::BestDayController < ApplicationController | ||
|
||
def index | ||
item = Item.find(params[:item_id]) | ||
|
||
render json: item.best_day, serializer: Api::V1::Items::BestDaySerializer | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Items::InvoiceItemsController < ApplicationController | ||
|
||
def index | ||
render json: Item.find(params[:item_id]).invoice_items | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::V1::Items::MerchantsController < ApplicationController | ||
|
||
def index | ||
render json: Item.find(params[:item_id]).merchant | ||
end | ||
|
||
end |
Oops, something went wrong.