megroth2 / rails_engine Goto Github PK
View Code? Open in Web Editor NEWMod 3 - Week 2 - Pair Project
Mod 3 - Week 2 - Pair Project
This endpoints will follow the same rules as the “find” endpoint.
The JSON response will always be an array of items, even if zero matches or only one match is found.
It should not return a 404 if no matches are found.
Example JSON response for GET /api/v1/merchants/find_all?name=ring
:
{
"data": [
{
"id": "4",
"type": "merchant",
"attributes": {
"name": "Ring World"
}
},
{
"id": "1",
"type": "merchant",
"attributes": {
"name": "Turing School"
}
}
]
}
This endpoint should:
POST /api/v1/items
{
"name": "value1",
"description": "value2",
"unit_price": 100.99,
"merchant_id": 14
}
Example JSON response for the Item resource:
{
"data": {
"id": "16",
"type": "item",
"attributes": {
"name": "Widget",
"description": "High quality widget",
"unit_price": 100.99,
"merchant_id": 14
}
}
}
get the merchant data for a given item ID
The relationship endpoint you should expose is: GET /api/v1/items/:id/merchant
This endpoint should:
GET /api/v1/<resource>/:id
Example JSON response for the Item resource:
{
"data": {
"id": "1",
"type": "item",
"attributes": {
"name": "Super Widget",
"description": "A most excellent widget of the finest crafting",
"unit_price": 109.99
}
}
}
Note that the unit_price is sent as numeric data, and not string data.
This endpoint should:
GET /api/v1/<resource>/:id
Example JSON response for the Item resource:
{
"data": {
"id": "1",
"type": "item",
"attributes": {
"name": "Super Widget",
"description": "A most excellent widget of the finest crafting",
"unit_price": 109.99
}
}
}
Note that the unit_price is sent as numeric data, and not string data.
This “index” endpoint should:
GET /api/v1/<resource>
Example JSON response for the Merchant resource:
{
"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",
}
}
]
}
Install SimpleCov, rspec-rails, pry, etc.
get all items for a given merchant ID
The relationship endpoint you should expose is: GET /api/v1/merchants/:id/items
This endpoint should:
PATCH /api/v1/items/:id
{
"name": "value1",
"description": "value2",
"unit_price": 100.99,
"merchant_id": 7
}
Example JSON response for the Item resource:
{
"data": {
"id": "1",
"type": "item",
"attributes": {
"name": "New Widget Name",
"description": "High quality widget, now with more widgety-ness",
"unit_price": 299.99,
"merchant_id": 7
}
}
}
This endpoint should:
204
HTTP status code204
on its own if you just .destroy the object)This endpoint should:
?name=ring
and it will search the name
field in the database tablename
query parameter should require the database to do a case-insensitive search for text fields
Valid examples:
GET /api/v1/merchants/find?name=Mart
GET /api/v1/items/find?name=ring
GET /api/v1/items/find?min_price=50
GET /api/v1/items/find?max_price=150
GET /api/v1/items/find?max_price=150&min_price=50
Invalid examples:
GET /api/v1/<resource>/find
- parameter cannot be missingGET /api/v1/<resource>/find?name=
- parameter cannot be emptyGET /api/v1/items/find?name=ring&min_price=50
- cannot send both name and min_priceGET /api/v1/items/find?name=ring&max_price=50
- cannot send both name and max_priceGET /api/v1/items/find?name=ring&min_price=50&max_price=250
- cannot send both name and min_price and max_priceExample JSON response for GET /api/v1/merchants/find?name=ring
:
{
"data": {
"id": 4,
"type": "merchant",
"attributes": {
"name": "Ring World"
}
}
}
This "index” endpoint should:
GET /api/v1/<resource>
Example JSON response for the Merchant resource:
{
"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",
}
}
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.