- Java JDK 11
- Apache Maven 3
- GIT
git clone https://github.com/mmondino/idtx-challenge.git
cd idtx-challenge
./mvnw spring-boot:run
Test 1:
curl -i "http://localhost:8080/api/v1/prices?brandId=1&productId=35455&pricingDate=2020-06-14T10:00:00"
Test 2:
curl -i "http://localhost:8080/api/v1/prices?brandId=1&productId=35455&pricingDate=2020-06-14T16:00:00"
Test 3:
curl -i "http://localhost:8080/api/v1/prices?brandId=1&productId=35455&pricingDate=2020-06-14T21:00:00"
Test 4:
curl -i "http://localhost:8080/api/v1/prices?brandId=1&productId=35455&pricingDate=2020-06-15T10:00:00"
Test 5:
curl -i "http://localhost:8080/api/v1/prices?brandId=1&productId=35455&pricingDate=2020-06-16T21:00:00"
src/test/java/io/idtx/pricing/api/challenge/GetPriceIT.java
http://localhost:8080/swagger-ui.html
For successful requests, this API returns HTTP 2XX status codes.
Status code | Description |
---|---|
200 OK | The request succeeded. |
For failed requests, this API returns HTTP 4XX status codes if something passed in the request has an error or 5XX status codes when something is wrong on our end with a server or service.
Status code | Description | Possible causes and solutions |
---|---|---|
400 Bad Request | INVALID_REQUEST. Malformed request syntax, request is syntactically incorrect, or violates a schema. | See Invalid requests |
404 Not Found | RESOURCE_NOT_FOUND. The specified resource does not exist. |
The specified resource does not exist. The server did not find anything that matches
the request URI. Either the URI is incorrect or the resource is not available.
For example, no price exists in the database matching the given filters parameters. See an example response |
405 Method Not Allowed | METHOD_NOT_SUPPORTED | The server does not implement the requested HTTP method. The service does not support the requested HTTP method. For example, POST /api/v1/prices. |
406 Not Acceptable | MEDIA_TYPE_NOT_ACCEPTABLE | The server does not implement the media type that would be acceptable to the client. The server cannot use the client-request media type to return the response payload. For example, this error occurs if the client sends an Accept: application/xml request header because the API can generate only an application/json response. |
415 Unsupported Media Type | UNSUPPORTED_MEDIA_TYPE | The server does not support the request payload’s media type. The API cannot process the media type of the request payload. For example, this error occurs if the client sends a Content-Type: application/xml request header because the API can only accept application/json request payloads. |
422 Unprocessable Entity | UNPROCESSABLE_ENTITY |
The API cannot complete the requested action, or the request action is semantically incorrect or fails
business validation. The API cannot complete the requested action and might require interaction with APIs
or processes outside of the current request. For example, this error occurs for any business validation
errors, including errors that are not usually of the 400 type. Too many prices found is one of this errors. See an example response |
Status code | Description | Possible causes and solutions |
---|---|---|
500 Internal Server Error | INTERNAL_SERVER_ERROR. An internal server error has occurred. | A system or application error occurred. Although the client appears to provide a correct request, something unexpected occurred on the server. |
503 Service Unavailable | SERVICE_UNAVAILABLE. Service Unavailable. | The server cannot handle the request for a service due to temporary maintenance. |
Request is invalid when:
- The API cannot convert the request payload data to the underlying data type.
- The data is not in the expected format.
- A mandatory field is not present.
- A data validation error occurred.
For invalid requests, this API returns the HTTP 400 Bad Request status code.
The API cannot convert the payload data to the underlying data type.
{
"timestamp": "2021-10-27T17:57:55.706017Z",
"problemType": "INVALID_REQUEST",
"problemCode": null,
"message": "The request is not valid",
"globalErrors": [],
"fieldErrors": [
{
"path": "brandId",
"errorType": "CONVERSION_ERROR",
"errorMessage": "expected long number",
"rejectedValue": "A"
},
{
"path": "productId",
"errorType": "CONVERSION_ERROR",
"errorMessage": "expected long number",
"rejectedValue": "B"
},
{
"path": "pricingDate",
"errorType": "CONVERSION_ERROR",
"errorMessage": "expected datetime format is yyyy-MM-ddTHH:mm:ss",
"rejectedValue": "C"
}
]
}
The data is not in the expected data format, a required field is not available or a simple data validation error occurred
{
"timestamp": "2021-10-27T17:58:33.431137Z",
"problemType": "INVALID_REQUEST",
"problemCode": null,
"message": "The request is not valid",
"globalErrors": [],
"fieldErrors": [
{
"path": "brandId",
"errorType": "VALIDATION_ERROR",
"errorMessage": "may not be null",
"rejectedValue": null
},
{
"path": "productId",
"errorType": "VALIDATION_ERROR",
"errorMessage": "may not be null",
"rejectedValue": null
},
{
"path": "pricingDate",
"errorType": "VALIDATION_ERROR",
"errorMessage": "may not be null",
"rejectedValue": null
}
]
}
{
"timestamp": "2021-10-27T18:12:56.313540Z",
"problemType": "RESOURCE_NOT_FOUND",
"problemCode": "PRICES.PRICE_NOT_FOUND",
"message": "Price not found"
}
{
"timestamp": "2021-10-27T18:10:50.999559Z",
"problemType": "BUSINESS_RULE_PROBLEM",
"problemCode": "PRICES.TOO_MANY_PRICES_FOUND",
"message": "Too many prices found. Ambiguous price"
}
{
"validFrom": "2020-06-14T00:00:00",
"validTo": "2020-12-31T23:59:59",
"brandId": 1,
"productId": 35455,
"priceListId": 1,
"amount": "35.50",
"currency": "EUR"
}