class IMSController {

    @RequestMapping(value = "/api/users/count", method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity getUserEstimate(@RequestBody IMSRequestQuery payload)
    {
        InventoryResult result;
        try
        {
            Date today = new Date();
            if (!CommonUtil.isBlank(payload.getToday()))
            {
                today = CommonUtil.dayToDate(payload.getToday());
            }

            result = userEstimateService.getUserEstimate(payload.getTargetingChannel(), payload.getDays(),
                    payload.getPrice(), today);
            String logMessage = String.format("Targeting channel: %s estimate: %d",
                    payload.getTargetingChannel().getQueryKey(), result.getAvailCount());

            LOGGER.info(logMessage);
        }
        catch (Exception e)
        {
            LOGGER.error(e.getMessage());
            return ResponseBuilder.buildError(e);
        }

        return ResponseBuilder.build(result, HTTP_OK_CODE);
    }

}