The People API was developed for people management. Adding people and your addresses.
First you need to clone this repository typing the command below in your terminal:
git clone https://github.com/dchueri/people.git
localhost:8080/persons
Method: GET
Return example:
Status: 200
Body:
[
{
"id": 1,
"name": "Person 1",
"birthDate": "1995-03-16"
},
{
"id": 2,
"name": "Person 2",
"birthDate": "1995-03-16"
},
...
]
localhost:8080/persons/{personId}
Method: GET
Return example:
Status: 200
Body:
{
"id": 1,
"name": "Person 1",
"birthDate": "1995-03-16",
"adresses": [
{
"id": 1,
"street": "Rua 08",
"cep": "78210078",
"number": "715",
"town": "Cáceres-MT",
"isMain": true
},
...
]
}
localhost:8080/persons/{personId}
Method: POST
Request body example:
{
"name": "New person", // String
"birthDate": "1995-03-16" // Date on format: YYYY-MM-DD
}
Return example:
Status: 201
Body:
{
"id": 1,
"name": "New person",
"birthDate": "1995-03-16"
}
localhost:8080/persons/{personId}
Method: PUT
Request body example:
{
"name": "Updated name", // String
}
Return example:
Status: 200
Body:
{
"id": 1,
"name": "Updated name",
"birthDate": "1995-03-16"
}
localhost:8080/persons/{personId}/addresses
Method: POST
Request body example:
{
"street": "Rua 08", // String
"cep": "78210078", // String
"number": "734", // String
"town": "Cáceres-MT", // String
"isMain": true, // boolean
"personId": 1 // Long
}
Return example:
Status: 201
Body:
{
"id": 1,
"street": "Rua 08",
"cep": "78210078",
"number": "734",
"town": "Cáceres-MT",
"isMain": true
}
IMPORTANT: A person can have just one main address. When the user added a new address as the main address, your last main address is defined with
isMain = false
.
localhost:8080/persons/{personId}/addresses/{addressId}
Method: PUT
Request body example:
{
"street": "Rua 07" // String
}
Return example:
Status: 204
Body:
{
"id": 1,
"street": "Rua 07",
"cep": "78210078",
"number": "734",
"town": "Cáceres-MT",
"isMain": false
}
IMPORTANT: A person can have just one main address. When the user updated a address as the main address, your last main address is defined with
isMain = false
.
localhost:8080/persons/{personId}/addresses/{addressId}
Method: DELETE
Return example:
Status: 204
Java
SpringBoot
Maven
JUnit
Mockito
H2
Diego Chueri |
---|