Overview
1. HTTP verbs
The services developed for the project try to comply with the HTTP and REST conventions in the use of verbs HTTP.
Verb | Usage |
---|---|
|
Used to retrieve an existing resource. |
|
Used to create a new resource. |
|
Used to update an existing resource. |
|
Used to delete an existing resource. |
2. HTTP status codes
The services developed for the project try to comply with the HTTP and REST conventions in the use of codes of HTTP status.
Status code | Usage |
---|---|
|
The request completed successfully. |
|
A new resource has been created successfully. The resource’s URI is available from the response’s.
|
|
An update to an existing resource has been applied successfully. |
|
The request was malformed. The response body will include an error providing further information. |
|
The request resource is restricted. The requested resource is restricted and requires authentication. |
|
The requested resource does not exist. |
|
The requested method not supported. |
|
The Content type is empty or invalid. |
|
The resource already exist. |
|
Internal server error, the request cannot be processed. |
3. Headers
Every response has the following header(s):
Name | Description |
---|---|
|
The Content-Type of the payload, default is |
4. Errors
Whenever an error response (http status code >= 400) is returned, the body will contain a JSON object that describes the problem. The error object has the following structure:
Path | Type | Description |
---|---|---|
|
Long |
The time, in milliseconds, at which the error occurred. |
|
Number |
The HTTP status code. |
|
String |
The HTTP status code description. |
|
String |
A description of the cause of the error. |
|
String |
The path to which the request was made. |
For example, a request that attempts to apply a non-existent tag to a note will produce a 400 Bad Request response:
HTTP/1.1 404 Not found
Content-Type: application/json;charset=UTF-8
Content-Length: 295
{
"timestamp": "2022-02-12T18:14:55.731+00:00",
"status": 404,
"error": "Not Found",
"message": "User not found",
"path": "/users/{id}"
}
5. Error types
Type | Status code | Error message |
---|---|---|
|
422 |
Account already exist. |
|
422 |
User already exist. |
|
404 |
User not found. |
Resources
6. User
The user
resource is used to manage information from a user.
6.2. Path Parameters
Parameter | Description |
---|---|
|
User identifier |
6.2.1. Response Fields
Path | Type | Optional | Description |
---|---|---|---|
id |
Number |
false |
User identifier |
name |
String |
false |
User name |
lastname |
String |
false |
User lastname |
age |
Number |
false |
User age |
String |
false |
User email |
|
accounts |
Array |
true |
Related user accounts |
6.3. Post Create User
A POST
request will create a new user.
6.3.1. Request Fields
Path | Type | Optional | Description | Constraints | Example Value |
---|---|---|---|---|---|
id |
Number |
true |
User identifier |
- |
|
name |
String |
false |
User name |
Must not be null |
Trinidad |
lastname |
String |
false |
User lastname |
Must not be null |
Rivas |
age |
Number |
false |
User age |
Must not be null |
34 |
String |
false |
User email |
Must be a well-formed email address- Must not be null |
||
accounts |
String |
true |
Related user accounts |
- |
6.3.2. Response Fields
Path | Type | Optional | Description |
---|---|---|---|
id |
Number |
false |
User identifier |
name |
String |
false |
User name |
lastname |
String |
false |
User lastname |
age |
Number |
false |
User age |
String |
false |
User email |
|
accounts |
String |
true |
User email |
6.5. Path Parameters
Parameter | Description |
---|---|
|
User identifier |
6.6. Get Users
A GET
request will get all existing users.
6.6.1. Curl Request
$ curl 'http://example.com:8080/users' -i -X GET \
-H 'Content-Type: application/json'
7. Account
7.1. Post Create User Account
A POST
request will create a new user account.
7.1.1. Request Fields
Path | Type | Optional | Description | Constraints | Example Value |
---|---|---|---|---|---|
id |
String |
true |
Account type |
- |
|
type |
String |
false |
Account type |
Must not be null |
DEBIT, CREDIT |
number |
String |
false |
Account number |
Must not be null- Size must be between 16 and 16 inclusive |
4909914807265711 |
balance |
Number |
true |
Account balance |
Must be positive or zero |
$8,933.95 |
7.1.2. Response Fields
Path | Type | Optional | Description |
---|---|---|---|
id |
Number |
false |
Account identifier |
type |
String |
false |
Account type |
number |
String |
false |
Account number |
balance |
Number |
true |
Account balance |
7.3. Path Parameters
Parameter | Description |
---|---|
|
User identifier |
7.3.1. Response Fields
Path | Type | Optional | Description |
---|---|---|---|
[].id |
Number |
false |
Account identifier |
[].type |
String |
false |
Account type |
[].number |
String |
false |
Account number |
[].balance |
Number |
true |
Account balance |