rails-engine's Issues
Find Endpoint for Merchants
In addition to the standard ReST endpoints, you will need to build “find” endpoints for both Items and Merchants.
Single Finders
-
GET /api/v1/<resource>/find?<attribute>=<value>
- This endpoint should return a single record that matches a set of criteria. Criteria will be input through query parameters.
- Should work for any attribute of the corresponding resource including the updated_at and created_at timestamps.
- find partial matches for strings and be case insensitive, for example, a request to
GET /api/v1/merchants/find?name=ring
would match a merchant with the name Turing and a merchant with the name Ring World.
Multi-Finders
- This endpoint should return all records that match a set of criteria. Criteria will be input through query parameters.
-
GET /api/v1/<resource>/find_all?<attribute>=<value>
- This endpoint should follow all of the same requirements for matching as the Single Finder endpoints.
BI Endpoints: Revenue for a Merchant
- This endpoint should return the total revenue for a single merchant.
- The URI should follow this pattern:
GET /api/v1/merchants/:id/revenue
BI Endpoints: Merchants with Most Items Sold
- This endpoint should return a variable number of merchants ranked by total number of items sold
- The URI should follow this pattern:
GET /api/v1/merchants/most_items?quantity=x
where x is the number of merchants to be returned.
Create Tables
Create tables and tests for:
Customers
-
Fields:
- first_name: string
- last_name: string
- created_at: datetime
- updated_at: datetime
-
Relationships:
- has_many invoices
Invoices
-
Fields:
- customer_id
- merchant_id
- status (enum: shipped)
- created_at: datetime
- updated_at: datetime
-
Relationships
- belongs_to customer
- belongs_to merchant
- has_many transactions
- has_many invoice_items
- has_many items, through invoice_items
Items
-
Fields:
- name: string
- description: string
- unit_price: integer
- merchant_id
- created_at: datetime
- updated_at: datetime
-
Relationships:
- belongs_to merchant
- has_many invoice_items
- has_many invoices, through invoice_items
Invoice Items
-
Fields:
- item_id
- invoice_id
- quantity: integer
- created_at: datetime
- updated_at: datetime
-
Relationships:
- belongs_to invoice
- belongs_to item
Merchants
-
Fields:
- name: string
- created_at: datetime
- updated_at: datetime
-
Relationships:
- has_many invoices
Transactions
-
Fields:
- invoice_id
- credit_card_number: string
- credit_card_expiration_date: datetime - not required
- result (enum: success, failed)
- created_at: datetime
- updated_at: datetime
-
Relationships:
- belongs_to invoice
Create Relationship Endpoints
These endpoints should show related records. The relationship endpoints you should expose are:
-
GET /api/v1/merchants/:id/items
- return all items associated with a merchant. -
GET /api/v1/items/:id/merchants
- return the merchant associated with an item
Complete One Extension
Business Intelligence Endpoints
HINT: Invoices must have a successful transaction and shipped to the customer to be considered as revenue.
- [Merchants with Most Revenue]
- [Merchants with Most Items Sold]
- [Revenue across Date Range]
- [Revenue for a Merchant]
BI Endpoints: Revenue across Date Range
- This endpoint should return the total revenue across all merchants between the given dates.
- The URI should follow this pattern:
GET /api/v1/revenue?start=<start_date>&end=<end_date>
Create Item API Endpoints
All endpoints should follow these technical expectations:
- All endpoints should be fully tested. The Rails Driver Spec Harness is not a substitute for writing your own tests.
- All endpoints will expect to return JSON data
- All endpoints should be exposed under an api and version (v1) namespace (e.g. /api/v1/merchants)
- API will be compliant with the JSON API spec
ReST Endpoints
- Index of Resource (
GET /api/v1/<resource>
) - Show Record (
GET /api/v1/<resource>/:id
) - Create Record (
POST /api/v1/<resource>
) - Update Record (
PATCH /api/v1/<resource>/:id
) - Destroy Record
- [ ] Destroys corresponding record and any
associated data (merchant and their items)
- [ ] Sends a 204 HTTP status code
Create ReadMe
Data Importing
- Replace
db/seeds.rb
with given content - Create migration files for the 5 tables created by
pg_restore
(merchants, customers, invoices, invoice_items, transactions) - Import the CSV data into the Items table
- Create a migration file for the Items table
Once items.csv
is finished importing in db/seeds.rb
:
- Add instructions in that file to use ActiveRecord to reset the Primary Key sequences in PostgreSQL for all 6 tables
Find Endpoint for Items
In addition to the standard ReST endpoints, you will need to build “find” endpoints for both Items and Merchants.
Single Finders
-
GET /api/v1/<resource>/find?<attribute>=<value>
- This endpoint should return a single record that matches a set of criteria. Criteria will be input through query parameters.
- Should work for any attribute of the corresponding resource including the updated_at and created_at timestamps.
- find partial matches for strings and be case insensitive, for example, a request to
GET /api/v1/merchants/find?name=ring
would match a merchant with the name Turing and a merchant with the name Ring World.
Multi-Finders
- This endpoint should return all records that match a set of criteria. Criteria will be input through query parameters.
-
GET /api/v1/<resource>/find_all?<attribute>=<value>
- This endpoint should follow all of the same requirements for matching as the Single Finder endpoints.
BI Endpoint: Merchants with Most Revenue
- This endpoint should return a variable number of merchants ranked by total revenue.
- The URI should follow this pattern:
GET /api/v1/merchants/most_revenue?quantity=x
where x is the number of merchants to be returned.
Sad Paths
- Flash messages/error messages built in
Create Merchant API Endpoints
All endpoints should follow these technical expectations:
- All endpoints should be fully tested. The Rails Driver Spec Harness is not a substitute for writing your own tests.
- All endpoints will expect to return JSON data
- All endpoints should be exposed under an api and version (v1) namespace (e.g. /api/v1/merchants)
- API will be compliant with the JSON API spec
ReST Endpoints
- Index of Resource (
GET /api/v1/<resource>
) - Show Record (
GET /api/v1/<resource>/:id
) - Create Record (
POST /api/v1/<resource>
) - Update Record (
PATCH /api/v1/<resource>/:id
) - Destroy Record
- [ ] Destroys corresponding record and any
associated data (merchant and their items)
- [ ] Sends a 204 HTTP status code
Setup
- Add the following gems:
- Pry
- FactoryBot
- Faker
- SimpleCov
- ShouldaMatchers
- Database Cleaner
- fast_jsonapi
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.