This is the first version of the backend API for the WIG!T Web Application. You can view the Swagger docs to see more details and test out the routes.
The following are endpoints implemented and the data needed in the JSON payload where applicable, as well as response codes and types.
NB: All routes should carry the prefix
/api/v1
.
Strong fields are required.
Routes that require sign in carry a star *
Admin routes carry two stars **
Super Admin routes carry three stars ***
- Get all products in the database. On success, it will return a 200 response code with a data object which is a list of all product objects in the payload. On failure, it will return a 500 response code and an error string in the payload.
- Get a particular product from the database. On success, it will return a 200 response code with a data object in the payload. On failure, it will return a 400 or 500 response code and an error string in the payload.
- Get all products in a given category. trending is a category. On success, it will return a 200 response code with a data object in the payload. This will be a list of all product objects in the given category. On failure, it will return a 400 or 500 response code and an error string in the payload.
- Get all products in a given substring `name` in their name. The search is case insensitive. On success, it will return a 200 response code with a data object in the payload. This will be a list of all product objects with the given substring `name`. On failure, it will return a 400 or 500 response code and an error string in the payload.
- Get all items in the user's cart. On success, it will return a 200 response code with a data object in the payload. This will be a list of all item objects in the user's cart. On failure, it will return a 500 response code and an error string in the payload.
- Get a list of all services. On success, it will return a 200 response code with a data object in the payload. This will be a list of all service objects. On failure, it will return a 500 response code and an error string in the payload.
- Get a particular service. On success, it will return a 200 response code with a data object in the payload which will be a service object. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get all free slots which are still valid. On success, it will return a 200 response code with a data object in the payload which will be a list of slot objects. On failure, it will return a 500 response code, and an error string in the payload.
- Get all orders belonging to the current user. On success, it will return a 200 response code with a data object in the payload which will be a list of order objects. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get a given order with order_id belonging to the current user. On success, it will return a 200 response code with a data object in the payload which will be an order. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get all orders based on the status for the current user. Values are pending, paid, shipped, delivered, or cancelled. On success, it will return a 200 response code with a data object in the payload which will be a list of orders. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get a list of the user's bookings. On success, it will return a 200 response code with a data object in the payload which will be a list of booking objects. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get a specific booking with booking_id belonging to the user. On success, it will return a 200 response code with a data object in the payload which will be a booking object. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get a list of all bookings in the database. On success, it will return a 200 response code with a data object in the payload which will be a list of booking objects. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get a specific booking with booking_id. On success, it will return a 200 response code with a data object in the payload which will be a booking object. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get all orders from the database. On success, it will return a 200 response code with a data object in the payload which will be a list of orders. On failure, it will return a 500 response code, and an error string in the payload.
- Get an order with given order_id from the database. On success, it will return a 200 response code with a data object in the payload which will be an order. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get all orders with given status from the database. Values are pending, paid, shipped, delivered, or cancelled. On success, it will return a 200 response code with a data object in the payload which will be a list of orders. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get all orders and bookings belonging to the user with given email. On success, it will return a 200 response code with a data object in the payload. The data object will contain orders object which is a list of orders, and bookings object which is a list of bookings. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Get all users with admin roles. On success, it will return a 200 response code with a data object in the payload which will be a list of users. On failure, it will return a 500 response code, and an error string in the payload.
- Get all users with customer roles. On success, it will return a 200 response code with a data object in the payload which will be a list of users. On failure, it will return a 500 response code, and an error string in the payload.
- Get the user with given email. On success, it will return a 200 response code with a data object in the payload. On failure, it will return a 500 response code, and an error string in the payload. On failure, it will return a 400 or 500 response code, and an error string in the payload.
-
Sign a user up.
- email: The new user's email address. Must be unique and between 5 and 45 characters long.
- password: The user's password. Between 8 and 45 characters.
- repeat_password: A repeat of the user's password.
- first_name: The user's first name. Not more than 45 characters.
- last_name: The user's last name. Not more than 45 characters.
- address: The user's address. Not more than 255 characters.
- phone: The user's phone number. Between 8 and 11 characters.
-
Sign a user with given credentials in.
- email: The user's email address. Between 5 and 45 characters long.
- password: The user's password. Between 8 and 45 characters.
-
Send a request to reset password for user with given email.
- email: The user's email address. Between 5 and 45 characters long.
-
Add an item to the user's cart.
- product_id: This is the id of the product to add to cart.
- quantity: This is the quantity of the product the user wants. An integer. Cannot be 0.
-
Add a new user booking to the database.
- slot_id: The id for the slot the user has been booked for.
- service_id: The id for the service the user has booked.
-
Create a new order for the current user. This order will be made up of all items in cart, so cart cannot be empty.
- delivery_method: This is a string. Value is either pickup or delivery.
-
Add a new product to the database.
- name: The name of the product. Must be 3 to 45 characters long.
- description: The details of what the product is. Must be between 3 to 1024 characters long.
- category: The category the product belong to. Must be 3 to 45 characters long.
- stock: The quantity of the product in stock. An integer.
- price: The price of the product. Decimal as a string. Will be rounded up to 2 decimal places.
- image_url: A link to the product display image. Not longer than 255 characters.
-
Add a new service to the database.
- name: The name of the service. Must be 3 to 45 characters long.
- description: The details of what the service is. Must be between 3 to 1024 characters long.
- price: The price of the service. Decimal as a string. Will be rounded up to 2 decimal places.
- available: A boolean. Says if the service is currently available or not.
-
Add a new slot to the database.
- date_time: This is the date and time for the slot. String value format of a datetime. y/m/d "2006-01-02T15:00:00Z"
- is_free: A boolean which says if the slot is free or not.
-
Send information to reset a password.
- email: The user's email address. Between 5 and 45 characters long.
- reset_token: The reset token sent back for that user when a post to this route was made.
- new_password: The user's new password. Must be 8 to 45 characters long.
- repeat_new_password: A repeat of the user's new password.
-
Update the information for the current user with email.
- email: This is the user's existing email or new email. Between 5 to 45 characters.
- first_name: This is the existing or new first name of the user. Not empty and not more than 45 characters.
- last_name: This is the existing or new last_name of the user. Not empty and not more than 45 characters.
- address: This is the existing or new address of the user. Not empty and not more than 255 characters.
- phone: This is the existing or new user's phone number. Not empty and between 8 and 11 characters.
- Update the quantity of the item with item_id in cart to quantity given in path.
-
Update the information for a given product with product_id.
- name: The name of the product. Must be 3 to 45 characters long.
- description: The details of what the product is. Must be between 3 to 1024 characters long.
- category: The category the product belong to. Must be 3 to 45 characters long.
- stock: The quantity of the product in stock. An integer.
- price: The price of the product. Decimal as a string. Will be rounded up to 2 decimal places.
- image_url: A link to the product display image. Not longer than 128 characters.
-
Update the information about a given service with service_id.
- name: The name of the service. Must be 3 to 45 characters long.
- description: The details of what the service is. Must be between 3 to 1024 characters long.
- price: The price of the service. Decimal as a string. Will be rounded up to 2 decimal places.
- available: A boolean. Says if the service is currently available or not.
- This updates the status of a booking. Allowed status' are pending(which is the default), paid, fulfilled, and cancelled. On success, it will return a 200 response code with a msg string and a data object of the booking in the payload. If a service is no longer available at the time of payment, the updated will be rejected. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Update the status of a given order with order_id. Status value is either pending(which is the default), paid, shipped, delivered, or cancelled. On success, it will return a 200 response code with a msg string and a data object in the payload. If any item in the order is no longer available (in the quantity specified), the status update will be rejected. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Update the role of a user with given email to new_role. Roles are either customer or admin. On success, it will return a 200 response code with a msg string and a data object in the payload which will be the updated user. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Clear the user's cart. On success, it will return a 200 response code with a msg string in the payload. On failure, it will return a 500 response code, and an error string in the payload.
- Delete an item with item_id from the user's cart. On success, it will return a 200 response code with a msg string in the payload. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Delete the current user account with email. On success, it will return a 200 response code with a msg string in the payload. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Delete a product with product_id. On success, it will return a 200 response code with a msg string and a data object in the payload. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Delete a service from the database. On success, it will return a 200 response code with a msg string in the payload. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Delete a slot from the database. On success, it will return a 200 response code with a msg string in the payload. On failure, it will return a 400 or 500 response code, and an error string in the payload.
- Delete the current user account with given email. On success, it will return a 200 response code with a msg string in the payload. On failure, it will return a 400 or 500 response code, and an error string in the payload.