Work through as many of the following endpoints as you can/would like:
-
Update your
GET /api/v0/vendors/:id
such that it returns an attribute,states_sold_in
, that lists the states that Vendor sells in. -
If a Vendor only sells at Markets in one state, the data type of the
states_sold_in
key should still be an array.Request:
GET /api/v0/vendors/54876 Content-Type: application/json Accept: application/json
Response:
status: 200
{ "data": { "id": "54876", "type": "vendor", "attributes": { "name": "The Sourdough Queen", "description": "This vendor bakes a variety of artisanal breads using sourdough starter, from crusty baguettes to hearty whole wheat loaves.", "contact_name": "Kasi Greenholt", "contact_phone": "(172) 129-4294", "credit_accepted": true, "states_sold_in": ["California","Nevada"] } } }
-
The URI should follow this pattern:
GET /api/v0/vendors/multiple_states
-
The response should include a list of vendors that sell at Markets in more than one state.
-
To make it a little extra spicy, you might try ordering the vendors by number of states sold in.
Request:
GET /api/v0/vendors/54876 Content-Type: application/json Accept: application/json
Response:
status: 200
{ "results": 56 "data": [ { "id": "54876", "type": "vendor", "attributes": { "name": "The Sourdough Queen", "description": "This vendor bakes a variety of artisanal breads using sourdough starter, from crusty baguettes to hearty whole wheat loaves.", "contact_name": "Kasi Greenholt", "contact_phone": "(172) 129-4294", "credit_accepted": true, "states_sold_in": ["California","Nevada"] } }, { "id": "54949", "type": "vendor", "attributes": { "name": "The Handmade Candle Company", "description": "This vendor sells handmade candles made from natural waxes and essential oils.", "contact_name": "Zachariah Emmerich", "contact_phone": "609.634.9167", "credit_accepted": true, "states_sold_in": ["Ohio", "Pennsylvania"] } }, ... ... ] }
-
The URI should follow this pattern:
GET /api/v0/vendors/popular_states
-
The response should return a list of states, in order of total number of vendors that sell at Markets in that state.
-
A little extra: add a
limit
parameter so a client can search for a certain number of top states. (api/v0/vendors/popular_states?limit=5
)Request:
GET /api/v0/vendors/popular_states?limit=5 Content-Type: application/json Accept: application/json
Response:
status: 200
{ "data": [ { "state": "California", "number_of_vendors": 152 }, { "state": "New York", "number_of_vendors": 134 }, { "state": "Massachusetts", "number_of_vendors": 70 }, { "state": "Michigan", "number_of_vendors": 68 }, { "state": "Ohio", "number_of_vendors": 66 }, ... ...
- The URI should follow this pattern:
GET /api/v0/vendors?state=<state>
- The vendors returned should be ordered in order of their popularity.
- popularity is determined by how many Markets that vendor sells at.
-
Note: The example response does not show the
states_sold_in
attribute. If you'd like to add that in, you can.Request:
GET /api/v0/vendors?state=Alabama Content-Type: application/json Accept: application/json
Response:
status: 200
{ "data": [ { "id": "55406", "type": "vendor", "attributes": { "name": "Olive My Heart", "description": "Artisanal olive oils and vinegars", "contact_name": "Lyndia Kutch", "contact_phone": "1-495-066-9447", "credit_accepted": false } }, { "id": "56153", "type": "vendor", "attributes": { "name": "Rainbow Knits", "description": "Vibrantly colored knitwear for all ages.", "contact_name": "Hilton Pacocha", "contact_phone": "1-267-788-2536", "credit_accepted": true, } }, { "id": "55400", "type": "vendor", "attributes": { "name": "Pretzel Perfect", "description": "Soft pretzels and dipping sauces", "contact_name": "Rafael Bogisich", "contact_phone": "1-720-033-3107", "credit_accepted": false, } }, ... ... ] }