ethanrossblack / market_money_erb

Market Money API creation project for Turing Mod 3
0 stars 0 forks source link

2. Get One Market #2

Closed ethanrossblack closed 1 year ago

ethanrossblack commented 1 year ago

2. Get One Market

Details:

  1. This endpoint should follow the pattern of GET /api/v0/markets/:id.
  2. If a valid market id is passed in, all market attributes, as well as a vendor_count should be returned.
  3. If an invalid market id is passed in, a 404 status as well as a descriptive error message should be sent back in the response.

    Example 1 😁

Request:

  GET /api/v0/markets/322458
  Content-Type: application/json
  Accept: application/json

Response: status: 200

{
    "data": {
        "id": "322458",
        "type": "market",
        "attributes": {
            "name": "14&U Farmers' Market",
            "street": "1400 U Street NW ",
            "city": "Washington",
            "county": "District of Columbia",
            "state": "District of Columbia",
            "zip": "20009",
            "lat": "38.9169984",
            "lon": "-77.0320505",
            "vendor_count": 1
        }
    }
}

Example 2 😭

Request:

  GET /api/v0/markets/123123123123 (where `123123123123` is an invalid Market id)
  Content-Type: application/json
  Accept: application/json

Response: status: 404

{
    "errors": [
        {
            "detail": "Couldn't find Market with 'id'=123123123123"
        }
    ]
}