You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Details
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 vendor in which you just added to a market, that you see the newly associated market 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.
POST /api/v0/market_vendors
Content-Type: application/json
Accept: application/json
Body:
{
"market_id": 322474,
"vendor_id": 54861
}
(where 322474 and 54861 are valid market and vendor id's, but an existing MarketVendor with those values already exists.)
Response: status: 422
{
"errors": [
{
"detail": "Validation failed: Market vendor asociation between market with market_id=70 and vendor_id=1150 already exists"
}
]
}
The text was updated successfully, but these errors were encountered:
Details
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 vendor in which you just added to a market, that you see the newly associated market 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.
Example #1 😁
Request:
POST /api/v0/market_vendors
Content-Type: application/json
Accept: application/json
Body:
{
"market_id": 322474,
"vendor_id": 54861
}
(where 322474 and 54861 are valid market and vendor id's.)
Response: status: 201
{
"message": "Successfully added vendor to market"
}
Example #2 😭
Request:
Body:
{
"market_id": 987654321,
"vendor_id": 54861
}
(where 987654321 is an invalid market id)
Response: status: 404
{
"errors": [
{
"detail": "Validation failed: Market must exist"
}
]
}
Example #3 😭
Request:
Body:
{
"market_id": 322474,
"vendor_id": 54861
}
(where 322474 and 54861 are valid market and vendor id's, but an existing MarketVendor with those values already exists.)
Response: status: 422
{
"errors": [
{
"detail": "Validation failed: Market vendor asociation between market with market_id=70 and vendor_id=1150 already exists"
}
]
}
The text was updated successfully, but these errors were encountered: