From command line run
-
createuser -h localhost -p 5432 -U postgres -d -l -S postgres
-
Change <POSTGRES_HOME>/data/pg_hba.conf from md5 -> trust to allow passwordless entry
- OPTIONAL use
pg_ctl reload
if already running
- OPTIONAL use
-
createdb -U postgres invoices
-
psql -U postgres invoices
-
Run the following sql command in prompt to create the table
CREATE TABLE invoices ( id SERIAL, invoice_number VARCHAR(64) NOT NULL, po_number VARCHAR(64) NOT NULL, due_date DATE NOT NULL, amount_cents BIGINT NOT NULL, created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() );
- cd into home directory of source code
mvn clean install
java -jar target\rest.0.0.1-SNAPSHOT.jar
or usemvn spring-boot:run
curl -d "invoice_number=ABC12345&po_number=X1B23C4D5E&due_date=2017-03-15&amount_cents=100000" -H "Content-Type: application/json" -X POST http://localhost:8080/v1/invoices
curl -X GET http://localhost:8080/v1/invoices?invoice_number=ABC12345&page=0&limit=1
curl -X GET http://localhost:8080/v1/invoices?po_number=X1B23C4D5E&page=0&limit=1
Note: If both invoice number and PO number are given, endpoint will return search by invoice number.