ethanrossblack / market_money_erb

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

11. Get Cash Dispensers Near a Market #11

Open ethanrossblack opened 1 year ago

ethanrossblack commented 1 year ago

11. Get Cash Dispensers Near a Market

Details:

  1. The endpoint should be in the pattern of GET /api/v0/markets/:id/nearest_atms
  2. You will need to utilize the TomTom API for this. Specifically, the category search endpoint. Find a category that would work for ATM's, and use the API to find ATM's near the location of the Farmer's Market.
  3. The atms that are returned should be in the order of closest to furthest away.
  4. 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.
  5. The data top level key should always point to an array even if one or zero atms were located near the market location.

Example 1 😁

Request:

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

Response: status: 200

{
    "data": [
        {
            "id": null,
            "type": "atm",
            "attributes": {
                "name": "ATM",
                "address": "3902 Central Avenue Southeast, Albuquerque, NM 87108",
                "lat": 35.07904,
                "lon": -106.60068,
                "distance": 0.10521432030421865
            }
        },
        {
            "id": null,
            "type": "atm",
            "attributes": {
                "name": "ATM",
                "address": "4100 Central Avenue Southeast, Albuquerque, NM 87108",
                "lat": 35.0788,
                "lon": -106.59842,
                "distance": 0.14448001321588486
            }
        },
        ...,
        ...,
        ...,
    ]
}

Example 2 😭

Request:

  GET /api/v0/markets/123123123123/nearest_atm (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"
      }
  ]
}
ethanrossblack commented 1 year ago

https://developer.tomtom.com/search-api/documentation/search-service/category-search

Category: "automatic teller machine"

ethanrossblack commented 1 year ago
https://api.tomtom.com/search/2/categorySearch/cash%20dispenser.json?lat=#{lat}&lon=#{lon}&radius=1000&categorySet=7397&view=Unified&key=*****

OR

'https://api.tomtom.com/search/2/nearbySearch/.json?lat=35.07904&lon=-106.60068&radius=1000&categorySet=7397&view=Unified&key=*****' \
https://developer.tomtom.com/map-display-api/documentation/vector/content Category Number 7397 ATM