API Endpoints - UB-ES-2021-A4/Booksy GitHub Wiki
On this page are explained, as an overview, the endpoints of the API and the different options that they grant. The given paths will be only the resource path, we assume that you have already introduced the hostname and the port, if necessary.
This resource gives access to the admin portal provided by Django. It's useful for debugging and administrative purposes.
OPTIONS: GET, POST
This endpoint retrieves the user's information in the web's database. In order to do it, you have to provide the user's ID. The returned data should contain the following information: user's ID, First name of the user, Last name of the user, username, email and profile image.
This endpoint gives access to the login resource. To do it, you have to provide a username and password. The returned data should be a token for the user.
Options: POST
This endpoint gives creates the new user's account and profile. To do it, you have to provide a form with the following data: First name, Last name, email, username and password. The user's profile image will be set as the default image and users can change it whenever they want.
Options: GET, PATCH
This endpoint updates the user's profile stored in the web's database. In order to do it, you have to provide the user's ID. There shouldn't be any returned data.
This endpoint gives access to the profile resource of a user. To do it, you have to provide an account ID. The returned data should be the serialized user's profile information and status code 200.
Options: GET, POST, PATCH, DELETE
The get option retrieves a list of all the products in the web's database. There can be two attributes provided: ?id=X
, will return only the product with the given ID. ?category='XX'
, will return a list of all the products with the given category.
If ?search='string'
is provided, the endpoint will return a list of all the products containing the requested string, being case insensitive.
Requires:
category
: Two char long category code.
user
: id number of an existing username.
title
: String up to 250 chars.
description
: String up to 1000 chars.
author
: String up to 50 chars.
price
: Float.
An image should be asked by the frontend in another step.
Requires:
id
: Integer id of the existing product.
category
: Two char long category code.
user
: id number of an existing username, must be the creator of the product in the first place.
title
: String up to 250 chars.
description
: String up to 1000 chars.
author
: String up to 50 chars.
price
: Float.
Requires:
?id=X
: Integer with the id number on the search bar.
user auth
: The user deleting the item has to be authorized to check if the user deleting the product is the one who uploaded it.
Options: GET, POST, PATCH, DELETE
Requires:
?id=XX
: On the search bar, it's the product ID, not the image id. This will return the path to the image related to the product.
Requires:
id
: This ID is the product ID we want to create a relation with.
file
: This file will be the image. The name doesn't matter as it will be treated in order to prevent overwriting.
id
: This ID is the product ID we want to create a relation with.
file
: This file will be the new image. The name doesn't matter as it will be treated to prevent overwriting.
user auth
: Authenticated user to check if it's the same one who created the product.
Options: GET
Returns a list of all the current available categories.
category_name
: Code of 2 chars of the category.
category_description
: Full string of the category name.
Alternatively, if ?category=XX
is given, the GET request will try to return the category_name
and the category_description
.
Options: POST
This endpoint needs a form file with the following information:
ids
: Lis of the IDS of all items the user is buying.
first_name
: First name of the client.
last_name
: Last name of the client.
direction
: Addres where the package will be sent.
city
: City where the adreess is.
country
: Country where the city is.
zip_code
: 5 digits code of the address.
category_name
: Code of 2 chars of the category.
card_name
: Credit card owner's full name.
card_num
: 16 digits credit card number
expiration_card
: Credit cards expiration date with the form MM/YY.
cvv
: 3 digits number in the back of the credit card.