Skip to content

API Routes Documentation

Carmen edited this page Apr 8, 2024 · 18 revisions

USER AUTHENTICATION/AUTHORIZATION

All endpoints that require authentication

All endpoints that require a current user to be logged in.

  • Request: endpoints that require authentication
  • Error Response: Require authentication
    • Status Code: 401

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Authentication required"
      }

All endpoints that require proper authorization

All endpoints that require authentication and the current user does not have the correct role(s) or permission(s).

  • Request: endpoints that require proper authorization
  • Error Response: Require proper authorization
    • Status Code: 403

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Forbidden"
      }

Get the Current User

Returns the information about the current user that is logged in.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/session
    • Body: none
  • Successful Response when there is a logged in user

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith",
          "email": "[email protected]",
          "username": "JohnSmith"
        } 
      }
  • Successful Response when there is no logged in user

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": null
      }

Log In a User

Logs in a current user with valid credentials and returns the current user's information.

  • Require Authentication: false

  • Request

    • Method: POST

    • URL: /api/session

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "credential": "[email protected]",
        "password": "secret password"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith",
          "email": "[email protected]",
          "username": "JohnSmith"
        } 
      }
  • Error Response: Invalid credentials

    • Status Code: 401

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Invalid credentials"
      }
  • 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": {
          "credential": "Email or username is required",
          "password": "Password is required"
        }
      }

Sign Up a User

Creates a new user, logs them in as the current user, and returns the current user's information.

  • Require Authentication: false

  • Request

    • Method: POST

    • URL: /api/users

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "firstName": "John",
        "lastName": "Smith",
        "email": "[email protected]",
        "username": "JohnSmith",
        "password": "secret password",
        "accountType": "Buyer",
        "bio": "I love plants!",
        "favPlant": "String of Hearts",
        "shopDescription": "I sell hella plants in healthy conditions!",
        "UserImages": [
          {
            "id": 1,
            "url": 2,
            "avatar": true
          }
        ],
        "paymentMethod": "paypal",
        "paymentDetails": "[email protected]"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith",
          "email": "[email protected]",
          "username": "JohnSmith",
          "accountType": "Buyer",
          "bio": "I love plants!",
          "favPlant": "String of Hearts",
          "shopDescription": "I sell hella plants in healthy conditions!",
          "UserImages": [
            {
              "id": 1,
              "url": 2,
              "avatar": true
            }
          ],
          "paymentMethod": "paypal",
          "paymentDetails": "[email protected]"
        }
      }
  • Error response: User already exists with the specified email

    • Status Code: 500

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User already exists",
        "errors": {
          "email": "User with that email already exists"
        }
      }
  • Error response: User already exists with the specified username

    • Status Code: 500

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User already exists",
        "errors": {
          "username": "User with that username already exists"
        }
      }
  • 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": {
          "email": "Invalid email",
          "username": "Username is required",
          "firstName": "First Name is required",
          "lastName": "Last Name is required",
          "accountType": "Account Type is required",
          "paymentMethod": "Payment method is required",
          "paymentDetails": "Payment details is required"
        }
      }

Get details of a user from an id

Returns the details of a user specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/users/:userId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith",
          "email": "[email protected]",
          "username": "JohnSmith",
          "accountType": "Buyer",
          "bio": "I love plants!",
          "favPlant": "String of Hearts",
          "shopDescription": "I sell hella plants in healthy conditions!",
          "UserImages": [
              {
                "id": 1,
                "url": 2,
                "avatar": true
              }
            ],
          "createdAt": "2023-11-19 20:39:36",
          "updatedAt": "2023-11-19 20:39:36",
          "Listings": [
            {
              "id": 1,
              "sellerId": 1,
              "plantName": "Monstera",
              "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot!",
              "price": 75,
              "ListingImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
            ],
              "guideId": 1,
              "potSize": 8,
              "stockQty": 1,
              "createdAt": "2023-11-19 20:39:36",
              "updatedAt": "2023-11-19 20:39:36",
           }
         ],
        "Guides": [
          {
            "id": 1,
            "userId": 1,
            "title": "Top 5 Pet-Friendly Plants",
            "description": "A list of pet-friendly plants, from the ultimate pet and plant lover!",
            "content": "Chinese Money Plant, Money Tree, Hoyas, Rattlesnake Plant, Spider Plant",
            "votes": 3,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36" ,
            "GuideImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
            ]
          }
        ]
      }
  • Error response: Couldn't find a user with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

