The Rails Engine API allows you to query metadata and perform business analytics on merchants, invoices, invoice items, items, customers, and transactions. The return format for all endpoints is JSON.
All URLs referenced in this documentation have the following base:
This section will help you get started with our API.
You're going to need:
- Ruby, version 2.3.1 or newer
- Bundler
-
Fork this repository on Github.
-
Clone your forked repository (not our original one) to your hard drive with
git clone https://github.com/mimilettd/rails_engine
-
cd rails_engine
-
Run
bundle
-
Create, migrate, and seed your database:
rake db:create
rake db:migrate
rake import
-
Run
rspec
to confirm passing tests. -
Initialize server locally by running
rails s
Merchant Record Endpoints
GET /api/v1/merchants.json
GET /api/v1/merchants/1.json
GET /api/v1/merchants/find_all
GET /api/v1/merchants/find?
GET /api/v1/merchants/random.json
Note: For find_all
and find
, you can use the following search params: id
, name
, created_at
, updated_at
.
Sample Response for /api/v1/merchants/find_all?name=Cummings-Thiel
:
[{"id":4,"name":"Cummings-Thiel"}]
Merchant Relationship Endpoints
GET /api/v1/merchants/:id/items
GET /api/v1/merchants/:id/invoices
Merchant Business Intelligence Endpoints
GET /api/v1/merchants/most_revenue?quantity=x
GET /api/v1/merchants/most_items?quantity=x
GET /api/v1/merchants/revenue?date=x
GET /api/v1/merchants/:id/revenue
GET /api/v1/merchants/:id/revenue?date=x
GET /api/v1/merchants/:id/favorite_customer
GET /api/v1/merchants/:id/customers_with_pending_invoices
Transactions Record Endpoints
GET /api/v1/transactions.json
GET /api/v1/transactions/1.json
GET /api/v1/transactions/find_all?
GET /api/v1/transactions/find?
GET /api/v1/transactions/random.json
Note: For find_all
and find
, you can use the following search params: id
, invoice_id
, credit_card_number
, result
, created_at
, updated_at
.
Transactions Relationship Endpoints
GET /api/v1/transactions/:id/invoice
Customer Record Endpoints
GET /api/v1/customers.json
GET /api/v1/customers/1.json
GET /api/v1/customers/find_all
GET /api/v1/customers/find?
GET /api/v1/customers/random.json
Note: For find_all
and find
, you can use the following search params: id
, first_name
, last_name
, created_at
, updated_at
.
Customer Relationship Endpoints
GET /api/v1/customers/:id/invoices
GET /api/v1/customers/:id/transactions
Customer Business Intelligence Endpoints
GET /api/v1/customers/:id/favorite_merchant
Invoice Record Endpoints
GET /api/v1/invoices.json
GET /api/v1/invoices/1.json
GET /api/v1/invoices/find_all
GET /api/v1/invoices/find?
GET /api/v1/invoices/random.json
Note: For find_all
and find
, you can use the following search params: id
, customer_id
, merchant_id
, status
, created_at
, updated_at
.
Invoice Relationship Endpoints
GET /api/v1/invoices/:id/transactions
GET /api/v1/invoices/:id/invoice_items
GET /api/v1/invoices/:id/items
GET /api/v1/invoices/:id/customer
GET /api/v1/invoices/:id/merchant
Transaction Record Endpoints
GET /api/v1/transactions.json
GET /api/v1/transactions/1.json
GET /api/v1/transactions/find_all
GET /api/v1/transactions/find?
GET /api/v1/transactions/random.json
Note: For find_all
and find
, you can use the following search params: id
, invoice_id
, credit_card_number
, result
, created_at
, updated_at
.
Transaction Relationship Endpoints
GET /api/v1/transactions/:id/invoice
Transaction Record Endpoints
GET /api/v1/transactions.json
GET /api/v1/transactions/1.json
GET /api/v1/transactions/find_all
GET /api/v1/transactions/find?
GET /api/v1/transactions/random.json
Customer Record Endpoints
GET /api/v1/customers.json
GET /api/v1/customers/1.json
GET /api/v1/customers/find_all
GET /api/v1/customers/find?
GET /api/v1/customers/random.json
Note: For find_all
and find
, you can use the following search params: id
, first_name
, last_name
, created_at
, updated_at
.
Customer Relationship Endpoints
GET /api/v1/customers/:id/invoices
GET /api/v1/customers/:id/transactions
Customer Business Intelligence Endpoints
GET /api/v1/customers/:id/favorite_merchant
This is the first paired project of Module 3 at the Turing School. More information on this project can be found here.