Brief Summary The application provides two API's
GetProducts API
{
"id": "(string) unique id of the event",
"timestamp": "(timestamp) utc timestamp of the event",
"products": [
{
"id": "(long) id of the product"
}
]
}
{
"id": "1234",
"timestamp": "2017-01-23T12:34:56.123456789Z",
"products": [
{
"id": 2
}
]
}
and
PutProducts API
{
"id": "(string) unique id of the event",
"timestamp": "(timestamp) utc timestamp of the event",
"products": [
{
"id": "(long) id of the product",
"name": "(string) name of the product",
"quantity": "(integer) quantity of the product",
"sale_amount": "(double) total sale amount"
}
]
}
{
"id": "1234",
"timestamp": "2017-01-23T12:34:56.123456789Z",
"products": [
{
"id":1,
"name": "test1.4",
"quantity": 1,
"sale_amount": 23.2
}
]
}
The Swagger Documentation can be found in localhost:8080/swagger-ui.html/
There are two Profiles in which service can run.
- Dev Mode : In this mode, no authentication is required
- Prod Mode: In this mode, first we have to authenticate by providing username/password. This mode uses JWT. The behaviour of the token can be controlled via following parameters :
-Djwt.header=authorization -Djwt.expires_in=300 -Djwt.secret=queenvictoria
. These parameters are present inapplication.properties
also. a) jwt.header := The Key Name by which token will be present in the header b) jwt.expires_in := time in secs. c) jwt.secret = The Secret Key
Steps for code execution
- Pull the code
- Create a Postgres db with the name
product-manager
- Copy contents from
data.sql
and run the queries
mvn spring-boot:run -Dspring.datasource.url=jdbc:postgresql://localhost:5432/product-manager -Dspring.datasource.username=<postgresusername>
-Dspring.datasource.password=<passwd>
mvn spring-boot:run -Dspring.profiles.active=prod -Dspring.datasource.url=jdbc:postgresql://localhost:5432/product-manager -Dspring.datasource.username=<postgresusername>
-Dspring.datasource.password=<passwd>
-Djwt.header=authorization -Djwt.expires_in=300 -Djwt.secret=queenvictoria