PLANT LISTINGS

Get all Plant Listings

Returns all the plant listings.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/listings
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Listings": [
          {
            "id": 1,
            "sellerId": 1,
            "plantName": "Monstera",
            "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot!",
            "price": 75,
            "ListingImages": [
              {
                 "id": 1,
                 "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
            ],
            "Seller": {
              "id": 1,
              "firstName": "John",
              "lastName": "Smith"
            },
            "guideId": 1,
            "potSize": 8,
            "stockQty": 1,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36",
          }
        ]
      }

Get All Listings Owned by Current User

Returns all the listings owned (created) by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/listings/current
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Listings": [
          {
            "id": 1,
            "sellerId": 1,
            "plantName": "Monstera",
            "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot!",
            "price": 75,
            "ListingImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
            ],
            "guideId": 1,
            "potSize": 8,
            "stockQty": 1,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36",
          }
        ]
      }

Get details of a Listing from an id

Returns the details of a listing specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/listings/:listingId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "id": 1,
          "sellerId": 1,
          "plantName": "Monstera",
          "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot. It has unfortunately getting too large for my home, so it needs a new home!",
          "price": 75,
          "guideId": 1,
          "potSize": 8,
          "stockQty": 1,
          "createdAt": "2023-11-19 20:39:36",
          "updatedAt": "2023-11-19 20:39:36",
        "ListingImages": [
          {
            "id": 1,
            "url": "image url",
          },
          {
            "id": 2,
            "url": "image url",
          }
        ],
        "Seller": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith"
        }
      }
  • Error response: Couldn't find a listing with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Create a Listing

Creates and returns a new listing.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/listings

    • Headers:

      • Content-Type: application/json
    • Body:

      {
      "plantName": "Monstera",
      "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot. It has unfortunately getting too large for my home, so it needs a new home!",
      "price": 75,
      "ListingImages": [
          {
            "url": "image url"
          }, 
          {
           "url": "image url"
          }, 
       ],
      "guideId": 1,
      "potSize": 8,
      "stockQty": 1,
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "sellerId": 1,
        "plantName": "Monstera",
        "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot. It has unfortunately getting too large for my home, so it needs a new home!",
        "price": 75,
        "ListingImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
            ],
        "Seller": {
          "id": 1,
          "firstName": "John",
          "lastName": "Smith"
        },
        "guideId": 1,
        "potSize": 8,
        "stockQty": 1,
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-11-19 20:39:36"
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "plantName": "Plant name is required; must be less than 50 characters",
          "description": "Description is required; must be less than 300 characters",
          "price": "Price is required",
          "ListingImages": "A minimum of one image is required",
          "potSize": "Pot size is required",
          "stockQty": "Quantity is required; must be at least 1"
        }
      }

Add an Image to a Listing by Listing id

Create and return a new image for a listing specified by id.

  • Require Authentication: true

  • Require proper authorization: Listing must belong to the current user

  • Request

    • Method: POST

    • URL: /api/listings/:listingId/images

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "url": "image url",
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "url": "image url",
      }
  • Error response: Couldn't find a Listing with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Edit a Listing

Updates and returns an existing listing.

  • Require Authentication: true

  • Require proper authorization: Listing must belong to the current user

  • Request

    • Method: PUT

    • URL: /api/listings/:listingId

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "plantName": "Monstera Deliciosa",
        "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot. It has unfortunately getting too large for my home, so it needs a new home!",
        "price": 50,
        "guideId": 1,
        "potSize": 6,
        "stockQty": 1,
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "sellerId": 1,
        "plantName": "Monstera Deliciosa",
        "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot. It has unfortunately getting too large for my home, so it needs a new home!",
        "price": 50,
        "ListingImages": [
          {
          "id": 1,
          "url": "image url"
          }
        ],
        "guideId": 1,
        "potSize": 6,
        "stockQty": 1,
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-11-20 10:06:40"
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "plantName": "Plant name is required; must be less than 50 characters",
          "description": "Description is required; must be less than 300 characters",
          "price": "Price is required",
          "ListingImages": "A minimum of one image is required",
          "potSize": "Pot size is required",
          "stockQty": "Quantity is required; must be at least 1"
        }
      }
  • Error response: Couldn't find a Listing with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Delete a Listing

