Giter Club home page Giter Club logo

market_money's Introduction

Market Money

This repo is meant to practice building an API. You will be building an API that exposes information about Farmer's Market's in the United States. Your API will have the ability to show all farmers markets, search for markets based on particular criteria, and find ATM's near the Farmer's Market's (since a lot of market's use cash).

Setup

You will need to seed your database to have Farmers Market's to work with. Follow the below directions to get your repository set up for development:

  1. git clone <repo ssh>
  2. cd market_money
  3. bundle install
  4. rails db:{create,migrate,seed}

Run rails c and check that you have 8675 markets. If so, you're ready to get started!

Directions

You will be building out 4 endpoints:

  1. Get All Markets
  2. Get One Market by Id
  3. Get All Markets by name, city, state, or zip
  4. Get closest ATMs near the Farmer's Market.

Below is a breakdown of each endpoint.

Get All Markets

Request:

/api/v0/markets

Example Response:

{
    "data": [
        {
            "id": "1",
            "type": "market",
            "attributes": {
                "fmid": 1012063,
                "name": " Caledonia Farmers Market Association - Danville",
                "street": null,
                "city": "Danville ",
                "county": "Caledonia",
                "state": "Vermont",
                "zip": "05828"
            }
        },
        {
            "id": "2",
            "type": "market",
            "attributes": {
                "fmid": 1011871,
                "name": " Stearns Homestead Farmers' Market",
                "street": "6975 Ridge Road",
                "city": "Parma ",
                "county": "Cuyahoga",
                "state": "Ohio",
                "zip": "44130"
            }
        },
        {...},
        {...},
        ...
        ...
    ]
}

Get One Market by Id

Request:

/api/v0/markets/1012063

Example Response:

{
    "data": {
        "id": "26027",
        "type": "market",
        "attributes": {
            "fmid": 1012063,
            "name": " Caledonia Farmers Market Association - Danville",
            "street": null,
            "city": "Danville ",
            "county": "Caledonia",
            "state": "Vermont",
            "zip": "05828"
        }
    }
}

Notes:

  • The market id that is send in the url should be the Farmer's Market Id, NOT the id from our database.
  • If an invalid FMID is given, render a 404 error with a descriptive message.

Get All Markets by name, city, state, or zip

Request:

api/v0/markets/search?name=Pearl

Example Response:

{
    "data": [
        {
            "id": "31883",
            "type": "market",
            "attributes": {
                "fmid": 1001938,
                "name": "Pearl Farmers Market",
                "street": "303 Pearl Parkway",
                "city": "San Antonio",
                "county": "Bexar",
                "state": "Texas",
                "zip": "78215"
            }
        },
        {
            "id": "31884",
            "type": "market",
            "attributes": {
                "fmid": 1007427,
                "name": "Pearl Farmers Market",
                "street": "6th Street and Peoria Avenue",
                "city": "Tulsa",
                "county": "Tulsa",
                "state": "Oklahoma",
                "zip": "74120"
            }
        },
        {...},
        {...},
        ...
        ...
    ]
}

Request:

api/v0/markets/search?name=Pearl&city=Denver

Example Response:

{
    "data": [
        {
            "id": "33048",
            "type": "market",
            "attributes": {
                "fmid": 1002313,
                "name": "South Pearl Street Farmers' Market",
                "street": "1500 S. Pearl Street",
                "city": "Denver",
                "county": "Denver",
                "state": "Colorado",
                "zip": "80210"
            }
        }
    ]
}

Notes:

  • This endpoint can take in query parameters for name,city,state, or zip. Any combination of them can be sent at any time.
  • If no query parameters are sent back, a messages should get sent back that notifies the user that they must supply 1 of 4 possible query parameters.
  • The search is case insensitive. So, if I had a parameter for "city"=>"Denver", this would give me back the same response as the parameter "city"=>"denver"
  • City and State should both be case insensitive
  • Zip must match what is passed in
  • Name should be a case insensitive fragment search
  • If no markets match the search criteria given, an empty array should be returned for the data value.

Get closest ATMs near the Farmer's Market.

Request:

api/v0/markets/1002313/nearest_atm

Example Response:

{
    "data": [
        {
            "id": null,
            "type": "atm",
            "attributes": {
                "name": "Metabank",
                "address": "1518 South Pearl Street, Denver, CO 80210",
                "lat": 39.689,
                "lon": -104.98011,
                "distance": 0.042179981516042665
            }
        },
        {
            "id": null,
            "type": "atm",
            "attributes": {
                "name": "Lynk Systems",
                "address": "1500 South Pearl Street, Denver, CO 80210",
                "lat": 39.68922,
                "lon": -104.98011,
                "distance": 0.056150646536912215
            }
        },
        {
            "id": null,
            "type": "atm",
            "attributes": {
                "name": "Atm",
                "address": "1477 South Pearl Street, Denver, CO 80210",
                "lat": 39.6897,
                "lon": -104.98076,
                "distance": 0.08732449203259186
            }
        },
        {
            "id": null,
            "type": "atm",
            "attributes": {
                "name": "Metabank",
                "address": "1475 South Pearl Street, Denver, CO 80210",
                "lat": 39.68985,
                "lon": -104.98057,
                "distance": 0.0964631149452528
            }
        },
        {...},
        ...
        ...
    ]
}

Notes:

  • 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.
  • Similar to finding a market by id, this market id in the URI should be the Farmer's Market Id.
  • If an invalid FMID is given, render a 404 error with a descriptive message.

market_money's People

Contributors

megstang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.