You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jsnjns 1fcd1e46a6 More braces fixed 4 years ago
src More braces fixed 4 years ago
.gitignore Initial commit 4 years ago
ContactsAPI.postman_collection.json Added request to Postman collection 4 years ago
LICENSE Initial commit 4 years ago
README.md Update 'README.md' 4 years ago
mvnw Initial commit 4 years ago
mvnw.cmd Initial commit 4 years ago
pom.xml Migrating to DTOs 4 years ago

README.md

Contacts REST API

About

The aim of this exercise is to create a simple contact entry system. It consists of a REST API that will enable a client to perform CRUD operations on the contact collection.

Requirements

The API must have the following endpoints:

Method Endpoint Description
GET /contacts List all contacts
POST /contacts Create a new contact
PUT /contacts/{id} Update a contact
GET /contacts/{id} Get a specific contact
DELETE /contacts/{id} Delete a contact
GET /contacts/call-list List of all contacts 1

1 Restricted to contacts with a home phone sorted by last name then first name

Software

The following software is required in order to build and run:

  1. Maven
  2. Java JDK 8 or later

Implementation

I chose to use the Spring Framework and more specifically, the Spring Boot and Spring Data JPA projects as the base for this API. Spring Boot makes it simple to create a stand-alone REST API and Spring Data JPA simplifies interfacing with an h2 database.

Build and Run

To build and run, from the command line, navigate to the root directory and run the command:

mvn spring-boot:run

The URL to access the API is: http://localhost:8080/api/v1/contacts

Running Tests

To run tests, from the command line, navigate to the root directory and run the command:

mvn test

Additional Resources

To prepopulate the database with demo data, uncomment the following lines in the src/main/resources/application.properties file

# spring.jpa.defer-datasource-initialization=true
# spring.sql.init.data-locations=classpath:demo.sql

An H2 console will be available at http://localhost:8080/h2-console to allow direct access to the underlying H2 database

username: sa /password: leave empty

Also included is the file ContactsAPI.postman_collection.json. This can be imported into the Postman application in order to issue REST commands.