Deletes an existing listing.

  • Require Authentication: true

  • Require proper authorization: Listing must belong to the current user

  • Request

    • Method: DELETE
    • URL: /listings/:listingId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a Listing with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

SHOPPING CART

Get All Shopping Cart items Added by Current User

Returns all the listings added to the Shopping Cart by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/cart
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "ShoppingCart": {
          "id": 1,
          "buyerId": 1,
          "createdAt": "2023-11-19 20:39:36",
          "updatedAt": "2023-11-19 20:39:36",
          "CartItems": [
              {
              "id": 1,
              "plantName": "Monstera",
              "price": 75,
              "ListingImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
             ],
              "stockQty": 1,
              "cartQty": 1,
              "createdAt": "2023-11-19 20:39:36",
              "updatedAt": "2023-11-19 20:39:36",
              },
              {
              "id": 2,
              "plantName": "Hoya Queen",
              "price": 75,
              "ListingImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
              ],
              "stockQty": 1,
              "cartQty": 1,
              "createdAt": "2023-11-19 20:39:36",
              "updatedAt": "2023-11-19 20:39:36",
              }
          ]
        }
      }

Add Listings to Shopping Cart

Creates (adds) and returns items to shopping cart.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/cart

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "CartItems": [
              {
              "id": 1,
              "cartQty": 1
              },
              {
              "id": 2,
              "cartQty": 1
              }
          ]
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "ShoppingCart": {
          "id": 1,
          "buyerId": 1,
          "createdAt": "2023-11-19 20:39:36",
          "updatedAt": "2023-11-19 20:39:36",
          "CartItems": [
            {
                "id": 1,
                "sellerId": 1,
                "plantName": "Monstera",
                "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot. It has unfortunately getting too large for my spot, so it needs a new home!",
                "price": 75,
                "ListingImages": [
                {
                  "id": 1,
                  "url": "image url"
                }, 
                {
                  "id": 2,
                  "url": "image url"
                }, 
                ],
                "guideId": 1,
                "potSize": 8,
                "stockQty": 1,
                "cartQty": 1,
                "createdAt": "2023-11-19 20:39:36",
                "updatedAt": "2023-11-19 20:39:36"
            },
            {
                "id": 2,
                "plantName": "Hoya Queen",
                "price": 75,
                "ListingImages": [
                {
                  "id": 1,
                  "url": "image url"
                }, 
                {
                  "id": 2,
                  "url": "image url"
                }, 
                ],
                "stockQty": 1,
                "cartQty": 1,
                "createdAt": "2023-11-19 20:39:36",
                "updatedAt": "2023-11-19 20:39:36",
            }
          ],
        }
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "cartQty": "Quantity must be higher than 0; requested quantity is higher than available inventory"
        }
      }

Edit Items in Shopping Cart

Updates and returns an existing shopping cart.

  • Require Authentication: true

  • Require proper authorization: Shopping cart must belong to the current user

  • Request

    • Method: PUT

    • URL: /api/cart/:cartId

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "CartItems": [
          {
              "id": 1,
              "cartQty": 2
          },
        ]
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      { "ShoppingCart": {
          "id": 1,
          "buyerId": 1,
          "createdAt": "2023-11-19 20:39:36",
          "updatedAt": "2023-11-19 20:39:36",
          "CartItems": [
            {
                "id": 1,
                "sellerId": 1,
                "plantName": "Monstera",
                "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot. It has unfortunately getting too large for my home, so it needs a new home!",
                "price": 75,
                "ListingImage": [
                {
                  "id": 1,
                  "url": "image url"
                }, 
                {
                  "id": 2,
                  "url": "image url"
                }, 
              ],
                "guideId": 1,
                "potSize": 8,
                "cartQty": 2,
                "createdAt": "2023-11-19 20:39:36",
                "updatedAt": "2023-11-19 20:39:36"
            }
          ],
        }
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "cartQty": "Requested quantity is higher than available inventory"
        }
      }
  • Error response: Couldn't find a Shopping Cart with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Shopping cart couldn't be found"
      }

