heather-yaple / auth-me-project

Repo for Auth Me project
0 stars 1 forks source link

Edit a Spot #11

Open heather-yaple opened 2 months ago

heather-yaple commented 2 months ago

Updates and returns an existing spot.

joe-corcoran commented 1 month ago

Edit a Spot Updates and returns an existing spot.

Require Authentication: true

Require proper authorization: Spot must belong to the current user

Request

Method: PUT

Route path: /api/spots/:spotId

Headers:

Content-Type: application/json Body:

{ "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "country": "United States of America", "lat": 37.7645358, "lng": -122.4730327, "name": "App Academy", "description": "Place where web developers are created", "price": 123 } Successful Response

Status Code: 200

Headers:

Content-Type: application/json Body:

{ "id": 1, "ownerId": 1, "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "country": "United States of America", "lat": 37.7645358, "lng": -122.4730327, "name": "App Academy", "description": "Place where web developers are created", "price": 123, "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-20 10:06:40" } Error Response: Body validation errors

Status Code: 400

Headers:

Content-Type: application/json Body:

{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "address": "Street address is required", "city": "City is required", "state": "State is required", "country": "Country is required", "lat": "Latitude must be within -90 and 90", "lng": "Longitude must be within -180 and 180", "name": "Name must be less than 50 characters", "description": "Description is required", "price": "Price per day must be a positive number" } } Error response: Couldn't find a Spot with the specified id

Status Code: 404

Headers:

Content-Type: application/json Body:

{ "message": "Spot couldn't be found" }