Giter Site home page Giter Site logo

market_money's Introduction

README

This README would normally document whatever steps are necessary to get the application up and running.

Things you may want to cover:

  • Ruby version

  • System dependencies

  • Configuration

  • Database creation

  • Database initialization

  • How to run the test suite

  • Services (job queues, cache servers, search engines, etc.)

  • Deployment instructions

  • ...

market_money's People

Contributors

margdaly avatar

Watchers

 avatar

market_money's Issues

2. Get One Market

GET /api/v0/markets/:id

  1. 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"
           }
       ]
   }

11. Get Cash Dispensers Near a Market

GET /api/v0/markets/:id/nearest_atms

  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.

3. Get All Vendors for a Market

GET /api/v0/markets/:id/vendors

  1. This endpoint should follow the pattern of GET /api/v0/markets/:id/vendors
  2. If a valid market id is passed in, a JSON object is sent back with a top-level data key that points to a collection of that market’s vendors. Each vendor contains all of it’s attributes.
  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.

7. Delete a Vendor

DELETE /api/v0/vendors/:id

  1. This endpoint should follow the pattern of DELETE /api/v0/vendors/:id
  2. When a valid id is passed in, that vendor will be destroyed, as well as any associations that vendor had. A status code of 204 should be sent back, without any content in the body.
  3. If an invalid id is passed in, a 404 status code as well as a descriptive message should be sent back with the response.

9. Delete a MarketVendor

DELETE /api/v0/market_vendors

  1. This endpoint should follow the pattern of DELETE /api/v0/market_vendors, and it should destroy an existing association between a market and a vendor (so that a vendor no longer is listed at a certain market).
  2. The market_id and the vendor_id should be passed in via the body.
  3. When a MarketVendor resource can be found with the passed in vendor_id and market_id, that resource should be destroyed, and a response will be sent back with a 204 status, with nothing returned in the body of the request.
  4. After implementing the happy path for this endpoint, run it, and check that when you call GET /api/v0/vendors/:id/markets for the vendor in which you just deleted an association to a market, that you don’t see the recently removed market listed.
  5. If a MarketVendor resource can NOT be found with the passed in vendor_id and market_id, a 404 status code as well as a descriptive message should be sent back with the response.

1. Get All Markets

GET /api/v0/markets

  1. pattern of GET /api/v0/markets and should return ALL markets in the database.
  2. In addition to the market’s main attributes, the market resource should also list an attribute for vendor_count, which is the number of vendors that are associated with that market.

Request:

GET /api/v0/markets
    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
               }
           },
           {
               "id": "322474",
               "type": "market",
               "attributes": {
                   "name": "2nd Street Farmers' Market",
                   "street": "194 second street",
                   "city": "Amherst",
                   "county": "Amherst",
                   "state": "Virginia",
                   "zip": "24521",
                   "lat": "37.583311",
                   "lon": "-79.048573",
                   "vendor_count": 35
               }
           },
           ...,
           ...,
       ]
   }

6. Update a Vendor

PATCH /api/v0/vendors/:id

  1. This endpoint should follow the pattern of PATCH /api/v0/vendors/:id, and can pass any number and combination of attribtues to be updated (name, description, contact_name, contact_phone, and credit_accepted) as JSON in the body of the request. (In postman, navigate to Body tab, select raw and change the format to JSON instead of Text)
  2. This endpoint should update an existing vendor with any parameters sent in via the body.
  3. If someone were to try to update a vendor resource to have a nil or empty attribute, a proper 400-level status code as well as a descriptive error message should be sent back in the response.
  4. A successful response will return the newly updated vendor resource.

8. Create a MarketVendor

POST /api/v0/market_vendors

  1. This endpoint should follow the pattern of POST /api/v0/market_vendors, and it should create a new association between a market and a vendor (so then, the vendor has a new market that they sell at).
  2. When valid ids for vendor and market are passed in, a MarketVendor will be created, and a response will be sent back with a 201 status, detailing that a Vendor was added to a Market.
  3. After implementing the happy path for this endpoint, run it, and check that when you call GET /api/v0/vendors/:id/markets for the vendor in which you just added to a market, that you see the newly associated market listed.
  4. If an invalid vendor id or and invalid market id is passed in, a 404 status code as well as a descriptive message should be sent back with the response.
  5. If a vendor id and/or a market id are not passed in, a 400 status code as well as a descriptive message should be sent back with the response.
  6. If there already exists a MarketVendor with that market_id and that vendor_id, a response with a 422 status code and a message informing the client that that association already exists, should be sent back. Looking at custom validation might help to implement a validation for uniqueness of the attributes for this resource.

5. Create a Vendor

POST /api/v0/vendors

  1. This endpoint should follow the pattern of POST /api/v0/vendors, and should pass ALL attributes required to create a vendor (name, description, contact_name, contact_phone, and credit_accepted) as JSON in the body of the request. (In postman, navigate to Body tab, select raw and change the format to JSON instead of Text)
  2. This endpoint should create a new vendor resource.
  3. A successful response will return a response with a 201 status code, and return the newly created vendor resource.
  4. If any number of attributes are left out in the body of the request, a status code of 400, as well as a descriptive error message should be sent back in the response.
  5. Validating the presence of a boolean value can be tricky since false is evaluated as nil. Validating the presence of a field that could be false will generate some a validation error when we don’t mean it to. We’d suggest creating your own custom validation for validating the presence of a boolean field.

4. Get One Vendor

GET /api/v0/vendors/:id

  1. This endpoint should follow the pattern of GET /api/v0/vendors/:id
  2. If a valid vendor id is passed in, a JSON object is sent back with a top-level data key that points to the vendor resource with that id, and all attributes for that vendor.
  3. If an invalid vendor id is passed in, a 404 status as well as a descriptive error message should be sent back in the response.

10. Search Markets by state, city, and/or name

GET /api/v0/markets/search

  1. The endpoint should be in the pattern of GET /api/v0/markets/search, and can accept city, state, and name parameters.
  2. The following combination of parameters can be sent in at any time:
  • state
  • state, city
  • state, city, name
  • state, name
  • name
  1. The following combination of parameters can NOT be sent in at any time:
  • city
  • city, name
  1. If an invalid set of parameters are sent in, a proper error message should be sent back, along with a 422 status code.
  2. In the event that valid parameters are sent in, and only one market is returned from the search, the data top level key should still point to an array holding that one market resource data.
  3. Similar to above, in the event that valid parameters are sent in, and NO markets are returned, the data top level key should point to an empty array. And a status code of 200 should still be returned

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.