Delete Items in Shopping Cart

Delete an existing guide.

  • Require Authentication: true

  • Require proper authorization: Cart must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/cart/:cartId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a Cart with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Shopping cart couldn't be found"
      }

Add Orders by Shopping Cart ID

Creates (adds) and returns orders based on shopping cart ID

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/checkout

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "Order": {
            "cartId": 1,
            "address": "123 Test St",
            "city": "Test City",
            "state": "CA",
            "zipCode": "94587",
            "paymentMethod": "VIZZA",
            "paymentDetails": 1234,
            "orderTotal": 150.00
          }
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "Order": {
            "id": 1,
            "buyerId": 1,
            "cartId": 1,
            "address": "123 Test St",
            "city": "Test City",
            "state": "CA",
            "zipCode": "94587",
            "paymentMethod": "VIZZA",
            "paymentDetails": 1234,
            "orderTotal": 150.00,
            "orderStatus": "Processing",
            "createdAt": "2023-11-19 20:39:36",
          }
      }
  • 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",
          "zipCode": "ZIP Code is required",
          "paymentMethod": "Payment method is required",
          "paymentDetails": "Payment details is required"
        }
      }
  • Error response: Couldn't find a Shopping Cart with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Shopping cart couldn't be found"
      }

SEARCH AND FILTER

Return listings filtered by query parameters.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/listings
    • Query Parameters
      • page: integer, minimum: 1, maximum: 10, default: 1
      • size: integer, minimum: 1, maximum: 20, default: 20
      • name: varhar, optional
      • minPotSize: decimal, optional, minimum: 0
      • maxPotSize: decimal, optional, minimum: 0
      • minPrice: decimal, optional, minimum: 0
      • maxPrice: decimal, optional, minimum: 0
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Listings": [
          {
            "id": 1,
            "sellerId": 1,
            "plantName": "Monstera",
            "description": "This is a full grown monstera in an 8-inch pot in soil, comes with the pot!",
            "price": 75,
            "ListingImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
             ],
            "guideId": 1,
            "potSize": 8,
            "stockQty": 1,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36",
          }
        ],
        "page": 2,
        "size": 25
      }
  • Error Response: Query parameter validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Bad Request", // (or "Validation error" if generated by Sequelize),
        "errors": {
          "page": "Page must be greater than or equal to 1",
          "size": "Size must be greater than or equal to 1",
          "name": "Name is invalid",
          "minPotSize": "Minimum pot size must be greater than or equal to 0",
          "maxPotSize": "Maximum pot size must be greater than or equal to 0",
          "minPrice": "Minimum price must be greater than or equal to 0",
          "maxPrice": "Maximum price must be greater than or equal to 0"
        }
      }

PLANT GUIDES

Get All Plant Guides

Returns all the plant guides.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/guides
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Guides": [
          {
            "id": 1,
            "userId": 1,
            "title": "Top 5 Pet-Friendly Plants",
            "description": "A list of pet-friendly plants, from the ultimate pet and plant lover!",
            "content": "Chinese Money Plant, Money Tree, Hoyas, Rattlesnake Plant, Spider Plant",
            "votes": 3,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36" ,
            "Author": {
              "id": 1,
              "username": "plantlover"
            },
            "GuideImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
            ]
          }
        ]
      }
  • Error response: Couldn't find a Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Get All Plant Guides by Current User

Returns all the guides written by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/guides/current
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Guides": [
          {
            "id": 1,
            "userId": 1,
            "title": "Top 5 Pet-Friendly Plants",
            "description": "A list of pet-friendly plants, from the ultimate pet and plant lover!",
            "content": "Chinese Money Plant, Money Tree, Hoyas, Rattlesnake Plant, Spider Plant",
            "votes": 3,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36" ,
            "Author": {
              "id": 1,
              "username": "plantlover"
            },
            "GuideImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
            ]
          }
        ]
      }

Get Guide Details by Guide ID

