day-cohort-70 / Bangazon-API-BandyChamps

0 stars 0 forks source link

Fixed bug #38-minimum products sold #62

Closed samsheps closed 1 month ago

samsheps commented 1 month ago

Description of PR that completes issue here...

Changes

Requests / Responses

If this PR contains code that defines a new request/response, or changes an existing one, please put the JSON representations here.

Request

GET /products?number_sold=2 displays all products that have been sold 2 or more times:

Response

HTTP/1.1 200 OK

```json
[
    {
        "id": 1,
        "name": "Optima",
        "price": 1655.15,
        "number_sold": 4,
        "description": "2008 Kia",
        "quantity": 3,
        "created_date": "2019-05-21",
        "location": "Seoul",
        "image_path": "http://localhost:8000/media/products/vehicle.png",
        "average_rating": 0
    },
    {
        "id": 2,
        "name": "Golf",
        "price": 653.59,
        "number_sold": 3,
        "description": "1994 Volkswagen",
        "quantity": 4,
        "created_date": "2019-07-10",
        "location": "Paris",
        "image_path": "http://localhost:8000/media/products/vehicle.png",
        "average_rating": 0
    },
    {
        "id": 3,
        "name": "Optima",
        "price": 1655.15,
        "number_sold": 3,
        "description": "2008 Kia",
        "quantity": 3,
        "created_date": "2019-05-21",
        "location": "Seoul",
        "image_path": "http://localhost:8000/media/products/vehicle.png",
        "average_rating": 0
    },
    {
        "id": 50,
        "name": "Golf",
        "price": 653.59,
        "number_sold": 2,
        "description": "1994 Volkswagen",
        "quantity": 4,
        "created_date": "2019-07-10",
        "location": "Berlin",
        "image_path": "http://localhost:8000/media/products/vehicle.png",
        "average_rating": 3.25
    }
]


## Testing

Description of how to test code...

- using Postman, go to the "Products" folder of "Collections" and visit the "GET products that have sold 2 or more" file. 
- perform the GET and compare results against your DB; attempt with other (relevant to your DB) numbers (1, 2, 3, 4, etc.)
- log into the client site and navigate to the "Filter Products" box; enter "2" into the "products sold" box, click "Filter," and check results against DB

## Related Issues

- Fixes #38