Address Book Assignment developed with Java and Spring Boot
-
Address book will hold name and phone numbers of contact entries
-
REST API have endpoints for the following -
-
Users should be able to add new contact entries
-
Users should be able to remove existing contact entries
-
Users should be able to print all contacts in an address book
-
Users should be able to maintain multiple address books
-
Users should be able to print a unique set of all contacts across multiple address books
-
Test
$ mvn test
Build
$ mvn install
Docker Build
$ docker build -t address-book/address-book-docker .
Docker Run
$ docker run -p 8080:8080 address-book/address-book-docker
- Create new Address Book
POST http://localhost:8080/api/v1/address-books
Payload:
{
"name": "finance contacts"
}
Response: 201 Created
{
"id": 762698279,
"name": "finance contacts",
"contacts": []
}
- Add Contact in Address Book
POST http://localhost:8080/api/v1/address-books/{addressBookId}/contacts
ex: POST http://localhost:8080/api/v1/address-books/762698279/contacts
Payload:
{
"firstName": "John",
"lastName": "Moore",
"phoneNumbers": [
"12343356",
"566554433"
]
}
Response: 201 Created
{
"id": 767781373,
"firstName": "John",
"lastName": "Moore",
"phoneNumbers": [
"12343356",
"566554433"
]
}
- Get Contact list in Address Book
GET http://localhost:8080/api/v1/address-books/{addressId}
ex: GET http://localhost:8080/api/v1/address-books/762698279
Response: 200 OK
{
"id": 767781373,
"firstName": "John",
"lastName": "Moore",
"phoneNumbers": [
"12343356",
"566554433"
]
}
]
- Update Contact in Address Book
PUT http://localhost:8080/api/v1/address-books/{addressId}/contacts
ex: PUT http://localhost:8080/api/v1/address-books/762698279/contacts
Payload:
{
"id": 767781373,
"firstName": "Josh",
"lastName": "Mayor",
"phoneNumbers": [
"12343356"
]
}
Response: 200 OK
{
"id": 767781373,
"firstName": "Josh",
"lastName": "Mayor",
"phoneNumbers": [
"12343356"
]
}
- Get list of all Address Books
GET http://localhost:8080/api/v1/address-books
- Get unique set of Contacts across all Address Books
GET http://localhost:8080/api/v1/address-books/unique-contacts
- Delete contact in Address Book
DELETE http://localhost:8080/api/v1/address-book/{addressId}/contact/{contactId}
ex: DELETE http://localhost:8080/api/v1/address-book/1383388594/contact/1964920837
- Delete Address Book
DELETE http://localhost:8080/api/v1/address-book/{addressId}/
ex: DELETE http://localhost:8080/api/v1/address-book/762698279/
http://localhost:8080/swagger-ui.html