Returns the details of a guide specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/listings/:listingId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Guides": [
          {
            "id": 1,
            "userId": 1,
            "title": "Top 5 Pet-Friendly Plants",
            "description": "A list of pet-friendly plants, from the ultimate pet and plant lover!",
            "content": "Chinese Money Plant, Money Tree, Hoyas, Rattlesnake Plant, Spider Plant",
            "votes": 3,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36" ,
            "Author": {
              "id": 1,
              "username": "plantlover"
            },
            "GuideImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
            ]
          }
        ]
      }
  • Error response: Couldn't find a Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Create a Guide

Creates and returns a new guide.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/listings

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "title": "How to Care for Monsteras",
          "description": "Tips for making your monstera thrive",
          "content": "The monstera loves medium indirect light and needs to be watered every 1-2 weeks. It thrives on more humid conditions, but normal room humidity will do as long as you give it a mist every once in a while.",
          "GuideImages": [
              {
                "id": 1,
                "url": "image url"
              }, 
              {
                "id": 2,
                "url": "image url"
              }, 
             ],
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "userId": 1,
        "title": "How to Care for Monsteras",
        "description": "Tips for making your monstera thrive",
        "content": "The monstera loves medium indirect light and needs to be watered every 1-2 weeks. It thrives on more humid conditions, but normal room humidity will do as long as you give it a mist every once in a while.",
        "GuideImages": [
          {
             "id": 1,
             "url": "image url"
          }, 
          {
             "id": 2,
             "url": "image url"
          }, 
        ],
        "Author": {
          "id:" 1,
          "username": "plantlover"
        },
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-11-19 20:39:36"
      }
  • 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": {
          "title": "Title is required",
          "description": "Description is required",
          "content": "Guide text is required",
          "GuideImages": "Image is required"
        }
      }
  • Error response: Couldn't find a Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Add an Image to a Guide by Guide id

Create and return a new image for a guide specified by id.

  • Require Authentication: true

  • Require proper authorization: Guide must belong to the current user

  • Request

    • Method: POST

    • URL: /api/guides/:guideId/images

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "url": "image url"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "url": "image url"
      }
  • Error response: Couldn't find a Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Guide couldn't be found"
      }
  • Error response: Cannot add any more images because there is a maximum of 10 images per resource

    • Status Code: 403

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Maximum number of images for this resource was reached"
      }

Edit a Guide

Update and return an existing guide.

  • Require Authentication: true

  • Require proper authorization: Guide must belong to the current user

  • Request

    • Method: PUT

    • URL: /api/guides/:guideId

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "title": "Care Guide for Monsteras",
        "description": "Get your monsteras to thrive with these tips",
        "content": "The monstera loves medium indirect light and needs to be watered every 1-2 weeks. It thrives on more humid conditions, but normal room humidity will do as long as you give it a mist every once in a while.",
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "userId": 1,
        "title": "Care Guide for Monsteras",
        "description": "Get your monsteras to thrive with these tips",
        "content": "The monstera loves medium indirect light and needs to be watered every 1-2 weeks. It thrives on more humid conditions, but normal room humidity will do as long as you give it a mist every once in a while.",
        "votes": 3,
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-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": {
          "title": "Title is required",
          "description": "Description is required",
          "content": "Guide text is required",
          "GuideImages": "Image is required"
        }
      }
  • Error response: Couldn't find a Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Delete a Guide

Delete an existing guide.

  • Require Authentication: true

  • Require proper authorization: Guide must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/guides/:guideId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

IMAGES

Delete a Listing Image

Delete an existing image for a Listing.

  • Require Authentication: true

  • Require proper authorization: Listing must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/images/:imageableId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a Listing Image with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Listing Image couldn't be found"
      }

Delete a Guide Image

Delete an existing image for a Plant Guide.

  • Require Authentication: true

  • Require proper authorization: Plant Guide must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/images/:imageableId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a Plant Guide Image with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Plant Guide Image couldn't be found"
      }

Delete a User Image

Delete an existing image for a User.

  • Require Authentication: true

  • Require proper authorization: Plant Guide must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/images/:imageableId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a User Image with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User Image couldn't be found"
      }

!BONUS! -- SELLER REVIEWS

Get all Seller Reviews of the Current User

Returns all the reviews written by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/reviews/current
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Reviews": [
          {
            "id": 1,
            "buyerId": 1,
            "sellerId": 2,
            "review": "The plant arrived in perfect conditions. A++ for this seller!",
            "stars": 5,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36" ,
            "Buyer": {
              "id": 1,
              "firstName": "John",
              "lastName": "Smith"
            }
          }
        ]
      }

