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).
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.
After implementing the happy path for this endpoint, run it, and check that when you call GET /api/v0/markets/:id/vendors for the market to which you just added a vendor, that you see the newly associated vendor listed.
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.
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.
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.
'US 8 complete. this sucked lol. Added Create method in market_vendor_controller, created PORO to set up conditionals to pass errors and to save the market_vendor relation if successful. Added tests.'
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).MarketVendor
will be created, and a response will be sent back with a 201 status, detailing that a Vendor was added to a Market.GET /api/v0/markets/:id/vendors
for the market to which you just added a vendor, that you see the newly associated vendor listed.MarketVendor
with thatmarket_id
and thatvendor_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.