Exposes multiple rest api endpoints, which can be used to create a product, retrieve product(s), update and delete a product. This API aggregates product data from multiple sources (by the means of web services integration) and return it as JSON to the caller.
Technologies Used:
Technology | Version |
---|---|
Java | 8 |
SpringBoot | 1.5.8 |
Flyway DB | 4.2.0 |
Postgres | 9.4.1212 |
MyBatis | 3.4.5 |
Mongo | 3.4.3 |
Spock Testing Framework | 2.4 |
Groovy | 2.4 |
Gradle | 3.5.1 |
Note: Assuming Postgres and Mongo already installed
- Clone the project
- Update the
application.yaml
file under resources directory with respective Postgres and Mongo DB details. - Run the
MyRetailRestApiApplication
, this will bring up the application and can be accessed via below URL:
http://localhost:8081/myretail/products/
Internal Resource hosted by myRetail to fetch product name details: http://localhost:8081/myretail/productNames/products/
End points:
- GET: /products/ fetches all product details
- GET: /products/{id} fetches single product details if found
- POST: /products/ creates a new product
- PUT: /products/{id} updates the product with new details
- DELETE: /products/{id} deletes the product
For more details please refer to myretail-sepcification
The following actions can be performed:
- Responds to an HTTP GET request at "/products/" to retrive all product details and "/products/{id}" to retrieve specific product details and delivers the product data as JSON, where {id} will be a number.
- Example response:
{
"id": 15,
"name": "The Big Lebowski (Blu-ray)(Widescreen)",
"current_price": {
"value": 399.99,
"currency_code": "CAD"
}
}
-
Performs an HTTP GET to retrieve the product name from an internal resource (http://localhost:8081/myretail/productNames/products/) hosted by the same application (http://localhost:8081/myretail/products/), which
- Reads pricing information from a NoSQL data store,
- Reads the product id and product name from the HTTP request and
- Aggregates the both the data objects into one single response object in JSON
-
Similarly performs HTTP POST/PUT/DELETE opeations to create/update the product name from an internal resource and reads pricing information from a NoSQL data store and produces the single respose in JSON.