Get all Reviews by a Seller's id

Returns all the reviews that belong to a seller specified by id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/user/:userId/reviews
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Reviews": [
          {
            "id": 1,
            "buyerId": 1,
            "sellerId": 2,
            "review": "The plant arrived in perfect conditions. A++ for this seller!",
            "stars": 5,
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36" ,
            "Buyer": {
              "id": 1,
              "firstName": "John",
              "lastName": "Smith"
            }
          }
        ]
      }
  • Error response: Couldn't find a Seller with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Create a Review for a Seller based on the Seller's id

Create and return a new review for a seller specified by id.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/user/:userId/reviews

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "review": "She was so helpful in answering my questions before I bought the plant",
        "stars": 5,
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "buyerId": 1,
        "sellerId": 2,
        "review": "She was so helpful in answering my questions before I bought the plant",
        "stars": 5,
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-11-19 20:39:36"
      }
  • 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": {
          "review": "Review text is required",
          "stars": "Stars must be an integer from 1 to 5",
        }
      }
  • Error response: Couldn't find a Seller with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Seller couldn't be found"
      }
  • Error response: Review from the current user already exists for the Seller

    • Status Code: 500

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User already has a review for this seller"
      }

Edit a Review

Update and return an existing review.

  • Require Authentication: true

  • Require proper authorization: Review must belong to the current user

  • Request

    • Method: PUT

    • URL: /api/reviews/:reviewId

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "review": "Shipping took way too long",
        "stars": 2,
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "buyerId": 1,
        "sellerId": 2,
        "review": "Shipping took way too long",
        "stars": 2,
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-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": {
          "review": "Review text is required",
          "stars": "Stars must be an integer from 1 to 5",
        }
      }
  • Error response: Couldn't find a Review with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Delete a Review

Delete an existing review.

  • Require Authentication: true

  • Require proper authorization: Review must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/reviews/:reviewId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a Review with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

!BONUS! -- PLANT GUIDES: COMMENTS

Get all of the Current User's Plant Guides comments

Return all the comments that the current user has made on Plant Guides.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/comments/current
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Comments": [
          {
            "id": 1,
            "userId": 1,
            "User": {
              "id": 1,
              "username": "plantl0ver",
              "city": "San Francisco",
              "state": "California",
            },
            "guideId": 1,
            "comment": "This guide is spot on!",
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36"
          }
        ]
      }

Get all comments based on the Plant Guide's id

Return all the comments for a plant guide specified by id.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/guides/:guideId/comments
    • Body: none
  • Successful Response:

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Comments": [
          {
            "guideId": 1,
            "userId": 1,
            "User": {
              "id": 1,
              "username": "plantl0ver",
              "city": "San Francisco",
              "state": "California",
            },
            "comment": "This guide is spot on!",
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36"
          },
          {
            "guideId": 1,
            "userId": 2,
            "User": {
              "id": 2,
              "username": "ferns_forever",
              "city": "Oakland",
              "state": "California",
            },
            "comment": "I'd also add monstera to this list.",
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36"
          }
        ]
      }
  • Error response: Couldn't find a Plant Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Plant guide couldn't be found"
      }

Create a comment on a Plant Guide based on the Plant Guide's id

Create and return a new comment from a plant guide specified by id.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/guides/:guideId/comments

    • Body:

      {
        "comment": "This guide is terrible!",
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "userId": 1,
        "guideId": 2,
        "comment": "This guide is terrible!",
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-11-19 20:39:36"
      }
  • 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": {
          "comment": "Comment is required"
        }
      }
  • Error response: Couldn't find a Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Edit a Comment

Update and return an existing comment.

  • Require Authentication: true

  • Require proper authorization: Comment must belong to the current user

  • Request

    • Method: PUT

    • URL: /api/comments/:commentId

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "comment": "So thankful for this guide!"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "userId": 1,
        "guideId": 2,
        "comment": "So thankful for this guide!",
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-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": {
          "comment": "Comment is required"
        }
      }
  • Error response: Couldn't find a comment with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Delete a Comment

Delete an existing comment.

  • Require Authentication: true

  • Require proper authorization: Comment must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/comments/:commentId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a comment with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

