ethanrossblack / market_money_erb

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

9. Delete a MarketVendor #9

Closed ethanrossblack closed 1 year ago

ethanrossblack commented 1 year ago

9. Delete a MarketVendor

#### Details 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. 2. 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. 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 deleted an association to a market, that you don't see the recently removed market listed. 4. 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.
Example #1 😁
**Request:** ``` DELETE /api/v0/market_vendors Content-Type: application/json Accept: application/json ``` **Body:** ```json { "market_id": 322474, "vendor_id": 54861 } ``` **Response:** `status: 204`
Example #2 😭
**Request:** ``` DELETE /api/v0/market_vendors Content-Type: application/json Accept: application/json ``` **Body:** ```json { "market_id": 4233, "vendor_id": 11520 } (where there is no MarketVendor that has a market_id=4233 AND a vendor_id=11520) ``` **Response:** `status: 404` ```json { "errors": [ { "detail": "No MarketVendor with market_id=4233 AND vendor_id=11520 exists" } ] } ```