Users
1. Get Users
Request
- Method:
GET
- Endpoint:
/users
- Parameters:
filter
(optional): Filter users by name, last name, or DNI.skip
(optional): Number of records to skip.limit
(optional): Maximum number of records to retrieve.orderBy
(optional): Property by which to order the results (e.g., “name”, “lastname”).desc
(optional): Set to true for descending order, false or omit for ascending order.
Example
Response
2. Get User by ID
Request
- Method:
GET
- Endpoint:
/users/{id}
- Parameters:
id
(required):
ID of the user.
Example
Response
3. Add User
Request
- Method:
POST
- Endpoint:
/users
- Body:
name
(required): First name of the user.lastname
(required): Last name of the user.idcard
(required): DNI (identification number) of the user.idrole
(required): Id of the selected role.main
(required): Email address of the user.password
(required): User password.
Example
Response
4. Update User
Request
- Method:
PATCH
- Endpoint:
/users
- Body:
id
(required): ID of the user to update.- Additional fields (optional): Updated values for
name
,lastname
,idcard
,password
,role
, ormail
.
Example
Response
5. Delete User (Logic)
Request
- Method:
DELETE
- Endpoint:
/users/{id}
- Parameters:
id
(required): ID of the user to delete.
Example
Response
6. Full Delete User
Request
- Method:
DELETE
- Endpoint:
/clients/fulldelete/{id}
- Parameters:
id
(required): ID of the user to fully delete (including database removal).
Example
Response
Pagination and Filtering in Get Users
When using the Get Users
endpoint, you can apply
pagination and filtering to retrieve specific sets of data.
Pagination
- Use the
skip
parameter to skip a certain number of records. - Use the
limit
parameter to set the maximum number of records to retrieve.
Example:
This will skip the first 10 records and retrieve the next 5 records.
Filtering
- Use the
filter
parameter to filter users by name, last name, or id card. - Use the
orderBy
parameter to specify the property by which to order the results. - Use the
desc
parameter to set the order as descending (true) or ascending (false).
Example:
This will filter users with the last name “Doe” and order the results by the first name in descending order.
Data Model
Attribute | Type | Description |
---|---|---|
id | Long | The ID of the user. |
name | String | The name of the user. |
id_role | Long | The id role of the user |
password | String | the password of the user |
last_name | String | The last name of the user. |
id_card | String | The identification number of the user. |
String | The email of the user. | |
state | Byte | The state of the user. |
Validations
- IdRole: Must be a positive integer and exist in the database.
- Mail: Valid email address. Must not exist in the database for other users with a different ID and a state of 1.
- Password: Minimum length of 6 characters.
- Name: Minimum length of 3 characters.
- LastName: Minimum length of 3 characters.
- IdCard: Must have 8 digits.