!BONUS! -- ORDER DETAILS

Get all Orders of the Current User

Returns all the orders made by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/orders/current/
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Orders": [
          {
              "id": 1,
              "buyerId": 1,
              "orderTotal": 150.00,
              "orderStatus": "Processing",
              "createdAt": "2023-11-19 20:39:36",
          }
        ]
      }

Get all Order Details by a Order id

Returns all the orders that belong to a buyer specified by id.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/orders/:orderId/
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "OrderDetails": [
          "id": 1,
          "orderId": 1,
          "OrderItems": [
            {
              "listingId": 1,
              "qty": 1,
              "price": 75
            },
            {
              "listingId": 2,
              "qty": 3,
              "price": 180
            }
          ]
        ]
      }
  • Error response: Couldn't find an order with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

!BONUS! -- FAVORITES

Get all favorites (listings and guides) of the Current User

Returns all the favorites marked by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/favorites/current
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Favorites": [
          {
            "id": 1,
            "userId": 1,
            "name": "Top Wishlist Plants"
            "Listings:" [
                {
                  "itemId": 2,
                  "itemType": "Listings"
                },
                {
                  "itemId": 3,
                  "itemType": "Listings"
                }
              ],
            "Guides:" [
                {
                  "itemId": 1,
                  "itemType": "Guides"
                }
              ],
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36",
          }
        ]
      }

Get all Favorites by a User's id

Returns all the favorites that belong to a user specified by id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: /api/user/:userId/favorites
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Favorites": [
          {
            "id": 1,
            "userId": 1,
            "name": "Top Wishlist Plants",
            "Listings:" [
                {
                  "itemId": 2,
                  "itemType": "Listings"
                },
                {
                  "itemId": 3,
                  "itemType": "Listings"
                }
              ],
            "Guides:" [
                {
                  "itemId": 1,
                  "itemType": "Guides"
                }
              ],
            "createdAt": "2023-11-19 20:39:36",
            "updatedAt": "2023-11-19 20:39:36",
          }
        ]
      }
  • Error response: Couldn't find a User with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Create a Favorites list for a user based on the user's id

Create and return a favorites list for a user specified by id.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/user/:userId/favorites

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "name": "Plants for Mom",
        "Items": [
          { 
            "itemId": 2,
            "itemType": "Listings"
          }
        ]
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "userId": 1,
        "name": "Plants for Mom",
        "Items": [
          { 
            "itemId": 2,
            "itemType": "Listings"
          }
        ],
        "createdAt": "2023-11-19 20:39:36",
        "updatedAt": "2023-11-19 20:39:36"
      }
  • 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": {
          "name": "Name is required; must be less than 50 characters",
        }
      }
  • Error response: Couldn't find a User with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

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

Delete a Favorites List

Delete an existing favorites list.

  • Require Authentication: true

  • Require proper authorization: Favorites list must belong to the current user

  • Request

    • Method: DELETE
    • URL: /api/favorites/:favoriteId
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted"
      }
  • Error response: Couldn't find a Favorites list with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Favorites list couldn't be found"
      }

!BONUS! -- GUIDE VOTES

Get All Votes by Guide ID

Returns the number of votes added Plant Guide by Guide ID

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: /api/guides/:guideID/votes
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "GuideVotes": [
              {
              "id": 1,
              "userId": 1,
              "guideId": 1,
              "voteType": "upvote",
              "createdAt": "2023-11-19 20:39:36",
              "updatedAt": "2023-11-19 20:39:36",
              },
              {
              "id": 2,
              "userId": 2,
              "guideId": 1,
              "voteType": "downvote",
              "createdAt": "2023-11-19 20:39:36",
              "updatedAt": "2023-11-19 20:39:36",
              }
          ]
      }

Create Vote

Creates (adds) votes to guide.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: /api/guides/:guided/votes

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "GuideVotes": [
              {
              "voteType": "downvote",
              }
          ]
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "GuideVotes": [
          {
              "id": 1,
              "userId": 2,
              "guideId": 1,
              "createdAt": "2023-11-19 20:39:36",
              "updatedAt": "2023-11-19 20:39:36"
          },
        ]
      }
  • Error response: Couldn't find a Guide with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Plant Guide couldn't be found"
      }
Clone this wiki locally